Skip to content

Commit

Permalink
SD: avoid timeout lock if millis() approaches 2^16
Browse files Browse the repository at this point in the history
this is a rework of @Timmmm 's PR #1977
  • Loading branch information
facchinm committed Mar 23, 2015
1 parent 1c65033 commit dd2dfb4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utility/Sd2Card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit dd2dfb4

Please sign in to comment.