[SOLVED]FILE_CheckSDcard() returns 0 2nd time launched with DisCon SD

hi

i want to check if the SD-Card is connected or not… so far so good, no problem, but there is a behaviour that cost me the night…

Connected SD:

1st execution of FILE_CheckSDCard() > Return “0”… that is good - it work right

2nd execution of FILE_CheckSDCard() > Return “0”… that is good - it work right

 

Disconnected SD:

1st execution of FILE_CheckSDCard() > Return “2”… that is good - it work right

2nd execution of FILE_CheckSDCard() > Return “0”… why that? the SD is still NOT connected…

this code is executed every 2 seconds:
 

MUTEX\_SDCARD\_TAKE; status = FILE\_CheckSDCard(); MUTEX\_SDCARD\_GIVE; if (status == 2) { //NO SD if (status == 0) { //SD

… EDIT

“FILE_CheckSDCard_”_ itself internally uses  “MIOS32_SDCARD_CheckAvailable();” maybe that is a trace

 

when using “MIOS32_SDCARD_CheckAvailable” instead of “FILE_CheckSDCard()”

but “FILE_DirExists” looses its functions and returns me everytime “-3” them, so useless for me again…so i am circling around…

//SD-Card Connected? u8 prev\_sdcard\_available = sdcard\_available; MUTEX\_SDCARD\_TAKE; sdcard\_available = MIOS32\_SDCARD\_CheckAvailable(prev\_sdcard\_available); MUTEX\_SDCARD\_GIVE; if( sdcard\_available && !prev\_sdcard\_available ) { statusSD = 1;} // SD Card has been connected else if( !sdcard\_available && prev\_sdcard\_available ) { statusSD = 0; if (statusSD == 0) {//NO DISK} if (statusSD == 1) {// YES CARD! \>\>\> next: check Card-content statusDir = FILE\_DirExists("mq"); //ask file.c: exist a folder "mq/" on the CARD? 

 

ok this 3 lines are needet, then its working:

//Check SD-Card MUTEX\_SDCARD\_TAKE; availableSD = FILE\_SDCardAvailable(); statusSD = FILE\_CheckSDCard(); statusDir = FILE\_DirExists("mq"); MUTEX\_SDCARD\_GIVE;

availableSD is the one to take…