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: X_NUCLEO_COMMON ST_INTERFACES
Diff: main.cpp
- Revision:
- 30:15743b79c6cb
- Parent:
- 29:6ff737b67e7d
- Child:
- 32:2871fbeb627d
--- a/main.cpp Thu Mar 07 15:39:45 2019 +0000
+++ b/main.cpp Sat Mar 09 00:46:54 2019 +0000
@@ -236,22 +236,19 @@
if (storage_status != 0) {
printf("Storage mounting failed.\n");
}
+#if USE_BUTTON == 1
+ // If the User button is pressed ons start, then format storage.
bool btn_pressed = (button.read() == MBED_CONF_APP_BUTTON_PRESSED_STATE);
if (btn_pressed) {
printf("User button is pushed on start...\n");
}
+#else
+ bool btn_pressed = FALSE;
+#endif /* USE_BUTTON */
+
if (storage_status || btn_pressed) {
printf("Formatting the storage...\n");
- sd.erase(0, sd.size());
- storage_status = fs.reformat(&sd);
- if (storage_status != 0) {
- if (sd.erase(0, sd.size()) == 0) {
- if (fs.format(&sd) == 0) {
- storage_status = 0;
- printf("The storage reformatted successfully.\n");
- }
- }
- }
+ int storage_status = StorageHelper::format(&fs, &sd);
if (storage_status != 0) {
printf("ERROR: Failed to reformat the storage (%d).\n", storage_status);
}