Add wakeable_delay for ESP32/LibreTiny using ulTaskNotifyTake

This commit is contained in:
J. Nick Koston
2026-04-04 10:40:14 -10:00
parent bfad79f34c
commit 88d7198fa4
2 changed files with 17 additions and 6 deletions
+2 -6
View File
@@ -928,14 +928,10 @@ inline void ESPHOME_ALWAYS_INLINE Application::yield_with_select_(uint32_t delay
// Sleep with instant wake via FreeRTOS task notification.
// Woken by: callback wrapper (socket data), wake_loop_threadsafe() (background tasks), or timeout.
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(delay_ms));
#elif defined(USE_ESP8266) || defined(USE_RP2040)
// Wakeable delay — broken early by wake_loop_any_context() / wake_loop_threadsafe()
// ESP8266: esp_delay() with wake flag callback
// RP2040: hardware timer + __wfe()/__sev()
esphome::wakeable_delay(delay_ms);
#else
#error "No wakeable delay implementation for this platform"
// All other platforms: wakeable delay broken early by wake_loop_any_context() / wake_loop_threadsafe()
esphome::wakeable_delay(delay_ms);
#endif
}
#endif // !defined(USE_SOCKET_SELECT_SUPPORT) || defined(USE_LWIP_FAST_SELECT)
+15
View File
@@ -14,6 +14,13 @@
#ifdef USE_LWIP_FAST_SELECT
#include "esphome/core/lwip_fast_select.h"
#ifdef USE_ESP32
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#else
#include <FreeRTOS.h>
#include <task.h>
#endif
#endif
#ifdef USE_ESP8266
#include <coredecls.h>
@@ -54,6 +61,14 @@ inline void wake_loop_any_context() { esphome_lwip_wake_main_loop(); }
inline void wake_loop_threadsafe() { esphome_lwip_wake_main_loop(); }
inline void wakeable_delay(uint32_t ms) {
if (ms == 0) {
yield();
return;
}
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(ms));
}
// === ESP8266 ===
#elif defined(USE_ESP8266)