Image Writer / Mbed 2 deprecated SDCardNotFound? No,I found a SDCard.

Dependencies:   SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
ImageWriter
Date:
Fri Apr 17 13:26:24 2015 +0000
Commit message:
SDCard Read Write test

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Fri Apr 17 13:26:24 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/mbed/code/SDFileSystem/#7b35d1709458
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 17 13:26:24 2015 +0000
@@ -0,0 +1,53 @@
+#include "mbed.h"
+#include "SDFileSystem.h"
+ 
+ 
+//Create an SDFileSystem object
+//SDFileSystem sd(PA_7, PA_6, PA_5, PA_15, "sd");// MOSI, MISO, SCK, CS
+SDFileSystem sd(D11, D12, D13, D10, "sd");// MOSI, MISO, SCK, CS
+Serial pc(USBTX, USBRX);
+ 
+int main() {
+//    pc.baud(19200);
+    pc.baud(9600);
+    for(int i=5; i>0; i--) 
+    {
+        pc.printf("Wait %i seconds..\r\n",i);
+        wait(1);
+    }
+    pc.printf("Initializing\r\n");
+    
+    //Mount the filesystem
+ 
+//    sd.mount();
+    
+    //Perform a write test
+    pc.printf("\nWriting to SD card...");
+    FILE *fp = fopen("/sd/sdtest.txt", "a+");
+    
+    wait(2);
+    if (fp != NULL) {
+        fprintf(fp, "We're writing to an SD card!");
+        fclose(fp);
+        pc.printf("success!\n");
+    } else {
+        pc.printf("failed!\n");
+    }
+ 
+    //Perform a read test
+    pc.printf("Reading from SD card...");
+    fp = fopen("/sd/sdtest.txt", "r");
+    if (fp != NULL) {
+        char c = fgetc(fp);
+        if (c == 'W')
+            pc.printf("success!\n");
+        else
+            pc.printf("incorrect char (%c)!\n", c);
+        fclose(fp);
+    } else {
+        pc.printf("failed!\n");
+    }
+ 
+    //Unmount the filesystem
+//     sd.unmount();
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Apr 17 13:26:24 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889
\ No newline at end of file