Simple USBHost MSD(USB flash drive) for EA LPC4088 QSB test program
Dependencies: LPC4088-USBHost mbed
main.cpp
00001 // Simple USBHost MSD(USB Flash drive) for EA LPC4088 QSB test program 00002 #include "USBHostMSD.h" 00003 00004 DigitalOut led1(LED1); 00005 DigitalOut led2(LED2); 00006 #define LED_OFF 0 00007 #define LED_ON 1 00008 00009 int main() { 00010 USBHostMSD msd("usb"); 00011 if (!msd.connect()) { 00012 error("USB Flash drive not found.\n"); 00013 } 00014 FILE* fp = fopen("/usb/test1.txt", "a"); 00015 if (fp) { 00016 fprintf(fp, "Hello from EA LPC4088 QSB\n"); 00017 for(int i = 0; i < 21; i++) { 00018 fprintf(fp, " %d", i); 00019 led2 = !led2; 00020 } 00021 fprintf(fp, "\n"); 00022 fclose(fp); 00023 } 00024 fp = fopen("/usb/test1.txt", "r"); 00025 if (fp) { 00026 int n = 0; 00027 while(1) { 00028 int c = fgetc(fp); 00029 if (c == EOF) { 00030 break; 00031 } 00032 printf("%c", c); 00033 n++; 00034 led1 = !led1; 00035 } 00036 fclose(fp); 00037 printf("%d bytes\n", n); 00038 } 00039 led2 = LED_OFF; 00040 while(1) { 00041 led1 = !led1; 00042 wait_ms(200); 00043 } 00044 }
Generated on Thu Jul 14 2022 01:21:56 by 1.7.2