微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > STM32单片机学习(12) 红外信号接收解码(外部中断)

STM32单片机学习(12) 红外信号接收解码(外部中断)

时间:11-20 来源:互联网 点击:
LED//else GPIO_ResetBits(GPIOA,GPIO_Pin_0);//灭while(1){if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_8)==1){time = HW_ReceiveTime();if(time>=250){//printf("VoverTime:%x\n",time); startSignal=0;HW_ReceivedData=0;Count=0;break;} else if(time>=200 && time<250){startSignal=1;//收到起始信号HW_ReceivedData=0;Count=0;continue;} else if(time>=60 && time<90) Data=1;//收到数据 1else if(time>=10 && time<50) Data=0;//收到数据 0//printf("%x ",Data);if(startSignal==1){HW_ReceivedData<=1;HW_ReceivedData+=Data;Count++;if(Count>=32){//printf("received:%x\n",HW_ReceivedData);if(HW_ReceivedData==0x1090000a) printf("红外编码:0x%8X,指令:打开空调\n",HW_ReceivedData);else if(HW_ReceivedData==0x90000a) printf("红外编码:0x%08X,指令:关闭空调\n",HW_ReceivedData);else printf("红外编码:0x%08X,指令:未知\n",HW_ReceivedData);HW_ReceivedData=0;Count=0;startSignal=0;break;} } }}EXTI_ClearITPendingBit(EXTI_Line8);//清除线路挂起位EXTI_ClearFlag(EXTI_Line8);//清除中断挂起位 } }

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top