Reset watchdog in SD init to prevent reboot

If the watchdog is enabled and bootscreen + SD card checks take too long, Marlin may hang at boot time because of the reset loop. We have this happen all the time with the Anet board if no SD card is inserted.
This commit is contained in:
Hans Raaf 2017-01-12 04:24:49 +01:00 committed by Scott Lahteine
parent 7743849608
commit d29cc8f7bc

View File

@ -31,6 +31,10 @@
#if ENABLED(SDSUPPORT)
#include "Sd2Card.h"
#if ENABLED(USE_WATCHDOG)
#include "watchdog.h"
#endif
//------------------------------------------------------------------------------
#if DISABLED(SOFTWARE_SPI)
// functions for hardware SPI
@ -299,6 +303,12 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
uint16_t t0 = (uint16_t)millis();
uint32_t arg;
// If init takes more than 4s it could trigger
// watchdog leading to a reboot loop.
#if ENABLED(USE_WATCHDOG)
watchdog_reset();
#endif
// set pin modes
pinMode(chipSelectPin_, OUTPUT);
chipSelectHigh();