final

Dependencies:   mbed FATFileSystem

Fork of KL46Z-USBHostMSD_HelloWorld by Norimasa Okamoto

Revision:
0:7012d3c02e58
Child:
1:88de0ef4739f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jan 21 09:06:20 2014 +0000
@@ -0,0 +1,36 @@
+// Simple USBHost MSD for FRDM-KL46Z test program
+#include "mbed.h"
+#include "USBHostMSD.h"
+
+DigitalOut led1(PTD5); // green
+DigitalOut led2(PTE29); // red
+#define LED_OFF 1
+#define LED_ON  0
+
+int main() {
+    USBHostMSD msd("usb");
+    
+    FILE* fp = fopen("/usb/test1.txt", "a");
+    if (fp) {
+        fprintf(fp, "Hello from FRDM-KL46Z\n");
+        fclose(fp);
+    }
+    fp = fopen("/usb/test1.txt", "r");
+    if (fp) {
+        while(1) {
+            int c = fgetc(fp);
+            if (c == EOF) {
+                break;
+            }
+            printf("%c", c);
+            led2 = !led2;
+        }
+        fclose(fp);
+    }
+    led1 = LED_OFF;
+    led2 = LED_OFF;
+    while(1) {
+        led1 = !led1;
+        wait_ms(200);
+    }
+}