📄 ir.lst
字号:
C51 COMPILER V7.50 IR 06/25/2008 18:07:54 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE IR
OBJECT MODULE PLACED IN .\Output\IR.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE IR.C BROWSE DEBUG OBJECTEXTEND PRINT(.\Output\IR.lst) OBJECT(.\Output\IR.ob
-j)
line level source
1 /*--------------------------------------------------------------------------
2 IR.C
3 C file for IR
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 <stdio.H>
13 #include "DEFINE.H"
14 #include "DATATYPE.H"
15 #include "IR.H"
16
17
18 Bool gbIR_Repeat;
19 Bool gbIRKeyInput;
20 Bool gbKey_CmdIn;
21 extern Bool fld;
22 bit fir,irnow,irpre;
23 unsigned char beeptimes,ircnt,beepcnt,irnum,temprem;
24 unsigned int nosigntim;
25 unsigned char rembuf[5];
26 extern Byte distance1,distance2,distance3,distance4;
27 extern Byte beepmode;
28 extern idata Byte vcjbeepon;
29 //Byte gbIR_State;
30 //Byte gucIRData _at_ 0x33;
31 //Byte gucPre_IRData;
32
33
34
35 // ********************************************************************************
36 // Function : Timer0ISR
37 // Description : Receive IR command via I/O pin.
38 // Input parameters : None.
39 // Return value : Bool - gbIRKeyInput, gbKey_CmdIn : Set when received data.
40 // Byte - gucIRData : Received IR code.
41 // Bool - gbIR_Repeat : Repeat code.
42 // ********************************************************************************
43 void Timer0ISR(void) interrupt 1 using 1
44 {
45 1 // static Byte ucIR_Count_Bits,ucIR_Counter;
46 1 // static Word uiIR_RecvWord;
47 1
48 1 TH0 = TIMER0_TH0;
49 1 TL0 = TIMER0_TL0;
50 1
51 1 /*
52 1 if(gbKey_CmdIn) // If set wait to cmd executed
53 1 return; // If set just return, do not thing
54 1
C51 COMPILER V7.50 IR 06/25/2008 18:07:54 PAGE 2
55 1 if(ucIR_Counter > 220) // 500*220 = 110ms
56 1 { // If over repeat peroid (108ms) reset
57 1 gbIRKeyInput = FALSE;
58 1 gucIRData = 0;
59 1 gbIR_State = IR_IDLE;
60 1 ucIR_Counter = 0;
61 1 ucIR_Count_Bits = 0;
62 1 gbIR_Repeat = FALSE;
63 1 gucPre_IRData = 0;
64 1 }
65 1 switch(gbIR_State)
66 1 {
67 1 case IR_IDLE: // 0
68 1 if(IR)
69 1 {
70 1 ucIR_Counter++;
71 1 }
72 1 else
73 1 {
74 1 gbIR_State = IR_LEADING_1;
75 1 ucIR_Counter = 1;
76 1 }
77 1 break;
78 1
79 1 case IR_LEADING_1:
80 1
81 1 if(IR)
82 1 {
83 1 if(approxPeriod(ucIR_Counter ,IR_NEC_LEADER_MIN ,IR_NEC_LEADER_MAX))
84 1 {
85 1 gbIR_State = IR_LEADING_2;
86 1 ucIR_Counter = 1;
87 1 }
88 1 else
89 1 {
90 1 gbIR_State = IR_IDLE;
91 1 ucIR_Counter = 0;
92 1 gucIRData = 0;
93 1 gbIRKeyInput = FALSE;
94 1 gbIR_Repeat = FALSE;
95 1 }
96 1 }
97 1 else
98 1 {
99 1 ucIR_Counter++;
100 1 }
101 1 break;
102 1
103 1 case IR_LEADING_2 :
104 1 if(IR)
105 1 {
106 1 ucIR_Counter++;
107 1 }
108 1 else
109 1 {
110 1 if (approxPeriod(ucIR_Counter, IR_NEC_CUSTOM_MIN ,IR_NEC_CUSTOM_MAX ))
111 1 { //new code,4.5/0.5 = 9
112 1 gbIR_State = IR_CUSTOM;
113 1 while(!IR);
114 1 }
115 1 else if (approxPeriod(ucIR_Counter, IR_NEC_REPEAT_MIN , IR_NEC_REPEAT_MAX ))
116 1 { // repeat code, 2.25/0.5=4.5
C51 COMPILER V7.50 IR 06/25/2008 18:07:54 PAGE 3
117 1 gbIR_State = IR_IDLE;
118 1 gbIRKeyInput = TRUE;
119 1 gbKey_CmdIn = TRUE; // murphy
120 1 gbIR_Repeat = TRUE;
121 1 gucIRData=gucPre_IRData;
122 1
123 1 while(!IR);
124 1 }
125 1 else
126 1 {
127 1 gucIRData = 0;
128 1 gbIRKeyInput = FALSE;
129 1 gbIR_State = IR_IDLE;
130 1 gbIR_Repeat = FALSE;
131 1 }
132 1 ucIR_Counter = 0;
133 1 }
134 1 break;
135 1
136 1 case IR_CUSTOM :
137 1 case IR_KEYDATA:
138 1 if(IR)
139 1 {
140 1 ucIR_Counter++;
141 1 break;
142 1 }
143 1 switch(ucIR_Counter)
144 1 {
145 1 case 0 :
146 1 case 1 :
147 1 case 2 :
148 1 uiIR_RecvWord = (Word) uiIR_RecvWord << 1;
149 1 ucIR_Count_Bits++;
150 1 break;
151 1 case 3 :
152 1 case 4 :
153 1 case 5 :
154 1 uiIR_RecvWord = ((Word) uiIR_RecvWord << 1 ) | 0x01;
155 1 ucIR_Count_Bits++;
156 1 break;
157 1 default:
158 1 gbIR_State = IR_IDLE;
159 1 ucIR_Count_Bits = 0;
160 1 gucIRData = 0;
161 1 gbIRKeyInput = FALSE;
162 1 gbIR_Repeat = FALSE;
163 1 break;
164 1 }
165 1 ucIR_Counter = 0;
166 1 if(ucIR_Count_Bits == IR_NEC_BITCOUNT)
167 1 {
168 1 ucIR_Count_Bits = 0;
169 1 if ((gbIR_State ==IR_CUSTOM) && (uiIR_RecvWord == CUSTOMCODE))
170 1 {
171 1
172 1 ucIR_Count_Bits = 0;
173 1 uiIR_RecvWord = 0;
174 1 gbIR_State = IR_KEYDATA;
175 1 }
176 1 else if (gbIR_State == IR_KEYDATA)
177 1 {
178 1 // if(HBYTE == ~LBYTE)
C51 COMPILER V7.50 IR 06/25/2008 18:07:54 PAGE 4
179 1 if(*((Byte *)&uiIR_RecvWord) == ~ *((Byte *)&uiIR_RecvWord+1))
180 1 {
181 1 // gucIRData = HBYTE;
182 1 gucIRData = *((Byte *)&uiIR_RecvWord);
183 1 gucPre_IRData=gucIRData;
184 1 if(!gucIRData) gucIRData = 0x0C; // IRPower Code
185 1 gbIRKeyInput = TRUE;
186 1 gbKey_CmdIn = TRUE;
187 1 gbIR_State = IR_IDLE;
188 1 }
189 1 }
190 1 else
191 1 {
192 1 gbIRKeyInput = FALSE;
193 1 gucIRData = 0;
194 1 gbIR_State = IR_IDLE;
195 1 gbIR_Repeat = FALSE;
196 1 }
197 1 }
198 1 while (!IR);
199 1 break;
200 1
201 1 default:
202 1 ucIR_Counter = 0;
203 1 gbIR_State = IR_IDLE;
204 1 gbIRKeyInput = FALSE;
205 1 gucIRData = 0;
206 1 gbIR_Repeat = FALSE;
207 1 break;
208 1 }
209 1 TH0 = TIMER0_TH0;
210 1 TL0 = TIMER0_TL0;
211 1 */
212 1
213 1 ir=1;
214 1 irnow = ir;
215 1
216 1 if(vcjbeepon)
217 1 {
218 2 beeptimes++;
219 2 if(beeptimes>150)
220 2 {
221 3 beeptimes=0;
222 3 beepcnt++;
223 3 if(beepcnt>7)beepcnt=0;
224 3 if(beepmode&(1<<beepcnt))
225 3 pbeep = 1;
226 3 else
227 3 pbeep = 0; //0
228 3 }
229 2 }
230 1 else
231 1 pbeep=0;
232 1
233 1 ircnt++;
234 1 if(!irnow)
235 1 {
236 2 nosigntim++;
237 2 if(nosigntim>600)
238 2 {
239 3 distance1=distance2=distance3=distance4=200;
240 3 nosigntim=600;
C51 COMPILER V7.50 IR 06/25/2008 18:07:54 PAGE 5
241 3 beepmode=0;
242 3 fld=0;
243 3 }
244 2 if(irpre)
245 2 {
246 3 if((ircnt>10)&&(ircnt<20))
247 3 {
248 4 fir = 1;
249 4 irnum = 0;
250 4 rembuf[0] = 0;
251 4 rembuf[1] = 0;
252 4 rembuf[2] = 0;
253 4 rembuf[3] = 0;
254 4 rembuf[4] = 0;
255 4 }
256 3 else
257 3 {
258 4 if(ircnt>5)
259 4 rembuf[irnum>>3] |= (1 << (irnum & 0x07));
260 4 irnum++;
261 4 if(irnum >= 40)
262 4 {
263 5 if(fir)
264 5 {
265 6 temprem = rembuf[0]+rembuf[1]+rembuf[2]+rembuf[3];
266 6 temprem = ~temprem;
267 6 if(temprem==rembuf[4])
268 6 {
269 7 distance1 = rembuf[0];
270 7 distance2 = rembuf[1];
271 7 distance3 = rembuf[2];
272 7 distance4 = rembuf[3];
273 7 fld=1;
274 7 }
275 6 }
276 5 }
277 4 }
278 3 ircnt=0;
279 3 }
280 2 }
281 1 else
282 1 {
283 2 if(ircnt>50)
284 2 {
285 3 ircnt=50;
286 3 fir=0;
287 3 }
288 2 nosigntim=0;
289 2 }
290 1
291 1
292 1
293 1 irpre = irnow;
294 1
295 1 // TH0 = TIMER0_TH0;
296 1 // TL0 = TIMER0_TL0;
297 1
298 1
299 1 }
300
*** WARNING C316 IN LINE 300 OF IR.C: unterminated conditionals
C51 COMPILER V7.50 IR 06/25/2008 18:07:54 PAGE 6
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 286 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 12 ----
IDATA SIZE = ---- ----
BIT SIZE = 6 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -