背景:【MXCube+FreeRTOS+STM32F407】 为了将串口数据上下文分离。在回调函数中,使用消息队列将接收的字符发至队列。在任务线程中进行处理数据。
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { //taskENTER_CRITICAL(); /* Prevent unused argument(s) compilation warning */ //UNUSED(huart); if (huart->Instance == USART2) { osMessageQueuePut(remoteQueueHandle, (uint8_t*)&remoteTmpBuffer[0], 0, 0); } else if(huart->Instance == USART6) { osMessageQueuePut(ledQueueHandle, (uint8_t*)&ledTmpBuffer[0], 0, 0); } else if(huart->Instance == USART3) { osMessageQueuePut(lockQueueHandle, (uint8_t*)&lockTmpBuffer[0], 0, 0); } //taskEXIT_CRITICAL(); }
|