Skip to content

Commit d4ae0a3

Browse files
authored
Merge pull request #472 from pennam/wdg-mbed
Watchdog: use mbed API
2 parents 00a6466 + 03b69d3 commit d4ae0a3

File tree

3 files changed

+5
-29
lines changed

3 files changed

+5
-29
lines changed

Diff for: src/ota/implementation/OTANanoRP2040.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ OTACloudProcessInterface::State NANO_RP2040OTACloudProcess::flashOTA() {
8383
}
8484

8585
OTACloudProcessInterface::State NANO_RP2040OTACloudProcess::reboot() {
86-
mbed_watchdog_trigger_reset();
87-
/* If watchdog is enabled we should not reach this point */
8886
NVIC_SystemReset();
8987

9088
return Resume; // This won't ever be reached

Diff for: src/utility/watchdog/Watchdog.cpp

+5-23
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#endif /* ARDUINO_ARCH_SAMD */
3434

3535
#ifdef ARDUINO_ARCH_MBED
36-
# include <watchdog_api.h>
36+
# include <drivers/Watchdog.h>
3737
# define PORTENTA_H7_WATCHDOG_MAX_TIMEOUT_ms (32760)
3838
# define NANO_RP2040_WATCHDOG_MAX_TIMEOUT_ms (8389)
3939
# define EDGE_CONTROL_WATCHDOG_MAX_TIMEOUT_ms (65536)
@@ -42,7 +42,7 @@
4242
/******************************************************************************
4343
* GLOBAL VARIABLES
4444
******************************************************************************/
45-
#if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_MBED)
45+
#if defined(ARDUINO_ARCH_SAMD)
4646
static bool is_watchdog_enabled = false;
4747
#endif
4848

@@ -96,18 +96,15 @@ static void mbed_watchdog_enable()
9696
# error "You need to define the maximum possible timeout for this architecture."
9797
#endif
9898

99-
if (hal_watchdog_init(&cfg) == WATCHDOG_STATUS_OK) {
100-
is_watchdog_enabled = true;
101-
}
102-
else {
99+
if (!mbed::Watchdog::get_instance().start(cfg.timeout_ms)) {
103100
DEBUG_WARNING("%s: watchdog could not be enabled", __FUNCTION__);
104101
}
105102
}
106103

107104
static void mbed_watchdog_reset()
108105
{
109-
if (is_watchdog_enabled) {
110-
hal_watchdog_kick();
106+
if (mbed::Watchdog::get_instance().is_running()) {
107+
mbed::Watchdog::get_instance().kick();
111108
}
112109
}
113110

@@ -131,21 +128,6 @@ static void mbed_watchdog_enable_network_feed(NetworkAdapter ni)
131128
#endif
132129
}
133130
}
134-
135-
void mbed_watchdog_trigger_reset()
136-
{
137-
watchdog_config_t cfg;
138-
cfg.timeout_ms = 1;
139-
140-
if (hal_watchdog_init(&cfg) == WATCHDOG_STATUS_OK) {
141-
is_watchdog_enabled = true;
142-
while(1){}
143-
}
144-
else {
145-
DEBUG_WARNING("%s: watchdog could not be reconfigured", __FUNCTION__);
146-
}
147-
148-
}
149131
#endif /* ARDUINO_ARCH_MBED */
150132

151133
#if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED)

Diff for: src/utility/watchdog/Watchdog.h

-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,4 @@ void watchdog_reset();
3434
void watchdog_enable_network_feed(NetworkAdapter ni);
3535
#endif /* (ARDUINO_ARCH_SAMD) || (ARDUINO_ARCH_MBED) */
3636

37-
#ifdef ARDUINO_ARCH_MBED
38-
void mbed_watchdog_trigger_reset();
39-
#endif /* ARDUINO_ARCH_MBED */
40-
4137
#endif /* ARDUINO_AIOTC_UTILITY_WATCHDOG_H_ */

0 commit comments

Comments
 (0)