drivers/sdcard: Allow up to 5 retries to initialise SD card.

Apparently some cards need more than 2 retries.  See issue #1482.
This commit is contained in:
Damien George 2015-10-10 00:07:40 +01:00
parent 845b5a2a58
commit 24652228af
1 changed files with 6 additions and 4 deletions

View File

@ -51,10 +51,12 @@ class SDCard:
for i in range(16):
self.spi.send(0xff)
# CMD0: init card; should return R1_IDLE_STATE (allow 2 attempts)
if self.cmd(0, 0, 0x95) != R1_IDLE_STATE:
if self.cmd(0, 0, 0x95) != R1_IDLE_STATE:
raise OSError("no SD card")
# CMD0: init card; should return R1_IDLE_STATE (allow 5 attempts)
for _ in range(5):
if self.cmd(0, 0, 0x95) == R1_IDLE_STATE:
break
else:
raise OSError("no SD card")
# CMD8: determine card version
r = self.cmd(8, 0x01aa, 0x87, 4)