Init aborts when it doesn't get a valid response to APP_CMD

This commit is contained in:
Michael Chisholm 2006-08-08 07:32:39 +00:00
parent 7b4d9b8d0a
commit fdf340791d
2 changed files with 9 additions and 13 deletions

View File

@ -83,17 +83,8 @@ static u32 _SCSD_relativeCardAddress = 0; // Preshifted Relative Card Address
extern bool _SCSD_writeData_s (u8 *data, u16* crc);
static bool _SCSD_unlock (void) {
//see if we can write to SCSD RAM
vu32 *ramPointer = (u32*)0x08000000;
_SC_changeMode (SC_MODE_RAM);
*ramPointer = 0x5555aaaa;
*ramPointer = ~*ramPointer;
if(*ramPointer != 0xaaaa5555) {
return false;
}
static inline void _SCSD_unlock (void) {
_SC_changeMode (SC_MODE_MEDIA);
return true;
}
static bool _SCSD_sendCommand (u8 command, u32 argument) {
@ -273,9 +264,7 @@ static bool _SCSD_readData (void* buffer) {
// Functions needed for the external interface
bool _SCSD_startUp (void) {
if (!_SCSD_unlock()) {
return false;
}
_SCSD_unlock();
return _SCSD_initCard();
}

View File

@ -33,6 +33,9 @@
2006-08-07 - Chishm
* Moved the SD initialization to a common function
* Increased timeouts for slower cards
2006-08-08 - Chishm
* Init aborts when it doesn't get a valid response to APP_CMD - speeds up detection when no card is inserted
*/
#include "io_sd_common.h"
@ -146,6 +149,10 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response,
for (i = 0; i < MAX_STARTUP_TRIES ; i++) {
cmd_6byte_response (responseBuffer, APP_CMD, 0);
// Check that the card gave the correct response
if (responseBuffer[0] != APP_CMD) {
return false;
}
if (
cmd_6byte_response (responseBuffer, SD_APP_OP_COND, SD_OCR_VALUE) &&
((responseBuffer[1] & 0x80) != 0))