int1.c
来自「用51单片机实现IR解码」· C语言 代码 · 共 2,191 行 · 第 1/5 页
C
2,191 行
}
Monitor=Get_IR_Data_Step+Philips_IR_RC6_Mode*1000; System_Flag_DispEvent=1;
Process_Interrupt_Poiter++;
//process interrupt 7
switch(Get_IR_Data_Step)
{
case GET_TRAILER_FALLING_STEP: //Previous_Interrupt_Edge_Tape=TRAILER_Bit_Falling_Edge;
switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
{
case INT_2_T:
return;
//Get_IR_Data_Step=GET_TRAILER_FALLING_STEP;
//Previous_Interrupt_Edge_Tape=TRAILER_Bit_Falling_Edge;
break;
case INT_3_T:
Get_IR_Data_Step=GET_CONTROL_BIT7_STEP;
Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
IR_Input_Bits_Buffer=0;//get the first control bit
break;
case INT_4_T:
return;
//Get_IR_Data_Step=GET_TRAILER_STEP;
//Previous_Interrupt_Edge_Tape=TRAILER_Bit_End_Edge;
break;
case INT_5_T:
return;
//Get_IR_Data_Step=GET_CONTROL_STEP;
//Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
//IR_Input_Bits_Buffer=0;//get the first control bit
break;
default:
return;
}
break;
case GET_TRAILER_STEP:// Previous_Interrupt_Edge_Tape=TRAILER_Bit_End_Edge;
switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
{
case INT_2_T:
return;
Get_IR_Data_Step=GET_CONTROL_BIT7_STEP;
Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
IR_Input_Bits_Buffer=1;//get the first control bit 1XXX XXXX
break;
case INT_3_T:
Get_IR_Data_Step=GET_CONTROL_BIT7_STEP;
Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
IR_Input_Bits_Buffer=0;//get the first control bit
break;
case INT_4_T:
return;
break;
default:
return;
}
break;
case GET_CONTROL_BIT7_STEP://Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
case GET_CONTROL_BIT6_STEP:
case GET_CONTROL_BIT5_STEP:
case GET_CONTROL_BIT4_STEP:
case GET_CONTROL_BIT3_STEP:
if(Previous_Interrupt_Edge_Tape==Zero_Bit_Falling_Edge)
{
switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
{
case INT_2_T:
Get_IR_Data_Step+=1;
Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0;//get the a bit '0'
break;
case INT_3_T:
Get_IR_Data_Step+=1;
Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0x1;//get the bit '1'
break;
case INT_4_T:
Get_IR_Data_Step+=2;
Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<2)+0x2;//get the bit '10'
break;
default:
return;
}
}
else if(Previous_Interrupt_Edge_Tape==One_bit_End_Edge)
{
switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
{
case INT_2_T:
Get_IR_Data_Step+=1;
Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+1;//get the a bit '1'
break;
case INT_3_T:
Get_IR_Data_Step+=2;
Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<2)+0x2;//get the bit '10'
break;
case INT_4_T:
return;
// Get_IR_Data_Step+=2;
//Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
//IR_Input_Bits_Buffer=IR_Input_Bits_Buffer<<2+0x2;//get the bit '10'
break;
default:
return;
}
}
break;
}
Process_Interrupt_Poiter++;
// Monitor=Get_IR_Data_Step+IR_Interrup_Time_Sequece[Process_Interrupt_Poiter+1]*1000+Previous_Interrupt_Edge_Tape*10000; System_Flag_DispEvent=1;
// Monitor=Get_IR_Data_Step+Previous_Interrupt_Edge_Tape*1000; System_Flag_DispEvent=1;
//return;
//process interrupt >8
while( Process_Interrupt_Poiter<IR_Bit_Counter)
{
// Monitor=Get_IR_Data_Step+9*1000; System_Flag_DispEvent=1;
if(Previous_Interrupt_Edge_Tape==Zero_Bit_Falling_Edge)
{
switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
{
case INT_2_T:
Get_IR_Data_Step+=1;
Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0;//get the a bit '0'
break;
case INT_3_T:
Get_IR_Data_Step+=1;
Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0x1;//get the bit '1'
Monitor=Get_IR_Data_Step+90000;//+IR_Interrup_Time_Sequece[Process_Interrupt_Poiter]*1000+Previous_Interrupt_Edge_Tape*10000;
System_Flag_DispEvent=1;
break;
case INT_4_T:
Get_IR_Data_Step+=2;
Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<2)+0x2;//get the bit '10'
break;
default:
Monitor=IR_Interrup_Time_Sequece[Process_Interrupt_Poiter];//*1000;Get_IR_Data_Step+//+Previous_Interrupt_Edge_Tape*10000;
System_Flag_DispEvent=1;
return;
}
}
else if(Previous_Interrupt_Edge_Tape==One_bit_End_Edge)
{
switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
{
case INT_2_T:
Get_IR_Data_Step+=1;
Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+1;//get the a bit '1'
break;
case INT_3_T:
Get_IR_Data_Step+=2;
Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<2)+0x2;//get the bit '10'
break;
case INT_4_T:
Monitor=Get_IR_Data_Step+60000;//+IR_Interrup_Time_Sequece[Process_Interrupt_Poiter]*1000+Previous_Interrupt_Edge_Tape*10000;
System_Flag_DispEvent=1;
return;
// Get_IR_Data_Step+=2;
//Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
//IR_Input_Bits_Buffer=IR_Input_Bits_Buffer<<2+0x2;//get the bit '10'
break;
default:
Monitor=IR_Interrup_Time_Sequece[Process_Interrupt_Poiter];//*1000;//+Previous_Interrupt_Edge_Tape*10000;
System_Flag_DispEvent=1; //Get_IR_Data_Step+
return;
}
}
Process_Interrupt_Poiter++;
};
// Monitor=IR_Input_Bits_Buffer;
// System_Flag_DispEvent=1;
//return;
if(Get_IR_Data_Step==GET_INFORMATION_BIT1_STEP)
{
IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+1;
System_Flag_Get_IR_Key=1;
//Monitor=IR_Input_Bits_Buffer;
//System_Flag_DispEvent=1;
}
else if(Get_IR_Data_Step==GET_INFORMATION_BIT0_STEP)
{
System_Flag_Get_IR_Key=1;
}
else
IR_Input_Bits_Buffer=0xffff;
//Monitor=IR_Input_Bits_Buffer;//+Get_IR_Data_Step+;//+90000;//+Philips_IR_RC6_Mode*1000;
// System_Flag_DispEvent=1;
}
BOOL System_Flag_Philips_IR_Key_Interrupt=0;
#define PHILIPS_RC6_KEY_INTERRUPTs_MIN 11 // 1+4/2+16/2
void T2EX_int (void) interrupt 5 using 2 /* Negative Transition on T2EX */
{
//process the interrupt reason
//BOOL temp_bit;
// EX1=0;
U8 interrupt_time=0;
/*1. When the timer2 overflow */
if(TF2)
{
if(System_Flag_Philips_IR_Key_Interrupt)
{
System_Flag_Philips_IR_Key_Interrupt=0;
System_Flag_Get_IR_Key=0;
Parase_IR_Interrupt_Date();
if(System_Flag_Get_IR_Key)
{
Key_Code=IR_Input_Bits_Buffer&0xFF;
Key_Code_Mode=IR_Input_Bits_Buffer>>8;
System_Flag_DispEvent=0;
}
}
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++;
Current_Intrrupt_data=0xff;
Previous_Interrupt_Edge_Tape=No_Valid;
Get_IR_Data_Step=GET_IR_INVALID_STEP;
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 );
if(IR_Bit_Width<INT_2_T_MIN)
{
//reset
Current_Interrupt_Time=INT_INVALID;
}
else if(IR_Bit_Width<INT_2_T_MAX)
{
Current_Interrupt_Time=INT_2_T;
}
else if(IR_Bit_Width<INT_3_T_MAX)
{
Current_Interrupt_Time=INT_3_T;
}
else if(IR_Bit_Width<INT_4_T_MAX)
{
Current_Interrupt_Time=INT_4_T;
}
else if(IR_Bit_Width<INT_5_T_MAX)
{
Current_Interrupt_Time=INT_5_T;
}
else if(IR_Bit_Width<INT_6_T_MAX)
{
Current_Interrupt_Time=INT_6_T;
}
else if(IR_Bit_Width<INT_8_T_MIN)
{
Current_Interrupt_Time=INT_INVALID; //reset
}
else if(IR_Bit_Width<INT_8_T_MAX)
{
Current_Interrupt_Time=INT_8_T;
IR_Bit_Counter=1;
}
else
{
IR_Bit_Counter=0;
Current_Intrrupt_data=0xff;
Previous_Interrupt_Edge_Tape=No_Valid;
Get_IR_Data_Step=GET_IR_INVALID_STEP;
return;
}
#if 1
if(IR_Bit_Counter==0) return;
IR_Interrup_Time_Sequece[IR_Bit_Counter]=Current_Interrupt_Time;
IR_Bit_Counter++;
IR_Interrup_Time_Sequece[IR_Bit_Counter]=0xff;
if(IR_Bit_Counter>=PHILIPS_RC6_KEY_INTERRUPTs_MIN)
System_Flag_Philips_IR_Key_Interrupt=1;
#else
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?