From df70dc9574d28fbd65cc8e3a08cbc0d9b2d0bf46 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Thu, 9 Feb 2023 05:52:04 +0000 Subject: [PATCH] Fix BMI160 accelerometer read in non-DMA SPI transfer (#12338) --- src/main/drivers/accgyro/accgyro_spi_bmi160.c | 2 +- src/main/drivers/bus_spi.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/drivers/accgyro/accgyro_spi_bmi160.c b/src/main/drivers/accgyro/accgyro_spi_bmi160.c index 7a714d3ac..a48cab1cc 100644 --- a/src/main/drivers/accgyro/accgyro_spi_bmi160.c +++ b/src/main/drivers/accgyro/accgyro_spi_bmi160.c @@ -322,7 +322,7 @@ static bool bmi160AccRead(accDev_t *acc) case GYRO_EXTI_INT: case GYRO_EXTI_NO_INT: { - dev->txBuf[0] = BMI160_REG_ACC_DATA_X_LSB | 0x80; + dev->txBuf[1] = BMI160_REG_ACC_DATA_X_LSB | 0x80; busSegment_t segments[] = { {.u.buffers = {NULL, NULL}, 7, true, NULL}, diff --git a/src/main/drivers/bus_spi.c b/src/main/drivers/bus_spi.c index bc332dd40..a8167e95d 100644 --- a/src/main/drivers/bus_spi.c +++ b/src/main/drivers/bus_spi.c @@ -41,6 +41,10 @@ #define NUM_QUEUE_SEGS 5 +#if !defined(STM32G4) && !defined(STM32H7) && !defined(AT32F435) +#define USE_TX_IRQ_HANDLER +#endif + static uint8_t spiRegisteredDeviceCount = 0; spiDevice_t spiDevice[SPIDEV_COUNT]; @@ -501,7 +505,7 @@ FAST_IRQ_HANDLER static void spiRxIrqHandler(dmaChannelDescriptor_t* descriptor) spiIrqHandler(dev); } -#if !defined(STM32G4) && !defined(STM32H7) +#ifdef USE_TX_IRQ_HANDLER // Interrupt handler for SPI transmit DMA completion FAST_IRQ_HANDLER static void spiTxIrqHandler(dmaChannelDescriptor_t* descriptor) { @@ -671,7 +675,7 @@ void spiInitBusDMA(void) dmaSetHandler(dmaRxIdentifier, spiRxIrqHandler, NVIC_PRIO_SPI_DMA, 0); bus->useDMA = true; -#if !defined(STM32G4) && !defined(STM32H7) +#ifdef USE_TX_IRQ_HANDLER } else if (dmaTxIdentifier) { // Transmit on DMA is adequate for OSD so worth having bus->dmaTx = dmaGetDescriptorByIdentifier(dmaTxIdentifier); -- 2.11.4.GIT