Made flash erasing compile conditional on USE_FLASHFS.

This commit is contained in:
mikeller 2017-02-13 00:25:42 +13:00 committed by Michael Keller
parent cb2356ba76
commit 15bef42fd2
2 changed files with 11 additions and 6 deletions

View File

@ -1475,9 +1475,11 @@ void handleBlackbox(timeUs_t currentTimeUs)
blackboxOpen(); blackboxOpen();
startBlackbox(); startBlackbox();
} }
#ifdef USE_FLASHFS
if (IS_RC_MODE_ACTIVE(BOXBLACKBOXERASE)) { if (IS_RC_MODE_ACTIVE(BOXBLACKBOXERASE)) {
blackboxSetState(BLACKBOX_STATE_START_ERASE); blackboxSetState(BLACKBOX_STATE_START_ERASE);
} }
#endif
break; break;
case BLACKBOX_STATE_PREPARE_LOG_FILE: case BLACKBOX_STATE_PREPARE_LOG_FILE:
if (blackboxDeviceBeginLog()) { if (blackboxDeviceBeginLog()) {
@ -1602,6 +1604,7 @@ void handleBlackbox(timeUs_t currentTimeUs)
blackboxSetState(BLACKBOX_STATE_STOPPED); blackboxSetState(BLACKBOX_STATE_STOPPED);
} }
break; break;
#ifdef USE_FLASHFS
case BLACKBOX_STATE_START_ERASE: case BLACKBOX_STATE_START_ERASE:
blackboxEraseAll(); blackboxEraseAll();
blackboxSetState(BLACKBOX_STATE_ERASING); blackboxSetState(BLACKBOX_STATE_ERASING);
@ -1609,7 +1612,7 @@ void handleBlackbox(timeUs_t currentTimeUs)
break; break;
case BLACKBOX_STATE_ERASING: case BLACKBOX_STATE_ERASING:
if (isBlackboxErased()) { if (isBlackboxErased()) {
//Done eraseing //Done erasing
blackboxSetState(BLACKBOX_STATE_ERASED); blackboxSetState(BLACKBOX_STATE_ERASED);
beeper(BEEPER_BLACKBOX_ERASE); beeper(BEEPER_BLACKBOX_ERASE);
} }
@ -1619,21 +1622,25 @@ void handleBlackbox(timeUs_t currentTimeUs)
blackboxSetState(BLACKBOX_STATE_STOPPED); blackboxSetState(BLACKBOX_STATE_STOPPED);
} }
break; break;
#endif
default: default:
break; break;
} }
// Did we run out of room on the device? Stop! // Did we run out of room on the device? Stop!
if (isBlackboxDeviceFull()) { if (isBlackboxDeviceFull()) {
#ifdef USE_FLASHFS
if (blackboxState != BLACKBOX_STATE_ERASING if (blackboxState != BLACKBOX_STATE_ERASING
&& blackboxState != BLACKBOX_STATE_START_ERASE && blackboxState != BLACKBOX_STATE_START_ERASE
&& blackboxState != BLACKBOX_STATE_ERASED) { && blackboxState != BLACKBOX_STATE_ERASED) {
#endif
blackboxSetState(BLACKBOX_STATE_STOPPED); blackboxSetState(BLACKBOX_STATE_STOPPED);
// ensure we reset the test mode flag if we stop due to full memory card // ensure we reset the test mode flag if we stop due to full memory card
if (startedLoggingInTestMode) startedLoggingInTestMode = false; if (startedLoggingInTestMode) startedLoggingInTestMode = false;
#ifdef USE_FLASHFS
} }
#endif
} else { // Only log in test mode if there is room! } else { // Only log in test mode if there is room!
if(blackboxConfig()->on_motor_test) { if(blackboxConfig()->on_motor_test) {
// Handle Motor Test Mode // Handle Motor Test Mode
if(inMotorTestMode()) { if(inMotorTestMode()) {

View File

@ -614,14 +614,13 @@ bool blackboxDeviceOpen(void)
/** /**
* Erase all blackbox logs * Erase all blackbox logs
*/ */
#ifdef USE_FLASHFS
void blackboxEraseAll(void) void blackboxEraseAll(void)
{ {
switch (blackboxConfig()->device) { switch (blackboxConfig()->device) {
#ifdef USE_FLASHFS
case BLACKBOX_DEVICE_FLASH: case BLACKBOX_DEVICE_FLASH:
flashfsEraseCompletely(); flashfsEraseCompletely();
break; break;
#endif
default: default:
//not supported //not supported
break; break;
@ -635,11 +634,9 @@ void blackboxEraseAll(void)
bool isBlackboxErased(void) bool isBlackboxErased(void)
{ {
switch (blackboxConfig()->device) { switch (blackboxConfig()->device) {
#ifdef USE_FLASHFS
case BLACKBOX_DEVICE_FLASH: case BLACKBOX_DEVICE_FLASH:
return flashfsIsReady(); return flashfsIsReady();
break; break;
#endif
default: default:
//not supported //not supported
return true; return true;
@ -647,6 +644,7 @@ bool isBlackboxErased(void)
} }
} }
#endif
/** /**
* Close the Blackbox logging device immediately without attempting to flush any remaining data. * Close the Blackbox logging device immediately without attempting to flush any remaining data.