ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
wake_esp8266.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_ESP8266
6
7#include "esphome/core/hal.h"
8
9#include <coredecls.h>
10
11namespace esphome {
12
14inline void ESPHOME_ALWAYS_INLINE wake_loop_impl() {
15 // Set the wake-requested flag BEFORE esp_schedule so the consumer is
16 // guaranteed to see it on its next gate check.
17 wake_request_set();
18 g_main_loop_woke = true;
19 esp_schedule();
20}
21
24
27
29inline void ESPHOME_ALWAYS_INLINE wake_loop_isrsafe() { wake_loop_impl(); }
30
31namespace internal {
32inline void ESPHOME_ALWAYS_INLINE wakeable_delay(uint32_t ms) {
33 if (ms == 0) [[unlikely]] {
34 delay(0);
35 return;
36 }
37 if (g_main_loop_woke) {
38 g_main_loop_woke = false;
39 // Yield even on the already-woken fast path so callers in tight loops
40 // (e.g. lwIP raw TCP wait_for_data_) make forward progress when ISRs
41 // keep re-setting g_main_loop_woke between iterations.
42 delay(0);
43 return;
44 }
45 esp_delay(ms, []() { return !g_main_loop_woke; });
46}
47} // namespace internal
48
49} // namespace esphome
50
51#endif // USE_ESP8266
void ESPHOME_ALWAYS_INLINE wakeable_delay(uint32_t ms)
Host wakeable_delay uses select() over the registered fds — defined in wake_host.cpp.
void wake_loop_threadsafe()
Non-ISR: always inline.
void ESPHOME_ALWAYS_INLINE wake_loop_impl()
Inline implementation — IRAM callers inline this directly.
volatile bool g_main_loop_woke
void HOT delay(uint32_t ms)
Definition hal.cpp:82
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.
static void uint32_t