Skip to content

Commit

Permalink
Fix iinitialization for older cards
Browse files Browse the repository at this point in the history
  • Loading branch information
greiman committed Dec 29, 2018
1 parent 7417ee9 commit 356c5e4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SdFat
version=1.0.11
version=1.0.12
author=Bill Greiman <[email protected]>
maintainer=Bill Greiman <[email protected]>
sentence=FAT16/FAT32 file system for SD cards.
Expand Down
5 changes: 5 additions & 0 deletions src/SdCard/SdInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion src/SdCard/SdSpiCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/SdFat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions src/SysCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 356c5e4

Please sign in to comment.