diff --git a/src/ota/implementation/OTANanoRP2040.cpp b/src/ota/implementation/OTANanoRP2040.cpp index 5b1266f60..7dad7baf6 100644 --- a/src/ota/implementation/OTANanoRP2040.cpp +++ b/src/ota/implementation/OTANanoRP2040.cpp @@ -83,8 +83,6 @@ OTACloudProcessInterface::State NANO_RP2040OTACloudProcess::flashOTA() { } OTACloudProcessInterface::State NANO_RP2040OTACloudProcess::reboot() { - mbed_watchdog_trigger_reset(); - /* If watchdog is enabled we should not reach this point */ NVIC_SystemReset(); return Resume; // This won't ever be reached diff --git a/src/utility/watchdog/Watchdog.cpp b/src/utility/watchdog/Watchdog.cpp index 942b569f1..d47234064 100644 --- a/src/utility/watchdog/Watchdog.cpp +++ b/src/utility/watchdog/Watchdog.cpp @@ -33,7 +33,7 @@ #endif /* ARDUINO_ARCH_SAMD */ #ifdef ARDUINO_ARCH_MBED -# include +# include # define PORTENTA_H7_WATCHDOG_MAX_TIMEOUT_ms (32760) # define NANO_RP2040_WATCHDOG_MAX_TIMEOUT_ms (8389) # define EDGE_CONTROL_WATCHDOG_MAX_TIMEOUT_ms (65536) @@ -42,7 +42,7 @@ /****************************************************************************** * GLOBAL VARIABLES ******************************************************************************/ -#if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_MBED) +#if defined(ARDUINO_ARCH_SAMD) static bool is_watchdog_enabled = false; #endif @@ -96,18 +96,15 @@ static void mbed_watchdog_enable() # error "You need to define the maximum possible timeout for this architecture." #endif - if (hal_watchdog_init(&cfg) == WATCHDOG_STATUS_OK) { - is_watchdog_enabled = true; - } - else { + if (!mbed::Watchdog::get_instance().start(cfg.timeout_ms)) { DEBUG_WARNING("%s: watchdog could not be enabled", __FUNCTION__); } } static void mbed_watchdog_reset() { - if (is_watchdog_enabled) { - hal_watchdog_kick(); + if (mbed::Watchdog::get_instance().is_running()) { + mbed::Watchdog::get_instance().kick(); } } @@ -131,21 +128,6 @@ static void mbed_watchdog_enable_network_feed(NetworkAdapter ni) #endif } } - -void mbed_watchdog_trigger_reset() -{ - watchdog_config_t cfg; - cfg.timeout_ms = 1; - - if (hal_watchdog_init(&cfg) == WATCHDOG_STATUS_OK) { - is_watchdog_enabled = true; - while(1){} - } - else { - DEBUG_WARNING("%s: watchdog could not be reconfigured", __FUNCTION__); - } - -} #endif /* ARDUINO_ARCH_MBED */ #if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED) diff --git a/src/utility/watchdog/Watchdog.h b/src/utility/watchdog/Watchdog.h index 3bfd35453..2ba43a875 100644 --- a/src/utility/watchdog/Watchdog.h +++ b/src/utility/watchdog/Watchdog.h @@ -34,8 +34,4 @@ void watchdog_reset(); void watchdog_enable_network_feed(NetworkAdapter ni); #endif /* (ARDUINO_ARCH_SAMD) || (ARDUINO_ARCH_MBED) */ -#ifdef ARDUINO_ARCH_MBED -void mbed_watchdog_trigger_reset(); -#endif /* ARDUINO_ARCH_MBED */ - #endif /* ARDUINO_AIOTC_UTILITY_WATCHDOG_H_ */