Skip to content

Commit

Permalink
Prevent WDT resets in SD library (#1815)
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Jun 13, 2016
1 parent 4341297 commit 9172033
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libraries/SD/src/utility/Sd2Card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ uint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) {
// wait for response
for (uint8_t i = 0; ((status_ = spiRec()) & 0x80) && i != 0xFF; i++)
;
#ifdef ESP8266
optimistic_yield(10000);
#endif
return status_;
}
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -569,6 +572,9 @@ uint8_t Sd2Card::setSckRate(uint8_t sckRateID) {
uint8_t Sd2Card::waitNotBusy(uint16_t timeoutMillis) {
uint16_t t0 = millis();
do {
#ifdef ESP8266
optimistic_yield(10000);
#endif
if (spiRec() == 0XFF) return true;
}
while (((uint16_t)millis() - t0) < timeoutMillis);
Expand All @@ -579,6 +585,9 @@ uint8_t Sd2Card::waitNotBusy(uint16_t timeoutMillis) {
uint8_t Sd2Card::waitStartBlock(void) {
uint16_t t0 = millis();
while ((status_ = spiRec()) == 0XFF) {
#ifdef ESP8266
optimistic_yield(10000);
#endif
if (((uint16_t)millis() - t0) > SD_READ_TIMEOUT) {
error(SD_CARD_ERROR_READ_TIMEOUT);
goto fail;
Expand Down

0 comments on commit 9172033

Please sign in to comment.