Skip to content

Commit 901b4f1

Browse files
authored
Instead of using the cumbersome __has_include approach rather define a weak function to be overwritten by higher level application layers. (#158)
1 parent bf02213 commit 901b4f1

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/utility/spi_drv.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ static bool inverted_reset = false;
6363

6464
bool SpiDrv::initialized = false;
6565

66+
__attribute__((weak)) void wifi_nina_feed_watchdog()
67+
{
68+
/* This function can be overwritten by a "strong" implementation
69+
* in a higher level application, such as the ArduinoIoTCloud
70+
* firmware stack.
71+
*/
72+
}
73+
6674
void SpiDrv::begin()
6775
{
6876
#ifdef ARDUINO_SAMD_MKRVIDOR4000
@@ -207,29 +215,16 @@ void SpiDrv::waitForSlaveSign()
207215
while (!waitSlaveSign());
208216
}
209217

210-
#if defined __has_include
211-
# if __has_include (<Adafruit_SleepyDog.h>)
212-
# include <Adafruit_SleepyDog.h>
213-
# define HAS_WATCHDOG 1
214-
# endif
215-
#else
216-
# define HAS_WATCHDOG 0
217-
#endif
218-
219218
void SpiDrv::waitForSlaveReady(bool const feed_watchdog)
220219
{
221-
#if HAS_WATCHDOG
222220
unsigned long const start = millis();
223-
#endif /* HAS_WATCHDOG */
224221
while (!waitSlaveReady())
225222
{
226-
#if HAS_WATCHDOG
227223
if (feed_watchdog) {
228224
if ((millis() - start) < 10000) {
229-
Watchdog.reset();
225+
wifi_nina_feed_watchdog();
230226
}
231227
}
232-
#endif /* HAS_WATCHDOG */
233228
}
234229
}
235230

0 commit comments

Comments
 (0)