Example to show how to use USB Host on the LPC4088 QSB.

Dependencies:   LPC4088-USBHost mbed

Files at this revision

API Documentation at this revision

Comitter:
embeddedartists
Date:
Fri Apr 24 06:13:20 2015 +0000
Commit message:
Example to show USB Host MassStorage

Changed in this revision

LPC4088-USBHost.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC4088-USBHost.lib	Fri Apr 24 06:13:20 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/embeddedartists/code/LPC4088-USBHost/#5402b105b911
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 24 06:13:20 2015 +0000
@@ -0,0 +1,44 @@
+// Simple USBHost MSD(USB Flash drive) for EA LPC4088 QSB test program
+#include "USBHostMSD.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+#define LED_OFF 0
+#define LED_ON  1
+
+int main() {
+    USBHostMSD msd("usb");
+    if (!msd.connect()) {
+        error("USB Flash drive not found.\n");
+    }    
+    FILE* fp = fopen("/usb/test1.txt", "a");
+    if (fp) {
+        fprintf(fp, "Hello from EA LPC4088 QSB\n");
+        for(int i = 0; i < 21; i++) {
+            fprintf(fp, " %d", i);
+            led2 = !led2;
+        }
+        fprintf(fp, "\n");
+        fclose(fp);
+    }
+    fp = fopen("/usb/test1.txt", "r");
+    if (fp) {
+        int n = 0;
+        while(1) {
+            int c = fgetc(fp);
+            if (c == EOF) {
+                break;
+            }
+            printf("%c", c);
+            n++;
+            led1 = !led1;
+        }
+        fclose(fp);
+        printf("%d bytes\n", n);
+    }
+    led2 = LED_OFF;
+    while(1) {
+        led1 = !led1;
+        wait_ms(200);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Apr 24 06:13:20 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889
\ No newline at end of file