#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_timer.h"
static TaskHandle_t Task_2_Handler = NULL;
void Task_1(void *pvParameters)
{
while (true)
{
printf("%s running on core %i (priorite %i)\n", "Task_1", xPortGetCoreID(), uxTaskPriorityGet( NULL ));
xTaskNotifyGive(Task_2_Handler);
xTaskNotifyGive(Task_2_Handler);
vTaskDelay(pdMS_TO_TICKS(5000));
printf("------------------------------------------\n");
}
}
void Task_2(void *pvParameters)
{
int64_t total_time, start_time, end_time;
while (true)
{
printf("%s running on core %i (priorite %i)\n", "Task_2", xPortGetCoreID(), uxTaskPriorityGet( NULL ));
start_time = esp_timer_get_time();
int count = ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
end_time = esp_timer_get_time();
total_time = (end_time - start_time);
printf("received notification %d times at %lld us\n", count, total_time);
printf("------------------------------------------\n");
}
}
void app_main(void)
{
printf("Init main\n");
xTaskCreate(&Task_2, "Task_2", 2048, NULL, 2, &Task_2_Handler);
xTaskCreate(&Task_1, "Task_1", 2048, NULL, 2, NULL);
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1