SDFileSystem Library Test for Nucleo F401RE

Dependencies:   SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
ryood
Date:
Tue Nov 22 07:24:11 2016 +0000
Commit message:
first commit

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
diff -r 000000000000 -r 86295a21d1e0 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Tue Nov 22 07:24:11 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/neilt6/code/SDFileSystem/#e4d2567200db
diff -r 000000000000 -r 86295a21d1e0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 22 07:24:11 2016 +0000
@@ -0,0 +1,50 @@
+/*
+ * SDFileSystem Test
+ * 
+ * Library
+ * SDFileSystem: https://developer.mbed.org/users/neilt6/code/SDFileSystem/ Revision:26
+ * mbed: Revision: 124
+ *
+ * 2016.11.22 created
+ *
+ */
+
+#include "mbed.h"
+#include "SDFileSystem.h"
+
+//Create an SDFileSystem object
+SDFileSystem sd(D11, D12, D13, D10, "sd");
+
+int main()
+{
+    //Mount the filesystem
+    sd.mount();
+
+    //Perform a write test
+    printf("\nWriting to SD card...");
+    FILE *fp = fopen("/sd/sdtest.txt", "w");
+    if (fp != NULL) {
+        fprintf(fp, "We're writing to an SD card!");
+        fclose(fp);
+        printf("success!\n");
+    } else {
+        printf("failed!\n");
+    }
+
+    //Perform a read test
+    printf("Reading from SD card...");
+    fp = fopen("/sd/sdtest.txt", "r");
+    if (fp != NULL) {
+        char c = fgetc(fp);
+        if (c == 'W')
+            printf("success!\n");
+        else
+            printf("incorrect char (%c)!\n", c);
+        fclose(fp);
+    } else {
+        printf("failed!\n");
+    }
+
+    //Unmount the filesystem
+    sd.unmount();
+}
\ No newline at end of file
diff -r 000000000000 -r 86295a21d1e0 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 22 07:24:11 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/2241e3a39974
\ No newline at end of file