USBMSD example using an SD card

Dependents:   USBMSD_SD_HelloWorld_FRDM-KL25Z USBMSD_SD_HelloWorld_Mbed USBMSD_SD_HelloWorld_FRDM-KL25Z V09_01h ... more

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Sun Dec 11 15:52:35 2011 +0000
Parent:
0:de50a209c5a9
Child:
2:055119ccf5a7
Commit message:

Changed in this revision

USBMSD_SD.cpp Show annotated file Show diff for this revision Revisions of this file
USBMSD_SD.h Show annotated file Show diff for this revision Revisions of this file
--- a/USBMSD_SD.cpp	Sun Dec 11 15:17:54 2011 +0000
+++ b/USBMSD_SD.cpp	Sun Dec 11 15:52:35 2011 +0000
@@ -121,6 +121,8 @@
 USBMSD_SD::USBMSD_SD(PinName mosi, PinName miso, PinName sclk, PinName cs) :
    _spi(mosi, miso, sclk), _cs(cs) {
       _cs = 1;
+      //no init
+      _status = 0x01;
       connect();
 }
 
@@ -147,7 +149,7 @@
     // Set to 100kHz for initialisation, and clock card with cs = 1
     _spi.frequency(100000); 
     _cs = 1;
-    for(int i=0; i<16; i++) {   
+    for(int i=0; i<16; i++) {
         _spi.write(0xFF);
     }
 
@@ -210,6 +212,8 @@
     }
         
     _spi.frequency(5000000); // Set to 5MHz for data transfer
+    // OK
+    _status = 0x00;
     return 0;
 }
 
@@ -235,7 +239,7 @@
     return 0;
 }
 
-int USBMSD_SD::disk_status() { return 0; }
+int USBMSD_SD::disk_status() { return _status; }
 int USBMSD_SD::disk_sync() { return 0; }
 int USBMSD_SD::disk_sectors() { return _sectors; }
 
--- a/USBMSD_SD.h	Sun Dec 11 15:17:54 2011 +0000
+++ b/USBMSD_SD.h	Sun Dec 11 15:52:35 2011 +0000
@@ -76,6 +76,7 @@
     int _sectors;
     
     int capacity;
+    int _status;
     
     SPI _spi;
     DigitalOut _cs;