Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SD Card not properly initializing
- Loading branch information
Showing
1 changed file
with
7 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,22 +84,14 @@ void sdDeselectCard(uint8_t pdrv) | |
{ | ||
ardu_sdcard_t * card = s_cards[pdrv]; | ||
digitalWrite(card->ssPin, HIGH); | ||
card->spi->write(0xFF); | ||
} | ||
|
||
bool sdSelectCard(uint8_t pdrv) | ||
{ | ||
ardu_sdcard_t * card = s_cards[pdrv]; | ||
digitalWrite(card->ssPin, LOW); | ||
card->spi->write(0xFF); | ||
|
||
if (sdWait(pdrv, 500)) { | ||
return true; | ||
} else { | ||
log_e("timeout"); | ||
sdDeselectCard(pdrv); | ||
return false; | ||
} | ||
sdWait(pdrv, 300); | ||
return true; | ||
} | ||
|
||
char sdCommand(uint8_t pdrv, char cmd, unsigned int arg, unsigned int* resp) | ||
|
@@ -448,6 +440,11 @@ DSTATUS ff_sd_initialize(uint8_t pdrv) | |
|
||
card->spi->beginTransaction(SPISettings(400000, MSBFIRST, SPI_MODE0)); | ||
|
||
digitalWrite(card->ssPin, HIGH); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
APokorny
Contributor
|
||
for (uint8_t i = 0; i < 20; i++) { | ||
card->spi->transfer(0XFF); | ||
} | ||
|
||
if (sdTransaction(pdrv, GO_IDLE_STATE, 0, NULL) != 1) { | ||
log_w("GO_IDLE_STATE failed"); | ||
goto unknown_card; | ||
|
out of curiosity isnt that change required on every "transaction"?