task 之间进行使用消息队列进行通信
int main(void)
{
xQueue = xQueueCreate(10, sizeof(uint8_t));
xTaskCreate( Task1,(signed portCHAR *)"Task1",configMINIMAL_STACK_SIZE,NULL,tskIDLE_PRIORITY,NULL);
xTaskCreate( Task2, ( signed portCHAR * ) "Task2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1,NULL );
vTaskStartScheduler(); //schdule start
return 0;
}
//任务一:Filling the message queue with content Grow uint8 type from 1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void Task1(void *pvParameters)
{
uint8_t SendNum = 1;
while(1)
{
vTaskDelay( 2000/portTICK_RATE_MS );
//fill content to msg queue
xQueueSend( xQueue, ( void* )&SendNum, 0 );
SendNum++;
}
}
//task two:Get the content from the message queue~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void Task2(void *pvParameters)
{
uint8_t ReceiveNum =0;
while(1)
{
//get content from msg queue
if( xQueueReceive( xQueue, &ReceiveNum, 100/portTICK_RATE_MS ) == pdPASS)
{
//PROCESS
}
}
}