diff --git a/source/fatfs/diskio.c b/source/fatfs/diskio.c index 003c4ba..6410933 100644 --- a/source/fatfs/diskio.c +++ b/source/fatfs/diskio.c @@ -37,16 +37,21 @@ DSTATUS disk_initialize ( BYTE pdrv /* Physical drive nmuber to identify the drive */ ) { - DRESULT ret = RES_OK; - static bool sdmmcInited = false; + DRESULT ret; + static u32 sdmmcInitResult = 4; - if(!sdmmcInited) + if(sdmmcInitResult == 4) sdmmcInitResult = sdmmc_sdcard_init(); + + if(pdrv == CTRNAND) { - if(!sdmmc_sdcard_init()) ret = RES_PARERR; - else sdmmcInited = true; + if(!(sdmmcInitResult & 1)) + { + ctrNandInit(); + ret = RES_OK; + } + else ret = RES_PARERR; } - - if(pdrv == CTRNAND) ctrNandInit(); + else ret = (!(sdmmcInitResult & 2)) ? RES_OK : RES_PARERR; return ret; } diff --git a/source/fatfs/sdmmc/sdmmc.c b/source/fatfs/sdmmc/sdmmc.c index c7b825b..c8327a1 100644 --- a/source/fatfs/sdmmc/sdmmc.c +++ b/source/fatfs/sdmmc/sdmmc.c @@ -472,8 +472,11 @@ void sdmmc_get_cid(bool isNand, u32 *info) sdmmc_send_command(device, 0x10507, device->initarg << 0x10); } -bool sdmmc_sdcard_init() +u32 sdmmc_sdcard_init() { + u32 ret = 0; InitSD(); - return (Nand_Init() | SD_Init()) == 0; + if(Nand_Init() != 0) ret &= 1; + if(SD_Init() != 0) ret &= 2; + return ret; } \ No newline at end of file diff --git a/source/fatfs/sdmmc/sdmmc.h b/source/fatfs/sdmmc/sdmmc.h index 42ef9ae..c17eb62 100644 --- a/source/fatfs/sdmmc/sdmmc.h +++ b/source/fatfs/sdmmc/sdmmc.h @@ -91,7 +91,7 @@ typedef struct mmcdevice { u32 res; } mmcdevice; -bool sdmmc_sdcard_init(); +u32 sdmmc_sdcard_init(); int sdmmc_sdcard_readsectors(u32 sector_no, u32 numsectors, u8 *out); int sdmmc_sdcard_writesectors(u32 sector_no, u32 numsectors, const u8 *in); int sdmmc_nand_readsectors(u32 sector_no, u32 numsectors, u8 *out);