Jump to content

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


Phatline
 Share

Recommended Posts

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?    

 

Edited by Phatline
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...