From fdf340791d907cd46fa69cb9ba1fce3e43481b99 Mon Sep 17 00:00:00 2001 From: Michael Chisholm Date: Tue, 8 Aug 2006 07:32:39 +0000 Subject: [PATCH] Init aborts when it doesn't get a valid response to APP_CMD --- source/disc_io/io_scsd.c | 15 ++------------- source/disc_io/io_sd_common.c | 7 +++++++ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/source/disc_io/io_scsd.c b/source/disc_io/io_scsd.c index 9a024d0..76f107d 100644 --- a/source/disc_io/io_scsd.c +++ b/source/disc_io/io_scsd.c @@ -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(); } diff --git a/source/disc_io/io_sd_common.c b/source/disc_io/io_sd_common.c index 0a38e62..24f6873 100644 --- a/source/disc_io/io_sd_common.c +++ b/source/disc_io/io_sd_common.c @@ -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))