?? kbd_drv.lst
字號:
C51 COMPILER V7.00 KBD_DRV 04/28/2004 09:31:56 PAGE 1
C51 COMPILER V7.00, COMPILATION OF MODULE KBD_DRV
OBJECT MODULE PLACED IN C:\Documents and Settings\lvxc\桌面\AA\kbd_drv.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE lib_mcu\kbd\kbd_drv.c OPTIMIZE(7,SPEED) BROWSE INCDIR(.\modules\system;.\;.
-\;.\lib_refd) DEFINE(KEIL) DEBUG OBJECTEXTEND PRINT(.\kbd_drv.lst) OBJECT(C:\Documents and Settings\lvxc\桌面\AA\kbd_drv
-.obj)
stmt level source
1 /*C**************************************************************************
2 * NAME: kbd_drv.c
3 *----------------------------------------------------------------------------
4 * Copyright (c) 2003 Atmel.
5 *----------------------------------------------------------------------------
6 * RELEASE: snd1c-refd-nf-4_0_3
7 * REVISION: 1.10
8 *----------------------------------------------------------------------------
9 * PURPOSE:
10 * This file contains the keypad driver routines
11 *
12 * NOTES:
13 * Driver Configuration:
14 * - KBD_EXIT_PD in config.h define as:
15 * TRUE: to allow exit of power down by keyboard
16 * FALSE: to disallow exit of power down by keyboard
17 * - LOCK_ROW in config.h
18 * - KEY_LOCK in config.h
19 * Global Variables:
20 * - gl_kbd_lock in bdata space
21 *****************************************************************************/
22
23 /*_____ I N C L U D E S ____________________________________________________*/
24
25 #include "config.h" /* lib configuration header */
26 #include "kbd_drv.h" /* Keyboard driver definition */
27
28
29 /*_____ M A C R O S ________________________________________________________*/
30
31
32 /*_____ D E F I N I T I O N ________________________________________________*/
33
34 static bdata bit gl_kbd_lock;
35
36 /*_____ D E C L A R A T I O N ______________________________________________*/
37
38 static void kbd_set_prio (Byte);
39 static void kbd_install (void);
40
41
42 /*F**************************************************************************
43 * NAME: kbd_init
44 *----------------------------------------------------------------------------
45 * PARAMS:
46 *
47 * return:
48 *----------------------------------------------------------------------------
49 * PURPOSE:
50 * Keyboard initialisation function
51 *----------------------------------------------------------------------------
52 * EXAMPLE:
53 *----------------------------------------------------------------------------
C51 COMPILER V7.00 KBD_DRV 04/28/2004 09:31:56 PAGE 2
54 * NOTE:
55 *----------------------------------------------------------------------------
56 * REQUIREMENTS:
57 * ram/xram:
58 * cycle:
59 * stack:
60 * code:
61 *****************************************************************************/
62 void kbd_init (void)
63 {
64 1 P_KBD |= MSK_COL; /* all columns inactive */
65 1 gl_kbd_lock = (!LOCK_ROW); /* Lock Key decoding */
66 1 #if KBD_EXIT_PD
Kbd_enable_pd_exit(); /* enable keyboard Power-Down exit */
kbd_set_prio(KBD_PRIO);
#endif
70 1 kbd_install();
71 1 }
72
73
74 /*F**************************************************************************
75 * NAME: kbd_install
76 *----------------------------------------------------------------------------
77 * PARAMS:
78 *
79 * return:
80 *----------------------------------------------------------------------------
81 * PURPOSE:
82 * Keyboard IT and columns mask init
83 *----------------------------------------------------------------------------
84 * EXAMPLE:
85 *----------------------------------------------------------------------------
86 * NOTE:
87 *----------------------------------------------------------------------------
88 * REQUIREMENTS:
89 * ram/xram:
90 * cycle:
91 * stack:
92 * code:
93 *****************************************************************************/
94 void kbd_install (void)
95 {
96 1 if (gl_kbd_lock)
97 1 {
98 2 KBCON = KB_LCK;
99 2 P_KBD &= MSK_LCK;
100 2 }
101 1 else
102 1 {
103 2 KBCON = KB_STD;
104 2 P_KBD &= MSK_STD;
105 2 }
106 1 KBSTA = KBSTA; /* dummy read for clearing pending interrupt */
107 1
108 1 #if KBD_EXIT_PD
Kbd_enable_int(); /* enable or re-enable the kbd interrupt */
#endif
111 1 }
112
113
114 /*F**************************************************************************
115 * NAME: kbd_set_prio
C51 COMPILER V7.00 KBD_DRV 04/28/2004 09:31:56 PAGE 3
116 *----------------------------------------------------------------------------
117 * PARAMS:
118 *
119 * return:
120 *----------------------------------------------------------------------------
121 * PURPOSE:
122 * Set the keyboard interface priority interrupt
123 *----------------------------------------------------------------------------
124 * EXAMPLE:
125 *----------------------------------------------------------------------------
126 * NOTE:
127 *----------------------------------------------------------------------------
128 * REQUIREMENTS:
129 * ram/xram:
130 * cycle:
131 * stack:
132 * code:
133 *****************************************************************************/
134 #if KBD_EXIT_PD
void kbd_set_prio (Byte priority)
{
if ((priority == 1) || (priority == 3)) /* set LSB priority bit */
{
IPL1 |= MSK_EKB;
}
if ((priority == 2) || (priority == 3)) /* set MSB priority bit */
{
IPH1 |= MSK_EKB;
}
}
#endif
147
148
149 /*F**************************************************************************
150 * NAME: kbd_decode
151 *----------------------------------------------------------------------------
152 * PARAMS:
153 *
154 * return:
155 * Decoded key pressed
156 *----------------------------------------------------------------------------
157 * PURPOSE:
158 * Decode the key that generated an IT
159 *----------------------------------------------------------------------------
160 * EXAMPLE:
161 *----------------------------------------------------------------------------
162 * NOTE:
163 *----------------------------------------------------------------------------
164 * REQUIREMENTS:
165 * ram/xram:
166 * cycle:
167 * stack:
168 * code:
169 *****************************************************************************/
170 Byte kbd_decode (void)
171 {
172 1 Byte key;
173 1
174 1 if (gl_kbd_lock)
175 1 {
176 2 gl_kbd_lock = FALSE;
177 2 kbd_install();
C51 COMPILER V7.00 KBD_DRV 04/28/2004 09:31:56 PAGE 4
178 2 return (KEY_LOCK);
179 2 }
180 1 else
181 1 {
182 2 P_KBD |= MSK_COL; /* all columns inactive */
183 2
184 2 /* COL3 = 0; /* COL3 test (always 0) */
185 2 key = (P_KBD & MSK_PKB);
186 2 if (key != NK_COL3)
187 2 {
188 3 if (key == KEY_LOCK)
189 3 {
190 4 gl_kbd_lock = TRUE; /* signal key locked */
191 4 }
192 3 kbd_install();
193 3 return (key);
194 3 }
195 2
196 2 COL2 = 0; /* COL2 test */
197 2 key = (P_KBD & MSK_PKB);
198 2 if (key != NK_COL2)
199 2 {
200 3 kbd_install();
201 3 return (key);
202 3 }
203 2
204 2 COL1 = 0; /* COL1 test */
205 2 key = (P_KBD & MSK_PKB);
206 2 if (key != NK_COL1)
207 2 {
208 3 kbd_install();
209 3 return (key);
210 3 }
211 2
212 2 COL0 = 0; /* COL0 test */
213 2 key = (P_KBD & MSK_PKB);
214 2 if (key != NK_COL0)
215 2 {
216 3 kbd_install();
217 3 return (key);
218 3 }
219 2 }
220 1 }
221
222
223 /*F**************************************************************************
224 * NAME: kbd_int
225 *----------------------------------------------------------------------------
226 * PARAMS:
227 *
228 * return:
229 *----------------------------------------------------------------------------
230 * PURPOSE:
231 * Keyboard interrupt function
232 *----------------------------------------------------------------------------
233 * EXAMPLE:
234 *----------------------------------------------------------------------------
235 * NOTE:
236 * This isr is called when a key is pressed to get out power-down Interrupt
237 * is re-enable in the install routine
238 *----------------------------------------------------------------------------
239 * REQUIREMENTS:
C51 COMPILER V7.00 KBD_DRV 04/28/2004 09:31:56 PAGE 5
240 * ram/xram:
241 * cycle:
242 * stack:
243 * code:
244 *****************************************************************************/
245 #if KBD_EXIT_PD
Interrupt(kbd_int (void), IRQ_KBD)
{
Kbd_disable_int(); /* disable interrupt */
}
#endif
251
252
253
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 110 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -