Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: F401RE-USBHost mbed
Fork of KL46Z-USBHostMSD_HelloWorld by
main.cpp
00001 #include "USBHostMSD.h" 00002 00003 DigitalOut led1(LED1); 00004 00005 int main() { 00006 USBHostMSD msd("usb"); 00007 if (!msd.connect()) { 00008 error("USB Flash drive not found.\n"); 00009 } 00010 FILE* fp = fopen("/usb/test1.txt", "a"); 00011 if (fp) { 00012 fprintf(fp, "Hello from mbed.\n"); 00013 for(int i = 0; i < 21; i++) { 00014 fprintf(fp, " %d", i); 00015 led1 = !led1; 00016 } 00017 fprintf(fp, "\n"); 00018 fclose(fp); 00019 } 00020 fp = fopen("/usb/test1.txt", "r"); 00021 if (fp) { 00022 int n = 0; 00023 while(1) { 00024 int c = fgetc(fp); 00025 if (c == EOF) { 00026 break; 00027 } 00028 printf("%c", c); 00029 n++; 00030 led1 = !led1; 00031 } 00032 fclose(fp); 00033 printf("%d bytes\n", n); 00034 } 00035 00036 while(1) { 00037 led1 = !led1; 00038 wait_ms(200); 00039 } 00040 }
Generated on Sun Jul 17 2022 12:29:02 by
1.7.2
