basic version
Dependencies: C12832_lcd USBHost mbed
Diff: main.cpp
- Revision:
- 11:f4639eb91e5f
- Parent:
- 9:88d70b0c1b8b
--- a/main.cpp Thu Jan 29 16:18:19 2015 +0000 +++ b/main.cpp Mon Feb 02 13:34:05 2015 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "rtos.h" #include "C12832_lcd.h" +#include "USBHostMSD.h" @@ -133,6 +134,31 @@ } } + +void msd_task(void const *) { + + USBHostMSD msd("usb2"); + + + + // try to connect a MSD device + while(!msd.connect()) { + Thread::wait(500); + } + // append a file + FILE * fp = fopen("/usb2/test.csv", "w"); + for (int i=0; i<2000; i++) { + + + sonarDistance_mutex.lock(); //Mutex lock for the sonar value + fprintf(fp,"%.2f\n",sonarDistance); + sonarDistance_mutex.unlock(); //Mutex unlock for the sonar value + + } + fclose(fp); + +} + int main(){ sonarDistance = 0.0f; servoPosition = 0.0f; @@ -143,6 +169,7 @@ Thread logic_thread(logic); Thread display_thread(display); Thread LED_meter_thread(LED_meter); + Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4); while(true) {