![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Example to show how to use USB Host on the LPC4088 QSB.
Dependencies: LPC4088-USBHost mbed
Revision 0:5cd11f3b13a2, committed 2015-04-24
- Comitter:
- embeddedartists
- Date:
- Fri Apr 24 06:13:20 2015 +0000
- Commit message:
- Example to show USB Host MassStorage
Changed in this revision
diff -r 000000000000 -r 5cd11f3b13a2 LPC4088-USBHost.lib --- /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
diff -r 000000000000 -r 5cd11f3b13a2 main.cpp --- /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); + } +}
diff -r 000000000000 -r 5cd11f3b13a2 mbed.bld --- /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