1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 00:05:33 +03:00

Add AFATFS support to Blackbox

This commit is contained in:
Nicholas Sherlock 2015-11-17 21:14:40 +13:00 committed by borisbstyle
parent 04d8dd27bf
commit 14c13085b7
8 changed files with 389 additions and 156 deletions

View file

@ -258,6 +258,7 @@ static const blackboxSimpleFieldDefinition_t blackboxSlowFields[] = {
typedef enum BlackboxState {
BLACKBOX_STATE_DISABLED = 0,
BLACKBOX_STATE_STOPPED,
BLACKBOX_STATE_PREPARE_LOG_FILE,
BLACKBOX_STATE_SEND_HEADER,
BLACKBOX_STATE_SEND_MAIN_FIELD_HEADER,
BLACKBOX_STATE_SEND_GPS_H_HEADER,
@ -479,7 +480,6 @@ static void blackboxSetState(BlackboxState newState)
break;
case BLACKBOX_STATE_SHUTTING_DOWN:
xmitState.u.startTime = millis();
blackboxDeviceEndLog();
break;
default:
;
@ -787,8 +787,20 @@ static void validateBlackboxConfig()
masterConfig.blackbox_rate_denom /= div;
}
if (masterConfig.blackbox_device >= BLACKBOX_DEVICE_END) {
masterConfig.blackbox_device = BLACKBOX_DEVICE_SERIAL;
// If we've chosen an unsupported device, change the device to serial
switch (masterConfig.blackbox_device) {
#ifdef USE_FLASHFS
case BLACKBOX_DEVICE_FLASH:
#endif
#ifdef USE_SDCARD
case BLACKBOX_DEVICE_SDCARD:
#endif
case BLACKBOX_DEVICE_SERIAL:
// Device supported, leave the setting alone
break;
default:
masterConfig.blackbox_device = BLACKBOX_DEVICE_SERIAL;
}
}
@ -834,7 +846,7 @@ void startBlackbox(void)
*/
blackboxLastArmingBeep = getArmingBeepTimeMicros();
blackboxSetState(BLACKBOX_STATE_SEND_HEADER);
blackboxSetState(BLACKBOX_STATE_PREPARE_LOG_FILE);
}
}
@ -1301,6 +1313,11 @@ void handleBlackbox(void)
}
switch (blackboxState) {
case BLACKBOX_STATE_PREPARE_LOG_FILE:
if (blackboxDeviceBeginLog()) {
blackboxSetState(BLACKBOX_STATE_SEND_HEADER);
}
break;
case BLACKBOX_STATE_SEND_HEADER:
//On entry of this state, xmitState.headerIndex is 0 and startTime is intialised
@ -1409,7 +1426,7 @@ void handleBlackbox(void)
*
* Don't wait longer than it could possibly take if something funky happens.
*/
if (millis() > xmitState.u.startTime + BLACKBOX_SHUTDOWN_TIMEOUT_MILLIS || blackboxDeviceFlush()) {
if (blackboxDeviceEndLog() && (millis() > xmitState.u.startTime + BLACKBOX_SHUTDOWN_TIMEOUT_MILLIS || blackboxDeviceFlush())) {
blackboxDeviceClose();
blackboxSetState(BLACKBOX_STATE_STOPPED);
}