Skip to content

Commit

Permalink
Watchdog: use mbed API to enable and trigger watchdog
Browse files Browse the repository at this point in the history
  • Loading branch information
pennam committed Jun 3, 2024
1 parent ffa84d1 commit 14c5abb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/utility/watchdog/Watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 Down

0 comments on commit 14c5abb

Please sign in to comment.