diff --git a/esphome/core/application.h b/esphome/core/application.h index 7826a49b5f..aa6ec3ebd3 100644 --- a/esphome/core/application.h +++ b/esphome/core/application.h @@ -553,7 +553,7 @@ class Application { #ifdef USE_ESP32 /// Wake from ISR (ESP32 only). - static void wake_loop_isrsafe(int *px) { esphome::wake_loop_isrsafe(px); } + static void wake_loop_isrsafe(BaseType_t *px) { esphome::wake_loop_isrsafe(px); } #endif /// Wake from any context (ISR, thread, callback). diff --git a/esphome/core/main_task.h b/esphome/core/main_task.h index 183ce65027..ed2885d2e2 100644 --- a/esphome/core/main_task.h +++ b/esphome/core/main_task.h @@ -28,10 +28,10 @@ static inline void esphome_main_task_notify() { } /// Wake the main loop task from an ISR. ISR-safe. -static inline void esphome_main_task_notify_from_isr(int *px_higher_priority_task_woken) { +static inline void esphome_main_task_notify_from_isr(BaseType_t *px_higher_priority_task_woken) { TaskHandle_t task = esphome_main_task_handle; if (task != NULL) { - vTaskNotifyGiveFromISR(task, (BaseType_t *) px_higher_priority_task_woken); + vTaskNotifyGiveFromISR(task, px_higher_priority_task_woken); } } diff --git a/esphome/core/wake.cpp b/esphome/core/wake.cpp index ecc7adcb4d..b6b59b5990 100644 --- a/esphome/core/wake.cpp +++ b/esphome/core/wake.cpp @@ -14,7 +14,7 @@ namespace esphome { // === ESP32 — IRAM_ATTR entry points === #ifdef USE_ESP32 -void IRAM_ATTR wake_loop_isrsafe(int *px_higher_priority_task_woken) { +void IRAM_ATTR wake_loop_isrsafe(BaseType_t *px_higher_priority_task_woken) { esphome_main_task_notify_from_isr(px_higher_priority_task_woken); } void IRAM_ATTR wake_loop_any_context() { esphome_main_task_notify_any_context(); } diff --git a/esphome/core/wake.h b/esphome/core/wake.h index 6df3df891c..fdbe2088c4 100644 --- a/esphome/core/wake.h +++ b/esphome/core/wake.h @@ -30,7 +30,7 @@ extern volatile bool g_main_loop_woke; #ifdef USE_ESP32 /// IRAM_ATTR entry point — defined in wake.cpp. -void wake_loop_isrsafe(int *px_higher_priority_task_woken); +void wake_loop_isrsafe(BaseType_t *px_higher_priority_task_woken); /// IRAM_ATTR entry point — defined in wake.cpp. void wake_loop_any_context(); #else @@ -73,7 +73,10 @@ inline void wakeable_delay(uint32_t ms) { delay(0); return; } - g_main_loop_woke = false; + if (g_main_loop_woke) { + g_main_loop_woke = false; + return; + } esp_delay(ms, []() { return !g_main_loop_woke; }); } } // namespace internal