Fork of SD file system with changes to prevent stalling if card is missing during initialization. Also uses a FAT file system that exposes the FILINFO of the current file, so true file sizes can be obtained, among other things

Dependencies:   FATFileSystemWithFilinfo

Fork of SDFileSystem by Mbed

Revision:
5:7bdd92175879
Parent:
3:7b35d1709458
--- a/SDFileSystem.cpp	Thu Oct 30 06:27:23 2014 +0000
+++ b/SDFileSystem.cpp	Thu Oct 30 06:29:26 2014 +0000
@@ -147,22 +147,23 @@
         _spi.write(0xFF);
     }
     
+    int ret = SDCARD_FAIL;
+    
     // send CMD0, should return with all zeros except IDLE STATE set (bit 0)
     if (_cmd(0, 0) != R1_IDLE_STATE) {
         debug("No disk, or could not put SD card in to SPI idle state\n");
-        return SDCARD_FAIL;
     }
     
     // send CMD8 to determine whther it is ver 2.x
     int r = _cmd8();
     if (r == R1_IDLE_STATE) {
-        return initialise_card_v2();
+        ret = initialise_card_v2();
     } else if (r == (R1_IDLE_STATE | R1_ILLEGAL_COMMAND)) {
-        return initialise_card_v1();
+        ret = initialise_card_v1();
     } else {
         debug("Not in idle state after sending CMD8 (not an SD card?)\n");
-        return SDCARD_FAIL;
     }
+    return ret;
 }
 
 int SDFileSystem::initialise_card_v1() {
@@ -199,6 +200,9 @@
 int SDFileSystem::disk_initialize() {
     int i = initialise_card();
     debug_if(SD_DBG, "init card = %d\n", i);
+    if (i==SDCARD_FAIL) {
+        return 1;
+    }
     _sectors = _sd_sectors();
     
     // Set block length to 512 (CMD16)