SD Example

Dependencies:   SDFileSystem mbed

Revision:
0:1a8003e5f568
diff -r 000000000000 -r 1a8003e5f568 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 20 21:07:00 2014 +0000
@@ -0,0 +1,38 @@
+/*
+    My SDcard
+    
+    Trying to save data in a file, but instead of replacing old data
+    i would like to append it.
+    
+*/
+
+#include "mbed.h"
+#include "SDFileSystem.h"
+
+// Puertos
+DigitalOut rled(LED_RED);
+DigitalOut gled(LED_GREEN);
+SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS
+
+// Objetos
+FILE *fp;
+
+char buffer[1024];
+
+int main(){
+    rled = 1;
+    wait(1);
+    while (true) {
+        FILE *fp = fopen("/sd/test.txt", "r");
+        if (fp == 0){
+            printf("Could not open file\n");
+        }else{
+            int x;
+            while ((x = fgetc(fp)) != EOF){
+                printf("%c", x);
+            }
+            fclose(fp);
+        } // IF
+        wait(1);
+    } // WHILE
+} // MAIN