save data to memory stick

Dependencies:   USBHost mbed

Fork of USBHostMSD_HelloWorld by Samuel Mokrani

main.cpp

Committer:
cathal66
Date:
2015-01-29
Revision:
9:dadf8d23bcf2
Parent:
4:f8a5c8aa895a

File content as of revision 9:dadf8d23bcf2:

#include "mbed.h"
#include "USBHostMSD.h"

DigitalOut led(LED1);

AnalogIn pot1(p19);

void msd_task(void const *) {
    
    USBHostMSD msd("usb");
    
  
        
        // try to connect a MSD device
        while(!msd.connect()) {
            Thread::wait(500);
        }
         // append a file
            FILE * fp = fopen("/usb/test.csv", "w");
            for (int i=0; i<100; i++)  {
                    fprintf(fp,"%.2f\n",pot1.read());
        
                    led=!led;
            }
            fclose(fp);

}


int main() {
    Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4);
    while(1) {
        led=!led;
        Thread::wait(500);
    }
}