|
29 | 29 |
|
30 | 30 | #ifdef ARDUINO_ARCH_SAMD
|
31 | 31 | # include <Adafruit_SleepyDog.h>
|
| 32 | +# include <WiFi.h> |
32 | 33 | # define SAMD_WATCHDOG_MAX_TIME_ms (16 * 1000)
|
33 | 34 | #endif /* ARDUINO_ARCH_SAMD */
|
34 | 35 |
|
35 | 36 | #ifdef ARDUINO_ARCH_MBED
|
36 | 37 | # include <watchdog_api.h>
|
| 38 | +# include <WiFi.h> |
| 39 | +# include <Ethernet.h> |
37 | 40 | # define PORTENTA_H7_WATCHDOG_MAX_TIMEOUT_ms (32760)
|
38 | 41 | # define NANO_RP2040_WATCHDOG_MAX_TIMEOUT_ms (8389)
|
39 | 42 | #endif /* ARDUINO_ARCH_MBED */
|
@@ -63,6 +66,13 @@ static void samd_watchdog_reset()
|
63 | 66 | }
|
64 | 67 | }
|
65 | 68 |
|
| 69 | +#if defined (WIFI_HAS_FEED_WATCHDOG_FUNC) |
| 70 | +static void samd_watchdog_enable_network_feed() |
| 71 | +{ |
| 72 | + WiFi.setFeedWatchdogFunc(watchdog_reset); |
| 73 | +} |
| 74 | +#endif |
| 75 | + |
66 | 76 | /* This function is called within the WiFiNINA library when invoking
|
67 | 77 | * the method 'connectBearSSL' in order to prevent a premature bite
|
68 | 78 | * of the watchdog (max timeout on SAMD is 16 s). wifi_nina_feed...
|
@@ -114,6 +124,19 @@ static void mbed_watchdog_reset()
|
114 | 124 | }
|
115 | 125 | }
|
116 | 126 |
|
| 127 | +#if defined (ARDUINO_PORTENTA_H7_WIFI_HAS_FEED_WATCHDOG_FUNC) |
| 128 | +static void mbed_watchdog_enable_network_feed(const bool use_ethernet) |
| 129 | +{ |
| 130 | + if(use_ethernet) { |
| 131 | +#if defined(ARDUINO_PORTENTA_H7_M7) |
| 132 | + Ethernet.setFeedWatchdogFunc(watchdog_reset); |
| 133 | +#endif |
| 134 | + } else { |
| 135 | + WiFi.setFeedWatchdogFunc(watchdog_reset); |
| 136 | + } |
| 137 | +} |
| 138 | +#endif |
| 139 | + |
117 | 140 | void mbed_watchdog_trigger_reset()
|
118 | 141 | {
|
119 | 142 | watchdog_config_t cfg;
|
@@ -154,4 +177,15 @@ void watchdog_reset()
|
154 | 177 | mbed_watchdog_reset();
|
155 | 178 | #endif
|
156 | 179 | }
|
| 180 | + |
| 181 | +#if defined (WIFI_HAS_FEED_WATCHDOG_FUNC) || defined (ARDUINO_PORTENTA_H7_WIFI_HAS_FEED_WATCHDOG_FUNC) |
| 182 | +void watchdog_enable_network_feed(const bool use_ethernet) |
| 183 | +{ |
| 184 | +#ifdef ARDUINO_ARCH_SAMD |
| 185 | + samd_watchdog_enable_network_feed(); |
| 186 | +#else |
| 187 | + mbed_watchdog_enable_network_feed(use_ethernet); |
| 188 | +#endif |
| 189 | +} |
| 190 | +#endif |
157 | 191 | #endif /* (ARDUINO_ARCH_SAMD) || (ARDUINO_ARCH_MBED) */
|
0 commit comments