int.c

来自「用51单片机实现IR解码」· C语言 代码 · 共 2,143 行 · 第 1/5 页

C
2,143
字号
	GET_IR_INVALID_STEP=0xff,
	

};
#define PHILIPS_RC6_KEY_INTERRUPTs_MIN	11   //   1+4/2+16/2
BOOL System_Flag_Philips_IR_Key_Interrupt=0;
BOOL System_Flag_Philips_IR_RC5_Indication_Bit=0;
BOOL Get_Key_Code_Part=0;
U8 Philips_IR_RC6_Mode=0;

U8 Current_Interrupt_Time=0;
U8 Previous_Interrupt_Edge_Tape=No_Valid;
U8 Get_IR_Data_Step=GET_IR_INVALID_STEP;
U8 IR_Interrup_Time_Sequece[22];


DE_DATA U8 Process_Interrupt_Poiter;
BOOL System_Flag_Get_Valid_Philips_IR_Key=0;
void Parase_RC5_IR_Interrupt_Date()
{
  //process interrupt =1	
   Process_Interrupt_Poiter=1;  
  switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
  	{
  	case RC5_INT_2_T:
		Get_IR_Data_Step=GET_RC5_INDICATION_BIT_STEP;
		Previous_Interrupt_Edge_Tape=RC5_One_bit_Falling_Edge;
		  IR_Input_Bits_Buffer=0x03; //get first 11
		  System_Flag_Philips_IR_RC5_Indication_Bit=1;
		break;
 	case RC5_INT_3_T:
		Get_IR_Data_Step=GET_RC5_INDICATION_BIT_STEP;
		Previous_Interrupt_Edge_Tape=RC5_Zero_Bit_END_Edge;
	        IR_Input_Bits_Buffer=0x02;
		System_Flag_Philips_IR_RC5_Indication_Bit=0;
		break;
		
	case RC5_INT_4_T:
		   Get_IR_Data_Step=GET_RC5_CONTROL_BIT_STEP;
		   Previous_Interrupt_Edge_Tape=RC5_One_bit_Falling_Edge;
	         IR_Input_Bits_Buffer=0x05;
		 System_Flag_Philips_IR_RC5_Indication_Bit=0;
		break;
       default:
	   	 Monitor=IR_Interrup_Time_Sequece[1]+3000;	  System_Flag_DispEvent=1; 

	   	return;
  	}
    
//	   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_Poiter=2; 
while( Process_Interrupt_Poiter<IR_Bit_Counter+1)
	{ 
	      
    
		//   Monitor=Get_IR_Data_Step+9*1000;	  System_Flag_DispEvent=1; 
                                 if(Previous_Interrupt_Edge_Tape==RC5_One_bit_Falling_Edge)
							{

							switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
					                  {
					                    case RC5_INT_2_T:
								
									Get_IR_Data_Step+=1;
									Previous_Interrupt_Edge_Tape=RC5_One_bit_Falling_Edge;
									  IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+1;//get the a bit '1'  
									
									break;
									
							      case RC5_INT_3_T:  
										  		Get_IR_Data_Step+=1;
											Previous_Interrupt_Edge_Tape=RC5_Zero_Bit_END_Edge;
										       IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0x0;//get the bit '0'

									          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 RC5_INT_4_T:
									 	Get_IR_Data_Step+=2;
									Previous_Interrupt_Edge_Tape=RC5_One_bit_Falling_Edge;
								       IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<2)+0x01;//get the bit '01'
								     
									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==RC5_Zero_Bit_END_Edge)
								{
										switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
							                  {
							                    case RC5_INT_2_T:
										
											Get_IR_Data_Step+=1;
											Previous_Interrupt_Edge_Tape=RC5_Zero_Bit_END_Edge;
											  IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0;//get the a bit '0'  
											
											break;
											
									      case RC5_INT_3_T:  
										  		Get_IR_Data_Step+=2;
											Previous_Interrupt_Edge_Tape=RC5_One_bit_Falling_Edge;
										       IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<2)+0x01;//get the bit '01'
											
											break;
											
											
										case RC5_INT_4_T:
											
									        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_RC5_COMMAND_BIT1_STEP)
	{
	IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1);
	System_Flag_Get_Valid_Philips_IR_Key=1;
	//Monitor=IR_Input_Bits_Buffer;
	//System_Flag_DispEvent=1;
     	}
    
     else if(Get_IR_Data_Step==GET_RC5_COMMAND_BIT0_STEP)
	{
	 System_Flag_Get_Valid_Philips_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; 
   
     
}

void Parase_RC6_IR_Interrupt_Date()
{

//process interrupt 1
  //if(IR_Interrup_Time_Sequece[1]!=INT_8_T) 
  //	return;
  Process_Interrupt_Poiter=2;
  
//process interrupt 2
  switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
  	{
  	case INT_2_T:
		Get_IR_Data_Step=GET_START_STEP;
		Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
		
		break;
 	case INT_3_T:
		Get_IR_Data_Step=GET_MODE_BIT0_STEP;
		Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
	        IR_Input_Bits_Buffer=0;
		break;
		
	case INT_4_T:
		
       default:
	   	return;
  	}
  
   
	 Process_Interrupt_Poiter++;
	   
//	  Monitor=Get_IR_Data_Step;	  System_Flag_DispEvent=1; 
//process interrupt 3
switch(Get_IR_Data_Step)

{
		case GET_START_STEP: //Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
			 switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
			  	{
				case INT_2_T:
					Get_IR_Data_Step=GET_MODE_BIT0_STEP;
					Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
					IR_Input_Bits_Buffer=1;    //get the mode 1XX
					break;
			 	case INT_3_T:
					Get_IR_Data_Step=GET_MODE_BIT1_STEP;
					Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
				        IR_Input_Bits_Buffer=0x02;   //get the mode 10X
					break;
					
				case INT_4_T:
					
			       default:
				   	return;
			  	}
		     break;
		case GET_MODE_BIT0_STEP://Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
			      switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
			  	{
				case INT_2_T:
					Get_IR_Data_Step=GET_MODE_BIT1_STEP;
					Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
					IR_Input_Bits_Buffer=0x00;  //get the mode 00X
					break;
					
			      case INT_3_T:  
					Get_IR_Data_Step=GET_MODE_BIT1_STEP;
					Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
				        IR_Input_Bits_Buffer=0x02;  // get the mode 01X
				      
					break;
					
					
				case INT_4_T:
					Get_IR_Data_Step=GET_MODE_BIT2_STEP;
					Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
				        IR_Input_Bits_Buffer=0x02;  // get the mode 010
				        Philips_IR_RC6_Mode=0x02;
					break;
			       default:
				   	return;
			  	}
			break;

}

  Process_Interrupt_Poiter++;
  
//process interrupt 4

//  Monitor=Get_IR_Data_Step;	  System_Flag_DispEvent=1; 

switch(Get_IR_Data_Step)

{
		case GET_MODE_BIT0_STEP:  //Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
			 switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
			  	{
				case INT_2_T:
					Get_IR_Data_Step=GET_MODE_BIT1_STEP;
					Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
					IR_Input_Bits_Buffer=0x01; //get the mode 01X
					break;
			 	case INT_3_T:
					Get_IR_Data_Step=GET_MODE_BIT2_STEP;
					Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
				        IR_Input_Bits_Buffer=0x06; //get the mode 110
				        Philips_IR_RC6_Mode=0x06;
					break;
					
				case INT_4_T:
					
			       default:
				   	return;
			  	}
		     break;
		case GET_MODE_BIT1_STEP:
			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=GET_MODE_BIT2_STEP;
						Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
						IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0x01; //get the mode 101
						      Philips_IR_RC6_Mode=0x05;
						break;
						
				      case INT_3_T:  
    						 return;
						/* not valid 
						Get_IR_Data_Step=GET_MODE_BIT1_STEP;
						Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
					        IR_Input_Bits_Buffer=0x01;  // get the mode 010
					        */
					   
						break;
						
						
					case INT_4_T:
						Get_IR_Data_Step=GET_TRAILER_FALLING_STEP;
						Previous_Interrupt_Edge_Tape=TRAILER_Bit_Falling_Edge;
					        IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0x01;  // get the mode 101
					              Philips_IR_RC6_Mode=0x05;
						break;
				       default:
					   	return;
				  	}
				}
			else 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=GET_MODE_BIT2_STEP;
						Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
						IR_Input_Bits_Buffer=0x00;
						 Philips_IR_RC6_Mode=0x00;
						break;
						
				      case INT_3_T:  
						Get_IR_Data_Step=GET_MODE_BIT2_STEP;
						Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
					        IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0x01;  // get the mode 101 or 001
						break;
						
						
					case INT_4_T:
						return;
						/*not valid
						Get_IR_Data_Step=GET_MODE_BIT2_STEP;
						Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
					        IR_Input_Bits_Buffer=0x02;  // get the mode 010
					        */
						break;
				       default:
					   	return;
				  	}

				}
			break;
		case GET_MODE_BIT2_STEP://Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
				 switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
				  	{
					case INT_2_T:
						return;
						/*not valid
						Get_IR_Data_Step=GET_MODE_BIT1_STEP;
						Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
						IR_Input_Bits_Buffer=0x00;
						*/
						break;
						
				      case INT_3_T:  
					  	
						Get_IR_Data_Step=GET_TRAILER_FALLING_STEP;
						Previous_Interrupt_Edge_Tape=TRAILER_Bit_Falling_Edge;
					        IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0;
					      Philips_IR_RC6_Mode=IR_Input_Bits_Buffer;
						break;
						
						
					case INT_4_T:
							return;
						/*not valid
						Get_IR_Data_Step=GET_MODE_BIT2_STEP;
						Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
					        IR_Input_Bits_Buffer=0x02;  // get the mode 010
					        */
						break;
					 case INT_5_T:  
								  	
									Get_IR_Data_Step=GET_TRAILER_STEP;
									Previous_Interrupt_Edge_Tape=TRAILER_Bit_End_Edge;
								     //   IR_Input_Bits_Buffer=IR_Input_Bits_Buffer<<1;
									  //    Philips_IR_RC6_Mode=IR_Input_Bits_Buffer;
									break;
				       default:
					   	return;
				  	}
			break;

}


   Process_Interrupt_Poiter++;

   Monitor=Get_IR_Data_Step+Philips_IR_RC6_Mode*1000;	  System_Flag_DispEvent=1; 
   
