I have been trying to use FreeRTOS task notification on ESP32 for a few days, and I am not sure I really understand the effect of the ulBitsToClearOnEntry and ulBitsToClearOnExit parameters of the xTaskNotifyWait() function.
I am able to send notifications between 2 tasks with xTaskNotify() and xTaskNotifyWait() functions, but even when tickling with the parameters of xTaskNotifyWait(), I don't really see any difference in the behavior. Here is the base code I used:
Code: Select all
const char *TAG = "MAIN";
TaskHandle_t TaskHandler1 = NULL;
TaskHandle_t TaskHandler2 = NULL;
void myTask1(void *pvParameters)
{
vTaskDelay(pdMS_TO_TICKS(1000)); // wait for the other task to be created
while(1)
{
xTaskNotify(TaskHandler2, 1 << 0, eSetBits);
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void myTask2(void *pvParameters)
{
uint32_t val = 0;
while(1)
{
if(xTaskNotifyWait(0x00, 0x00, &val, 0) == pdPASS)
{
if(val & (1 << 0))
{
ESP_LOGI(TAG, "Received notification %u", val);
}
}
vTaskDelay(pdMS_TO_TICKS(10));
}
}
void app_main(void)
{
xTaskCreate(myTask1, "Task1", 2048, NULL, 2, &TaskHandler1);
xTaskCreate(myTask2, "Task2", 2048, NULL, 2, &TaskHandler2);
}
Thank you in advance!