Skip to content

Commit

Permalink
- Try Serial Port 2 first.
Browse files Browse the repository at this point in the history
- Fix SD Card detection.
- Really adhere to EXI speed setting.
- Remove nonsense.
  • Loading branch information
Extrems committed Nov 24, 2019
1 parent 84774b6 commit f5760b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
38 changes: 9 additions & 29 deletions cube/swiss/source/devices/fat/deviceHandler-FAT.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,21 +411,6 @@ s32 deviceHandler_FAT_setupFile(file_handle* file, file_handle* file2) {
return 1;
}

int EXI_ResetSD(int drv) {
/* Wait for any pending transfers to complete */
while ( *(vu32 *)0xCC00680C & 1 );
while ( *(vu32 *)0xCC006820 & 1 );
while ( *(vu32 *)0xCC006834 & 1 );
*(vu32 *)0xCC00680C = 0xC0A;
*(vu32 *)0xCC006820 = 0xC0A;
*(vu32 *)0xCC006834 = 0x80A;
/*** Needed to re-kick after insertion etc ***/
EXI_ProbeEx(drv);
EXI_Detach(drv);
sdgecko_initIODefault();
return 1;
}

s32 fatFs_Mount(u8 devNum, char *path) {
if(fs[devNum] != NULL) {
disk_flush(devNum);
Expand All @@ -449,34 +434,32 @@ s32 deviceHandler_FAT_init(file_handle* file) {
int ret = 0;
print_gecko("Init %s %i\r\n", (isSDCard ? "SD":"IDE"), slot);
// Slot A - SD Card
if(isSDCard && slot == 0 && EXI_ResetSD(slot)) {
if(isSDCard && slot == 0) {
carda->shutdown();
setSDGeckoSpeed();
carda->startup();
setSDGeckoSpeed();
ret = fatFs_Mount(0, "sda:\0");
}
// Slot B - SD Card
if(isSDCard && slot == 1 && EXI_ResetSD(1)) {
if(isSDCard && slot == 1) {
cardb->shutdown();
setSDGeckoSpeed();
cardb->startup();
setSDGeckoSpeed();
ret = fatFs_Mount(1, "sdb:\0");
}
// SP2 - SD Card
if(isSDCard && slot == 2 && EXI_ResetSD(2)) {
if(isSDCard && slot == 2) {
cardc->shutdown();
setSDGeckoSpeed();
cardc->startup();
setSDGeckoSpeed();
ret = fatFs_Mount(2, "sdc:\0");
}
// Slot A - IDE-EXI
if(!isSDCard && !slot) {
ideexia->startup();
ret = fatFs_Mount(3, "idea:\0");
}
// Slot B - IDE-EXI
if(!isSDCard && slot) {
ideexib->startup();
ret = fatFs_Mount(4, "ideb:\0");
}
if(ret)
Expand Down Expand Up @@ -533,22 +516,19 @@ s32 deviceHandler_FAT_deleteFile(file_handle* file) {
}

bool deviceHandler_FAT_test_sd_a() {
setSDGeckoSpeed();
carda->shutdown();
carda->startup();
return carda->isInserted();
return sdgecko_readStatus(0) == CARDIO_ERROR_READY;
}
bool deviceHandler_FAT_test_sd_b() {
setSDGeckoSpeed();
cardb->shutdown();
cardb->startup();
return cardb->isInserted();
return sdgecko_readStatus(1) == CARDIO_ERROR_READY;
}
bool deviceHandler_FAT_test_sd_c() {
cardc->shutdown();
setSDGeckoSpeed();
cardc->startup();
return cardc->isInserted();
return sdgecko_readStatus(2) == CARDIO_ERROR_READY;
}
bool deviceHandler_FAT_test_ide_a() {
return ide_exi_inserted(0);
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ int main ()
i = 0;
allDevices[i++] = &__device_wkf;
allDevices[i++] = &__device_wode;
allDevices[i++] = &__device_sd_c;
allDevices[i++] = &__device_sd_a;
allDevices[i++] = &__device_sd_b;
allDevices[i++] = &__device_card_a;
allDevices[i++] = &__device_card_b;
allDevices[i++] = &__device_sd_c;
allDevices[i++] = &__device_dvd;
allDevices[i++] = &__device_ide_a;
allDevices[i++] = &__device_ide_b;
Expand Down

0 comments on commit f5760b4

Please sign in to comment.