#include "FreeRTOS.h" #include "task.h" #include "queue.h" QueueHandle_t qh = 0; void task_tx(void* p) { int i = 0; for ( ;; ) { i++; if(xQueueSend(qh, &i, 500)==0) { printf("Failed to send item to queue within 500ms\n"); } else { printf("sent: %u\n", i); } vTaskDelay(1000); } } void task_rx(void* p) { int j = 0; for ( ;; ) { if(xQueueReceive(qh, &j, 1000)==0) { printf("Failed to receive item within 1000 ms\n"); } else { printf("Received: %u\n", j); } } } int Example2( void ) { qh = xQueueCreate(5, sizeof(int)); xTaskCreate(task_tx, "Sender", 2048, NULL, 1, NULL); xTaskCreate(task_rx, "Receiver", 2048, NULL, 1, NULL); vTaskStartScheduler(); for ( ; ; ); }