File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 11name =Adafruit SleepyDog Library
2- version =1.6.4
2+ version =1.6.5
33author =Adafruit
44maintainer =Adafruit <
[email protected] >
55sentence =Arduino library to use the watchdog timer for system reset and low power sleep.
Original file line number Diff line number Diff line change @@ -16,12 +16,24 @@ int WatchdogESP32::enable(int maxPeriodMS) {
1616 if (maxPeriodMS < 0 )
1717 return 0 ;
1818
19- // ESP32 expects TWDT in seconds
19+ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1)
20+ // Initialize the wdt configuration for ESP-IDF v5.x and above
21+ esp_task_wdt_config_t wdt_config = {
22+ .timeout_ms = (uint32_t )maxPeriodMS,
23+ .idle_core_mask = 0 , // Subscribe to the idle task on the APP CPU
24+ .trigger_panic = true ,
25+ };
26+ // TWDT already initialized by the RTOS, reconfigure it
27+ esp_err_t err = esp_task_wdt_reconfigure (&wdt_config);
28+ #else
29+ // IDF V4.x and below expect TWDT in seconds
2030 uint32_t maxPeriod = maxPeriodMS / 1000 ;
2131 // Enable the TWDT and execute the esp32 panic handler when TWDT times out
2232 esp_err_t err = esp_task_wdt_init (maxPeriod, true );
33+ #endif
34+
2335 if (err != ESP_OK)
24- return 0 ; // Initialization failed due to lack of memory
36+ return 0 ; // Failed to initialize TWDT
2537
2638 // NULL to subscribe the current running task to the TWDT
2739 err = esp_task_wdt_add (NULL );
You can’t perform that action at this time.
0 commit comments