123

Dependencies:   SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
Amber77
Date:
Wed Sep 20 20:40:15 2017 +0000
Commit message:
20170921

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 09c855ba2df2 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Wed Sep 20 20:40:15 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
diff -r 000000000000 -r 09c855ba2df2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 20 20:40:15 2017 +0000
@@ -0,0 +1,55 @@
+// SDFileSystem---1. https://developer.mbed.org/users/mbed_official/code/SDFileSystem/
+//                2. https://developer.mbed.org/users/simon/code/SDCardTest/
+// VCC:3.3v
+#include "mbed.h"
+#include "SDFileSystem.h"
+ 
+//SDFileSystem sd(PA_7, PA_6, PA_5, PB_6, "sd"); //  mosi, miso, sclk, cs
+//SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
+//SPI_MOSI = PA_7, SPI_MISO = PA_6, SPI_SCK = PA_5, SPI_CS = PB_6,
+SDFileSystem sd( D4, D5, D3, D6, "sd"); //  mosi, miso, sclk, cs
+
+int main() 
+{
+    printf("Hello World!\n");   
+    
+    mkdir("/sd/Amber", 0777);  //SD裡面的資料夾叫Amber,在此做宣告
+    FILE *fp = fopen("/sd/Amber/Amber77.txt", "w");       //將檔案存進SD的資料夾Amber裡面,並取名為Amber77.txt
+ 
+    /*mkdir("/sd/mydir", 0777);  //SD裡面的資料夾叫mydir,在此做宣告
+    FILE *fp = fopen("/sd/mydir/Amber77.txt", "w");*/       //將檔案存進SD的資料夾mydir裡面,並取名為sdtest.txt
+    
+    /*
+    mkdir("/sd/Amber20170222", 0777);  //SD裡面的資料夾叫Amber77,在此做宣告
+    FILE *fp = fopen("/sd/Amber20170222/AngVel_PWM20170222a.csv", "a");     
+    //將檔案存進SD的資料夾Amber77裡面,並取名為PWM_AngVel_PWM.xls/.xlsx/.csv
+    fprintf(fp,"RunTime,Now_angularVelocity,control_PWM_Value\n");
+    
+    if(fp == NULL) 
+            {
+                    error("Could not open file for write\n");
+            }
+            fprintf(fp,"%.3f,%.3f,%.3f\n", RunTime,Now_angularVelocity,control_PWM_Value);  
+            
+    if(!mybutton)
+        {
+            StopRun.write(1);
+            CW_CCW.write(1);                   // clockwise:0    counterclockwise:1
+            PWM.write(0);
+            break;
+        }
+    }
+    fclose(fp);
+    
+    */
+    
+    
+    if(fp == NULL) 
+    {
+        error("Could not open file for write\n");
+    }
+    fprintf(fp, "Go to the file ");             //檔案如sdtest.txt裡面的資料內容
+    fclose(fp); 
+ 
+    printf("Goodbye World!\n");
+}
\ No newline at end of file
diff -r 000000000000 -r 09c855ba2df2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 20 20:40:15 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f
\ No newline at end of file