it is test project using DISCO-F469NI target board

Dependencies:   BSP_DISCO_F469NI LCD_DISCO_F469NI USBHOST

Revision:
3:b61f4db32ed5
Parent:
2:1fb6f946b69b
--- a/main.cpp	Tue Aug 08 09:46:29 2017 +0900
+++ b/main.cpp	Tue Aug 08 12:04:34 2017 +0900
@@ -1,17 +1,85 @@
+#include <stdlib.h>
+
 #include "mbed.h"
-#include "LCD_DISCO_F469NI.h"
+//#include "LCD_DISCO_F469NI.h"
+#include "USBHostMSD.h"
+#include "FATFileSystem.h"
 
-LCD_DISCO_F469NI lcd;
+//LCD_DISCO_F469NI lcd;
 
 DigitalOut led_green(LED1);
 DigitalOut led_orange(LED2);
 DigitalOut led_red(LED3);
 DigitalOut led_blue(LED4);
 
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+void msd_task(void const *) {
+
+    USBHostMSD msd;
+    int i = 0;
+    FATFileSystem fs("usb");
+    int err;
+    printf("wait for usb memory stick insertion\n");
+    while(1) {
+
+        // try to connect a MSD device
+        while(!msd.connect()) {
+            Thread::wait(500);
+        }
+        if (fs.mount(&msd) != 0) continue;
+        else
+            printf("file system mounted\n");
+
+        if  (!msd.connect()) {
+            continue;
+        }
+
+        // in a loop, append a file
+        // if the device is disconnected, we try to connect it again
+
+        // append a file
+        File file;
+        err = file.open(&fs, "test1.txt", O_WRONLY | O_CREAT |O_APPEND);
+
+        if (err == 0) {
+            char tmp[100];
+            sprintf(tmp,"Hello fun USB stick  World: %d!\r\n", i++);
+            file.write(tmp,strlen(tmp));
+            sprintf(tmp,"Goodbye World!\r\n");
+            file.write(tmp,strlen(tmp));
+            file.close();
+        } else {
+            printf("FILE == NULL\r\n");
+        }
+        Thread::wait(500);
+        printf("again\n");
+        // if device disconnected, try to connect again
+        while (msd.connected()) {
+            Thread::wait(500);
+        }
+        while (fs.unmount() < 0) {
+            Thread::wait(500);
+            printf("unmount\n");
+        }
+    }
+}
+
 int main() {
 
-    lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"MBED EXAMPLE", CENTER_MODE);
-    wait(1);
+    pc.baud(115200);
+
+    //lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"MBED EXAMPLE", CENTER_MODE);
+    //wait(1);
+
+    Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4);
+
+    //lcd.Clear(LCD_COLOR_BLUE);
+    //lcd.SetBackColor(LCD_COLOR_BLUE);
+    //lcd.SetTextColor(LCD_COLOR_WHITE);
+
+    //BSP_LCD_SetFont(&Font20);
+    //lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"HAVE FUN !!!", CENTER_MODE);
 
     while(1) {
         // WARNING: LEDs are OFF