Merge pull request #5681 from thinkyhead/rc_prevent_boot_loop

Reset watchdog in SD init to prevent reboot
This commit is contained in:
Scott Lahteine 2017-01-12 06:13:56 -08:00 committed by GitHub
commit 7a9c1a279b

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();