串口中断
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { CmdAnalyze();//命令分析 if(cmd == cmd_event1) event1 = true; else if(cmd == cmd_event2) event2 = true; ... ... }
主程序
void Main(){ while(1){ if(true == event1){ event1 = false; task_event1();//处理事件1的任务 } if(true == event2){ event2 = false; task_event2();//处理事件的任务 } } }
标签:框架,event2,cmd,处理事件,单片机,串口,true,event1 From: https://www.cnblogs.com/lizhiqiang0204/p/16647330.html