Fix diskio.c stuff

This commit is contained in:
Aurora 2016-10-07 14:51:32 +02:00
parent 1a62e91c01
commit f36ff303d9
3 changed files with 18 additions and 10 deletions

View File

@ -37,16 +37,21 @@ DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber to identify the drive */ BYTE pdrv /* Physical drive nmuber to identify the drive */
) )
{ {
DRESULT ret = RES_OK; DRESULT ret;
static bool sdmmcInited = false; static u32 sdmmcInitResult = 4;
if(!sdmmcInited) if(sdmmcInitResult == 4) sdmmcInitResult = sdmmc_sdcard_init();
if(pdrv == CTRNAND)
{ {
if(!sdmmc_sdcard_init()) ret = RES_PARERR; if(!(sdmmcInitResult & 1))
else sdmmcInited = true; {
ctrNandInit();
ret = RES_OK;
} }
else ret = RES_PARERR;
if(pdrv == CTRNAND) ctrNandInit(); }
else ret = (!(sdmmcInitResult & 2)) ? RES_OK : RES_PARERR;
return ret; return ret;
} }

View File

@ -472,8 +472,11 @@ void sdmmc_get_cid(bool isNand, u32 *info)
sdmmc_send_command(device, 0x10507, device->initarg << 0x10); sdmmc_send_command(device, 0x10507, device->initarg << 0x10);
} }
bool sdmmc_sdcard_init() u32 sdmmc_sdcard_init()
{ {
u32 ret = 0;
InitSD(); InitSD();
return (Nand_Init() | SD_Init()) == 0; if(Nand_Init() != 0) ret &= 1;
if(SD_Init() != 0) ret &= 2;
return ret;
} }

View File

@ -91,7 +91,7 @@ typedef struct mmcdevice {
u32 res; u32 res;
} mmcdevice; } mmcdevice;
bool sdmmc_sdcard_init(); u32 sdmmc_sdcard_init();
int sdmmc_sdcard_readsectors(u32 sector_no, u32 numsectors, u8 *out); 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_sdcard_writesectors(u32 sector_no, u32 numsectors, const u8 *in);
int sdmmc_nand_readsectors(u32 sector_no, u32 numsectors, u8 *out); int sdmmc_nand_readsectors(u32 sector_no, u32 numsectors, u8 *out);