欢迎来到天天文库
浏览记录
ID:55272036
大小:2.60 MB
页数:52页
时间:2020-05-08
《红外通信单片机c51程序.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、/*遥控接收在此中断程序内完成//遥控码放在ir_da[]中/************************************//* InterruptforIRsubroutine *//* externalinterruptsourceINT0 *//************************************///#include//#include"funtion_sub.h"#include"message.H"#include"include.h"//#defi
2、neuCHAR unsignedcharexternbitir_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;externuCHARi
3、r_word;externuCHARir_bit;externuCHARir_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;Us
4、ing_Timer1=0;IR_Out_Times=0;TR1=0;//EX1_Pri_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){//正在发送/
6、/return;//有必要的话可以夺取控制权.//}//Using_Timer1=1;tempTH1=TH1;EX1=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_ret
7、urn1;caseIR_1_125MS://bit'0'if(ir_start){ir_0_1=0;ir_flag=1;}break;caseIR_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;}
8、if(ir_flag){ir_data[ir_word]>>=1;if(ir_0_1){ ir_data[ir_word]
9、=0x80;}else{ir_data[ir_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;PUS
10、H_Message_Buf(IR_Key,ir_data[2]);}elseif((ir_data[0]==IR_CUSTOM_CODE1)&&(ir_data[1]==IR_CUSTOM_CODE2)){ir_enable=1;Using_Timer1=0;PUSH_Message_Buf(IR_Key,ir_data[2]);}#elsei
此文档下载收益归作者所有