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 SDFileSystem_HelloWorld mbed
Fork of SDFileSystem_HelloWorld by
Revision 1:a305ecc5c0cb, committed 2017-05-11
- Comitter:
- brdarji
- Date:
- Thu May 11 08:24:00 2017 +0000
- Parent:
- 0:bdbd3d6fc5d5
- Commit message:
- SD card data read example
Changed in this revision
diff -r bdbd3d6fc5d5 -r a305ecc5c0cb SDFileSystem.lib --- a/SDFileSystem.lib Fri Dec 07 11:25:01 2012 +0000 +++ b/SDFileSystem.lib Thu May 11 08:24:00 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4 +https://developer.mbed.org/users/brdarji/code/SDFileSystem/#8dbda7efa9c2
diff -r bdbd3d6fc5d5 -r a305ecc5c0cb SDFileSystem_HelloWorld.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem_HelloWorld.lib Thu May 11 08:24:00 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mbed_official/code/SDFileSystem_HelloWorld/#bdbd3d6fc5d5
diff -r bdbd3d6fc5d5 -r a305ecc5c0cb main.cpp
--- a/main.cpp Fri Dec 07 11:25:01 2012 +0000
+++ b/main.cpp Thu May 11 08:24:00 2017 +0000
@@ -1,19 +1,37 @@
#include "mbed.h"
#include "SDFileSystem.h"
-SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+SDFileSystem sd(P0_18, P0_17, P0_15, P0_16, "sd"); //mosi, miso, sclk, cs
+Serial pc(USBTX,USBRX);
int main() {
- printf("Hello World!\n");
-
- mkdir("/sd/mydir", 0777);
-
- FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
- if(fp == NULL) {
- error("Could not open file for write\n");
- }
- fprintf(fp, "Hello fun SD Card World!");
- fclose(fp);
-
- printf("Goodbye World!\n");
-}
+ char i=0;
+ float data;
+ char c,data1[8];
+
+ FILE *fp = fopen("/sd/dat12.dat", "r");
+ while(1)
+ {
+ c = fgetc(fp);
+ data1[i] = c;
+ if((data1[i] == '\r'))
+ {
+ data = atof(data1);
+ i=0;
+ pc.printf("%0.3f\r\n",data);
+ wait(1);
+ }
+ else
+ {
+ i++;
+ }
+
+ if(feof(fp))
+ {
+ break ;
+ }
+ wait_ms(10);
+ }
+ fclose(fp);
+ return 0;
+}
\ No newline at end of file
