diff options
author | Johannes Schickel | 2009-05-24 21:53:29 +0000 |
---|---|---|
committer | Johannes Schickel | 2009-05-24 21:53:29 +0000 |
commit | c97a1aed74fc54176e0de66fc2b6bbe0767e8de6 (patch) | |
tree | 5fed1a82a5546fd28d5d6b6695a6fe6be30f75fa /backends/platform/ds | |
parent | fd0578f151193e8fe4f31415c631f08d7179ddf9 (diff) | |
download | scummvm-rg350-c97a1aed74fc54176e0de66fc2b6bbe0767e8de6.tar.gz scummvm-rg350-c97a1aed74fc54176e0de66fc2b6bbe0767e8de6.tar.bz2 scummvm-rg350-c97a1aed74fc54176e0de66fc2b6bbe0767e8de6.zip |
Also strip trailing whitespaces in C and Objective-C source files. (Seems I forgot that we got those too :-P)
svn-id: r40872
Diffstat (limited to 'backends/platform/ds')
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_efa2.c | 28 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_fcsr.c | 16 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_m3_common.c | 10 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_m3cf.c | 54 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_m3sd.c | 4 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_mmcf.c | 26 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_mpcf.c | 52 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_njsd.c | 76 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_nmmc.c | 58 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_sccf.c | 2 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_scsd.c | 8 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/fat/io_sd_common.c | 58 |
12 files changed, 196 insertions, 196 deletions
diff --git a/backends/platform/ds/arm9/source/fat/io_efa2.c b/backends/platform/ds/arm9/source/fat/io_efa2.c index f3aa65cfcb..468361969e 100644 --- a/backends/platform/ds/arm9/source/fat/io_efa2.c +++ b/backends/platform/ds/arm9/source/fat/io_efa2.c @@ -47,7 +47,7 @@ See gba_nds_fat.txt for help and license details. // ID of Samsung K9K1G NAND flash chip #define EFA2_NAND_ID 0xEC79A5C0 -// first sector of udisk +// first sector of udisk #define EFA2_UDSK_START 0x40 // @@ -101,7 +101,7 @@ void efa2_nand_lock(void) { // // Set NAND Flash chip enable and write protection bits ? -// +// // val | ~CE | ~WP | // -----+-----+-----+ // 0 | 0 | 0 | @@ -125,7 +125,7 @@ inline void efa2_nand_reset(void) { // // Read out NAND ID information, could be used for card detection -// +// // | EFA2 1GBit | // ------------------+------------+ // maker code | 0xEC | @@ -166,7 +166,7 @@ EFA2_ClearStatus Reads and checks NAND status information bool return OUT: true if NAND is idle -----------------------------------------------------------------*/ -bool EFA2_ClearStatus (void) +bool EFA2_ClearStatus (void) { // tbd: currently there is no write support, so always return // true, there is no possibility for pending operations @@ -178,7 +178,7 @@ EFA2_IsInserted Checks to see if the NAND chip used by the EFA2 is present bool return OUT: true if the correct NAND chip is found -----------------------------------------------------------------*/ -bool EFA2_IsInserted (void) +bool EFA2_IsInserted (void) { EFA2_ClearStatus(); return (efa2_nand_id() == EFA2_NAND_ID); @@ -223,7 +223,7 @@ bool EFA2_ReadSectors (u32 sector, u8 numSecs, void* buffer) efa2_nand_reset(); // set NAND to READ1 operation mode and transfer page address - REG_EFA2_NAND_CMD = 0x00; // write READ1 command + REG_EFA2_NAND_CMD = 0x00; // write READ1 command REG_EFA2_NAND_WR = 0x00; // write address [7:0] REG_EFA2_NAND_WR = (page ) & 0xff; // write address [15:8] REG_EFA2_NAND_WR = (page >> 8 ) & 0xff; // write address[23:16] @@ -280,7 +280,7 @@ bool EFA2_WriteSectors (u32 sector, u8 numSecs, void* buffer) EFA2_Shutdown unload the EFA2 interface -----------------------------------------------------------------*/ -bool EFA2_Shutdown(void) +bool EFA2_Shutdown(void) { return EFA2_ClearStatus(); } @@ -368,7 +368,7 @@ See gba_nds_fat.txt for help and license details. // ID of Samsung K9K1G NAND flash chip #define EFA2_NAND_ID 0xEC79A5C0 -// first sector of udisk +// first sector of udisk #define EFA2_UDSK_START 0x40 // @@ -422,7 +422,7 @@ void efa2_nand_lock(void) { // // Set NAND Flash chip enable and write protection bits ? -// +// // val | ~CE | ~WP | // -----+-----+-----+ // 0 | 0 | 0 | @@ -446,7 +446,7 @@ inline void efa2_nand_reset(void) { // // Read out NAND ID information, could be used for card detection -// +// // | EFA2 1GBit | // ------------------+------------+ // maker code | 0xEC | @@ -487,7 +487,7 @@ EFA2_ClearStatus Reads and checks NAND status information bool return OUT: true if NAND is idle -----------------------------------------------------------------*/ -bool EFA2_ClearStatus (void) +bool EFA2_ClearStatus (void) { // tbd: currently there is no write support, so always return // true, there is no possibility for pending operations @@ -499,7 +499,7 @@ EFA2_IsInserted Checks to see if the NAND chip used by the EFA2 is present bool return OUT: true if the correct NAND chip is found -----------------------------------------------------------------*/ -bool EFA2_IsInserted (void) +bool EFA2_IsInserted (void) { EFA2_ClearStatus(); return (efa2_nand_id() == EFA2_NAND_ID); @@ -544,7 +544,7 @@ bool EFA2_ReadSectors (u32 sector, u8 numSecs, void* buffer) efa2_nand_reset(); // set NAND to READ1 operation mode and transfer page address - REG_EFA2_NAND_CMD = 0x00; // write READ1 command + REG_EFA2_NAND_CMD = 0x00; // write READ1 command REG_EFA2_NAND_WR = 0x00; // write address [7:0] REG_EFA2_NAND_WR = (page ) & 0xff; // write address [15:8] REG_EFA2_NAND_WR = (page >> 8 ) & 0xff; // write address[23:16] @@ -601,7 +601,7 @@ bool EFA2_WriteSectors (u32 sector, u8 numSecs, void* buffer) EFA2_Shutdown unload the EFA2 interface -----------------------------------------------------------------*/ -bool EFA2_Shutdown(void) +bool EFA2_Shutdown(void) { return EFA2_ClearStatus(); } diff --git a/backends/platform/ds/arm9/source/fat/io_fcsr.c b/backends/platform/ds/arm9/source/fat/io_fcsr.c index d576dfbb0f..7a67a6b1b0 100644 --- a/backends/platform/ds/arm9/source/fat/io_fcsr.c +++ b/backends/platform/ds/arm9/source/fat/io_fcsr.c @@ -4,7 +4,7 @@ compact_flash.c By chishm (Michael Chisholm) - Hardware Routines for using a GBA Flash Cart and SRAM as a + Hardware Routines for using a GBA Flash Cart and SRAM as a block device. This software is completely free. No warranty is provided. @@ -57,7 +57,7 @@ FCSR_IsInserted Is a GBA Flash Cart with a valid file system inserted? bool return OUT: true if a GBA FC card is inserted -----------------------------------------------------------------*/ -bool FCSR_IsInserted (void) +bool FCSR_IsInserted (void) { bool flagFoundFileSys = false; @@ -85,7 +85,7 @@ FCSR_ClearStatus Finish any pending operations bool return OUT: always true for GBA FC -----------------------------------------------------------------*/ -bool FCSR_ClearStatus (void) +bool FCSR_ClearStatus (void) { return true; } @@ -101,7 +101,7 @@ void* buffer OUT: pointer to 512 byte buffer to store data in bool return OUT: true if successful -----------------------------------------------------------------*/ bool FCSR_ReadSectors (u32 sector, u8 numSecs, void* buffer) -{ +{ int i; bool flagSramSector = false; int numSectors = (numSecs > 0 ? numSecs : 256); @@ -208,14 +208,14 @@ bool FCSR_WriteSectors (u32 sector, u8 numSecs, void* buffer) FCSR_Shutdown unload the Flash Cart interface -----------------------------------------------------------------*/ -bool FCSR_Shutdown(void) +bool FCSR_Shutdown(void) { int i; if (FCSR_ClearStatus() == false) return false; FCSR_FileSysPointer = 0; - + for (i=0; i < 4; i++) { FCSR_SramSectorPointer[i] = 0; @@ -262,11 +262,11 @@ bool FCSR_StartUp(void) // Get SRAM sector regions from header block for (i = 0; i < 4; i++) { - FCSR_SramSectorStart[i] = fileSysPointer[i+4]; + FCSR_SramSectorStart[i] = fileSysPointer[i+4]; SramRegionSize[i] = fileSysPointer[i+8]; FCSR_SramSectorEnd[i] = FCSR_SramSectorStart[i] + SramRegionSize[i]; } - + // Calculate SRAM region pointers FCSR_SramSectorPointer[0] = (u8*)(SRAM_START + 4); for (i = 1; i < 4; i++) diff --git a/backends/platform/ds/arm9/source/fat/io_m3_common.c b/backends/platform/ds/arm9/source/fat/io_m3_common.c index ab2c143327..9c8280c808 100644 --- a/backends/platform/ds/arm9/source/fat/io_m3_common.c +++ b/backends/platform/ds/arm9/source/fat/io_m3_common.c @@ -1,13 +1,13 @@ /* - io_m3_common.c + io_m3_common.c Routines common to all version of the M3 - + Some code based on M3 SD drivers supplied by M3Adapter. Some code written by SaTa may have been unknowingly used. Copyright (c) 2006 Michael "Chishm" Chisholm - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -47,7 +47,7 @@ void _M3_changeMode (u32 mode) { _M3_readHalfword (0x08000000 + (mode << 1)); _M3_readHalfword (0x0800080e); _M3_readHalfword (0x08000000); - + if ((mode & 0x0f) != 4) { _M3_readHalfword (0x09000000); } else { @@ -56,5 +56,5 @@ void _M3_changeMode (u32 mode) { _M3_readHalfword (0x08000188); _M3_readHalfword (0x08000188); } -} +} diff --git a/backends/platform/ds/arm9/source/fat/io_m3cf.c b/backends/platform/ds/arm9/source/fat/io_m3cf.c index 910f01097e..968d83ae33 100644 --- a/backends/platform/ds/arm9/source/fat/io_m3cf.c +++ b/backends/platform/ds/arm9/source/fat/io_m3cf.c @@ -73,7 +73,7 @@ M3CF_IsInserted Is a compact flash card inserted? bool return OUT: true if a CF card is inserted -----------------------------------------------------------------*/ -bool M3CF_IsInserted (void) +bool M3CF_IsInserted (void) { // Change register, then check if value did change M3_REG_STS = CF_STS_INSERTED; @@ -86,17 +86,17 @@ M3CF_ClearStatus Tries to make the CF card go back to idle mode bool return OUT: true if a CF card is idle -----------------------------------------------------------------*/ -bool M3CF_ClearStatus (void) +bool M3CF_ClearStatus (void) { int i; - + // Wait until CF card is finished previous commands i=0; while ((M3_REG_CMD & CF_STS_BUSY) && (i < CARD_TIMEOUT)) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(M3_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -128,7 +128,7 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) u8 *buff_u8 = (u8*)buffer; int temp; #endif - + #if defined _CF_USE_DMA && defined NDS && defined ARM9 DC_FlushRange( buffer, j * BYTE_PER_READ); #endif @@ -139,7 +139,7 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(M3_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -148,20 +148,20 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Set number of sectors to read - M3_REG_SEC = numSecs; - + M3_REG_SEC = numSecs; + // Set read sector M3_REG_LBA1 = sector & 0xFF; // 1st byte of sector number M3_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number M3_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number M3_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number - + // Set command to read M3_REG_CMD = CF_CMD_READ; - - + + while (j--) { // Wait until card is ready for reading @@ -172,7 +172,7 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Read data #ifdef _CF_USE_DMA #ifdef NDS @@ -194,12 +194,12 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *buff++ = *M3_DATA; + *buff++ = *M3_DATA; } #else i=256; while(i--) - *buff++ = *M3_DATA; + *buff++ = *M3_DATA; #endif } #if defined _CF_USE_DMA && defined NDS @@ -230,7 +230,7 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) u8 *buff_u8 = (u8*)buffer; int temp; #endif - + #if defined _CF_USE_DMA && defined NDS && defined ARM9 DC_FlushRange( buffer, j * BYTE_PER_READ); #endif @@ -241,7 +241,7 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(M3_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -250,19 +250,19 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Set number of sectors to write - M3_REG_SEC = numSecs; - + M3_REG_SEC = numSecs; + // Set write sector M3_REG_LBA1 = sector & 0xFF; // 1st byte of sector number M3_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number M3_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number M3_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number - + // Set command to write M3_REG_CMD = CF_CMD_WRITE; - + while (j--) { // Wait until card is ready for writing @@ -273,7 +273,7 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Write data #ifdef _CF_USE_DMA #ifdef NDS @@ -295,19 +295,19 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *M3_DATA = *buff++; + *M3_DATA = *buff++; } #else i=256; while(i--) - *M3_DATA = *buff++; + *M3_DATA = *buff++; #endif } #if defined _CF_USE_DMA && defined NDS // Wait for end of transfer before returning while(DMA3_CR & DMA_BUSY); #endif - + return true; } @@ -317,7 +317,7 @@ M3_Unlock Returns true if M3 was unlocked, false if failed Added by MightyMax -----------------------------------------------------------------*/ -bool M3_Unlock(void) +bool M3_Unlock(void) { // run unlock sequence volatile unsigned short tmp ; diff --git a/backends/platform/ds/arm9/source/fat/io_m3sd.c b/backends/platform/ds/arm9/source/fat/io_m3sd.c index 914b83e06e..2bbda37a5a 100644 --- a/backends/platform/ds/arm9/source/fat/io_m3sd.c +++ b/backends/platform/ds/arm9/source/fat/io_m3sd.c @@ -218,7 +218,7 @@ void M3SD_writesector(u16 * p,u32 sectorn) } } while ((verify > 0) && (tries < 16)); - + free(data); free(check); } // */ @@ -356,7 +356,7 @@ bool M3SD_Shutdown(void) bool M3SD_StartUp(void) { vu16* waitCr = (vu16*)0x4000204; - + *waitCr |= 0x6000; // *(vu16*)0x4000204=0x6000; // Try unlocking 3 times, because occationally it fails to detect the reader. diff --git a/backends/platform/ds/arm9/source/fat/io_mmcf.c b/backends/platform/ds/arm9/source/fat/io_mmcf.c index 3034afe311..5ccb3122e4 100644 --- a/backends/platform/ds/arm9/source/fat/io_mmcf.c +++ b/backends/platform/ds/arm9/source/fat/io_mmcf.c @@ -74,14 +74,14 @@ static bool cf_block_ready(void) do { while (!(CF_RD_STATUS & 0x40)); - } while (CF_RD_STATUS & 0x80); + } while (CF_RD_STATUS & 0x80); */ do { i++; - while ( (!(CF_RD_STATUS & 0x40)) && (i < CARD_TIMEOUT) ) i++; - } while ( (CF_RD_STATUS & 0x80) && (i < CARD_TIMEOUT) ); + while ( (!(CF_RD_STATUS & 0x40)) && (i < CARD_TIMEOUT) ) i++; + } while ( (CF_RD_STATUS & 0x80) && (i < CARD_TIMEOUT) ); if (i >= CARD_TIMEOUT) { return false; @@ -110,7 +110,7 @@ MMCF_IsInserted Is a compact flash card inserted? bool return OUT: true if a CF card is inserted -----------------------------------------------------------------*/ -bool MMCF_IsInserted (void) +bool MMCF_IsInserted (void) { if ( !cf_set_features(0xAA) ) return false; @@ -123,7 +123,7 @@ MMCF_ClearStatus Tries to make the CF card go back to idle mode bool return OUT: true if a CF card is idle -----------------------------------------------------------------*/ -bool MMCF_ClearStatus (void) +bool MMCF_ClearStatus (void) { return true; } @@ -185,7 +185,7 @@ bool MMCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *buff++ = *MP_DATA; + *buff++ = *MP_DATA; } #else i=256; @@ -222,15 +222,15 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) u8 *buff_u8 = (u8*)buffer; int temp; #endif - + #if defined _CF_USE_DMA && defined NDS && defined ARM9 DC_FlushRange( buffer, j * BYTE_PER_READ); #endif - if (numSecs > 1) + if (numSecs > 1) { int r = 0; - + for (r = 0; r < numSecs; r++) { MMCF_WriteSectors(sector + r, 1, ((unsigned char *) (buffer)) + 512); @@ -270,12 +270,12 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *MP_DATA = *buff++; + *MP_DATA = *buff++; } #else i=256; while(i--) - *MP_DATA = *buff++; + *MP_DATA = *buff++; #endif } @@ -283,7 +283,7 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) #if defined _CF_USE_DMA && defined NDS // Wait for end of transfer before returning while(DMA3_CR & DMA_BUSY); -#endif +#endif //#define _CF_VERIFY @@ -312,7 +312,7 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) MMCF_Shutdown unload the GBAMP CF interface -----------------------------------------------------------------*/ -bool MMCF_Shutdown(void) +bool MMCF_Shutdown(void) { return MMCF_ClearStatus() ; } diff --git a/backends/platform/ds/arm9/source/fat/io_mpcf.c b/backends/platform/ds/arm9/source/fat/io_mpcf.c index a12b6e8e1e..6b56e29291 100644 --- a/backends/platform/ds/arm9/source/fat/io_mpcf.c +++ b/backends/platform/ds/arm9/source/fat/io_mpcf.c @@ -73,7 +73,7 @@ MPCF_IsInserted Is a compact flash card inserted? bool return OUT: true if a CF card is inserted -----------------------------------------------------------------*/ -bool MPCF_IsInserted (void) +bool MPCF_IsInserted (void) { // Change register, then check if value did change MP_REG_STS = CF_STS_INSERTED; @@ -86,17 +86,17 @@ MPCF_ClearStatus Tries to make the CF card go back to idle mode bool return OUT: true if a CF card is idle -----------------------------------------------------------------*/ -bool MPCF_ClearStatus (void) +bool MPCF_ClearStatus (void) { int i; - + // Wait until CF card is finished previous commands i=0; while ((MP_REG_CMD & CF_STS_BUSY) && (i < CARD_TIMEOUT)) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(MP_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -139,7 +139,7 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(MP_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -148,20 +148,20 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Set number of sectors to read - MP_REG_SEC = numSecs; - + MP_REG_SEC = numSecs; + // Set read sector MP_REG_LBA1 = sector & 0xFF; // 1st byte of sector number MP_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number MP_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number MP_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number - + // Set command to read MP_REG_CMD = CF_CMD_READ; - - + + while (j--) { // Wait until card is ready for reading @@ -172,7 +172,7 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Read data #ifdef _CF_USE_DMA #ifdef NDS @@ -194,12 +194,12 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *buff++ = *MP_DATA; + *buff++ = *MP_DATA; } #else i=256; while(i--) - *buff++ = *MP_DATA; + *buff++ = *MP_DATA; #endif } #if (defined _CF_USE_DMA) && (defined NDS) @@ -229,7 +229,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) u8 *buff_u8 = (u8*)buffer; int temp; #endif - + #if defined _CF_USE_DMA && defined NDS && defined ARM9 DC_FlushRange( buffer, j * BYTE_PER_READ); #endif @@ -240,7 +240,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) { i++; } - + // Wait until card is ready for commands i = 0; while ((!(MP_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT)) @@ -249,19 +249,19 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Set number of sectors to write - MP_REG_SEC = numSecs; - + MP_REG_SEC = numSecs; + // Set write sector MP_REG_LBA1 = sector & 0xFF; // 1st byte of sector number MP_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number MP_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number MP_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number - + // Set command to write MP_REG_CMD = CF_CMD_WRITE; - + while (j--) { // Wait until card is ready for writing @@ -272,7 +272,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } if (i >= CARD_TIMEOUT) return false; - + // Write data #ifdef _CF_USE_DMA #ifdef NDS @@ -294,19 +294,19 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) } } else { while(i--) - *MP_DATA = *buff++; + *MP_DATA = *buff++; } #else i=256; while(i--) - *MP_DATA = *buff++; + *MP_DATA = *buff++; #endif } #if defined _CF_USE_DMA && defined NDS // Wait for end of transfer before returning while(DMA3_CR & DMA_BUSY); #endif - + return true; } @@ -314,7 +314,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer) MPCF_Shutdown unload the GBAMP CF interface -----------------------------------------------------------------*/ -bool MPCF_Shutdown(void) +bool MPCF_Shutdown(void) { return MPCF_ClearStatus() ; } diff --git a/backends/platform/ds/arm9/source/fat/io_njsd.c b/backends/platform/ds/arm9/source/fat/io_njsd.c index fbb223d560..b9cb52aa00 100644 --- a/backends/platform/ds/arm9/source/fat/io_njsd.c +++ b/backends/platform/ds/arm9/source/fat/io_njsd.c @@ -3,11 +3,11 @@ Hardware Routines for reading an SD card using a NinjaDS SD adapter. - + Original code supplied by NinjaMod - + Copyright (c) 2006 Michael "Chishm" Chisholm - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -28,7 +28,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + 2006-08-05 - Chishm * First release */ @@ -84,7 +84,7 @@ static u32 _NJSD_relativeCardAddress = 0; static inline bool _NJSD_waitIRQ(void) { /*#ifdef _NJSD_SYNC int i = IRQ_TIMEOUT; - while (!(REG_IF & 0x100000) && --i); + while (!(REG_IF & 0x100000) && --i); REG_IF = 0x100000; if (i <= 0) { return false; @@ -96,7 +96,7 @@ static inline bool _NJSD_waitIRQ(void) { //if (!(REG_IME & 1)) //{ // irq's disabled... - while (!(REG_IF & 0x100000) && (!(_NJSD_irqFlag)) && --i); + while (!(REG_IF & 0x100000) && (!(_NJSD_irqFlag)) && --i); _NJSD_irqFlag = 0; REG_IF = 0x100000; if (i <= 0) { @@ -106,7 +106,7 @@ static inline bool _NJSD_waitIRQ(void) { } //} else { // irq's enabled - // while (!(_NJSD_irqFlag) && --i); + // while (!(_NJSD_irqFlag) && --i); // _NJSD_irqFlag = 0; // REG_IF = 0x100000; // if (i <= 0) { @@ -118,8 +118,8 @@ static inline bool _NJSD_waitIRQ(void) { //#endif } -static inline void _NJSD_writeCardCommand - (u8 cmd0, u8 cmd1, u8 cmd2, u8 cmd3, u8 cmd4, u8 cmd5, u8 cmd6, u8 cmd7) +static inline void _NJSD_writeCardCommand + (u8 cmd0, u8 cmd1, u8 cmd2, u8 cmd3, u8 cmd4, u8 cmd5, u8 cmd6, u8 cmd7) { CARD_COMMAND[0] = cmd0; CARD_COMMAND[1] = cmd1; @@ -142,7 +142,7 @@ static bool _NJSD_reset (void) { if (i <= 0) { return false; } - + return true; } @@ -179,7 +179,7 @@ static bool _NJSD_sendCMDR (int speed, u8 *rsp_buf, int type, u8 cmd, u32 param) REG_IME = 0; #endif - REG_IE &= ~0x100000; + REG_IE &= ~0x100000; REG_IF = 0x100000; CARD_CR1H = CARD_CR1_ENABLE; @@ -191,7 +191,7 @@ static bool _NJSD_sendCMDR (int speed, u8 *rsp_buf, int type, u8 cmd, u32 param) } else { CARD_COMMAND[0] = 0xF0 | (speed << 2) | 0 | (1 << 1); } - + CARD_COMMAND[1] = (type & 0x40) | ((( type >> 2) & 7) << 3); CARD_COMMAND[2] = 0x40 | cmd; CARD_COMMAND[3] = (param>>24) & 0xFF; @@ -301,7 +301,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) { } - REG_IE &= ~0x100000; + REG_IE &= ~0x100000; REG_IF = 0x100000; CARD_CR1H = CARD_CR1_ENABLE; @@ -334,7 +334,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) { i++; } } while (CARD_CR2 & CARD_BUSY); - + i = WRITE_TIMEOUT; responseBuffer[3] = 0; do { @@ -352,7 +352,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; #endif - + return true; } @@ -365,12 +365,12 @@ static bool _NJSD_sendCLK (int speed, int count) { REG_IME = 0; #endif - REG_IE &= ~0x100000; + REG_IE &= ~0x100000; REG_IF = 0x100000; //CARD_CR1H = CARD_CR1_ENABLE; // | CARD_CR1_IRQ; _NJSD_writeCardCommand (0xE0 | ((speed & 3) << 2), 0, (count - 1), 0, 0, 0, 0, 0); - + CARD_CR2 = _NJSD_cardFlags; i = COMMAND_TIMEOUT; while ((CARD_CR2 & CARD_BUSY) && --i); @@ -404,7 +404,7 @@ static bool _NJSD_sendCMDN (int speed, u8 cmd, u32 param) { REG_IME = 0; #endif - REG_IE &= ~0x100000; + REG_IE &= ~0x100000; REG_IF = 0x100000; CARD_CR1H = CARD_CR1_ENABLE; // | CARD_CR1_IRQ; @@ -438,22 +438,22 @@ static bool _NJSD_sendCMDN (int speed, u8 cmd, u32 param) { static bool _NJSD_cardInit (void) { u8 responseBuffer[17]; int i; - + // If the commands succeed the first time, assume they'll always succeed if (! _NJSD_sendCLK (SD_CLK_200KHz, 256) ) return false; if (! _NJSD_sendCMDN (SD_CLK_200KHz, GO_IDLE_STATE, 0) ) return false; _NJSD_sendCLK (SD_CLK_200KHz, 8); - + _NJSD_sendCLK (SD_CLK_200KHz, 256); _NJSD_sendCMDN (SD_CLK_200KHz, GO_IDLE_STATE, 0); _NJSD_sendCLK (SD_CLK_200KHz, 8); - + for (i = 0; i < MAX_STARTUP_TRIES ; i++) { _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, APP_CMD, 0); - if ( + if ( _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SD_APP_OP_COND, SD_OCR_VALUE) && ((responseBuffer[1] & 0x80) != 0)) - { + { // Card is ready to receive commands now break; } @@ -461,10 +461,10 @@ static bool _NJSD_cardInit (void) { if (i >= MAX_STARTUP_TRIES) { return false; } - + // The card's name, as assigned by the manufacturer _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_136, ALL_SEND_CID, 0); - + // Get a new address for (i = 0; i < MAX_STARTUP_TRIES ; i++) { _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SEND_RELATIVE_ADDR, 0); @@ -479,17 +479,17 @@ static bool _NJSD_cardInit (void) { // Some cards won't go to higher speeds unless they think you checked their capabilities _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_136, SEND_CSD, _NJSD_relativeCardAddress); - + // Only this card should respond to all future commands _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SELECT_CARD, _NJSD_relativeCardAddress); - + // Set a 4 bit data bus _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, APP_CMD, _NJSD_relativeCardAddress); _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SET_BUS_WIDTH, 2); // 4-bit mode. // Use 512 byte blocks _NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SET_BLOCKLEN, 512); // 512 byte blocks - + return true; } @@ -521,7 +521,7 @@ bool _NJSD_startup(void) { return false; } return true; -} +} bool _NJSD_writeSectors (u32 sector, u32 numSectors, const void* buffer) { @@ -531,7 +531,7 @@ bool _NJSD_writeSectors (u32 sector, u32 numSectors, const void* buffer) { while (numSectors--) { _SD_CRC16 ( data, BYTES_PER_READ, crc); - + if (! _NJSD_writeSector (data, crc, offset)) { return false; } @@ -549,7 +549,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { #ifdef _NJSD_SYNC u32 old_REG_IME; #endif - + u8* tbuf = (u8*)buffer; if (numSectors == 0) { @@ -573,7 +573,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { if (!_NJSD_waitIRQ ()) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; -#endif +#endif return false; } } @@ -586,10 +586,10 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { if (!_NJSD_waitIRQ ()) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; -#endif +#endif return false; } - + if (((int)buffer & 0x03) != 0){ cardPolledTransfer (0xA1406000, tmp, BYTES_PER_READ, (u8*)_NJSD_read_cmd); memcpy (tbuf + (numSectors - 1) * BYTES_PER_READ, tmp, BYTES_PER_READ); @@ -618,7 +618,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { #ifdef _NJSD_SYNC u32 old_REG_IME; #endif - + u8* tbuf = (u8*)buffer; if (numSectors == 0) { @@ -637,7 +637,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { if (!_NJSD_waitIRQ ()) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; -#endif +#endif return false; } } @@ -645,10 +645,10 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) { if (!_NJSD_waitIRQ ()) { #ifdef _NJSD_SYNC REG_IME = old_REG_IME; -#endif +#endif return false; } - + cardPolledTransfer (0xA1406000, (u32*)(tbuf + (numSectors - 1) * BYTES_PER_READ), BYTES_PER_READ, (u8*)_NJSD_read_cmd); } else { _NJSD_sendCMDR (_NJSD_speed, NULL, SD_RSP_STREAM, READ_SINGLE_BLOCK, sector * BYTES_PER_READ); diff --git a/backends/platform/ds/arm9/source/fat/io_nmmc.c b/backends/platform/ds/arm9/source/fat/io_nmmc.c index a29c26e43a..261096a27b 100644 --- a/backends/platform/ds/arm9/source/fat/io_nmmc.c +++ b/backends/platform/ds/arm9/source/fat/io_nmmc.c @@ -13,10 +13,10 @@ project at chishm@hotmail.com See gba_nds_fat.txt for help and license details. - + 2006-02-09 - www.neoflash.com: * First stable release - + 2006-02-13 - Chishm * Added ReadMK2Config function * Added read config test to init function so no unnecessary card commands are sent @@ -87,7 +87,7 @@ void Neo_WriteMK2Config(u8 config) { Neo_EnableEEPROM(false); } -u8 Neo_ReadMK2Config(void) +u8 Neo_ReadMK2Config(void) { u8 config; Neo_EnableEEPROM(true); @@ -104,7 +104,7 @@ u8 Neo_ReadMK2Config(void) u8 selectMMC_command [8] = {0xFF, 0x00, 0x6A, 0xDF, 0x37, 0x59, 0x33, 0xA3}; -void Neo_SelectMMC (u8 dataByte) +void Neo_SelectMMC (u8 dataByte) { selectMMC_command[1] = dataByte; // Set enable / disable byte cardWriteCommand (selectMMC_command); // Send "5. Use the EEPROM CS to access the MK2 MMC/SD card" @@ -154,12 +154,12 @@ bool Neo_CheckMMCResponse( u8 response, u8 mask ) { bool Neo_InitMMC() { Neo_MK2GameMode(); Neo_WriteMK2Config( MK2_CONFIG_ZIP_RAM_CLOSE | MK2_CONFIG_GAME_FLASH_CLOSE); - + // Make sure the configuration was accepted if (Neo_ReadMK2Config() != (MK2_CONFIG_ZIP_RAM_CLOSE | MK2_CONFIG_GAME_FLASH_CLOSE)) { return false; // If not, then it wasn't initialised properly } - + return true; } @@ -167,7 +167,7 @@ bool Neo_InitMMC() { bool NMMC_IsInserted(void) { int i; - + Neo_EnableMMC( true ); // Open SPI port to MMC card Neo_SendMMCCommand(MMC_SEND_CSD, 0); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured @@ -183,13 +183,13 @@ bool NMMC_IsInserted(void) { for (i = 0; i < 28; i++) { Neo_SPI(0xff); } - + return true; } bool NMMC_ClearStatus (void) { u32 i; - + Neo_EnableMMC( true ); // Open SPI port to MMC card for (i = 0; i < 10; i++) { Neo_SPI(0xFF); // Send 10 0xFF bytes to MMC card @@ -224,14 +224,14 @@ bool NMMC_StartUp(void) { return false; } Neo_EnableMMC( true ); // Open SPI port to MMC card - + // Set block length Neo_SendMMCCommand(MMC_SET_BLOCKLEN, BYTE_PER_READ ); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured Neo_EnableMMC( false ); return false; } - + // Check if we can use a higher SPI frequency Neo_SendMMCCommand(MMC_SEND_CSD, 0); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured @@ -252,77 +252,77 @@ bool NMMC_StartUp(void) { if ((transSpeed & 0xf0) >= 0x30) { spi_freq = 0; } - + Neo_EnableMMC( false ); return true; -} +} -bool NMMC_WriteSectors (u32 sector, u8 numSecs, void* buffer) +bool NMMC_WriteSectors (u32 sector, u8 numSecs, void* buffer) { u32 i; u8 *p=buffer; - + int totalSecs = (numSecs == 0) ? 256 : numSecs; sector *= BYTE_PER_READ; - + Neo_EnableMMC( true ); // Open SPI port to MMC card Neo_SendMMCCommand( 25, sector ); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured Neo_EnableMMC( false ); return false; } - + while (totalSecs--) { Neo_SPI( 0xFC ); // Send Start Block token for( i = 0; i < BYTE_PER_READ; i++ ) // Send a block of data Neo_SPI( *p++ ); Neo_SPI( 0xFF ); // Send fake CRC16 Neo_SPI( 0xFF ); // Send fake CRC16 - + if( ( Neo_SPI( 0xFF ) & 0x0F ) != 0x05 ) { // Make sure the block was accepted Neo_EnableMMC( false ); return false; } while( Neo_SPI( 0xFF ) == 0x00 ); // Wait for the block to be written } - + // Stop transmission block Neo_SPI( 0xFD ); // Send Stop Transmission Block token for( i = 0; i < BYTE_PER_READ; i++ ) // Send a block of fake data Neo_SPI( 0xFF ); Neo_SPI( 0xFF ); // Send fake CRC16 Neo_SPI( 0xFF ); // Send fake CRC16 - + Neo_SPI (0xFF); // Send 8 clocks while( Neo_SPI( 0xFF ) == 0x00 ); // Wait for the busy signal to clear - - for ( i = 0; i < 0x10; i++) { + + for ( i = 0; i < 0x10; i++) { Neo_SPI (0xFF); // Send clocks for the MMC card to finish what it's doing } - + Neo_EnableMMC( false ); // Close SPI port to MMC card return true; } -bool NMMC_ReadSectors (u32 sector, u8 numSecs, void* buffer) +bool NMMC_ReadSectors (u32 sector, u8 numSecs, void* buffer) { u32 i; u8 *p=buffer; - + int totalSecs = (numSecs == 0) ? 256 : numSecs; sector *= BYTE_PER_READ; - + Neo_EnableMMC( true ); // Open SPI port to MMC card - + while (totalSecs--) { Neo_SendMMCCommand(MMC_READ_BLOCK, sector ); if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured Neo_EnableMMC( false ); return false; } - + if( Neo_CheckMMCResponse( 0xFE, 0xFF ) == false ) { // Check for Start Block token Neo_EnableMMC( false ); return false; @@ -333,7 +333,7 @@ bool NMMC_ReadSectors (u32 sector, u8 numSecs, void* buffer) Neo_SPI( 0xFF ); // Ignore CRC16 sector += BYTE_PER_READ; } - + Neo_EnableMMC( false ); // Close SPI port to MMC card return true; } diff --git a/backends/platform/ds/arm9/source/fat/io_sccf.c b/backends/platform/ds/arm9/source/fat/io_sccf.c index 0c77f4673c..bda628fdaa 100644 --- a/backends/platform/ds/arm9/source/fat/io_sccf.c +++ b/backends/platform/ds/arm9/source/fat/io_sccf.c @@ -57,7 +57,7 @@ bool SCCF_Unlock(void) temp = (~temp & 0xFF); return (CF_REG_LBA1 == temp); #undef CF_REG_LBA1 -} +} bool SCCF_Shutdown(void) { return MPCF_ClearStatus() ; diff --git a/backends/platform/ds/arm9/source/fat/io_scsd.c b/backends/platform/ds/arm9/source/fat/io_scsd.c index 9359fefb6d..0a6ab5a528 100644 --- a/backends/platform/ds/arm9/source/fat/io_scsd.c +++ b/backends/platform/ds/arm9/source/fat/io_scsd.c @@ -1,8 +1,8 @@ /* io_scsd.c by SaTa. based on io_sccf.c - - + + */ /* @@ -43,7 +43,7 @@ extern void InitSCMode(void); // CFと同じ extern void ReadSector(u16 *buff,u32 sector,u8 ReadNumber); extern void WriteSector(u16 *buff,u32 sector,u8 writeNumber); extern bool MemoryCard_IsInserted(void); // CFと違う -// +// /*----------------------------------------------------------------- SCSD_Unlock @@ -55,7 +55,7 @@ bool SCSD_Unlock(void) { InitSCMode(); return MemoryCard_IsInserted(); -} +} bool SCSD_Shutdown(void) { return MPCF_ClearStatus() ; diff --git a/backends/platform/ds/arm9/source/fat/io_sd_common.c b/backends/platform/ds/arm9/source/fat/io_sd_common.c index 0a38e6277c..ade9df0d80 100644 --- a/backends/platform/ds/arm9/source/fat/io_sd_common.c +++ b/backends/platform/ds/arm9/source/fat/io_sd_common.c @@ -5,10 +5,10 @@ Common SD card routines - SD routines partially based on sd.s by Romman + SD routines partially based on sd.s by Romman Copyright (c) 2006 Michael "Chishm" Chisholm - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + 2006-08-07 - Chishm * Moved the SD initialization to a common function * Increased timeouts for slower cards @@ -61,10 +61,10 @@ u8 _SD_CRC7(u8* data, int cnt) { } crc = (crc << 1) | 1; return(crc); -} +} /* -Calculates the CRC16 for a sector of data. Calculates it +Calculates the CRC16 for a sector of data. Calculates it as 4 separate lots, merged into one buffer. This is used for 4 SD data lines, not for 1 data line alone. */ @@ -79,53 +79,53 @@ void _SD_CRC16 (u8* buff, int buffLength, u8* crc16buff) { b = 0; // r4 c = 0; // r5 d = 0; // r6 - + buffLength = buffLength * 8; - - + + do { if (bitPattern & 0x80) dataByte = *buff++; - + a = a << 1; if ( a & 0x10000) a ^= crcConst; if (dataByte & (bitPattern >> 24)) a ^= crcConst; - + b = b << 1; if (b & 0x10000) b ^= crcConst; if (dataByte & (bitPattern >> 25)) b ^= crcConst; - + c = c << 1; if (c & 0x10000) c ^= crcConst; if (dataByte & (bitPattern >> 26)) c ^= crcConst; - + d = d << 1; if (d & 0x10000) d ^= crcConst; if (dataByte & (bitPattern >> 27)) d ^= crcConst; - + bitPattern = (bitPattern >> 4) | (bitPattern << 28); } while (buffLength-=4); - + count = 16; // r8 - + do { bitPattern = bitPattern << 4; if (a & 0x8000) bitPattern |= 8; if (b & 0x8000) bitPattern |= 4; if (c & 0x8000) bitPattern |= 2; if (d & 0x8000) bitPattern |= 1; - + a = a << 1; b = b << 1; c = c << 1; d = d << 1; - + count--; - + if (!(count & 0x01)) { *crc16buff++ = (u8)(bitPattern & 0xff); } } while (count != 0); - + return; } @@ -136,20 +136,20 @@ cmd_17byte_response: a pointer to a function that sends the SD card a command an use4bitBus: initialise card to use a 4 bit data bus when communicating with the card RCA: a pointer to the location to store the card's Relative Card Address, preshifted up by 16 bits. */ -bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, +bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, _SD_FN_CMD_17BYTE_RESPONSE cmd_17byte_response, bool use4bitBus, u32 *RCA) { u8 responseBuffer[17] = {0}; int i; - + for (i = 0; i < MAX_STARTUP_TRIES ; i++) { cmd_6byte_response (responseBuffer, APP_CMD, 0); - if ( + if ( cmd_6byte_response (responseBuffer, SD_APP_OP_COND, SD_OCR_VALUE) && ((responseBuffer[1] & 0x80) != 0)) - { + { // Card is ready to receive commands now break; } @@ -157,10 +157,10 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, if (i >= MAX_STARTUP_TRIES) { return false; } - + // The card's name, as assigned by the manufacturer cmd_17byte_response (responseBuffer, ALL_SEND_CID, 0); - + // Get a new address for (i = 0; i < MAX_STARTUP_TRIES ; i++) { cmd_6byte_response (responseBuffer, SEND_RELATIVE_ADDR, 0); @@ -175,10 +175,10 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, // Some cards won't go to higher speeds unless they think you checked their capabilities cmd_17byte_response (responseBuffer, SEND_CSD, *RCA); - + // Only this card should respond to all future commands cmd_6byte_response (responseBuffer, SELECT_CARD, *RCA); - + if (use4bitBus) { // Set a 4 bit data bus cmd_6byte_response (responseBuffer, APP_CMD, *RCA); @@ -187,7 +187,7 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, // Use 512 byte blocks cmd_6byte_response (responseBuffer, SET_BLOCKLEN, 512); // 512 byte blocks - + // Wait until card is ready for data i = 0; do { @@ -196,7 +196,7 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response, } i++; } while (!cmd_6byte_response (responseBuffer, SEND_STATUS, *RCA) && ((responseBuffer[3] & 0x1f) != ((SD_STATE_TRAN << 1) | READY_FOR_DATA))); - + return true; } |