9 #include "esp_idf_version.h" 10 #include "esp_task_wdt.h" 13 #include "hardware/watchdog.h" 14 #include "pico/stdlib.h" 20 static const char *
const TAG =
"http_request.watchdog";
23 if (timeout_ms == 0) {
26 this->saved_timeout_ms_ = this->get_timeout_();
27 this->set_timeout_(timeout_ms);
31 if (this->timeout_ms_ == 0) {
34 this->set_timeout_(this->saved_timeout_ms_);
37 void WatchdogManager::set_timeout_(uint32_t timeout_ms) {
38 ESP_LOGV(TAG,
"Adjusting WDT to %" PRIu32
"ms", timeout_ms);
40 #if ESP_IDF_VERSION_MAJOR >= 5 41 esp_task_wdt_config_t wdt_config = {
42 .timeout_ms = timeout_ms,
43 .idle_core_mask = 0x03,
44 .trigger_panic =
true,
46 esp_task_wdt_reconfigure(&wdt_config);
48 esp_task_wdt_init(timeout_ms / 1000,
true);
49 #endif // ESP_IDF_VERSION_MAJOR 53 watchdog_enable(timeout_ms,
true);
57 uint32_t WatchdogManager::get_timeout_() {
58 uint32_t timeout_ms = 0;
61 timeout_ms = (uint32_t) CONFIG_ESP_TASK_WDT_TIMEOUT_S * 1000;
65 timeout_ms = watchdog_get_count() / 1000;
68 ESP_LOGVV(TAG,
"get_timeout: %" PRIu32
"ms", timeout_ms);
WatchdogManager(uint32_t timeout_ms)
Implementation of SPI Controller mode.