Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem mbed
Revision 0:96613601cfb9, committed 2015-04-17
- Comitter:
- ImageWriter
- Date:
- Fri Apr 17 13:26:24 2015 +0000
- Commit message:
- SDCard Read Write test
Changed in this revision
--- /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