From 43913bea6e33978671bfdff1b9893631777f3791 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Fri, 14 Jul 2017 15:07:59 +0100 Subject: [PATCH] Ensure storage device status is reset after erasing flash --- src/main/cms/cms_menu_blackbox.c | 48 +++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/main/cms/cms_menu_blackbox.c b/src/main/cms/cms_menu_blackbox.c index f46e740ed3..baf3104a23 100644 --- a/src/main/cms/cms_menu_blackbox.c +++ b/src/main/cms/cms_menu_blackbox.c @@ -52,29 +52,6 @@ #include "io/flashfs.h" #include "io/beeper.h" - -#ifdef USE_FLASHFS -static long cmsx_EraseFlash(displayPort_t *pDisplay, const void *ptr) -{ - UNUSED(ptr); - - displayClearScreen(pDisplay); - displayWrite(pDisplay, 5, 3, "ERASING FLASH..."); - displayResync(pDisplay); // Was max7456RefreshAll(); Why at this timing? - - flashfsEraseCompletely(); - while (!flashfsIsReady()) { - delay(100); - } - - beeper(BEEPER_BLACKBOX_ERASE); - displayClearScreen(pDisplay); - displayResync(pDisplay); // Was max7456RefreshAll(); wedges during heavy SPI? - - return 0; -} -#endif // USE_FLASHFS - static const char * const cmsx_BlackboxDeviceNames[] = { "NONE", "FLASH ", @@ -163,6 +140,31 @@ static void cmsx_Blackbox_GetDeviceStatus() tfp_sprintf(cmsx_BlackboxDeviceStorageFree, "%ld%s", storageFree, unit); } +#ifdef USE_FLASHFS +static long cmsx_EraseFlash(displayPort_t *pDisplay, const void *ptr) +{ + UNUSED(ptr); + + displayClearScreen(pDisplay); + displayWrite(pDisplay, 5, 3, "ERASING FLASH..."); + displayResync(pDisplay); // Was max7456RefreshAll(); Why at this timing? + + flashfsEraseCompletely(); + while (!flashfsIsReady()) { + delay(100); + } + + beeper(BEEPER_BLACKBOX_ERASE); + displayClearScreen(pDisplay); + displayResync(pDisplay); // Was max7456RefreshAll(); wedges during heavy SPI? + + // Update storage device status to show new used space amount + cmsx_Blackbox_GetDeviceStatus(); + + return 0; +} +#endif // USE_FLASHFS + static long cmsx_Blackbox_onEnter(void) { cmsx_Blackbox_GetDeviceStatus();