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000
BOOL Get_Key_Code_Part=0;
void T2EX_int (void) interrupt 5 using 2 /* Negative Transition on T2EX */
{
//process the interrupt reason
BOOL temp_bit;
// EX1=0;
/*1. When the timer2 overflow */
if(TF2)
{
IR_Get_Start_Begin=0;
//clear interrupt flag
TF2=0;
EXF2=0;
//reaset the Timer2
TR2=0; /*stop timer2*/
TH2=0; TL2=0; /*reload the prescalor 19.6ms for X=40M , 28.9mS for X=27M 37.5ms for X=22.118M*/
TR2=1;
IR_Bit_Counter=0;
Get_Single_Key_Code=0;
IR_Input_Bits_Buffer=0x0000;
Timer2_Overflow_Times_Counter++;
if(Get_Key_Code_Part)
{
Enable_Repeat_Bit=1;
}
if(Timer2_Overflow_Times_Counter&0x08) //8*28.9ms>=224ms //&0x10 //16*9.8ms>=150ms)
{
//when the time intervel is large than 108-58.5=49.5ms,disable the repeat key
Enable_Repeat_Bit=0;
Get_Key_Code_Part=0;
Timer2_Overflow_Times_Counter=0x08; //0x10;
}
return;
}
/* 2.the extern T2EX high-to-low triggle the interrupt*/
EXF2=0;
//reaset the Timer2
TR2=0; /*stop timer2*/
TH2=0; TL2=0; /*reload the prescalor 19.6ms for X=40M , 9.69ms for X=40.78X2 37.5ms for X=22.118M 25.98ms for X=24.598X*/
TR2=1; /*start timer2*/
//check the bit width
IR_Bit_Width= RCAP2L+ ( (U16)(RCAP2H) <<8 );
//when the start bit interrupt,we will kill this interrupt
if(IR_Get_Start_Begin==0)
{
IR_Get_Start_Begin=1;
#if( SYSTEM_CRYSTAL ==USE_CRYSTAL_40M039_X2)
//only when the X>69.36M ,theis part is needed
if(Timer2_Overflow_Times_Counter==1)
{
if(Enable_Repeat_Bit==1)
{
if(IR_Bit_Width>NEC_IR_REPEAT_BIT_WIDTH_MIN&&IR_Bit_Width<NEC_IR_REPEAT_BIT_WIDTH_MAX)
{
RCAP2H=0;
RCAP2L=0;
if(IR_Key_Repeat_Counter>=IR_KEY_REPEAT_MASK_TIMES)
{
//look for the repeat enable table ,if repeat enable send the key ,else do nothing
if(IR_Key_Repeat_Enable_Table[IR_Key_Code]==1)
{
Key_Code=IR_Key_Code;
IR_Key_Repeat_Counter=IR_KEY_REPEAT_MASK_TIMES;
}
else
IR_Key_Repeat_Counter=0;
}
IR_Key_Repeat_Counter++;
}
}
}
#endif
Timer2_Overflow_Times_Counter=0;
return;
}
if(Enable_Repeat_Bit==1)
{
if(IR_Bit_Width>NEC_IR_REPEAT_BIT_WIDTH_MIN&&IR_Bit_Width<NEC_IR_REPEAT_BIT_WIDTH_MAX)
{
RCAP2H=0;
RCAP2L=0;
if(IR_Key_Repeat_Counter>=IR_KEY_REPEAT_MASK_TIMES)
{
//look for the repeat enable table ,if repeat enable send the key ,else do nothing
if(IR_Key_Repeat_Enable_Table[IR_Key_Code]==1)
{
Key_Code=IR_Key_Code;
IR_Key_Repeat_Counter=IR_KEY_REPEAT_MASK_TIMES;
}
else
IR_Key_Repeat_Counter=0;
}
IR_Key_Repeat_Counter++;
return;
}
}
IR_Bit_Counter++;
if(IR_Bit_Width>NEC_IR_0_BIT_WIDTH_MIN&&IR_Bit_Width<NEC_IR_0_BIT_WIDTH_MAX)
{
// Monitor=2; System_Flag_DispEvent=1;
// get '0' bit
temp_bit=0;
}
else if(IR_Bit_Width>NEC_IR_1_BIT_WIDTH_MIN&&IR_Bit_Width<NEC_IR_1_BIT_WIDTH_MAX)
{
//Monitor=8; System_Flag_DispEvent=1;
//get '1' bit
temp_bit=1;
}
else
{
//Monitor=1000; System_Flag_DispEvent=1;
// kill off the interfere and no use puls
Get_Single_Key_Code=0;
IR_Input_Bits_Buffer=IR_INPUT_BUFFER_CLEAR;
IR_Key_Repeat_Counter=0;
IR_Bit_Counter=0;
// IR_Get_Start_Begin=0; // for the invalid puls we shouldl kill the bit,but we use the bit counter to kill,
//not kill the IR_Get_Start_Begin, because the start leader part 9ms_ and 4.5ms~ ,we also kill it ,not use it
Enable_Repeat_Bit=0;
return;
}
{
// IR_Bit_Counter++;
// IR_Input_Bits_Buffer=IR_Input_Bits_Buffer>>1;
if(temp_bit)
IR_Input_Bits_Buffer|=0x8000;
// else
// IR_Input_Bits_Buffer&=0x7FFF;
if(IR_Bit_Counter==16)//16) // 15) //17)
{
if(IR_Input_Bits_Buffer==NEC_IR_CUSTOMER_CODE)
{
//after get the customer code, we use the IR_Input_Bits_Buffer as the code input
IR_Input_Bits_Buffer=IR_INPUT_BUFFER_CLEAR;
//Monitor=8800; System_Flag_DispEvent=1;
}
else
{
Monitor=IR_Input_Bits_Buffer; System_Flag_DispEvent=1;
Get_Single_Key_Code=0;
IR_Input_Bits_Buffer=IR_INPUT_BUFFER_CLEAR;
IR_Key_Repeat_Counter=0;
// IR_Bit_Counter=0;
IR_Get_Start_Begin=0;
return;
}
}
else if(IR_Bit_Counter==32)//32)//33)
{
// Get_Single_Key_Code=1;
IR_Key_Code=IR_Key_Assign_Table[(U8)(IR_Input_Bits_Buffer)];//(IR_Input_Bits_Buffer>>8);
IR_Bit_Counter=0;
Key_Code=IR_Key_Code;
IR_Get_Start_Begin=0;
IR_Key_Repeat_Counter=0;
//when get a valid key ,then enable the repeat key
Get_Key_Code_Part=1;
// System_Flag_DispEvent=1; Common_Register=IR_Input_Bits_Buffer;
}
IR_Input_Bits_Buffer=IR_Input_Bits_Buffer>>1;
}
}
#elif( IR_SYSTEM==PHILIPS_IR_SYSTEM)
CODE U8 IR_Key_Assign_Table[]={
KEY_IR_,// 0x00,
KEY_IR_ ,// 0x01,
KEY_IR_,// 0x02,
KEY_IR_ ,// 0x03,
KEY_IR_ ,// 0x04,
KEY_IR_ ,// 0x05,
KEY_IR_ ,// 0x06,
KEY_IR_,// 0x07,
KEY_IR_,// 0x08,
KEY_IR_,// 0x09,
KEY_IR_,// 0x0A,
KEY_IR_,// 0x0B,
KEY_IR_,// 0x0C,
KEY_IR_,// 0x0D,
KEY_IR_NEXT,// 0x0E,
KEY_IR_STOP,// 0x0F,
KEY_IR_OK,// 0x10,
KEY_IR_UP,// 0x11,
KEY_IR_FB,// 0x12,
KEY_IR_FF,// 0x13,
KEY_IR_DOWN,// 0x14,
KEY_IR_,// 0x15,
KEY_IR_,// 0x16,
KEY_IR_PREVIOUS,// 0x17,
KEY_IR_PLAY,// 0x18,
KEY_IR_VOLOUME_DOWN,// 0x19,
KEY_IR_VOLOUME_UP,// 0x1A,
KEY_IR_,// 0x1B,
KEY_IR_,// 0x1C,
KEY_IR_,// 0x1D,
KEY_IR_,// 0x1E,
KEY_IR_MENU,// 0x1F,
KEY_IR_,// 0x20,
KEY_IR_,// 0x21,
KEY_IR_,// 0x22,
KEY_IR_,// 0x23,
KEY_IR_,// 0x24,
KEY_IR_,// 0x25,
KEY_IR_,// 0x26,
KEY_IR_,// 0x27,
KEY_IR_,// 0x28,
KEY_IR_,// 0x29,
KEY_IR_,// 0x2A,
KEY_IR_,// 0x2B,
KEY_IR_,// 0x2C,
KEY_IR_,// 0x2D,
KEY_IR_MUTE,// 0x2E,
KEY_IR_,// 0x2F,
KEY_IR_,// 0x33,
KEY_IR_,// 0x31,
KEY_IR_,// 0x32,
KEY_IR_,// 0x33,
KEY_IR_,// 0x34,
KEY_IR_,// 0x35,
KEY_IR_,// 0x36,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -