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: mbed SDFileSystem
sdCard.cpp@7:af45a10fdfb6, 2019-04-27 (annotated)
- Committer:
- kchen7
- Date:
- Sat Apr 27 21:47:02 2019 +0000
- Revision:
- 7:af45a10fdfb6
- Parent:
- 5:e297f321fa20
baseline demo version
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| fenix2519 | 5:e297f321fa20 | 1 | //// Block devices |
| fenix2519 | 5:e297f321fa20 | 2 | ////#include "SPIFBlockDevice.h" |
| fenix2519 | 5:e297f321fa20 | 3 | ////#include "DataFlashBlockDevice.h" |
| fenix2519 | 5:e297f321fa20 | 4 | //#include "SDBlockDevice.h" |
| fenix2519 | 5:e297f321fa20 | 5 | //#include "HeapBlockDevice.h" |
| fenix2519 | 5:e297f321fa20 | 6 | // |
| fenix2519 | 5:e297f321fa20 | 7 | //// File systems |
| fenix2519 | 5:e297f321fa20 | 8 | //#include "LittleFileSystem.h" |
| fenix2519 | 5:e297f321fa20 | 9 | //#include "FATFileSystem.h" |
| fenix2519 | 5:e297f321fa20 | 10 | // |
| fenix2519 | 5:e297f321fa20 | 11 | // |
| fenix2519 | 5:e297f321fa20 | 12 | //// Physical block device, can be any device that supports the BlockDevice API |
| fenix2519 | 5:e297f321fa20 | 13 | //SDBlockDevice bd( p5, p6, p7, p8); // mosi, miso, sck, cs |
| fenix2519 | 5:e297f321fa20 | 14 | // |
| fenix2519 | 5:e297f321fa20 | 15 | //// File system declaration |
| fenix2519 | 5:e297f321fa20 | 16 | //FATFileSystem fs("fs"); |
| fenix2519 | 5:e297f321fa20 | 17 | // |
| fenix2519 | 5:e297f321fa20 | 18 | // |
| fenix2519 | 5:e297f321fa20 | 19 | //// Set up the button to trigger an erase |
| fenix2519 | 5:e297f321fa20 | 20 | //InterruptIn irq(p9); |
| fenix2519 | 5:e297f321fa20 | 21 | //void erase() { |
| fenix2519 | 5:e297f321fa20 | 22 | // printf("Initializing the block device... "); |
| fenix2519 | 5:e297f321fa20 | 23 | // fflush(stdout); |
| fenix2519 | 5:e297f321fa20 | 24 | // int err = bd.init(); |
| fenix2519 | 5:e297f321fa20 | 25 | // printf("%s\n", (err ? "Fail :(" : "OK")); |
| fenix2519 | 5:e297f321fa20 | 26 | // if (err) { |
| fenix2519 | 5:e297f321fa20 | 27 | // error("error: %s (%d)\n", strerror(-err), err); |
| fenix2519 | 5:e297f321fa20 | 28 | // } |
| fenix2519 | 5:e297f321fa20 | 29 | // |
| fenix2519 | 5:e297f321fa20 | 30 | // printf("Erasing the block device... "); |
| fenix2519 | 5:e297f321fa20 | 31 | // fflush(stdout); |
| fenix2519 | 5:e297f321fa20 | 32 | // err = bd.erase(0, bd.size()); |
| fenix2519 | 5:e297f321fa20 | 33 | // printf("%s\n", (err ? "Fail :(" : "OK")); |
| fenix2519 | 5:e297f321fa20 | 34 | // if (err) { |
| fenix2519 | 5:e297f321fa20 | 35 | // error("error: %s (%d)\n", strerror(-err), err); |
| fenix2519 | 5:e297f321fa20 | 36 | // } |
| fenix2519 | 5:e297f321fa20 | 37 | // |
| fenix2519 | 5:e297f321fa20 | 38 | // printf("Deinitializing the block device... "); |
| fenix2519 | 5:e297f321fa20 | 39 | // fflush(stdout); |
| fenix2519 | 5:e297f321fa20 | 40 | // err = bd.deinit(); |
| fenix2519 | 5:e297f321fa20 | 41 | // printf("%s\n", (err ? "Fail :(" : "OK")); |
| fenix2519 | 5:e297f321fa20 | 42 | // if (err) { |
| fenix2519 | 5:e297f321fa20 | 43 | // error("error: %s (%d)\n", strerror(-err), err); |
| fenix2519 | 5:e297f321fa20 | 44 | // } |
| fenix2519 | 5:e297f321fa20 | 45 | //} |
