mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 05:45:31 +03:00
Merge pull request #2481 from blckmn/bb_fix
BlackBox - initialise SDCARD or FLASH if selected (not both)
This commit is contained in:
commit
ecd51bec62
4 changed files with 20 additions and 8 deletions
|
@ -1657,7 +1657,8 @@ void handleBlackbox(timeUs_t currentTimeUs)
|
||||||
|
|
||||||
static bool canUseBlackboxWithCurrentConfiguration(void)
|
static bool canUseBlackboxWithCurrentConfiguration(void)
|
||||||
{
|
{
|
||||||
return feature(FEATURE_BLACKBOX);
|
return feature(FEATURE_BLACKBOX) &&
|
||||||
|
(blackboxConfig()->device != BLACKBOX_SDCARD || feature(FEATURE_SDCARD));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
|
|
||||||
#include "config/parameter_group.h"
|
#include "config/parameter_group.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BLACKBOX_SERIAL = 0,
|
||||||
|
BLACKBOX_SPIFLASH,
|
||||||
|
BLACKBOX_SDCARD
|
||||||
|
} blackBoxDevice_e;
|
||||||
|
|
||||||
typedef struct blackboxConfig_s {
|
typedef struct blackboxConfig_s {
|
||||||
uint8_t rate_num;
|
uint8_t rate_num;
|
||||||
uint8_t rate_denom;
|
uint8_t rate_denom;
|
||||||
|
|
|
@ -488,15 +488,16 @@ void init(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_FLASHFS
|
#ifdef USE_FLASHFS
|
||||||
|
if (blackboxConfig()->device == BLACKBOX_SPIFLASH) {
|
||||||
#if defined(USE_FLASH_M25P16)
|
#if defined(USE_FLASH_M25P16)
|
||||||
m25p16_init(flashConfig());
|
m25p16_init(flashConfig());
|
||||||
#endif
|
#endif
|
||||||
|
flashfsInit();
|
||||||
flashfsInit();
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_SDCARD
|
#ifdef USE_SDCARD
|
||||||
if (feature(FEATURE_SDCARD)) {
|
if (feature(FEATURE_SDCARD) && blackboxConfig()->device == BLACKBOX_SDCARD) {
|
||||||
sdcardInsertionDetectInit();
|
sdcardInsertionDetectInit();
|
||||||
sdcard_init(sdcardConfig()->useDma);
|
sdcard_init(sdcardConfig()->useDma);
|
||||||
afatfs_init();
|
afatfs_init();
|
||||||
|
|
|
@ -57,9 +57,13 @@ void targetPreInit(void)
|
||||||
|
|
||||||
/* ensure the CS pin for the flash is pulled hi so any SD card initialisation does not impact the chip */
|
/* ensure the CS pin for the flash is pulled hi so any SD card initialisation does not impact the chip */
|
||||||
if (hardwareRevision == BJF4_REV3) {
|
if (hardwareRevision == BJF4_REV3) {
|
||||||
IO_t io = IOGetByTag(IO_TAG(M25P16_CS_PIN));
|
IO_t flashIo = IOGetByTag(IO_TAG(M25P16_CS_PIN));
|
||||||
IOConfigGPIO(io, IOCFG_OUT_PP);
|
IOConfigGPIO(flashIo, IOCFG_OUT_PP);
|
||||||
IOHi(io);
|
IOHi(flashIo);
|
||||||
|
|
||||||
|
IO_t sdcardIo = IOGetByTag(IO_TAG(SDCARD_SPI_CS_PIN));
|
||||||
|
IOConfigGPIO(sdcardIo, IOCFG_OUT_PP);
|
||||||
|
IOHi(sdcardIo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue