Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utility/server_drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void ServerDrv::startClient(const char* host, uint8_t host_len, uint32_t ipAddre

SpiDrv::spiSlaveDeselect();
//Wait the reply elaboration
SpiDrv::waitForSlaveReady();
SpiDrv::waitForSlaveReady(/* feed_watchdog = */ (protMode == TLS_BEARSSL_MODE));
SpiDrv::spiSlaveSelect();

// Wait for reply
Expand Down
25 changes: 23 additions & 2 deletions src/utility/spi_drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,30 @@ void SpiDrv::waitForSlaveSign()
while (!waitSlaveSign());
}

void SpiDrv::waitForSlaveReady()
#if defined __has_include
# if __has_include (<Adafruit_SleepyDog.h>)
# include <Adafruit_SleepyDog.h>
# define HAS_WATCHDOG 1
# endif
#else
# define HAS_WATCHDOG 0
#endif

void SpiDrv::waitForSlaveReady(bool const feed_watchdog)
{
while (!waitSlaveReady());
#if HAS_WATCHDOG
unsigned long const start = millis();
#endif /* HAS_WATCHDOG */
while (!waitSlaveReady())
{
#if HAS_WATCHDOG
if (feed_watchdog) {
if ((millis() - start) < 10000) {
Watchdog.reset();
}
}
#endif /* HAS_WATCHDOG */
}
}

void SpiDrv::getParam(uint8_t* param)
Expand Down
2 changes: 1 addition & 1 deletion src/utility/spi_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SpiDrv

static char spiTransfer(volatile char data);

static void waitForSlaveReady();
static void waitForSlaveReady(bool const feed_watchdog = false);

//static int waitSpiChar(char waitChar, char* readChar);

Expand Down