diff --git a/src/main/drivers/bus.c b/src/main/drivers/bus.c index f97cdbc44c..291d0fe600 100755 --- a/src/main/drivers/bus.c +++ b/src/main/drivers/bus.c @@ -90,7 +90,9 @@ static bool busDevInit_SPI(busDevice_t * dev, const busDeviceDescriptor_t * desc dev->irqPin = IOGetByTag(descriptor->irqPin); dev->busdev.spi.spiBus = descriptor->busdev.spi.spiBus; dev->busdev.spi.csnPin = IOGetByTag(descriptor->busdev.spi.csnPin); - if (dev->busdev.spi.csnPin) { + + if (dev->busdev.spi.csnPin && spiBusInitHost(dev)) { + // Init CSN pin IOInit(dev->busdev.spi.csnPin, owner, RESOURCE_SPI_CS, 0); IOConfigGPIO(dev->busdev.spi.csnPin, SPI_IO_CS_CFG); IOHi(dev->busdev.spi.csnPin); diff --git a/src/main/drivers/bus.h b/src/main/drivers/bus.h index 489454aa6a..f040e86978 100755 --- a/src/main/drivers/bus.h +++ b/src/main/drivers/bus.h @@ -269,6 +269,7 @@ bool i2cBusWriteRegister(const busDevice_t * dev, uint8_t reg, uint8_t data); bool i2cBusReadBuffer(const busDevice_t * dev, uint8_t reg, uint8_t * data, uint8_t length); bool i2cBusReadRegister(const busDevice_t * dev, uint8_t reg, uint8_t * data); +bool spiBusInitHost(const busDevice_t * dev); bool spiBusIsBusy(const busDevice_t * dev); void spiBusSetSpeed(const busDevice_t * dev, busSpeed_e speed); bool spiBusTransfer(const busDevice_t * dev, uint8_t * rxBuf, const uint8_t * txBuf, int length); diff --git a/src/main/drivers/bus_busdev_spi.c b/src/main/drivers/bus_busdev_spi.c index b5616bdd99..7fb4df2a5c 100755 --- a/src/main/drivers/bus_busdev_spi.c +++ b/src/main/drivers/bus_busdev_spi.c @@ -29,6 +29,12 @@ #include "drivers/bus_spi.h" #include "drivers/time.h" +bool spiBusInitHost(const busDevice_t * dev) +{ + const bool spiLeadingEdge = (dev->flags & DEVFLAGS_SPI_MODE_0); + return spiInitDevice(dev->busdev.spi.spiBus, spiLeadingEdge); +} + void spiBusSelectDevice(const busDevice_t * dev) { IOLo(dev->busdev.spi.csnPin); diff --git a/src/main/drivers/bus_spi.c b/src/main/drivers/bus_spi.c index c6b4936d42..24134d20da 100644 --- a/src/main/drivers/bus_spi.c +++ b/src/main/drivers/bus_spi.c @@ -72,22 +72,6 @@ #define SPI3_NSS_PIN NONE #endif -#ifdef SPI1_CLOCK_LEADING_EDGE -# define SPI1_LEADING_EDGE true -#else -# define SPI1_LEADING_EDGE false -#endif -#ifdef SPI2_CLOCK_LEADING_EDGE -# define SPI2_LEADING_EDGE true -#else -# define SPI2_LEADING_EDGE false -#endif -#ifdef SPI3_CLOCK_LEADING_EDGE -# define SPI3_LEADING_EDGE true -#else -# define SPI3_LEADING_EDGE false -#endif - #if defined(STM32F3) static const uint16_t spiDivisorMapFast[] = { SPI_BaudRatePrescaler_256, // SPI_CLOCK_INITIALIZATON 281.25 KBits/s @@ -106,9 +90,22 @@ static const uint16_t spiDivisorMapSlow[] = { }; static spiDevice_t spiHardwareMap[] = { - { .dev = SPI1, .nss = IO_TAG(SPI1_NSS_PIN), .sck = IO_TAG(SPI1_SCK_PIN), .miso = IO_TAG(SPI1_MISO_PIN), .mosi = IO_TAG(SPI1_MOSI_PIN), .rcc = RCC_APB2(SPI1), .af = GPIO_AF_SPI1, .leadingEdge = SPI1_LEADING_EDGE, .divisorMap = spiDivisorMapFast }, - { .dev = SPI2, .nss = IO_TAG(SPI2_NSS_PIN), .sck = IO_TAG(SPI2_SCK_PIN), .miso = IO_TAG(SPI2_MISO_PIN), .mosi = IO_TAG(SPI2_MOSI_PIN), .rcc = RCC_APB1(SPI2), .af = GPIO_AF_SPI2, .leadingEdge = SPI2_LEADING_EDGE, .divisorMap = spiDivisorMapSlow }, - { .dev = SPI3, .nss = IO_TAG(SPI3_NSS_PIN), .sck = IO_TAG(SPI3_SCK_PIN), .miso = IO_TAG(SPI3_MISO_PIN), .mosi = IO_TAG(SPI3_MOSI_PIN), .rcc = RCC_APB1(SPI3), .af = GPIO_AF_SPI3, .leadingEdge = SPI3_LEADING_EDGE, .divisorMap = spiDivisorMapSlow } +#ifdef USE_SPI_DEVICE_1 + { .dev = SPI1, .nss = IO_TAG(SPI1_NSS_PIN), .sck = IO_TAG(SPI1_SCK_PIN), .miso = IO_TAG(SPI1_MISO_PIN), .mosi = IO_TAG(SPI1_MOSI_PIN), .rcc = RCC_APB2(SPI1), .af = GPIO_AF_SPI1, .divisorMap = spiDivisorMapFast }, +#else + { .dev = NULL }, // No SPI1 +#endif +#ifdef USE_SPI_DEVICE_2 + { .dev = SPI2, .nss = IO_TAG(SPI2_NSS_PIN), .sck = IO_TAG(SPI2_SCK_PIN), .miso = IO_TAG(SPI2_MISO_PIN), .mosi = IO_TAG(SPI2_MOSI_PIN), .rcc = RCC_APB1(SPI2), .af = GPIO_AF_SPI2, .divisorMap = spiDivisorMapSlow }, +#else + { .dev = NULL }, // No SPI2 +#endif +#ifdef USE_SPI_DEVICE_3 + { .dev = SPI3, .nss = IO_TAG(SPI3_NSS_PIN), .sck = IO_TAG(SPI3_SCK_PIN), .miso = IO_TAG(SPI3_MISO_PIN), .mosi = IO_TAG(SPI3_MOSI_PIN), .rcc = RCC_APB1(SPI3), .af = GPIO_AF_SPI3, .divisorMap = spiDivisorMapSlow }, +#else + { .dev = NULL }, // No SPI3 +#endif + { .dev = NULL }, // No SPI4 }; #elif defined(STM32F4) static const uint16_t spiDivisorMapFast[] = { @@ -128,9 +125,22 @@ static const uint16_t spiDivisorMapSlow[] = { }; static spiDevice_t spiHardwareMap[] = { - { .dev = SPI1, .nss = IO_TAG(SPI1_NSS_PIN), .sck = IO_TAG(SPI1_SCK_PIN), .miso = IO_TAG(SPI1_MISO_PIN), .mosi = IO_TAG(SPI1_MOSI_PIN), .rcc = RCC_APB2(SPI1), .af = GPIO_AF_SPI1, .leadingEdge = SPI1_LEADING_EDGE, .divisorMap = spiDivisorMapFast }, - { .dev = SPI2, .nss = IO_TAG(SPI2_NSS_PIN), .sck = IO_TAG(SPI2_SCK_PIN), .miso = IO_TAG(SPI2_MISO_PIN), .mosi = IO_TAG(SPI2_MOSI_PIN), .rcc = RCC_APB1(SPI2), .af = GPIO_AF_SPI2, .leadingEdge = SPI2_LEADING_EDGE, .divisorMap = spiDivisorMapSlow }, - { .dev = SPI3, .nss = IO_TAG(SPI3_NSS_PIN), .sck = IO_TAG(SPI3_SCK_PIN), .miso = IO_TAG(SPI3_MISO_PIN), .mosi = IO_TAG(SPI3_MOSI_PIN), .rcc = RCC_APB1(SPI3), .af = GPIO_AF_SPI3, .leadingEdge = SPI3_LEADING_EDGE, .divisorMap = spiDivisorMapSlow } +#ifdef USE_SPI_DEVICE_1 + { .dev = SPI1, .nss = IO_TAG(SPI1_NSS_PIN), .sck = IO_TAG(SPI1_SCK_PIN), .miso = IO_TAG(SPI1_MISO_PIN), .mosi = IO_TAG(SPI1_MOSI_PIN), .rcc = RCC_APB2(SPI1), .af = GPIO_AF_SPI1, .divisorMap = spiDivisorMapFast }, +#else + { .dev = NULL }, // No SPI1 +#endif +#ifdef USE_SPI_DEVICE_2 + { .dev = SPI2, .nss = IO_TAG(SPI2_NSS_PIN), .sck = IO_TAG(SPI2_SCK_PIN), .miso = IO_TAG(SPI2_MISO_PIN), .mosi = IO_TAG(SPI2_MOSI_PIN), .rcc = RCC_APB1(SPI2), .af = GPIO_AF_SPI2, .divisorMap = spiDivisorMapSlow }, +#else + { .dev = NULL }, // No SPI2 +#endif +#ifdef USE_SPI_DEVICE_3 + { .dev = SPI3, .nss = IO_TAG(SPI3_NSS_PIN), .sck = IO_TAG(SPI3_SCK_PIN), .miso = IO_TAG(SPI3_MISO_PIN), .mosi = IO_TAG(SPI3_MOSI_PIN), .rcc = RCC_APB1(SPI3), .af = GPIO_AF_SPI3, .divisorMap = spiDivisorMapSlow }, +#else + { .dev = NULL }, // No SPI3 +#endif + { .dev = NULL }, // No SPI4 }; #else #error "Invalid CPU" @@ -150,10 +160,18 @@ SPIDevice spiDeviceByInstance(SPI_TypeDef *instance) return SPIINVALID; } -void spiInitDevice(SPIDevice device) +bool spiInitDevice(SPIDevice device, bool leadingEdge) { spiDevice_t *spi = &(spiHardwareMap[device]); + if (!spi->dev) { + return false; + } + + if (spi->initDone) { + return true; + } + // Enable SPI clock RCC_ClockCmd(spi->rcc, ENABLE); RCC_ResetCmd(spi->rcc, ENABLE); @@ -163,7 +181,7 @@ void spiInitDevice(SPIDevice device) IOInit(IOGetByTag(spi->mosi), OWNER_SPI, RESOURCE_SPI_MOSI, device + 1); #if defined(STM32F3) || defined(STM32F4) - if (spi->leadingEdge) { + if (leadingEdge) { IOConfigGPIOAF(IOGetByTag(spi->sck), SPI_IO_AF_SCK_CFG, spi->af); IOConfigGPIOAF(IOGetByTag(spi->miso), SPI_IO_AF_MISO_CFG, spi->af); IOConfigGPIOAF(IOGetByTag(spi->mosi), SPI_IO_AF_CFG, spi->af); @@ -190,7 +208,7 @@ void spiInitDevice(SPIDevice device) spiInit.SPI_CRCPolynomial = 7; spiInit.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; - if (spi->leadingEdge) { + if (leadingEdge) { // SPI_MODE0 spiInit.SPI_CPOL = SPI_CPOL_Low; spiInit.SPI_CPHA = SPI_CPHA_1Edge; @@ -212,43 +230,9 @@ void spiInitDevice(SPIDevice device) // Drive NSS high to disable connected SPI device. IOHi(IOGetByTag(spi->nss)); } -} -bool spiInit(SPIDevice device) -{ - switch (device) { - case SPIINVALID: - return false; - case SPIDEV_1: -#ifdef USE_SPI_DEVICE_1 - spiInitDevice(device); - return true; -#else - break; -#endif - case SPIDEV_2: -#ifdef USE_SPI_DEVICE_2 - spiInitDevice(device); - return true; -#else - break; -#endif - case SPIDEV_3: -#if defined(USE_SPI_DEVICE_3) && (defined(STM32F303xC) || defined(STM32F4)) - spiInitDevice(device); - return true; -#else - break; -#endif - case SPIDEV_4: -#if defined(USE_SPI_DEVICE_4) - spiInitDevice(device); - return true; -#else - break; -#endif - } - return false; + spi->initDone = true; + return true; } uint32_t spiTimeoutUserCallback(SPI_TypeDef *instance) diff --git a/src/main/drivers/bus_spi.h b/src/main/drivers/bus_spi.h index 616a89c548..a0970f119c 100644 --- a/src/main/drivers/bus_spi.h +++ b/src/main/drivers/bus_spi.h @@ -70,12 +70,12 @@ typedef struct SPIDevice_s { ioTag_t miso; rccPeriphTag_t rcc; uint8_t af; - bool leadingEdge; const uint16_t * divisorMap; volatile uint16_t errorCount; + bool initDone; } spiDevice_t; -bool spiInit(SPIDevice device); +bool spiInitDevice(SPIDevice device, bool leadingEdge); bool spiIsBusBusy(SPI_TypeDef *instance); void spiSetSpeed(SPI_TypeDef *instance, SPIClockSpeed_e speed); uint8_t spiTransferByte(SPI_TypeDef *instance, uint8_t in); diff --git a/src/main/drivers/bus_spi_hal.c b/src/main/drivers/bus_spi_hal.c index b4d5be9724..fd07aa587e 100644 --- a/src/main/drivers/bus_spi_hal.c +++ b/src/main/drivers/bus_spi_hal.c @@ -68,27 +68,6 @@ #define SPI4_NSS_PIN NONE #endif -#ifdef SPI1_CLOCK_LEADING_EDGE -# define SPI1_LEADING_EDGE true -#else -# define SPI1_LEADING_EDGE false -#endif -#ifdef SPI2_CLOCK_LEADING_EDGE -# define SPI2_LEADING_EDGE true -#else -# define SPI2_LEADING_EDGE false -#endif -#ifdef SPI3_CLOCK_LEADING_EDGE -# define SPI3_LEADING_EDGE true -#else -# define SPI3_LEADING_EDGE false -#endif -#ifdef SPI4_CLOCK_LEADING_EDGE -# define SPI4_LEADING_EDGE true -#else -# define SPI4_LEADING_EDGE false -#endif - static const uint16_t spiDivisorMapFast[] = { LL_SPI_BAUDRATEPRESCALER_DIV256, // SPI_CLOCK_INITIALIZATON 421.875 KBits/s LL_SPI_BAUDRATEPRESCALER_DIV32, // SPI_CLOCK_SLOW 843.75 KBits/s @@ -105,10 +84,26 @@ static const uint16_t spiDivisorMapSlow[] = { }; static spiDevice_t spiHardwareMap[] = { - { .dev = SPI1, .nss = IO_TAG(SPI1_NSS_PIN), .sck = IO_TAG(SPI1_SCK_PIN), .miso = IO_TAG(SPI1_MISO_PIN), .mosi = IO_TAG(SPI1_MOSI_PIN), .rcc = RCC_APB2(SPI1), .af = GPIO_AF5_SPI1, .leadingEdge = SPI1_LEADING_EDGE, .divisorMap = spiDivisorMapFast }, - { .dev = SPI2, .nss = IO_TAG(SPI2_NSS_PIN), .sck = IO_TAG(SPI2_SCK_PIN), .miso = IO_TAG(SPI2_MISO_PIN), .mosi = IO_TAG(SPI2_MOSI_PIN), .rcc = RCC_APB1(SPI2), .af = GPIO_AF5_SPI2, .leadingEdge = SPI2_LEADING_EDGE, .divisorMap = spiDivisorMapSlow }, - { .dev = SPI3, .nss = IO_TAG(SPI3_NSS_PIN), .sck = IO_TAG(SPI3_SCK_PIN), .miso = IO_TAG(SPI3_MISO_PIN), .mosi = IO_TAG(SPI3_MOSI_PIN), .rcc = RCC_APB1(SPI3), .af = GPIO_AF6_SPI3, .leadingEdge = SPI3_LEADING_EDGE, .divisorMap = spiDivisorMapSlow }, - { .dev = SPI4, .nss = IO_TAG(SPI4_NSS_PIN), .sck = IO_TAG(SPI4_SCK_PIN), .miso = IO_TAG(SPI4_MISO_PIN), .mosi = IO_TAG(SPI4_MOSI_PIN), .rcc = RCC_APB2(SPI4), .af = GPIO_AF5_SPI4, .leadingEdge = SPI4_LEADING_EDGE, .divisorMap = spiDivisorMapSlow } +#ifdef USE_SPI_DEVICE_1 + { .dev = SPI1, .nss = IO_TAG(SPI1_NSS_PIN), .sck = IO_TAG(SPI1_SCK_PIN), .miso = IO_TAG(SPI1_MISO_PIN), .mosi = IO_TAG(SPI1_MOSI_PIN), .rcc = RCC_APB2(SPI1), .af = GPIO_AF5_SPI1, .divisorMap = spiDivisorMapFast }, +#else + { .dev = NULL }, // No SPI1 +#endif +#ifdef USE_SPI_DEVICE_2 + { .dev = SPI2, .nss = IO_TAG(SPI2_NSS_PIN), .sck = IO_TAG(SPI2_SCK_PIN), .miso = IO_TAG(SPI2_MISO_PIN), .mosi = IO_TAG(SPI2_MOSI_PIN), .rcc = RCC_APB1(SPI2), .af = GPIO_AF5_SPI2, .divisorMap = spiDivisorMapSlow }, +#else + { .dev = NULL }, // No SPI2 +#endif +#ifdef USE_SPI_DEVICE_3 + { .dev = SPI3, .nss = IO_TAG(SPI3_NSS_PIN), .sck = IO_TAG(SPI3_SCK_PIN), .miso = IO_TAG(SPI3_MISO_PIN), .mosi = IO_TAG(SPI3_MOSI_PIN), .rcc = RCC_APB1(SPI3), .af = GPIO_AF6_SPI3, .divisorMap = spiDivisorMapSlow }, +#else + { .dev = NULL }, // No SPI3 +#endif +#ifdef USE_SPI_DEVICE_4 + { .dev = SPI4, .nss = IO_TAG(SPI4_NSS_PIN), .sck = IO_TAG(SPI4_SCK_PIN), .miso = IO_TAG(SPI4_MISO_PIN), .mosi = IO_TAG(SPI4_MOSI_PIN), .rcc = RCC_APB2(SPI4), .af = GPIO_AF5_SPI4, .divisorMap = spiDivisorMapSlow } +#else + { .dev = NULL } // No SPI4 +#endif }; SPIDevice spiDeviceByInstance(SPI_TypeDef *instance) @@ -138,12 +133,16 @@ void spiTimeoutUserCallback(SPI_TypeDef *instance) spiHardwareMap[device].errorCount++; } -void spiInitDevice(SPIDevice device) +bool spiInitDevice(SPIDevice device, bool leadingEdge) { spiDevice_t *spi = &(spiHardwareMap[device]); if (!spi->dev) { - return; + return false; + } + + if (spi->initDone) { + return true; } // Enable SPI clock @@ -154,7 +153,7 @@ void spiInitDevice(SPIDevice device) IOInit(IOGetByTag(spi->miso), OWNER_SPI, RESOURCE_SPI_MISO, device + 1); IOInit(IOGetByTag(spi->mosi), OWNER_SPI, RESOURCE_SPI_MOSI, device + 1); - if (spi->leadingEdge == true) { + if (leadingEdge) { IOConfigGPIOAF(IOGetByTag(spi->sck), SPI_IO_AF_SCK_CFG_LOW, spi->af); } else { IOConfigGPIOAF(IOGetByTag(spi->sck), SPI_IO_AF_SCK_CFG_HIGH, spi->af); @@ -175,8 +174,8 @@ void spiInitDevice(SPIDevice device) .TransferDirection = SPI_DIRECTION_2LINES, .Mode = SPI_MODE_MASTER, .DataWidth = SPI_DATASIZE_8BIT, - .ClockPolarity = spi->leadingEdge ? SPI_POLARITY_LOW : SPI_POLARITY_HIGH, - .ClockPhase = spi->leadingEdge ? SPI_PHASE_1EDGE : SPI_PHASE_2EDGE, + .ClockPolarity = leadingEdge ? SPI_POLARITY_LOW : SPI_POLARITY_HIGH, + .ClockPhase = leadingEdge ? SPI_PHASE_1EDGE : SPI_PHASE_2EDGE, .NSS = SPI_NSS_SOFT, .BaudRate = SPI_BAUDRATEPRESCALER_8, .BitOrder = SPI_FIRSTBIT_MSB, @@ -193,44 +192,9 @@ void spiInitDevice(SPIDevice device) if (spi->nss) { IOHi(IOGetByTag(spi->nss)); } -} -bool spiInit(SPIDevice device) -{ - switch (device) - { - case SPIINVALID: - return false; - case SPIDEV_1: -#if defined(USE_SPI_DEVICE_1) - spiInitDevice(device); - return true; -#else - break; -#endif - case SPIDEV_2: -#if defined(USE_SPI_DEVICE_2) - spiInitDevice(device); - return true; -#else - break; -#endif - case SPIDEV_3: -#if defined(USE_SPI_DEVICE_3) - spiInitDevice(device); - return true; -#else - break; -#endif - case SPIDEV_4: -#if defined(USE_SPI_DEVICE_4) - spiInitDevice(device); - return true; -#else - break; -#endif - } - return false; + spi->initDone = true; + return true; } uint8_t spiTransferByte(SPI_TypeDef *instance, uint8_t txByte) diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index ea8b37bffd..d327d685a8 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -381,27 +381,6 @@ void init(void) // Initialize buses busInit(); -#ifdef USE_SPI -#ifdef USE_SPI_DEVICE_1 - spiInit(SPIDEV_1); -#endif -#ifdef USE_SPI_DEVICE_2 - spiInit(SPIDEV_2); -#endif -#ifdef USE_SPI_DEVICE_3 -#ifdef ALIENFLIGHTF3 - if (hardwareRevision == AFF3_REV_2) { - spiInit(SPIDEV_3); - } -#else - spiInit(SPIDEV_3); -#endif -#endif -#ifdef USE_SPI_DEVICE_4 - spiInit(SPIDEV_4); -#endif -#endif - #ifdef USE_HARDWARE_REVISION_DETECTION updateHardwareRevision(); #endif diff --git a/src/main/target/ALIENFLIGHTF4/target.h b/src/main/target/ALIENFLIGHTF4/target.h index 9bdb5a1439..39bb130d0c 100644 --- a/src/main/target/ALIENFLIGHTF4/target.h +++ b/src/main/target/ALIENFLIGHTF4/target.h @@ -126,7 +126,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PC2 #define SPI2_MOSI_PIN PC3 -#define SPI2_CLOCK_LEADING_EDGE #define SPI3_NSS_PIN PA15 #define SPI3_SCK_PIN PB3 diff --git a/src/main/target/ALIENFLIGHTNGF7/target.h b/src/main/target/ALIENFLIGHTNGF7/target.h index 8eef1ed8eb..116cf92d5f 100644 --- a/src/main/target/ALIENFLIGHTNGF7/target.h +++ b/src/main/target/ALIENFLIGHTNGF7/target.h @@ -134,7 +134,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PC2 #define SPI2_MOSI_PIN PC3 -#define SPI2_CLOCK_LEADING_EDGE #define SPI3_NSS_PIN PA15 #define SPI3_SCK_PIN PB3 diff --git a/src/main/target/ANYFCF7/target.h b/src/main/target/ANYFCF7/target.h index b174105df9..293416a71d 100644 --- a/src/main/target/ANYFCF7/target.h +++ b/src/main/target/ANYFCF7/target.h @@ -129,7 +129,6 @@ #define SPI4_SCK_PIN PE12 #define SPI4_MISO_PIN PE13 #define SPI4_MOSI_PIN PE14 -#define SPI4_CLOCK_LEADING_EDGE #define USE_OSD #define USE_MAX7456 diff --git a/src/main/target/BEEROTORF4/target.h b/src/main/target/BEEROTORF4/target.h index 20a6963cb0..1c11634ba8 100644 --- a/src/main/target/BEEROTORF4/target.h +++ b/src/main/target/BEEROTORF4/target.h @@ -117,7 +117,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 #define SPI2_MOSI_PIN PB15 -#define SPI2_CLOCK_LEADING_EDGE //MAX7456 / SPI RX #define USE_SPI_DEVICE_3 diff --git a/src/main/target/BETAFLIGHTF3/target.h b/src/main/target/BETAFLIGHTF3/target.h index 978ef55dc1..3b70e722fc 100755 --- a/src/main/target/BETAFLIGHTF3/target.h +++ b/src/main/target/BETAFLIGHTF3/target.h @@ -83,7 +83,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 #define SPI2_MOSI_PIN PB15 -#define SPI2_CLOCK_LEADING_EDGE #define USE_OSD #define USE_MAX7456 diff --git a/src/main/target/BLUEJAYF4/target.h b/src/main/target/BLUEJAYF4/target.h index bf5dc37144..92184c0930 100644 --- a/src/main/target/BLUEJAYF4/target.h +++ b/src/main/target/BLUEJAYF4/target.h @@ -121,7 +121,6 @@ #define SPI3_SCK_PIN PC10 #define SPI3_MISO_PIN PC11 #define SPI3_MOSI_PIN PC12 -#define SPI3_CLOCK_LEADING_EDGE #define USE_I2C #define USE_I2C_DEVICE_1 diff --git a/src/main/target/F4BY/target.h b/src/main/target/F4BY/target.h index ade4be0ccb..bcdf88a1e8 100644 --- a/src/main/target/F4BY/target.h +++ b/src/main/target/F4BY/target.h @@ -108,7 +108,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 #define SPI2_MOSI_PIN PB15 -#define SPI2_CLOCK_LEADING_EDGE #define USE_SPI_DEVICE_3 #define SPI3_NSS_PIN PA15 diff --git a/src/main/target/FISHDRONEF4/target.h b/src/main/target/FISHDRONEF4/target.h index 9e8a1921cf..cadc1356e8 100644 --- a/src/main/target/FISHDRONEF4/target.h +++ b/src/main/target/FISHDRONEF4/target.h @@ -94,7 +94,6 @@ #define SPI3_MISO_PIN PB4 #define SPI3_MOSI_PIN PB5 #define SPI3_NSS_PIN PB6 -#define SPI3_CLOCK_LEADING_EDGE #define USE_SDCARD #define USE_SDCARD_SPI diff --git a/src/main/target/FRSKYF3/target.h b/src/main/target/FRSKYF3/target.h index 13a2bfad99..6fe5507157 100644 --- a/src/main/target/FRSKYF3/target.h +++ b/src/main/target/FRSKYF3/target.h @@ -82,7 +82,6 @@ #define SPI1_SCK_PIN PA5 #define SPI1_MISO_PIN PA6 #define SPI1_MOSI_PIN PA7 -#define SPI1_CLOCK_LEADING_EDGE #define USE_SDCARD #define USE_SDCARD_SPI diff --git a/src/main/target/FRSKYF4/target.h b/src/main/target/FRSKYF4/target.h index cefdc61f3a..b727701ace 100755 --- a/src/main/target/FRSKYF4/target.h +++ b/src/main/target/FRSKYF4/target.h @@ -84,7 +84,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 #define SPI2_MOSI_PIN PB15 -#define SPI2_CLOCK_LEADING_EDGE #define USE_SPI_DEVICE_3 #define SPI3_NSS_PIN PA15 diff --git a/src/main/target/FURYF3/target.h b/src/main/target/FURYF3/target.h index 41e0a22485..114ee507c3 100755 --- a/src/main/target/FURYF3/target.h +++ b/src/main/target/FURYF3/target.h @@ -92,7 +92,6 @@ #ifdef USE_SDCARD #define USE_SDCARD_SPI -#define SPI2_CLOCK_LEADING_EDGE #define SDCARD_DETECT_INVERTED #define SDCARD_DETECT_PIN PB2 diff --git a/src/main/target/FURYF4OSD/target.h b/src/main/target/FURYF4OSD/target.h index cc9296e955..d970ccb84e 100644 --- a/src/main/target/FURYF4OSD/target.h +++ b/src/main/target/FURYF4OSD/target.h @@ -60,7 +60,6 @@ #define SPI3_SCK_PIN PC10 #define SPI3_MISO_PIN PC11 #define SPI3_MOSI_PIN PC12 -#define SPI3_CLOCK_LEADING_EDGE // *************** M25P256 flash ******************** #define USE_FLASHFS diff --git a/src/main/target/KAKUTEF7/target.h b/src/main/target/KAKUTEF7/target.h index 9d0b44791e..7cb4383faa 100644 --- a/src/main/target/KAKUTEF7/target.h +++ b/src/main/target/KAKUTEF7/target.h @@ -84,7 +84,6 @@ #define SPI1_SCK_PIN PA5 #define SPI1_MISO_PIN PA6 #define SPI1_MOSI_PIN PA7 -#define SPI1_CLOCK_LEADING_EDGE #define SPI2_NSS_PIN PB12 #define SPI2_SCK_PIN PB13 diff --git a/src/main/target/KROOZX/target.h b/src/main/target/KROOZX/target.h index acbbb08865..924b619277 100755 --- a/src/main/target/KROOZX/target.h +++ b/src/main/target/KROOZX/target.h @@ -136,7 +136,6 @@ #define SPI3_SCK_PIN PB3 #define SPI3_MISO_PIN PB4 #define SPI3_MOSI_PIN PB5 -#define SPI3_CLOCK_LEADING_EDGE #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT diff --git a/src/main/target/MATEKF405/target.h b/src/main/target/MATEKF405/target.h index 6d635a92fd..201dfa3522 100644 --- a/src/main/target/MATEKF405/target.h +++ b/src/main/target/MATEKF405/target.h @@ -69,7 +69,6 @@ #define SPI3_SCK_PIN PB3 #define SPI3_MISO_PIN PB4 #define SPI3_MOSI_PIN PB5 -#define SPI3_CLOCK_LEADING_EDGE #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT diff --git a/src/main/target/MATEKF405SE/target.h b/src/main/target/MATEKF405SE/target.h index 39ec76c8e6..9660b84972 100644 --- a/src/main/target/MATEKF405SE/target.h +++ b/src/main/target/MATEKF405SE/target.h @@ -104,7 +104,6 @@ #define SPI3_SCK_PIN PB3 #define SPI3_MISO_PIN PB4 #define SPI3_MOSI_PIN PB5 -#define SPI3_CLOCK_LEADING_EDGE #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT diff --git a/src/main/target/MATEKF722/target.h b/src/main/target/MATEKF722/target.h index 5ae6150922..90dcc4e757 100755 --- a/src/main/target/MATEKF722/target.h +++ b/src/main/target/MATEKF722/target.h @@ -85,7 +85,6 @@ #define SPI3_SCK_PIN PB3 #define SPI3_MISO_PIN PB4 #define SPI3_MOSI_PIN PB5 -#define SPI3_CLOCK_LEADING_EDGE #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT diff --git a/src/main/target/MATEKF722SE/target.h b/src/main/target/MATEKF722SE/target.h index 5cf1b3cc28..837cb9d66e 100644 --- a/src/main/target/MATEKF722SE/target.h +++ b/src/main/target/MATEKF722SE/target.h @@ -122,7 +122,6 @@ # define SDCARD_SPI_BUS BUS_SPI3 # define SDCARD_CS_PIN PD2 # define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT -# define SPI3_CLOCK_LEADING_EDGE // TODO(digitalentity): implement DEVFLAGS_SPI_MODE_0 flag in SPI drivers #endif // *************** UART ***************************** diff --git a/src/main/target/OMNIBUS/target.h b/src/main/target/OMNIBUS/target.h index cccbce0120..1127030379 100644 --- a/src/main/target/OMNIBUS/target.h +++ b/src/main/target/OMNIBUS/target.h @@ -96,7 +96,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 #define SPI2_MOSI_PIN PB15 -#define SPI2_CLOCK_LEADING_EDGE //#define USE_RX_SPI #define RX_SPI_INSTANCE SPI2 diff --git a/src/main/target/OMNIBUSF4/target.h b/src/main/target/OMNIBUSF4/target.h index 6ab62f2550..11802f4f36 100644 --- a/src/main/target/OMNIBUSF4/target.h +++ b/src/main/target/OMNIBUSF4/target.h @@ -180,7 +180,6 @@ #if defined(OMNIBUSF4PRO) || defined(OMNIBUSF4V3) #define USE_SPI_DEVICE_2 - #define SPI2_CLOCK_LEADING_EDGE #define SPI2_NSS_PIN PB12 #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 diff --git a/src/main/target/OMNIBUSF7/target.h b/src/main/target/OMNIBUSF7/target.h index 8e7fcfb07d..c3a7262078 100644 --- a/src/main/target/OMNIBUSF7/target.h +++ b/src/main/target/OMNIBUSF7/target.h @@ -136,8 +136,6 @@ #define SPI4_SCK_PIN PE2 #define SPI4_MISO_PIN PE5 #define SPI4_MOSI_PIN PE6 -#define SPI4_CLOCK_LEADING_EDGE - #define USE_OSD #define USE_MAX7456 diff --git a/src/main/target/SPRACINGF3EVO/target.h b/src/main/target/SPRACINGF3EVO/target.h index 0259638054..7a4f57490a 100755 --- a/src/main/target/SPRACINGF3EVO/target.h +++ b/src/main/target/SPRACINGF3EVO/target.h @@ -109,7 +109,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 #define SPI2_MOSI_PIN PB15 -#define SPI2_CLOCK_LEADING_EDGE #define USE_SDCARD #define USE_SDCARD_SPI diff --git a/src/main/target/SPRACINGF3MINI/target.h b/src/main/target/SPRACINGF3MINI/target.h index 6cd241afd9..758bd30577 100644 --- a/src/main/target/SPRACINGF3MINI/target.h +++ b/src/main/target/SPRACINGF3MINI/target.h @@ -101,7 +101,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 #define SPI2_MOSI_PIN PB15 -#define SPI2_CLOCK_LEADING_EDGE #define USE_SDCARD #define USE_SDCARD_SPI diff --git a/src/main/target/SPRACINGF3NEO/target.h b/src/main/target/SPRACINGF3NEO/target.h index 3199a9eed8..465a829b4f 100755 --- a/src/main/target/SPRACINGF3NEO/target.h +++ b/src/main/target/SPRACINGF3NEO/target.h @@ -101,7 +101,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 #define SPI2_MOSI_PIN PB15 -#define SPI2_CLOCK_LEADING_EDGE #define SPI3_NSS_PIN PA15 #define SPI3_SCK_PIN PB3 diff --git a/src/main/target/SPRACINGF4EVO/target.h b/src/main/target/SPRACINGF4EVO/target.h index f48b9a24a4..b3a9b6c2a5 100755 --- a/src/main/target/SPRACINGF4EVO/target.h +++ b/src/main/target/SPRACINGF4EVO/target.h @@ -120,7 +120,6 @@ #define SPI2_SCK_PIN PB13 #define SPI2_MISO_PIN PB14 #define SPI2_MOSI_PIN PB15 -#define SPI2_CLOCK_LEADING_EDGE #define SPI3_NSS_PIN PA15 // NC #define SPI3_SCK_PIN PB3 // NC diff --git a/src/main/target/SPRACINGF7DUAL/target.h b/src/main/target/SPRACINGF7DUAL/target.h index d174add309..14b5d8726a 100644 --- a/src/main/target/SPRACINGF7DUAL/target.h +++ b/src/main/target/SPRACINGF7DUAL/target.h @@ -153,7 +153,6 @@ #define SPI3_SCK_PIN PB3 #define SPI3_MISO_PIN PB4 #define SPI3_MOSI_PIN PB5 -#define SPI3_CLOCK_LEADING_EDGE #define SDCARD_SPI_BUS BUS_SPI3 #define SDCARD_CS_PIN PC3 diff --git a/src/main/target/YUPIF4/target.h b/src/main/target/YUPIF4/target.h index 45202fd71d..edfe12c243 100644 --- a/src/main/target/YUPIF4/target.h +++ b/src/main/target/YUPIF4/target.h @@ -139,7 +139,6 @@ #define SPI3_SCK_PIN PC10 #define SPI3_MISO_PIN PC11 #define SPI3_MOSI_PIN PC12 -#define SPI3_CLOCK_LEADING_EDGE // ADC inputs #define BOARD_HAS_VOLTAGE_DIVIDER