//process interrupt 5
switch(Get_IR_Data_Step)

{
		case GET_MODE_BIT1_STEP://					Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
		                     

				  switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])
				  	{
					case INT_2_T:
						Get_IR_Data_Step=GET_MODE_BIT2_STEP;
						Previous_Interrupt_Edge_Tape=One_bit_End_Edge;
						IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0x01; 
						 Philips_IR_RC6_Mode=IR_Input_Bits_Buffer;
						break;
						
				      case INT_3_T:  
    						 return;
						/* not valid 
						Get_IR_Data_Step=GET_MODE_BIT1_STEP;
						Previous_Interrupt_Edge_Tape=Zero_Bit_Falling_Edge;
					        IR_Input_Bits_Buffer=0x01;  // get the mode 010
					        */
					   
						break;
						
						
					case INT_4_T:
						Get_IR_Data_Step=GET_TRAILER_FALLING_STEP;
						Previous_Interrupt_Edge_Tape=TRAILER_Bit_Falling_Edge;
					        IR_Input_Bits_Buffer=(IR_Input_Bits_Buffer<<1)+0x01;  // 
					              Philips_IR_RC6_Mode=IR_Input_Bits_Buffer;
						break;
				       default:
					   	return;
				  	
			  	}
					break;
		case GET_MODE_BIT2_STEP:           
						if(Previous_Interrupt_Edge_Tape==Zero_Bit_Falling_Edge)
						{
						 switch(IR_Interrup_Time_Sequece[Process_Interrupt_Poiter])

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?