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: S25FL216K_FATFileSystem mbed
Fork of S25FL216K_HelloWorld by
main.cpp@0:5e431050adf7, 2013-07-31 (annotated)
- Committer:
- Sissors
- Date:
- Wed Jul 31 19:21:41 2013 +0000
- Revision:
- 0:5e431050adf7
- Child:
- 1:e8698224bb08
v1.0
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Sissors | 0:5e431050adf7 | 1 | #include "mbed.h" | 
| Sissors | 0:5e431050adf7 | 2 | #include "Flash_USBFileSystem.h" | 
| Sissors | 0:5e431050adf7 | 3 | |
| Sissors | 0:5e431050adf7 | 4 | DigitalOut myled(LED1); | 
| Sissors | 0:5e431050adf7 | 5 | FlashUSB flash(PTD6, PTD7, PTB11, PTE4); | 
| Sissors | 0:5e431050adf7 | 6 | |
| Sissors | 0:5e431050adf7 | 7 | void usbCallback(bool available) | 
| Sissors | 0:5e431050adf7 | 8 | { | 
| Sissors | 0:5e431050adf7 | 9 | if (available) { | 
| Sissors | 0:5e431050adf7 | 10 | FILE *fp = fopen("/USB/usbtest.txt", "r"); | 
| Sissors | 0:5e431050adf7 | 11 | char buffer[100]; | 
| Sissors | 0:5e431050adf7 | 12 | fgets (buffer, 100, fp); | 
| Sissors | 0:5e431050adf7 | 13 | printf("%s\r\n", buffer); | 
| Sissors | 0:5e431050adf7 | 14 | fclose(fp); | 
| Sissors | 0:5e431050adf7 | 15 | } | 
| Sissors | 0:5e431050adf7 | 16 | } | 
| Sissors | 0:5e431050adf7 | 17 | |
| Sissors | 0:5e431050adf7 | 18 | int main() | 
| Sissors | 0:5e431050adf7 | 19 | { | 
| Sissors | 0:5e431050adf7 | 20 | flash.attachUSB(&usbCallback); | 
| Sissors | 0:5e431050adf7 | 21 | |
| Sissors | 0:5e431050adf7 | 22 | wait(0.1); | 
| Sissors | 0:5e431050adf7 | 23 | printf("Hello World!\r\n"); | 
| Sissors | 0:5e431050adf7 | 24 | |
| Sissors | 0:5e431050adf7 | 25 | FILE *fp = fopen("/USB/usbtest.txt", "w"); | 
| Sissors | 0:5e431050adf7 | 26 | |
| Sissors | 0:5e431050adf7 | 27 | if(fp == NULL) { | 
| Sissors | 0:5e431050adf7 | 28 | printf("Could not open file, assuming unformatted disk!\r\n"); | 
| Sissors | 0:5e431050adf7 | 29 | printf("Click in the nice popup window to format disk with default settings!\r\n"); | 
| Sissors | 0:5e431050adf7 | 30 | } else { | 
| Sissors | 0:5e431050adf7 | 31 | wait(0.2); | 
| Sissors | 0:5e431050adf7 | 32 | fprintf(fp, "Type your text here!"); | 
| Sissors | 0:5e431050adf7 | 33 | fclose(fp); | 
| Sissors | 0:5e431050adf7 | 34 | } | 
| Sissors | 0:5e431050adf7 | 35 | |
| Sissors | 0:5e431050adf7 | 36 | //Connect USB | 
| Sissors | 0:5e431050adf7 | 37 | flash.connect(); | 
| Sissors | 0:5e431050adf7 | 38 | while(1) { | 
| Sissors | 0:5e431050adf7 | 39 | wait(0.2); | 
| Sissors | 0:5e431050adf7 | 40 | myled = !myled; | 
| Sissors | 0:5e431050adf7 | 41 | } | 
| Sissors | 0:5e431050adf7 | 42 | |
| Sissors | 0:5e431050adf7 | 43 | } | 
