📄 ir.lst
字号:
C51 COMPILER V8.08 IR 03/06/2008 13:41:14 PAGE 1
C51 COMPILER V8.08, COMPILATION OF MODULE IR
OBJECT MODULE PLACED IN .\obj\IR.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE SRC\IR.C BROWSE DEBUG OBJECTEXTEND PRINT(.\lst\IR.lst) OBJECT(.\obj\IR.obj)
line level source
1 #include "comm.h"
2 #include "Key_process.h"
3 #include "ir.h"
4 #include "debug.h"
5
6
7 bit pre_bit = 0;
8 uint32 dataIR = 0; /* System/customer IR code */
9 static uchar cntIRbits = 0; /* Number of IR sys/cust. bits */
10 char stateIR = IR_IDLE; /* IR state machine state */
11 extern bit ir_enable;
12 extern uchar codeIR;
13 uchar pre_code = 0;
14 bit repeat_flag =0;
15
16
17 #if 0
static void code_valid()
{
if(dataIR == pre_code)
{
if(pre_code == _POWER_KEY) /*POWER key do not allow repeat*/
return;
}
else
{
ir_enable = 1;
codeIR = dataIR & 0xFF;
pre_code = dataIR;
}
stateIR = IR_IDLE;
j cntIRbits = 1;
dataIR = 1;
pre_bit = 1;
}
#endif
39
40 void Timer_0(void) interrupt 1
41 {
42 1 //extern int Get_key_timer;
43 1 /*15.6ms 正常的一次信号是 9.0MS + 4.5 超过这个时间,就表示,信号不符合
44 1
45 1 或是IR_REEP
46 1 */
47 1 TR0 = 0;
48 1 TL0=0x00;
49 1 TH0=0x90;
50 1 /*TR0 = 1;*/
51 1 #if 0 //def IRREP
if (stateIR == IR_REPEAT)
{
repeat_flag =1;
if(pre_code == _POWER_KEY)
C51 COMPILER V8.08 IR 03/06/2008 13:41:14 PAGE 2
return; /*POWER 键不需要连按*/
codeIR = pre_code; /* Indicate a new code */
ir_enable = 1;
}
#endif
61 1
62 1
63 1
64 1 stateIR = IR_IDLE;
65 1 cntIRbits = 1;
66 1 dataIR = 1;
67 1 pre_bit = 1;
68 1 }
69 #if 0
void ir_core_philips()
{
uint width;
TR0=0;
/* two_byte_tmp._WORD.H_BYTE = TH0;
two_byte_tmp._WORD.L_BYTE = TL0;*/
width = (uint)(TH0 * 256) + TL0;
TL0=0x00;
TH0=0x90;
TR0=1;
/* width = two_byte_tmp.word;*/
if((width > PLUSE2_WIDTH_MIN) && (width < PLUSE2_WIDTH_MAX))
{
width = 2;
}
else if((width > PLUSE3_WIDTH_MIN) && (width < PLUSE3_WIDTH_MAX))
{
width = 3;
}
else if((width > PLUSE4_WIDTH_MIN) && (width < PLUSE4_WIDTH_MAX))
{
width = 4;
}
else
{
width = 1;
}
pre_bit = dataIR & 0x1;
if(stateIR == IR_IDLE)
{
stateIR = IR_CUSTOM;
cntIRbits = 1;
dataIR = 1;
pre_bit = 1;
}
else
{
switch(width){
case 2:
cntIRbits += 2;
break;
case 3:
cntIRbits += 3;
break;
C51 COMPILER V8.08 IR 03/06/2008 13:41:14 PAGE 3
case 4:
cntIRbits += 4;
break;
default:
break;
}
dataIR <<= 1;
if(cntIRbits & 0x1) /*half bit*/
{
switch(width){
case 2: /*如果接收到2个脉冲之后数据是半位,则数据和前一位的值一样*/
if(pre_bit)
dataIR |= 0x1;
break;
case 3: /*如果接收到3个脉冲之后数据是半位,则数据是前一位的值以及前一位的反*/
if(pre_bit)
{
dataIR |= 1;
dataIR <<= 1;
}
else
{
dataIR <<= 1;
dataIR |= 1;
}
break;
case 4: /*如果接收到4个脉冲之后数据是半位,则数据是前一位的值的反以及前一位的值*/
if(pre_bit)
{
dataIR <<= 1;
dataIR |= 1;
}
else
{
dataIR |= 1;
dataIR <<= 1;
}
break;
}
}
else /*full bit*/
{
switch(width){
case 2: /*如果接收到2个脉冲之后数据是完整位,则数据和前一位的值一样*/
if(pre_bit)
dataIR |= 0x1;
break;
case 3:
case 4:
if(pre_bit) /*如果接收到3个或者4个脉冲宽度之后数据是完整位,则数据为前一位的反以及前一位一样的值*/
{
dataIR <<= 1;
dataIR |= 1;
}
else
{
dataIR |= 1;
dataIR <<= 1;
}
break;
}
}
C51 COMPILER V8.08 IR 03/06/2008 13:41:14 PAGE 4
}
if(cntIRbits == 0x1B)
{
code_valid();
}
if(cntIRbits > 0x1B)
{
stateIR = IR_IDLE;
}
}
#endif
192
193
194
195 #define IR_NEC
196 #if 1//def IR_NEC
197 #ifdef DEBUG_PRINTF
unsigned char sys_code;
unsigned char ivcode;
#endif
203
204 void ir_core_nec() using 1
205 {
206 1 int reset = 0;
207 1 uint width;
208 1 // static uchar rep_cnt=0;
209 1 //unsigned char temp_data,temp_data1;
210 1 TR0=0;
211 1 width = (uint)((TH0 -0x90)* 256) + TL0 ;
212 1 TL0=0x00;
213 1 TH0=0x90;
214 1 TR0=1;
215 1 // temp_data = (width>>8);
216 1 // temp_data1 = width&0xff;
217 1
218 1 if (stateIR == IR_IDLE)
219 1 {
220 2 stateIR = IR_LEADER_LOW;
221 2
222 2 }
223 1 else if (stateIR == IR_CUSTOM)
224 1 {
225 2
226 2 dataIR <<= 1;
227 2 if ((width >= DATA_1_MIN) && (width <= DATA_1_MAX))
228 2 {
229 3 dataIR |= 0x1;
230 3 }
231 2 else if ((width < DATA_0_MIN) || (width > DATA_1_MAX))
232 2 {
233 3 reset = 1;
234 3 }
235 2
236 2 cntIRbits++;
237 2
238 2 /* First 16 bits are syscode */
239 2 #if 1
240 2 if (cntIRbits == 16 )
241 2 {
C51 COMPILER V8.08 IR 03/06/2008 13:41:14 PAGE 5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -