Now tries multiple times to get a Relative Card Address at startup

This commit is contained in:
Michael Chisholm 2006-08-05 08:08:47 +00:00
parent f7f51d6a5e
commit c9759d5b6c
2 changed files with 28 additions and 6 deletions

View File

@ -35,6 +35,9 @@
before reporting no card inserted.
* Fixed writeData function to timeout on error
* writeSectors function now wait until the card is ready before continuing with a transfer
2006-08-05 - Chishm
* Tries multiple times to get a Relative Card Address at startup
*/
#include "io_m3sd.h"
@ -272,9 +275,17 @@ static bool _M3SD_initCard (void) {
_M3SD_getResponse_R2 (responseBuffer);
// Get a new address
for (i = 0; i < MAX_STARTUP_TRIES ; i++) {
_M3SD_sendCommand (SEND_RELATIVE_ADDR, 0);
_M3SD_getResponse_R6 (responseBuffer);
_M3SD_relativeCardAddress = (responseBuffer[1] << 24) | (responseBuffer[2] << 16);
if ((responseBuffer[3] & 0x1e) != (SD_STATE_STBY << 1)) {
break;
}
}
if (i >= MAX_STARTUP_TRIES) {
return false;
}
// Some cards won't go to higher speeds unless they think you checked their capabilities
_M3SD_sendCommand (SEND_CSD, _M3SD_relativeCardAddress);

View File

@ -36,6 +36,9 @@
2006-07-25 - Chishm
* Improved startup function that doesn't delay hundreds of seconds
before reporting no card inserted.
2006-08-05 - Chishm
* Tries multiple times to get a Relative Card Address at startup
*/
#include "io_scsd.h"
@ -224,9 +227,17 @@ static bool _SCSD_initCard (void) {
_SCSD_getResponse_R2 (responseBuffer);
// Get a new address
for (i = 0; i < MAX_STARTUP_TRIES ; i++) {
_SCSD_sendCommand (SEND_RELATIVE_ADDR, 0);
_SCSD_getResponse_R6 (responseBuffer);
_SCSD_relativeCardAddress = (responseBuffer[1] << 24) | (responseBuffer[2] << 16);
if ((responseBuffer[3] & 0x1e) != (SD_STATE_STBY << 1)) {
break;
}
}
if (i >= MAX_STARTUP_TRIES) {
return false;
}
// Some cards won't go to higher speeds unless they think you checked their capabilities
_SCSD_sendCommand (SEND_CSD, _SCSD_relativeCardAddress);