ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
wake_freertos.cpp
Go to the documentation of this file.
2
3#if defined(USE_ESP32) || defined(USE_LIBRETINY)
4
5#include "esphome/core/hal.h"
6#include "esphome/core/wake.h"
7
8namespace esphome {
9
10// === Wake-requested flag storage ===
11// ESP32 is always MULTI_ATOMICS; LibreTiny is MULTI_ATOMICS on chips with
12// proper atomics (e.g. RTL8720) and MULTI_NO_ATOMICS on others (e.g. BK72XX).
13#ifdef ESPHOME_THREAD_MULTI_ATOMICS
14// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
15std::atomic<uint8_t> g_wake_requested{0};
16#else
17// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
18volatile uint8_t g_wake_requested = 0;
19#endif
20
21void IRAM_ATTR wake_loop_isrsafe(BaseType_t *px_higher_priority_task_woken) {
22 // ISR-safe: set flag before notify so the wake is visible on the next gate
23 // check. wake_request_set() is just an aligned 8-bit store / atomic store
24 // and is safe from IRAM.
25 wake_request_set();
26 esphome_main_task_notify_from_isr(px_higher_priority_task_woken);
27}
28
29void IRAM_ATTR wake_loop_any_context() { wake_main_task_any_context(); }
30
31} // namespace esphome
32
33#endif // USE_ESP32 || USE_LIBRETINY
std::atomic< uint8_t > g_wake_requested
Definition wake.h:49
void ESPHOME_ALWAYS_INLINE wake_loop_isrsafe()
ISR-safe: no task_woken arg because ESP8266 has no FreeRTOS. Caller must be IRAM_ATTR.
void IRAM_ATTR wake_loop_any_context()
IRAM_ATTR entry point for ISR callers — defined in wake_esp8266.cpp.
Platform-specific main loop wake primitives.