Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watchdog: use mbed API #472

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/ota/implementation/OTANanoRP2040.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 5 additions & 23 deletions src/utility/watchdog/Watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif /* ARDUINO_ARCH_SAMD */

#ifdef ARDUINO_ARCH_MBED
# include <watchdog_api.h>
# include <drivers/Watchdog.h>
# define PORTENTA_H7_WATCHDOG_MAX_TIMEOUT_ms (32760)
# define NANO_RP2040_WATCHDOG_MAX_TIMEOUT_ms (8389)
# define EDGE_CONTROL_WATCHDOG_MAX_TIMEOUT_ms (65536)
Expand All @@ -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

Expand Down Expand Up @@ -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();
}
}

Expand All @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions src/utility/watchdog/Watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
Loading