微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > STM32之中断与事件一个使用GPIO作为外部中断的示例

STM32之中断与事件一个使用GPIO作为外部中断的示例

时间:11-20 来源:互联网 点击:

中断例程:

void EXTI15_10_IRQHandler(void){rt_interrupt_enter();/* °²È«ÆøÄÒÓ²Ïß¼ì²â´¦Àí*/vcm_airbag_exti_check();/* GPSÌìÏß¿ªÂ·¼ì²â´¦Àí*/gps_exti_check();rt_interrupt_leave();}


void vcm_airbag_exti_check(void){//¼ì²éµ±Ç°ÖжϵÄ״̬ÊÇ·ñºÏ·¨if(EXTI_GetITStatus(AIRBAG_EXTI_LINE) != RESET){	//¶ÁȹܽŵÄ״̬,ÕâÀï·µ»Ø0±íʾ°²È«ÆøÄÒ±¬¿ªif(0 ==GPIO_ReadInputDataBit(AIRBAG_GPIO_PORT,AIRBAG_GPIO_PIN)){ recv_frame.bus_type = BTYPE_HS_CAN;recv_frame.id = 0x545;recv_frame.data_buff[0] = 0x00;recv_frame.data_buff[1] = 0x01;recv_frame.data_buff[2] = 0x00;recv_frame.data_buff[3] = 0x00;recv_frame.data_buff[4] = 0x00;recv_frame.data_buff[5] = 0x00;recv_frame.data_buff[6] = 0x00;recv_frame.data_buff[7] = 0x00;VCM_DEBUG("[vcm] warning: airbag gpio interrupt rising.\r\n");}else{recv_frame.bus_type = BTYPE_HS_CAN;recv_frame.id = 0x545;recv_frame.data_buff[0] = 0x00;recv_frame.data_buff[1] = 0x00;recv_frame.data_buff[2] = 0x00;recv_frame.data_buff[3] = 0x00;recv_frame.data_buff[4] = 0x00;recv_frame.data_buff[5] = 0x00;recv_frame.data_buff[6] = 0x00;recv_frame.data_buff[7] = 0x00;VCM_DEBUG("[vcm] warning: airbag gpio interrupt falling.\r\n");}rt_mq_send(&recv_frame_mq,&recv_frame,sizeof(can_bus_frame));//ÇåÖжϱê־λEXTI_ClearITPendingBit(AIRBAG_EXTI_LINE);		}	}

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

网站地图

Top