diff --git a/library.properties b/library.properties index ca487e6f..2eea4bc4 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SdFat -version=1.0.11 +version=1.0.12 author=Bill Greiman maintainer=Bill Greiman sentence=FAT16/FAT32 file system for SD cards. diff --git a/src/SdCard/SdInfo.h b/src/SdCard/SdInfo.h index 3658459f..7ebb4106 100644 --- a/src/SdCard/SdInfo.h +++ b/src/SdCard/SdInfo.h @@ -120,6 +120,11 @@ const uint8_t SD_CARD_TYPE_SDHC = 3; #define SPI_SIXTEENTH_SPEED SD_SCK_HZ(F_CPU/32) //------------------------------------------------------------------------------ // SD operation timeouts +/** CMD0 loop delay ms */ +const uint16_t SD_CMD0_DELAY = 100; +/** init timeout ms */ +/** command timeout ms */ +const uint16_t SD_CMD_TIMEOUT = 300; /** init timeout ms */ const uint16_t SD_INIT_TIMEOUT = 2000; /** erase timeout ms */ diff --git a/src/SdCard/SdSpiCard.cpp b/src/SdCard/SdSpiCard.cpp index 5414e6dc..008f5607 100644 --- a/src/SdCard/SdSpiCard.cpp +++ b/src/SdCard/SdSpiCard.cpp @@ -143,6 +143,7 @@ bool SdSpiCard::begin(SdSpiDriver* spi, uint8_t csPin, SPISettings settings) { error(SD_CARD_ERROR_CMD0); goto fail; } + delayMS(SD_CMD0_DELAY); } #if USE_SD_CRC if (cardCommand(CMD59, 1) != R1_IDLE_STATE) { @@ -208,7 +209,7 @@ uint8_t SdSpiCard::cardCommand(uint8_t cmd, uint32_t arg) { spiStart(); } // wait if busy - waitNotBusy(SD_WRITE_TIMEOUT); + waitNotBusy(SD_CMD_TIMEOUT); #if USE_SD_CRC // form message diff --git a/src/SdFat.h b/src/SdFat.h index 307990b2..79189c5f 100644 --- a/src/SdFat.h +++ b/src/SdFat.h @@ -37,7 +37,7 @@ #endif // INCLUDE_SDIOS //------------------------------------------------------------------------------ /** SdFat version */ -#define SD_FAT_VERSION "1.0.11" +#define SD_FAT_VERSION "1.0.12" //============================================================================== /** * \class SdBaseFile diff --git a/src/SysCall.h b/src/SysCall.h index e990e2af..331d59d1 100644 --- a/src/SysCall.h +++ b/src/SysCall.h @@ -36,22 +36,27 @@ #else // defined(ARDUINO) #error "Unknown system" #endif // defined(ARDUINO) -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ #ifdef ESP8266 // undefine F macro if ESP8266. #undef F #endif // ESP8266 -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ #ifndef F /** Define macro for strings stored in flash. */ #define F(str) (str) #endif // F -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ /** \return the time in milliseconds. */ inline uint16_t curTimeMS() { return millis(); } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ +/** Delay milliseconds */ +inline void delayMS(uint16_t ms) { + delay(ms); +} +//------------------------------------------------------------------------------ /** * \class SysCall * \brief SysCall - Class to wrap system calls.