
.
Revision 26:06d3aa3eff55, committed 2018-12-10
- Comitter:
- mbed_official
- Date:
- Mon Dec 10 13:30:30 2018 +0000
- Parent:
- 25:65a9183a2178
- Child:
- 27:a1b682cc912b
- Commit message:
- Use BlockDevice get_default_instance method to determine block device
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-filesystem
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Sep 26 15:01:07 2018 +0100 +++ b/main.cpp Mon Dec 10 13:30:30 2018 +0000 @@ -17,32 +17,14 @@ #include <stdio.h> #include <errno.h> -// Block devices -#if COMPONENT_SPIF -#include "SPIFBlockDevice.h" -#endif - -#if COMPONENT_DATAFLASH -#include "DataFlashBlockDevice.h" -#endif - -#if COMPONENT_SD -#include "SDBlockDevice.h" -#endif - -#include "HeapBlockDevice.h" +#include "BlockDevice.h" // File systems #include "LittleFileSystem.h" #include "FATFileSystem.h" -// Physical block device, can be any device that supports the BlockDevice API -SPIFBlockDevice bd( - MBED_CONF_SPIF_DRIVER_SPI_MOSI, - MBED_CONF_SPIF_DRIVER_SPI_MISO, - MBED_CONF_SPIF_DRIVER_SPI_CLK, - MBED_CONF_SPIF_DRIVER_SPI_CS); +BlockDevice *bd = BlockDevice::get_default_instance(); // File system declaration LittleFileSystem fs("fs"); @@ -53,7 +35,7 @@ void erase() { printf("Initializing the block device... "); fflush(stdout); - int err = bd.init(); + int err = bd->init(); printf("%s\n", (err ? "Fail :(" : "OK")); if (err) { error("error: %s (%d)\n", strerror(-err), err); @@ -61,7 +43,7 @@ printf("Erasing the block device... "); fflush(stdout); - err = bd.erase(0, bd.size()); + err = bd->erase(0, bd->size()); printf("%s\n", (err ? "Fail :(" : "OK")); if (err) { error("error: %s (%d)\n", strerror(-err), err); @@ -69,7 +51,7 @@ printf("Deinitializing the block device... "); fflush(stdout); - err = bd.deinit(); + err = bd->deinit(); printf("%s\n", (err ? "Fail :(" : "OK")); if (err) { error("error: %s (%d)\n", strerror(-err), err); @@ -88,14 +70,14 @@ // Try to mount the filesystem printf("Mounting the filesystem... "); fflush(stdout); - int err = fs.mount(&bd); + int err = fs.mount(bd); printf("%s\n", (err ? "Fail :(" : "OK")); if (err) { // Reformat if we can't mount the filesystem // this should only happen on the first boot printf("No filesystem found, formatting... "); fflush(stdout); - err = fs.reformat(&bd); + err = fs.reformat(bd); printf("%s\n", (err ? "Fail :(" : "OK")); if (err) { error("error: %s (%d)\n", strerror(-err), err);
--- a/mbed-os.lib Wed Sep 26 15:01:07 2018 +0100 +++ b/mbed-os.lib Mon Dec 10 13:30:30 2018 +0000 @@ -1,1 +1,2 @@ -https://github.com/ARMmbed/mbed-os/#610e35ddc6d59f153173c1e7b2748cf96d6c9bcd +https://github.com/ARMmbed/mbed-os/#2fd0c5cfbd83fce62da6308f9d64c0ab64e1f0d6 +