欢迎来到天天文库
浏览记录
ID:22569731
大小:2.64 MB
页数:52页
时间:2018-10-30
《红外通信单片机c51程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、/*遥控接收在此中断程序内完成//遥控码放在ir_da[]中/************************************//* InterruptforIRsubroutine *//* externalinterruptsourceINT0 *//************************************///#include//#include"funtion_sub.h"#include"message.H"#include"include.h"//#defineuCHAR unsign
2、edcharexternbitir_enable;externbitir_start;externbitir_key_continue_pressed;externbitUsing_Timer1;externbitLeaderCode_9MS;externbitLeaderCode_4_5MS;externbitIR_Sending;externbitIR_Keep_Press;//长按externbitIR_2MS_Re;externbitIR_560US_Re;externuCHARir_word;externuCHARir_bit;ext
3、ernuCHARir_data[4];externuCHARidata IR_Tran_data[4];externucharidataIR_Out_Times;externuCHARPRE_REMOTE_KEY; voidRESET_IROUT(){LeaderCode_9MS=0;//强制中止IR_OUTLeaderCode_4_5MS=0;IR_2MS_Re=0;IR_Keep_Press=0;IR_560US_Re=0;IR_Sending=0;Using_Timer1=0;IR_Out_Times=0;TR1=0;//EX1_Pr
4、i_Hight;//Timer1_Pri_LOW;}voidIRTimer1Start(void){TR1=0;TF1=0;RESET_IROUT();TMOD=TMOD
5、0X10;TH1=0X00;TL1=0X00;Using_Timer1=1;TR1=1;}voidint1Remote()interrupt2{uCHAR tempTH1;bitir_0_1,ir_flag;//if(IR_Out_Times!=0){//正在发送//return;//有必要地话可以夺取控制权.//}//Using_Timer1=1;tempTH1=TH1;E
6、X1=0;ir_flag=0;ir_enable=0;if(TF1){IRTimer1Start();gotoir_return1;}IRTimer1Start();switch(tempTH1){caseIR_13_5MS://irstartir_word=0;ir_bit=0;ir_start=1;PRE_REMOTE_KEY=0;ir_key_continue_pressed=0;gotoir_return1;caseIR_1_125MS://bit'0'if(ir_start){ir_0_1=0;ir_flag=1;}break;cas
7、eIR_2_25MS://bit'1'if(ir_start){ir_0_1=1;ir_flag=1;}break; caseIR_11_25MS1://irkeycontinuepressedir_bit=0;ir_word=4;ir_key_continue_pressed=1;break;default:ir_bit=0;ir_word=0;gotoir_return1;}if(ir_flag){ir_data[ir_word]>>=1;if(ir_0_1){ ir_data[ir_word]
8、=0x80;}else{ir_data[i
9、r_word]&=0x7f;}ir_bit++;ir_flag=0;}if(ir_bit==8){ir_word++;ir_bit=0;}if(ir_word==4){ir_word=0;Using_Timer1=0;#ifdefRC42if(ir_key_continue_pressed){ir_enable=1;Using_Timer1=0;PUSH_Message_Buf(IR_Key,ir_data[2]);}elseif((ir_data[0]==IR_CUSTOM_CODE1)&&(ir_data[1]==IR_CUSTOM_COD
10、E2)){ir_enable=1;Using_Timer1=0;PUSH_Message_Buf(IR_Key,ir_data[2]);}#elsei
此文档下载收益归作者所有