final
Dependencies: mbed FATFileSystem
Fork of KL46Z-USBHostMSD_HelloWorld by
main.cpp
- Committer:
- va009039
- Date:
- 2014-06-13
- Revision:
- 3:4238ec88ddcf
- Parent:
- 2:982b2bbbeda4
- Child:
- 4:77d6450f34d7
File content as of revision 3:4238ec88ddcf:
#include "USBHostMSD.h" DigitalOut led1(LED1); 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 mbed.\n"); for(int i = 0; i < 21; i++) { fprintf(fp, " %d", i); led1 = !led1; } 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); } while(1) { led1 = !led1; wait_ms(200); } }