SD Read

Dependencies:   SDFileSystem mbed

Fork of AVC_My_sdcard_read by Gerardo CR

Revision:
0:1a8003e5f568
Child:
1:cb4b883237fd
--- /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