#include <inttypes.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "freertos/event_groups.h"
EventGroupHandle_t eventGroup ;
EventBits_t a = 0b0001;
void send(void *p) {
while (1) {
vTaskDelay(pdMS_TO_TICKS(1000));
xEventGroupSetBits(eventGroup,a);
printf("xEventGroupSetBits\n");
}
}
void receive(void *p) {
while (1) {
xEventGroupWaitBits(eventGroup,0b1011 /* uxBitsToWaitFor */,pdTRUE /* xClearOnExit */,pdFALSE /* xWaitForAllBits */,pdMS_TO_TICKS(999999999) /* xTicksToWait */);
printf("xEventGroupWaitBits\n");
}
}
void app_main(void) {
eventGroup = xEventGroupCreate();
xTaskCreate(&send, "xEventGroupSetBits", 2048, NULL, configMAX_PRIORITIES-1, NULL);
xTaskCreate(&receive, "xEventGroupWaitBits", 2048, NULL, 0, NULL);
return;
}
freertos入门之EventGroup
最新推荐文章于 2024-07-19 23:11:36 发布