ESPHome 2026.4.0
Loading...
Searching...
No Matches
main_task.h
Go to the documentation of this file.
1#pragma once
2
5
6#if defined(USE_ESP32) || defined(USE_LIBRETINY)
7
8#ifdef USE_ESP32
9#include <freertos/FreeRTOS.h>
10#include <freertos/task.h>
11#else
12#include <FreeRTOS.h>
13#include <task.h>
14#endif
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20extern TaskHandle_t esphome_main_task_handle;
21
23static inline void esphome_main_task_notify() {
24 TaskHandle_t task = esphome_main_task_handle;
25 if (task != NULL) {
26 xTaskNotifyGive(task);
27 }
28}
29
31static inline void esphome_main_task_notify_from_isr(BaseType_t *px_higher_priority_task_woken) {
32 TaskHandle_t task = esphome_main_task_handle;
33 if (task != NULL) {
34 vTaskNotifyGiveFromISR(task, px_higher_priority_task_woken);
35 }
36}
37
38#ifdef USE_ESP32
40static inline void esphome_main_task_notify_any_context() {
41 if (xPortInIsrContext()) {
42 int px_higher_priority_task_woken = 0;
43 esphome_main_task_notify_from_isr(&px_higher_priority_task_woken);
44 portYIELD_FROM_ISR(px_higher_priority_task_woken);
45 } else {
46 esphome_main_task_notify();
47 }
48}
49#endif
50
51#ifdef __cplusplus
52}
53#endif
54
55#endif // USE_ESP32 || USE_LIBRETINY
TaskHandle_t esphome_main_task_handle
Main loop task handle and wake helpers — shared between wake.h (C++) and lwip_fast_select....
Definition main_task.c:4