diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index ae06edc3378..c96e644afed 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -54,6 +54,16 @@ void yield() extern TaskHandle_t loopTaskHandle; extern bool loopTaskWDTEnabled; +void IRAM_ATTR abortLoopDelay(){ + if(loopTaskHandle != NULL){ + if (xPortInIsrContext()){ + vTaskNotifyGiveFromISR(loopTaskHandle, NULL); + } else { + xTaskNotifyGive(loopTaskHandle); + } + } +} + void enableLoopWDT(){ if(loopTaskHandle != NULL){ if(esp_task_wdt_add(loopTaskHandle) != ESP_OK){ @@ -141,7 +151,7 @@ unsigned long IRAM_ATTR millis() void delay(uint32_t ms) { - vTaskDelay(ms / portTICK_PERIOD_MS); + ulTaskNotifyTake(pdTRUE, ms / portTICK_PERIOD_MS); } void IRAM_ATTR delayMicroseconds(uint32_t us) diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index 4b5fb2c2ebb..167c219f022 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -74,6 +74,7 @@ void yield(void); float temperatureRead(); #if CONFIG_AUTOSTART_ARDUINO +void abortLoopDelay(); //enable/disable WDT for Arduino's setup and loop functions void enableLoopWDT(); void disableLoopWDT();