From a6be90f98346b24137bbbd77f70fc2d04ffc03fe Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Mon, 23 Mar 2015 15:28:19 +0100 Subject: [PATCH] SD: avoid timeout lock if millis() approaches 2^16 this is a rework of @Timmmm 's PR #1977 --- libraries/SD/src/utility/Sd2Card.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/SD/src/utility/Sd2Card.cpp b/libraries/SD/src/utility/Sd2Card.cpp index a72d3d271..c9b49247f 100644 --- a/libraries/SD/src/utility/Sd2Card.cpp +++ b/libraries/SD/src/utility/Sd2Card.cpp @@ -283,7 +283,7 @@ uint8_t Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) { // command to go idle in SPI mode while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) { - if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) { + if (((uint16_t)(millis() - t0)) > SD_INIT_TIMEOUT) { error(SD_CARD_ERROR_CMD0); goto fail; } @@ -305,7 +305,7 @@ uint8_t Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) { while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) { // check for timeout - if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) { + if (((uint16_t)(millis() - t0)) > SD_INIT_TIMEOUT) { error(SD_CARD_ERROR_ACMD41); goto fail; }