save data to memory stick

Dependencies:   USBHost mbed

Fork of USBHostMSD_HelloWorld by Samuel Mokrani

Revision:
9:dadf8d23bcf2
Parent:
4:f8a5c8aa895a
--- a/main.cpp	Thu Mar 14 14:23:42 2013 +0000
+++ b/main.cpp	Thu Jan 29 17:29:50 2015 +0000
@@ -3,41 +3,27 @@
 
 DigitalOut led(LED1);
 
+AnalogIn pot1(p19);
+
 void msd_task(void const *) {
     
     USBHostMSD msd("usb");
-    int i = 0;
     
-    while(1) {
+  
         
         // try to connect a MSD device
         while(!msd.connect()) {
             Thread::wait(500);
         }
-        
-        // in a loop, append a file
-        // if the device is disconnected, we try to connect it again
-        while(1) {
-            
-            // append a file
-            FILE * fp = fopen("/usb/test1.txt", "a");
+         // append a file
+            FILE * fp = fopen("/usb/test.csv", "w");
+            for (int i=0; i<100; i++)  {
+                    fprintf(fp,"%.2f\n",pot1.read());
         
-            if (fp != NULL) {
-                fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++);
-                printf("Goodbye World!\r\n");
-                fclose(fp);
-            } else {
-                printf("FILE == NULL\r\n");
+                    led=!led;
             }
-            
-            Thread::wait(500);
-        
-            // if device disconnected, try to connect again
-            if (!msd.connected())
-                break;
-        }
-            
-    }
+            fclose(fp);
+
 }