基于esp32 平台 。
参考:
https://www.freertos.org/fr-content-src/uploads/2018/07/161204_Mastering_the_FreeRTOS_Real_Time_Kernel-A_Hands-On_Tutorial_Guide.pdf
#include <inttypes.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/event_groups.h"
QueueHandle_t queue;
void send(void *p) {
printf("xQueueSend\n");
BaseType_t a = 0;
while (1) {
a++;
vTaskDelay(pdMS_TO_TICKS(1000));
xQueueSend(queue,&a,pdMS_TO_TICKS(1000*1000));
printf("send:%d\n",a);
}
}
void receive(void *p) {
printf("receive\n");
BaseType_t a = 0;
while (1) {
xQueueReceive(queue,&a,pdMS_TO_TICKS(1000*1000));
printf("received:%d\n",a);
}
}
void vApplicationIdleHook( void ){
printf("vApplicationIdleHook\n");
}
void app_main(void) {
queue = xQueueCreate(10,sizeof(BaseType_t));
xTaskCreate(&send, "hid_task", 2048, NULL, configMAX_PRIORITIES-1, NULL);
xTaskCreate(&receive, "hid_task", 2048, NULL, 0, NULL);
return;
}