From 81844f53600c3035fda6b9affb79c19573ee8f1d Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Sat, 12 Jan 2019 13:02:38 +0100 Subject: [PATCH] Add API to feed the loop WDT (call from loop only) --- cores/esp32/esp32-hal-cpu.c | 2 -- cores/esp32/esp32-hal-misc.c | 7 +++++++ cores/esp32/esp32-hal.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cores/esp32/esp32-hal-cpu.c b/cores/esp32/esp32-hal-cpu.c index d9e95dc8067..c9b8f4c6644 100644 --- a/cores/esp32/esp32-hal-cpu.c +++ b/cores/esp32/esp32-hal-cpu.c @@ -131,10 +131,8 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz){ uint32_t capb, apb; //Get XTAL Frequency and calculate min CPU MHz rtc_xtal_freq_t xtal = rtc_clk_xtal_freq_get(); - uint32_t min_cpu_mhz = 10; if(xtal > RTC_XTAL_FREQ_AUTO){ if(xtal < RTC_XTAL_FREQ_40M) { - min_cpu_mhz = xtal / 2; //13Mhz for 26Mhz XTAL if(cpu_freq_mhz <= xtal && cpu_freq_mhz != xtal && cpu_freq_mhz != (xtal/2)){ log_e("Bad frequency: %u MHz! Options are: 240, 160, 80, %u and %u MHz", cpu_freq_mhz, xtal, xtal/2); return false; diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 06ed677d5d2..27f5ad237c4 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -69,6 +69,13 @@ void disableLoopWDT(){ } } } + +void feedLoopWDT(){ + esp_err_t err = esp_task_wdt_reset(); + if(err != ESP_OK){ + log_e("Failed to feed WDT! Error: %d", err); + } +} #endif void enableCore0WDT(){ diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index 36ffccac231..ef87a04410d 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -77,6 +77,8 @@ float temperatureRead(); //enable/disable WDT for Arduino's setup and loop functions void enableLoopWDT(); void disableLoopWDT(); +//feed WDT for the loop task +void feedLoopWDT(); #endif //enable/disable WDT for the IDLE task on Core 0 (SYSTEM)