SDFileSystem edited to have CD

Dependencies:   FATFileSystem

Dependents:   SongPop

Fork of SDFileSystem by mbed official

Files at this revision

API Documentation at this revision

Comitter:
bkf34
Date:
Wed Mar 11 22:13:39 2015 +0000
Parent:
2:c8f66dc765d4
Commit message:
l

Changed in this revision

SDFileSystem.cpp Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.h Show annotated file Show diff for this revision Revisions of this file
diff -r c8f66dc765d4 -r 7526c2b13d28 SDFileSystem.cpp
--- a/SDFileSystem.cpp	Thu Nov 29 10:56:21 2012 +0000
+++ b/SDFileSystem.cpp	Wed Mar 11 22:13:39 2015 +0000
@@ -119,9 +119,11 @@
 
 #define SD_DBG             0
 
-SDFileSystem::SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name) :
-    FATFileSystem(name), _spi(mosi, miso, sclk), _cs(cs) {
+SDFileSystem::SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName cd, const char* name) :
+    FATFileSystem(name), _spi(mosi, miso, sclk), _cs(cs), _cd(cd) {
     _cs = 1;
+    _cd.mode(PullUp);
+    wait(.01);
 }
 
 #define R1_IDLE_STATE           (1 << 0)
@@ -462,4 +464,14 @@
             return 0;
     };
     return blocks;
+    
 }
+
+bool SDFileSystem::cdcheck()
+{
+if(_cd == 0)
+   { return false;
+   }
+return true;
+}
+        
\ No newline at end of file
diff -r c8f66dc765d4 -r 7526c2b13d28 SDFileSystem.h
--- a/SDFileSystem.h	Thu Nov 29 10:56:21 2012 +0000
+++ b/SDFileSystem.h	Wed Mar 11 22:13:39 2015 +0000
@@ -51,13 +51,14 @@
      * @param cs   DigitalOut pin used as SD Card chip select
      * @param name The name used to access the virtual filesystem
      */
-    SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
+    SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName cd, const char* name);
     virtual int disk_initialize();
     virtual int disk_status();
     virtual int disk_read(uint8_t * buffer, uint64_t block_number);
     virtual int disk_write(const uint8_t * buffer, uint64_t block_number);
     virtual int disk_sync();
     virtual uint64_t disk_sectors();
+    bool cdcheck();
 
 protected:
 
@@ -76,6 +77,7 @@
     
     SPI _spi;
     DigitalOut _cs;
+    DigitalIn _cd;
     int cdv;
 };