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

Fixed SPI SD card support on H7 targets with SDIO support enabled.

This commit is contained in:
Michael Keller 2021-10-01 03:21:04 +13:00
parent a1c6cda572
commit 8730a8efea

View file

@ -401,16 +401,6 @@ void init(void)
dbgPinInit(); dbgPinInit();
#endif #endif
#ifdef USE_SDCARD
// Ensure the SD card is initialised before the USB MSC starts to avoid a race condition
#if !defined(CONFIG_IN_SDCARD) && defined(STM32H7) && defined(USE_SDCARD_SDIO) // H7 only for now, likely should be applied to F4/F7 too
sdioPinConfigure();
SDIO_GPIO_Init();
initFlags |= SD_INIT_ATTEMPTED;
sdCardAndFSInit();
#endif
#endif
#ifdef USE_BRUSHED_ESC_AUTODETECT #ifdef USE_BRUSHED_ESC_AUTODETECT
// Now detect again with the actually configured pin for motor 1, if it is not the default pin. // Now detect again with the actually configured pin for motor 1, if it is not the default pin.
ioTag_t configuredMotorIoTag = motorConfig()->dev.ioTags[0]; ioTag_t configuredMotorIoTag = motorConfig()->dev.ioTags[0];
@ -597,6 +587,11 @@ void init(void)
initFlags |= SPI_AND_QSPI_INIT_ATTEMPTED; initFlags |= SPI_AND_QSPI_INIT_ATTEMPTED;
} }
#if defined(USE_SDCARD_SDIO) && !defined(CONFIG_IN_SDCARD) && defined(STM32H7)
sdioPinConfigure();
SDIO_GPIO_Init();
#endif
#ifdef USE_USB_MSC #ifdef USE_USB_MSC
/* MSC mode will start after init, but will not allow scheduler to run, /* MSC mode will start after init, but will not allow scheduler to run,
* so there is no bottleneck in reading and writing data */ * so there is no bottleneck in reading and writing data */
@ -604,6 +599,10 @@ void init(void)
if (mscCheckBootAndReset() || mscCheckButton()) { if (mscCheckBootAndReset() || mscCheckButton()) {
ledInit(statusLedConfig()); ledInit(statusLedConfig());
#ifdef USE_SDCARD
sdCardAndFSInit();
#endif
#if defined(USE_FLASHFS) #if defined(USE_FLASHFS)
// If the blackbox device is onboard flash, then initialize and scan // If the blackbox device is onboard flash, then initialize and scan
// it to identify the log files *before* starting the USB device to // it to identify the log files *before* starting the USB device to
@ -805,8 +804,8 @@ void init(void)
if (blackboxConfig()->device == BLACKBOX_DEVICE_SDCARD) { if (blackboxConfig()->device == BLACKBOX_DEVICE_SDCARD) {
if (sdcardConfig()->mode) { if (sdcardConfig()->mode) {
if (!(initFlags & SD_INIT_ATTEMPTED)) { if (!(initFlags & SD_INIT_ATTEMPTED)) {
initFlags |= SD_INIT_ATTEMPTED;
sdCardAndFSInit(); sdCardAndFSInit();
initFlags |= SD_INIT_ATTEMPTED;
} }
} }
} }