Skip to content

Abortable Arduino delay() #3227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cores/esp32/esp32-hal-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ void yield()
extern TaskHandle_t loopTaskHandle;
extern bool loopTaskWDTEnabled;

void IRAM_ATTR abortLoopDelay(){
if(loopTaskHandle != NULL){
vTaskNotifyGiveFromISR(loopTaskHandle, NULL);
}
}

void enableLoopWDT(){
if(loopTaskHandle != NULL){
if(esp_task_wdt_add(loopTaskHandle) != ESP_OK){
Expand Down Expand Up @@ -141,7 +147,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)
Expand Down
1 change: 1 addition & 0 deletions cores/esp32/esp32-hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down