@@ -48,20 +48,48 @@ static bool is_watchdog_enabled = false;
48
48
* FUNCTION DEFINITION
49
49
******************************************************************************/
50
50
51
- #ifdef ARDUINO_ARCH_SAMD
52
- void samd_watchdog_enable ()
51
+ void watchdog_enable ()
53
52
{
53
+ #ifdef ARDUINO_ARCH_SAMD
54
54
is_watchdog_enabled = true ;
55
55
Watchdog.enable (SAMD_WATCHDOG_MAX_TIME_ms);
56
+ #elif ARDUINO_ARCH_MBED
57
+ watchdog_config_t cfg;
58
+ #if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
59
+ cfg.timeout_ms = PORTENTA_H7_WATCHDOG_MAX_TIMEOUT_ms;
60
+ #elif defined(ARDUINO_NANO_RP2040_CONNECT)
61
+ cfg.timeout_ms = NANO_RP2040_WATCHDOG_MAX_TIMEOUT_ms;
62
+ #else
63
+ # error "You need to define the maximum possible timeout for this architecture."
64
+ #endif
65
+
66
+ if (hal_watchdog_init (&cfg) == WATCHDOG_STATUS_OK) {
67
+ is_watchdog_enabled = true ;
68
+ }
69
+ else {
70
+ DEBUG_WARNING (" %s: watchdog could not be enabled" , __FUNCTION__);
71
+ }
72
+ #else
73
+ # error "ARDUINO_ARCH not defined."
74
+ #endif
56
75
}
57
76
58
- void samd_watchdog_reset ()
77
+ void watchdog_reset ()
59
78
{
79
+ #ifdef ARDUINO_ARCH_SAMD
60
80
if (is_watchdog_enabled) {
61
81
Watchdog.reset ();
62
82
}
83
+ #elif ARDUINO_ARCH_MBED
84
+ if (is_watchdog_enabled) {
85
+ hal_watchdog_kick ();
86
+ }
87
+ #else
88
+ # error "ARDUINO_ARCH not defined."
89
+ #endif
63
90
}
64
91
92
+ #ifdef ARDUINO_ARCH_SAMD
65
93
/* This function is called within the WiFiNINA library when invoking
66
94
* the method 'connectBearSSL' in order to prevent a premature bite
67
95
* of the watchdog (max timeout on SAMD is 16 s). wifi_nina_feed...
@@ -70,47 +98,21 @@ void samd_watchdog_reset()
70
98
*/
71
99
void wifi_nina_feed_watchdog ()
72
100
{
73
- samd_watchdog_reset ();
101
+ watchdog_reset ();
74
102
}
75
103
76
104
void mkr_gsm_feed_watchdog ()
77
105
{
78
- samd_watchdog_reset ();
106
+ watchdog_reset ();
79
107
}
80
108
81
109
void mkr_nb_feed_watchdog ()
82
110
{
83
- samd_watchdog_reset ();
111
+ watchdog_reset ();
84
112
}
85
113
#endif /* ARDUINO_ARCH_SAMD */
86
114
87
115
#ifdef ARDUINO_ARCH_MBED
88
- void mbed_watchdog_enable ()
89
- {
90
- watchdog_config_t cfg;
91
- #if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
92
- cfg.timeout_ms = PORTENTA_H7_WATCHDOG_MAX_TIMEOUT_ms;
93
- #elif defined(ARDUINO_NANO_RP2040_CONNECT)
94
- cfg.timeout_ms = NANO_RP2040_WATCHDOG_MAX_TIMEOUT_ms;
95
- #else
96
- # error "You need to define the maximum possible timeout for this architecture."
97
- #endif
98
-
99
- if (hal_watchdog_init (&cfg) == WATCHDOG_STATUS_OK) {
100
- is_watchdog_enabled = true ;
101
- }
102
- else {
103
- DEBUG_WARNING (" %s: watchdog could not be enabled" , __FUNCTION__);
104
- }
105
- }
106
-
107
- void mbed_watchdog_reset ()
108
- {
109
- if (is_watchdog_enabled) {
110
- hal_watchdog_kick ();
111
- }
112
- }
113
-
114
116
void mbed_watchdog_trigger_reset ()
115
117
{
116
118
watchdog_config_t cfg;
0 commit comments