1、 创建任务和消息队列
#define QUEUE_LEN 1024
#define QUEUE_SIZE 1
void m_create_isr_uart(void)
{
Test_Queue = xQueueCreate((UBaseType_t ) QUEUE_LEN,(UBaseType_t ) QUEUE_SIZE);
if(NULL != Test_Queue)
{
LOG_BLE("create queue sem ok\n");
}
xTaskCreate(uart_task, "uart_task", configMINIMAL_STACK_SIZE + 200, NULL, 2, &uart_task_handle);
}
2、 创建串口入口函数
#ifndef TAG_BLE
#define LOG_BLE(...)
#endif
static QueueHandle_t Test_Queue =NULL;
static TaskHandle_t uart_task_handle;
static void uart_task (void * pvParameter)
{
BaseType_t xReturn = pdPASS;
uint8_t temp;
while(1)
{
xReturn = xQueueReceive(Test_Queue,&temp,portMAX_DELAY);
if(pdPASS == xReturn )
{
simple_uart_put(temp);
}
}
}
3、 串口中断接收处理函数
void uart_send_queue_sem_from_isr(uint8_t data )
{
xQueueSendFromISR(Test_Queue,&data,NULL);
}
实验说明和现象:
串口回显测试。
①串口任务,阻塞等待消息队列数据,获取到数据后将通过串口打印出来。