Skip to content

Commit

Permalink
Add API to feed the loop WDT (call from loop only)
Browse files Browse the repository at this point in the history
  • Loading branch information
me-no-dev committed Jan 12, 2019
1 parent f7cf583 commit 81844f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 0 additions & 2 deletions cores/esp32/esp32-hal-cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions cores/esp32/esp32-hal-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
2 changes: 2 additions & 0 deletions cores/esp32/esp32-hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 81844f5

Please sign in to comment.