Writing to micro SD only.

Dependencies:   SDFileSystem mbed

Fork of SDFileSystem_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
aaaaaYukiaaaaa
Date:
Tue May 30 05:01:36 2017 +0000
Parent:
1:3d3fb5f81373
Commit message:
This program is writing to micro SD only.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 3d3fb5f81373 -r ee19d6b4dc98 main.cpp
--- a/main.cpp	Tue May 30 04:55:17 2017 +0000
+++ b/main.cpp	Tue May 30 05:01:36 2017 +0000
@@ -6,40 +6,8 @@
 AnalogIn inpt(p20);
 DigitalOut myled(LED1);
  
+void SD(int num, double btry);
 
-void SD(int num, double btry){
-    myled = 1;
-    
-    printf("Hello World!\n");   
- 
-    mkdir("/sd/mydir", 0777);
-    
-    FILE *fp_csv = fopen("/sd/mydir/sdtest.csv", "a");
-    if(fp_csv == NULL) {
-        error("Could not open file for write\n");
-    }
-    
-    fprintf(fp_csv, "%f,%f\n", btry, (float)num);
-    
-    fclose(fp_csv); 
-    
-    /////////////////
-    
-//    FILE *fp_txt = fopen("/sd/mydir/sdtest.txt", "a");
-//    if(fp_txt == NULL) {
-//        error("Could not open file for write\n");
-//    }
-//    fprintf(fp_txt, "Hello fun SD Card World!\n");
-//    fprintf(fp_txt, "Hello fun SD Card World!\n");
-//    fprintf(fp_txt, "%f,%f\n", btry, (float)num);
-//    
-//    fclose(fp_txt); 
-    
-    
-    printf("Goodbye World!\n");
-    myled = 0;
-}
- 
 int main() {
     float btry_lg = 0;
     int nmbr_lg = 0;
@@ -82,3 +50,36 @@
         wait(0.1);
     }
 }
+
+void SD(int num, double btry){
+    myled = 1;
+    
+    printf("Hello World!\n");   
+ 
+    mkdir("/sd/mydir", 0777);
+    
+    FILE *fp_csv = fopen("/sd/mydir/sdtest.csv", "a");
+    if(fp_csv == NULL) {
+        error("Could not open file for write\n");
+    }
+    
+    fprintf(fp_csv, "%f,%f\n", btry, (float)num);
+    
+    fclose(fp_csv); 
+    
+    /////////////////
+    
+//    FILE *fp_txt = fopen("/sd/mydir/sdtest.txt", "a");
+//    if(fp_txt == NULL) {
+//        error("Could not open file for write\n");
+//    }
+//    fprintf(fp_txt, "Hello fun SD Card World!\n");
+//    fprintf(fp_txt, "Hello fun SD Card World!\n");
+//    fprintf(fp_txt, "%f,%f\n", btry, (float)num);
+//    
+//    fclose(fp_txt); 
+    
+    
+    printf("Goodbye World!\n");
+    myled = 0;
+}
\ No newline at end of file