Skip to content

Commit

Permalink
Allow 0 for no timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 13, 2023
1 parent dc31834 commit b04b3ac
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Marlin/src/sd/Sd2Card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ uint8_t DiskIODriver_SPI_SD::cardCommand(const uint8_t cmd, const uint32_t arg)
// Select card
chipSelect();

#ifdef SD_WRITE_TIMEOUT
#if SD_WRITE_TIMEOUT
waitNotBusy(SD_WRITE_TIMEOUT); // Wait up to 300 ms if busy
#endif

Expand Down Expand Up @@ -239,7 +239,7 @@ bool DiskIODriver_SPI_SD::erase(uint32_t firstBlock, uint32_t lastBlock) {
error(SD_CARD_ERROR_ERASE);
break;
}
#ifdef SD_ERASE_TIMEOUT
#if SD_ERASE_TIMEOUT
if (!waitNotBusy(SD_ERASE_TIMEOUT)) {
error(SD_CARD_ERROR_ERASE_TIMEOUT);
break;
Expand Down Expand Up @@ -636,7 +636,7 @@ bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t *src) {
error(SD_CARD_ERROR_CMD24);
}
else if (writeData(DATA_START_BLOCK, src)) {
#ifdef SD_WRITE_TIMEOUT
#if SD_WRITE_TIMEOUT
success = waitNotBusy(SD_WRITE_TIMEOUT); // Wait for flashing to complete
if (!success) error(SD_CARD_ERROR_WRITE_TIMEOUT);
#else
Expand Down Expand Up @@ -666,7 +666,7 @@ bool DiskIODriver_SPI_SD::writeData(const uint8_t *src) {
do {

// Wait for previous write to finish
#ifdef SD_WRITE_TIMEOUT
#if SD_WRITE_TIMEOUT
if (!waitNotBusy(SD_WRITE_TIMEOUT)) {
error(SD_CARD_ERROR_WRITE_MULTIPLE);
break;
Expand Down Expand Up @@ -741,7 +741,7 @@ bool DiskIODriver_SPI_SD::writeStop() {
bool success = false;
do {

#ifdef SD_WRITE_TIMEOUT
#if SD_WRITE_TIMEOUT
if (!waitNotBusy(SD_WRITE_TIMEOUT)) {
error(SD_CARD_ERROR_STOP_TRAN);
break;
Expand All @@ -752,15 +752,15 @@ bool DiskIODriver_SPI_SD::writeStop() {

spiSend(STOP_TRAN_TOKEN);

#ifdef SD_WRITE_TIMEOUT
#if SD_WRITE_TIMEOUT
if (!waitNotBusy(SD_WRITE_TIMEOUT)) break;
#else
while (spiRec() != 0xFF) {}
#endif

success = true;

} while(0);
} while (0);

chipDeselect();
return success;
Expand Down

0 comments on commit b04b3ac

Please sign in to comment.