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

Fixed handling of SPI parameters for Unified Targets. (#9218)

Fixed handling of SPI parameters for Unified Targets.
This commit is contained in:
Michael Keller 2019-11-25 18:47:02 +13:00 committed by mikeller
parent 78befad3b8
commit e28cf4323b
10 changed files with 63 additions and 52 deletions

View file

@ -208,6 +208,41 @@ static IO_t busSwitchResetPin = IO_NONE;
}
#endif
bool requiresSpiLeadingEdge(SPIDevice device)
{
#if defined(CONFIG_IN_SDCARD) || defined(CONFIG_IN_EXTERNAL_FLASH)
#if !defined(SDCARD_SPI_INSTANCE) && !defined(RX_SPI_INSTANCE)
UNUSED(device);
#endif
#if defined(SDCARD_SPI_INSTANCE)
if (device == spiDeviceByInstance(SDCARD_SPI_INSTANCE)) {
return true;
}
#endif
#if defined(RX_SPI_INSTANCE)
if (device == spiDeviceByInstance(RX_SPI_INSTANCE)) {
return true;
}
#endif
#else
#if !defined(USE_SDCARD) && !defined(USE_RX_SPI)
UNUSED(device);
#endif
#if defined(USE_SDCARD)
if (device == SPI_CFG_TO_DEV(sdcardConfig()->device)) {
return true;
}
#endif
#if defined(USE_RX_SPI)
if (device == SPI_CFG_TO_DEV(rxSpiConfig()->spibus)) {
return true;
}
#endif
#endif // CONFIG_IN_SDCARD || CONFIG_IN_EXTERNAL_FLASH
return false;
}
static void configureSPIAndQuadSPI(void)
{
#ifdef USE_SPI
@ -220,22 +255,22 @@ static void configureSPIAndQuadSPI(void)
spiPreinit();
#ifdef USE_SPI_DEVICE_1
spiInit(SPIDEV_1);
spiInit(SPIDEV_1, requiresSpiLeadingEdge(SPIDEV_1));
#endif
#ifdef USE_SPI_DEVICE_2
spiInit(SPIDEV_2);
spiInit(SPIDEV_2, requiresSpiLeadingEdge(SPIDEV_2));
#endif
#ifdef USE_SPI_DEVICE_3
spiInit(SPIDEV_3);
spiInit(SPIDEV_3, requiresSpiLeadingEdge(SPIDEV_3));
#endif
#ifdef USE_SPI_DEVICE_4
spiInit(SPIDEV_4);
spiInit(SPIDEV_4, requiresSpiLeadingEdge(SPIDEV_4));
#endif
#ifdef USE_SPI_DEVICE_5
spiInit(SPIDEV_5);
spiInit(SPIDEV_5, requiresSpiLeadingEdge(SPIDEV_5));
#endif
#ifdef USE_SPI_DEVICE_6
spiInit(SPIDEV_6);
spiInit(SPIDEV_6, requiresSpiLeadingEdge(SPIDEV_6));
#endif
#endif // USE_SPI
@ -248,12 +283,13 @@ static void configureSPIAndQuadSPI(void)
#endif // USE_QUAD_SPI
}
#ifdef USE_SDCARD
void sdCardAndFSInit()
{
sdcard_init(sdcardConfig());
afatfs_init();
}
#endif
void init(void)
{