An example program for the S25FL216K flash memory
Dependencies: S25FL216K_FATFileSystem mbed
Fork of S25FL216K_HelloWorld by
main.cpp@4:6a2931c19204, 2014-12-19 (annotated)
- Committer:
- mkilivan
- Date:
- Fri Dec 19 14:41:55 2014 +0000
- Revision:
- 4:6a2931c19204
- Parent:
- 3:321618d7c9a5
- Child:
- 6:d3431822f4a9
Tried to create two files
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); |
mkilivan | 4:6a2931c19204 | 5 | //FlashUSB flash(PTD6, PTD7, PTB11, PTE4); |
mkilivan | 4:6a2931c19204 | 6 | FlashUSB flash(P0_9, P0_8, P0_7, P0_6); |
Sissors | 0:5e431050adf7 | 7 | |
Sissors | 0:5e431050adf7 | 8 | |
Sissors | 0:5e431050adf7 | 9 | int main() |
Sissors | 0:5e431050adf7 | 10 | { |
Sissors | 0:5e431050adf7 | 11 | wait(0.1); |
Sissors | 0:5e431050adf7 | 12 | printf("Hello World!\r\n"); |
Sissors | 0:5e431050adf7 | 13 | |
mkilivan | 4:6a2931c19204 | 14 | FILE *fp = fopen("/USB/in1.txt", "w"); |
Sissors | 0:5e431050adf7 | 15 | |
Sissors | 0:5e431050adf7 | 16 | if(fp == NULL) { |
Sissors | 0:5e431050adf7 | 17 | printf("Could not open file, assuming unformatted disk!\r\n"); |
Sissors | 3:321618d7c9a5 | 18 | printf("Formatting disk!\r\n"); |
Sissors | 3:321618d7c9a5 | 19 | flash.format(); |
Sissors | 3:321618d7c9a5 | 20 | printf("Disk formatted!\r\n"); |
Sissors | 3:321618d7c9a5 | 21 | printf("Reset your device!\r\n"); |
Sissors | 1:e8698224bb08 | 22 | while(1); |
Sissors | 0:5e431050adf7 | 23 | } else { |
Sissors | 0:5e431050adf7 | 24 | wait(0.2); |
Sissors | 0:5e431050adf7 | 25 | fprintf(fp, "Type your text here!"); |
Sissors | 0:5e431050adf7 | 26 | fclose(fp); |
Sissors | 0:5e431050adf7 | 27 | } |
Sissors | 1:e8698224bb08 | 28 | |
mkilivan | 4:6a2931c19204 | 29 | fp = fopen("/USB/in2.txt", "w"); |
mkilivan | 4:6a2931c19204 | 30 | if (fp == NULL) { |
mkilivan | 4:6a2931c19204 | 31 | printf("out.txt can't created.\r\n"); |
mkilivan | 4:6a2931c19204 | 32 | } else { |
mkilivan | 4:6a2931c19204 | 33 | fprintf(fp, "Hello World!\r\n"); |
Sissors | 1:e8698224bb08 | 34 | fclose(fp); |
Sissors | 0:5e431050adf7 | 35 | } |
Sissors | 0:5e431050adf7 | 36 | |
Sissors | 0:5e431050adf7 | 37 | } |