📄 key.lst
字号:
C51 COMPILER V7.50 KEY 06/25/2008 18:07:57 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE KEY
OBJECT MODULE PLACED IN .\Output\KEY.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE KEY.C BROWSE DEBUG OBJECTEXTEND PRINT(.\Output\KEY.lst) OBJECT(.\Output\KEY
-.obj)
line level source
1 /*--------------------------------------------------------------------------
2 KEY.C
3 C file for KEY
4
5 History:
6 07/20/2006 : First Version V0.1 ---HsinChu Office
7
8 Copyright (c) 1998-2006 AverLogic Inc
9 All rights reserved.
10 --------------------------------------------------------------------------*/
11 #include "REG52.H"
12 #include "DATATYPE.H"
13 #include "DEFINE.H"
14 #include "STRUCT.H"
15 #include "KEY.H"
16 #include "IR.H"
17 #include "MSG.H"
18 #include <stdio.h>
19 extern Bool gbKey_CmdIn;
20 extern Byte gucIRData,gbIR_State;
21 //extern Bool gbIRKeyInput;
22 extern Byte guc5msCounter;
23 extern Bool gbIR_Repeat;
24 unsigned int presstime;
25
26 // *********************************************************
27 // Key To IR Data Structure
28 // *********************************************************
29 struct Key2IR
30 {
31 Byte KeyPress;
32 Byte IrButton;
33 };
34
35 Byte ucIrRep;
36
37 // *********************************************************
38 // Key To IR Look Up Table
39 // *********************************************************
40 #ifdef AL320NEWEVB //jason 11/21
41 code struct Key2IR Key2IR_LUT[]=
42 {
43
44 // KEY01, IR_POWER,
45 KEY02, IR_LEFT,
46 KEY03, IR_RIGHT,
47 KEY04, IR_MENU,
48 // KEY05, IR_EXIT,
49
50 // KEY06, IR_MUTE,
51 // KEY07, IR_CHINC,
52 // KEY08, IR_CHDEC,
53 // KEY23, IR_MTS
54 };
C51 COMPILER V7.50 KEY 06/25/2008 18:07:57 PAGE 2
55 #else
code struct Key2IR Key2IR_LUT[]=
{
// KEY01, IR_POWER,
KEY02, IR_MENU,
KEY03, IR_RIGHT,
KEY04, IR_LEFT,
// KEY05, IR_CHINC,
// KEY06, IR_MUTE,
// KEY07, IR_CHDEC,
// KEY08, IR_EXIT,
};
#endif
70 Byte irLutSize = sizeof(Key2IR_LUT)/sizeof(struct Key2IR);
71
72 // *********************************************************
73 // Structure : irLUTab[]
74 // Description : The Structure is the basic type of irLUTab[]
75 // *********************************************************
76 struct IR_LUT
77 {
78 IRCODE ir_code;
79 MSGID MsgID;
80 Byte Repeat;
81 };
82
83 // *********************************************************
84 // Structure : irLUTab[]
85 // Description : The Structure is built for control IR command
86 // repeat value = 1 : no delay
87 // repeat value = 4 : 4 repeat code exe 1 time
88 // repeat value = 8 : 8 repeat code exe 1 time
89 // *********************************************************
90 code struct IR_LUT irLUT[] =
91 {
92 // ir_code , msgID , repeat
93 // -------- -------------- ------
94 // IR_POWER, KEYPRESS_POWER, 3,
95 // IR_CHINC, KEYPRESS_CHINC, 4,
96 // IR_VOLINC, KEYPRESS_VOLINC, 3,
97 // IR_CHDEC, KEYPRESS_CHDEC, 4,
98 // IR_VOLDEC, KEYPRESS_VOLDEC, 3,
99
100 // IR_SELECT, KEYPRESS_SELECT, 4,
101 // IR_UP, KEYPRESS_UP, 4,
102 IR_LEFT, KEYPRESS_RIGHT, 2,
103 IR_RIGHT, KEYPRESS_LEFT, 2,
104 // IR_DOWN, KEYPRESS_DOWN, 4,
105
106 // IR_INPUT, KEYPRESS_SOURCE, 4,
107 // IR_MTS, KEYPRESS_MTS, 4,
108 // IR_MUTE, KEYPRESS_MUTE, 2,
109 // IR_RECALL, KEYPRESS_RECALL, 4,
110 // IR_SCAN, KEYPRESS_SCAN, 4,
111 // IR_RESET, KEYPRESS_RESET, 4,
112 IR_MENU, KEYPRESS_MENU, 128,
113 // IR_EXIT, KEYPRESS_EXIT, 1
114 };
115
116 Byte InxSize = sizeof(irLUT)/sizeof(struct IR_LUT);
C51 COMPILER V7.50 KEY 06/25/2008 18:07:57 PAGE 3
117
118 // *********************************************************
119 // Function : Key_LutInx
120 // Description : Search through the LUT to find the entry
121 // in the IRHandler table
122 // Input parameters : Byte - ucBtonData : Button Data
123 // Return value : Byte - uclutIndex : Lool Up Table Index
124 // Byte - uclutRep : Repeat Value
125 // Bool - ret_val = True : Found
126 // = False: Not Thing Found
127 // *********************************************************
128 Bool Key_LutInx(Byte ucBtonData, Byte* uclutIndex , Byte* uclutRep)
129 {
130 1 Byte i;
131 1 Bool ret_val = FALSE;
132 1
133 1 for (i=0; i<InxSize; i++)
134 1 {
135 2 if (irLUT[i].ir_code == ucBtonData)
136 2 {
137 3 *uclutIndex = irLUT[i].MsgID;
138 3 *uclutRep = irLUT[i].Repeat;
139 3 ret_val = TRUE;
140 3 break;
141 3 }
142 2 }
143 1 return ret_val;
144 1 }
145
146 // *********************************************************
147 // Function : Key2IRLut
148 // Description : Translate Key code to IR code through search
149 // irLUT[]
150 // Input parameters : Byte - ucKeyData : Key code
151 // Return value : Byte - ret_val : PASS : Ir code
152 // FAIL : One of the above failed
153 // *********************************************************
154 Byte Key_2IrLut(Byte ucKeyData)
155 {
156 1 Byte i;
157 1 Byte ret_val = FALSE;
158 1
159 1 for (i=0; i<irLutSize; i++)
160 1 {
161 2 if (Key2IR_LUT[i].KeyPress == ucKeyData)
162 2 {
163 3 ret_val = Key2IR_LUT[i].IrButton;
164 3 break;
165 3 }
166 2 }
167 1 return ret_val;
168 1 }
169
170 // *********************************************************
171 // Function : Key_Scan
172 // Description : Capture key code when key pressed.
173 // Input parameters : None.
174 // Return value : Byte - ucKeyNum : Not zero : Key code
175 // Zero : Unpressed
176 // *********************************************************
177 Byte debounce;
178 Byte Key_Scan(void)
C51 COMPILER V7.50 KEY 06/25/2008 18:07:57 PAGE 4
179 {
180 1 Byte ucKeyNum;
181 1 static Byte ucPreKey;
182 1 if(gbKey_CmdIn) // If set key or Ir data received
183 1 return (0x00); // If set return 0x00
184 1
185 1 // BUTTON |= 0x0e; // All Key Pull-high
186 1 // BUTTON |= 0x70; // All Key Pull-high
187 1 P0=0Xff;
188 1 ucKeyNum = P0;
189 1 ucKeyNum &= 0x07;
190 1 ucKeyNum =ucKeyNum <<2;
191 1 if(ucKeyNum == ucPreKey)
192 1 {
193 2 if(debounce<200)debounce++;
194 2 if(debounce==1)
195 2 {
196 3 gbKey_CmdIn = 1;
197 3 return(Key_2IrLut((~ucKeyNum & 0x1c))); // Translate to IR code
198 3 }
199 2 if(debounce>5)
200 2 {
201 3 gbKey_CmdIn = 1;
202 3 gbIR_Repeat=TRUE;
203 3 return(Key_2IrLut((~ucKeyNum & 0x1C))); // Translate to IR code
204 3 }
205 2 }
206 1 else
207 1 {
208 2 presstime=0;
209 2 ucPreKey = ucKeyNum;
210 2 gbIR_Repeat=0;
211 2 debounce=0;
212 2 }
213 1 /*
214 1 ucKeyNum = BUTTON & 0x70; // Get Key Data
215 1 if( ucKeyNum==0x00 )
216 1 ucKeyNum=0x70 ;
217 1
218 1 if(ucKeyNum != 0x70) // Detect Button if pressed
219 1 {
220 1 ucKeyNum = BUTTON & 0x70;
221 1 guc5msCounter = 0;
222 1 gbKey_CmdIn = 1;
223 1 while((BUTTON & 0x70) != 0x70)
224 1 { // Detect Button if released
225 1 if(guc5msCounter >30) { // Wait max time 500ms
226 1 if (ucPreKey==ucKeyNum)
227 1 gbIR_Repeat=TRUE;
228 1
229 1 ucPreKey=ucKeyNum;
230 1 break;
231 1 }
232 1 }
233 1 ucKeyNum = (~ucKeyNum & 0x70); // Inverse the key code
234 1
235 1 return(Key_2IrLut(ucKeyNum)); // Translate to IR code
236 1 }
237 1 */
238 1 return(0x00); // return 0x00 represent no key pressed
239 1 }
240
C51 COMPILER V7.50 KEY 06/25/2008 18:07:57 PAGE 5
241 // *********************************************************
242 // Function : Button2Msg
243 // Description : Execute Key & IR command
244 // Input parameters : None
245 // Return value : None
246 // *********************************************************
247 void Key_2Msg(void)
248 {
249 1 Byte ucKeyData;
250 1 Byte ucIrIndex;
251 1 static Byte ucIrCounter;
252 1
253 1 ucKeyData = Key_Scan();
254 1
255 1 if(!gbKey_CmdIn) // If not set just return,
256 1 return; // do not thing
257 1
258 1 // if(!ucKeyData)return;
259 1 // ucKeyData = gucIRData; // Get From IR.C
260 1 if(gbIR_Repeat)
261 1 { // Repeat code
262 2 ucIrCounter ++; // repeat mode filter counter
263 2 if(!(ucIrCounter % ucIrRep)) // mod ucIrRep
264 2 {
265 3 if(Key_LutInx(ucKeyData, &ucIrIndex, &ucIrRep))
266 3 Msg_Handler(ucIrIndex);
267 3 gbIR_Repeat=FALSE;
268 3 }
269 2 }
270 1 else if(Key_LutInx(ucKeyData, &ucIrIndex, &ucIrRep))
271 1 { // New code
272 2 Msg_Handler(ucIrIndex);
273 2 ucIrCounter = 0;
274 2 }
275 1 gbKey_CmdIn = 0;
276 1 }
277
278
*** WARNING C316 IN LINE 278 OF KEY.C: unterminated conditionals
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 298 ----
CONSTANT SIZE = 15 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 8 9
IDATA SIZE = ---- ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -