From 1f9f221e0122b319f4b480689a2d0a9c65ff7f87 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 12:24:09 +0200 Subject: [PATCH 01/24] spi: data-ready reads on F4 and F7, through DMA The SPI of F7 has a 4-byte FIFO and that of F4 none, so there every data-ready read goes through two DMA streams. The SPI stays enabled, as for the main loop's transfers, and setting its DMA requests starts the read. The streams are taken like on H7, among the options the reference manual gives each request, at the end of initialisation. Nobody has tested this on an F4 or F7 board yet, so gyro_data_ready AUTO leaves it off there: ON turns it on. --- docs/Settings.md | 2 +- src/main/drivers/adc.h | 6 ++ src/main/drivers/adc_stm32f4xx.c | 26 +++++++ src/main/drivers/adc_stm32f7xx.c | 21 ++++++ src/main/drivers/bus_spi.c | 81 ++++++++++++++++++++++ src/main/drivers/bus_spi_data_ready_dma.c | 67 ++++++++++++++++-- src/main/drivers/bus_spi_data_ready_impl.h | 6 +- src/main/drivers/bus_spi_hal_ll.c | 54 ++++++++++++++- src/main/fc/settings.yaml | 2 +- src/main/target/common.h | 2 +- 10 files changed, 258 insertions(+), 9 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 82809020ba7..f608fdc6c92 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2140,7 +2140,7 @@ Gyro processing anti-aliasing filter cutoff frequency. In normal operation this ### gyro_data_ready -Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU (ICM-42605, ICM-42688-P) and a target that declares the interrupt pin. AUTO and ON do it, OFF polls the gyro. +Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU (ICM-42605, ICM-42688-P) and a target that declares the interrupt pin. AUTO does it on H7. On F4 and F7 the read goes through DMA and is new: set ON to try it, and please report how it works. OFF polls the gyro everywhere. | Allowed Values | | | --- | --- | diff --git a/src/main/drivers/adc.h b/src/main/drivers/adc.h index 1749c9fa63e..6955bbb987b 100644 --- a/src/main/drivers/adc.h +++ b/src/main/drivers/adc.h @@ -45,6 +45,12 @@ typedef struct drv_adc_config_s { void adcInit(drv_adc_config_t *init); uint16_t adcGetChannel(uint8_t channel); +#if defined(STM32F4) || defined(STM32F7) +struct dmaChannelDescriptor_s; +// ADC1 can use DMA2 stream 0 or stream 4. If it has `stream` and the other one is free, it moves +// there, for a user that can have only `stream`. For users that take their streams after everyone else +bool adcDmaMoveOff(struct dmaChannelDescriptor_s *stream); +#endif bool adcIsFunctionAssigned(uint8_t function); int adcGetFunctionChannelAllocation(uint8_t function); diff --git a/src/main/drivers/adc_stm32f4xx.c b/src/main/drivers/adc_stm32f4xx.c index 42f9583ed8c..f9ef7eb15cc 100644 --- a/src/main/drivers/adc_stm32f4xx.c +++ b/src/main/drivers/adc_stm32f4xx.c @@ -153,6 +153,32 @@ static void adcInstanceInit(ADCDevice adcDevice) ADC_SoftwareStartConv(adc->ADCx); } +bool adcDmaMoveOff(DMA_t stream) +{ + adcDevice_t *adc = &adcHardware[ADCDEV_1]; + if (!adc->enabled || dmaGetByRef(adc->DMAy_Streamx) != stream) { + return false; + } + DMA_Stream_TypeDef *other = adc->DMAy_Streamx == DMA2_Stream0 ? DMA2_Stream4 : DMA2_Stream0; + DMA_t otherDma = dmaGetByRef(other); + if (!otherDma || dmaGetOwner(otherDma) != OWNER_FREE) { + return false; + } + + // Stopped first: a conversion the DMA misses would be an overrun, which stops its requests + ADC_Cmd(adc->ADCx, DISABLE); + ADC_DMACmd(adc->ADCx, DISABLE); + DMA_Cmd(adc->DMAy_Streamx, DISABLE); + while (DMA_GetCmdStatus(adc->DMAy_Streamx) != DISABLE) { + } + ADC_ClearFlag(adc->ADCx, ADC_FLAG_OVR); + dmaInit(stream, OWNER_FREE, 0); + + adc->DMAy_Streamx = other; + adcInstanceInit(ADCDEV_1); + return true; +} + void adcHardwareInit(drv_adc_config_t *init) { UNUSED(init); diff --git a/src/main/drivers/adc_stm32f7xx.c b/src/main/drivers/adc_stm32f7xx.c index c680f2c379f..b9bea381237 100644 --- a/src/main/drivers/adc_stm32f7xx.c +++ b/src/main/drivers/adc_stm32f7xx.c @@ -164,6 +164,27 @@ static void adcInstanceInit(ADCDevice adcDevice) } } +bool adcDmaMoveOff(DMA_t stream) +{ + adcDevice_t *adc = &adcHardware[ADCDEV_1]; + if (!adc->enabled || dmaGetByRef(adc->DMAy_Streamx) != stream) { + return false; + } + DMA_Stream_TypeDef *other = adc->DMAy_Streamx == DMA2_Stream0 ? DMA2_Stream4 : DMA2_Stream0; + DMA_t otherDma = dmaGetByRef(other); + if (!otherDma || dmaGetOwner(otherDma) != OWNER_FREE) { + return false; + } + + HAL_ADC_Stop_DMA(&adc->ADCHandle); + HAL_DMA_DeInit(&adc->DmaHandle); + dmaInit(stream, OWNER_FREE, 0); + + adc->DMAy_Streamx = other; + adcInstanceInit(ADCDEV_1); + return true; +} + void adcHardwareInit(drv_adc_config_t *init) { UNUSED(init); diff --git a/src/main/drivers/bus_spi.c b/src/main/drivers/bus_spi.c index 8220ad01cd9..18f7a489cec 100644 --- a/src/main/drivers/bus_spi.c +++ b/src/main/drivers/bus_spi.c @@ -18,11 +18,14 @@ #include #include +#include + #include #ifdef USE_SPI #include "drivers/bus_spi.h" +#include "drivers/bus_spi_data_ready_impl.h" #include "drivers/exti.h" #include "drivers/io.h" #include "drivers/io_impl.h" @@ -248,6 +251,84 @@ bool spiTransfer(SPI_TypeDef *instance, uint8_t *out, const uint8_t *in, int len return true; } +#if defined(USE_SPI_DATA_READY) +// Data-ready reads (see bus_spi_data_ready.c). The F4 SPI has no FIFO, so every read uses two +// DMA streams; the buffers stay out of the CCM RAM, which the DMA can not reach + +// Longest read, address included +#define SPI_DATA_READY_MAX 32 + +typedef struct { + uint8_t len; // bytes after the address + spiDataReadyDma_t streams; +} spiDataReadyHw_t; + +static spiDataReadyHw_t spiDataReadyHw[SPIDEV_COUNT]; +static uint8_t spiDataReadyTx[SPIDEV_COUNT][SPI_DATA_READY_MAX]; +static uint8_t spiDataReadyRx[SPIDEV_COUNT][SPI_DATA_READY_MAX]; + +static void spiDataReadyDmaDone(DMA_t rx) +{ + const SPIDevice device = (SPIDevice)rx->userParam; + if (!spiDataReadyDmaEnded(rx)) { + // The read never ends: the main loop takes it off the bus when it next needs it + return; + } + + // A copy: a data-ready that came meanwhile starts the next read into the same buffer + uint8_t data[SPI_DATA_READY_MAX]; + memcpy(data, spiDataReadyRx[device] + 1, spiDataReadyHw[device].len); + spiDataReadyDone(device, data); +} + +bool spiDataReadyHwInit(SPIDevice device, uint8_t reg, uint8_t len) +{ + spiDataReadyHw_t *h = &spiDataReadyHw[device]; + if (!spiHardwareMap[device].dev || len + 1 > SPI_DATA_READY_MAX) { + return false; + } + if (!spiDataReadyDmaInit(device, &h->streams, spiDataReadyDmaDone, device)) { + return false; + } + + h->len = len; + memset(spiDataReadyTx[device], 0xFF, SPI_DATA_READY_MAX); + spiDataReadyTx[device][0] = reg; + return true; +} + +// Setting the DMA requests starts the read: receive first, as the reference manual has it +void spiDataReadyHwStart(SPIDevice device) +{ + const spiDataReadyHw_t *h = &spiDataReadyHw[device]; + SPI_TypeDef *instance = spiHardwareMap[device].dev; + + // A byte left in the data register would be taken for the first one of this read + (void)instance->DR; + spiDataReadyDmaStart(&h->streams, &instance->DR, &instance->DR, spiDataReadyTx[device], spiDataReadyRx[device], h->len + 1); + instance->CR2 |= SPI_CR2_RXDMAEN; + instance->CR2 |= SPI_CR2_TXDMAEN; +} + +void spiDataReadyHwStop(SPIDevice device) +{ + const spiDataReadyHw_t *h = &spiDataReadyHw[device]; + SPI_TypeDef *instance = spiHardwareMap[device].dev; + + spiDataReadyDmaStop(&h->streams); + instance->CR2 &= ~(SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); + + // A read stopped half way may leave a byte going out: let it finish and drop the echo + for (int timeout = 1000; timeout && (!(instance->SR & SPI_SR_TXE) || (instance->SR & SPI_SR_BSY)); timeout--); + (void)instance->DR; +} + +void spiDataReadyHwDisable(SPIDevice device) +{ + spiDataReadyDmaDisable(&spiDataReadyHw[device].streams); +} +#endif + void spiSetSpeed(SPI_TypeDef *instance, SPIClockSpeed_e speed) { #define BR_CLEAR_MASK 0xFFC7 diff --git a/src/main/drivers/bus_spi_data_ready_dma.c b/src/main/drivers/bus_spi_data_ready_dma.c index 3cec396c896..844e3127ec7 100644 --- a/src/main/drivers/bus_spi_data_ready_dma.c +++ b/src/main/drivers/bus_spi_data_ready_dma.c @@ -26,19 +26,24 @@ #include "drivers/bus_spi.h" -#if defined(USE_SPI_DATA_READY) && defined(STM32H7) +#if defined(USE_SPI_DATA_READY) && (defined(STM32F4) || defined(STM32F7) || defined(STM32H7)) #include "drivers/bus_spi_data_ready_impl.h" +#include "drivers/adc.h" #include "drivers/dma.h" #include "drivers/nvic.h" #include "drivers/resource.h" +#if defined(STM32H7) #include "stm32h7xx_ll_dma.h" +#endif // DMA streams for data-ready reads, taken at the end of init from those nobody owns; a bus with -// no free pair reads without DMA. H7 routes any request through its DMAMUX +// no free pair reads without DMA. H7 routes any request through its DMAMUX, F4/F7 have fixed ones #define SPI_DMA_FLAGS (DMA_IT_TCIF | DMA_IT_HTIF | DMA_IT_TEIF | DMA_IT_DMEIF | DMA_IT_FEIF) +// F4 and F7: the request's channel in the stream's CR (CHSEL) +#define SPI_DMA_CHSEL(ch) ((uint32_t)(ch) << 25) // Streams named for serial ports stay theirs: a port may open after init static const dmaTag_t spiDmaReserved[] = { @@ -106,6 +111,7 @@ static bool spiDmaIsFree(DMA_t d) return true; } +#if defined(STM32H7) static const uint32_t spiDmaRequest[SPIDEV_COUNT][2] = { { DMA_REQUEST_SPI1_RX, DMA_REQUEST_SPI1_TX }, { DMA_REQUEST_SPI2_RX, DMA_REQUEST_SPI2_TX }, @@ -125,9 +131,44 @@ static DMA_t spiDmaFindFree(DMA_t other) } return NULL; } +#else +// The streams, with their channel, each SPI's receive and transmit requests can use +static const dmaTag_t spiDmaOptions[SPIDEV_COUNT][2][2] = { + { { DMA_TAG(2, 0, 3), DMA_TAG(2, 2, 3) }, { DMA_TAG(2, 3, 3), DMA_TAG(2, 5, 3) } }, // SPI1 + { { DMA_TAG(1, 3, 0), DMA_NONE }, { DMA_TAG(1, 4, 0), DMA_NONE } }, // SPI2 + { { DMA_TAG(1, 0, 0), DMA_TAG(1, 2, 0) }, { DMA_TAG(1, 5, 0), DMA_TAG(1, 7, 0) } }, // SPI3 +#if defined(STM32F7) + { { DMA_TAG(2, 0, 4), DMA_TAG(2, 3, 5) }, { DMA_TAG(2, 1, 4), DMA_TAG(2, 4, 5) } }, // SPI4 +#endif +}; + +static DMA_t spiDmaFindFree(const dmaTag_t *options, uint32_t *channel) +{ + for (int i = 0; i < 2; i++) { + DMA_t d = options[i] ? dmaGetByTag(options[i]) : NULL; + if (spiDmaIsFree(d)) { + *channel = SPI_DMA_CHSEL(DMATAG_GET_CHANNEL(options[i])); + return d; + } + } +#if defined(USE_ADC) + // Both taken: move the ADC to its other stream (many boards give it DMA2 stream 0, and a timer + // the other stream SPI1 could receive on) + for (int i = 0; i < 2; i++) { + DMA_t d = options[i] ? dmaGetByTag(options[i]) : NULL; + if (d && dmaGetOwner(d) == OWNER_ADC && adcDmaMoveOff(d) && spiDmaIsFree(d)) { + *channel = SPI_DMA_CHSEL(DMATAG_GET_CHANNEL(options[i])); + return d; + } + } +#endif + return NULL; +} +#endif bool spiDataReadyDmaInit(SPIDevice device, spiDataReadyDma_t *dma, dmaCallbackHandlerFuncPtr done, uint32_t userParam) { +#if defined(STM32H7) DMA_t rx = spiDmaFindFree(NULL); DMA_t tx = spiDmaFindFree(rx); if (!rx || !tx) { @@ -135,6 +176,19 @@ bool spiDataReadyDmaInit(SPIDevice device, spiDataReadyDma_t *dma, dmaCallbackHa } LL_DMA_SetPeriphRequest(rx->dma, DMATAG_GET_STREAM(rx->tag), spiDmaRequest[device][0]); LL_DMA_SetPeriphRequest(tx->dma, DMATAG_GET_STREAM(tx->tag), spiDmaRequest[device][1]); +#else + DMA_t rx = spiDmaFindFree(spiDmaOptions[device][0], &dma->rxChannel); + if (!rx) { + return false; + } + // Owned before the transmit search: moving the ADC for that one must not put it back here + dmaInit(rx, OWNER_SPI, device + 1); + DMA_t tx = spiDmaFindFree(spiDmaOptions[device][1], &dma->txChannel); + if (!tx) { + dmaInit(rx, OWNER_FREE, 0); + return false; + } +#endif dmaInit(rx, OWNER_SPI, device + 1); dmaInit(tx, OWNER_SPI, device + 1); @@ -168,8 +222,13 @@ static void spiDmaStreamStart(DMA_t d, uint32_t cr, volatile void *periph, const void spiDataReadyDmaStart(const spiDataReadyDma_t *dma, volatile void *txReg, volatile void *rxReg, const uint8_t *tx, uint8_t *rx, uint16_t n) { - spiDmaStreamStart(dma->rx, DMA_SxCR_MINC | DMA_SxCR_PL_1 | DMA_SxCR_TCIE | DMA_SxCR_TEIE, rxReg, rx, n); - spiDmaStreamStart(dma->tx, DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PL_0, txReg, tx, n); +#if defined(STM32H7) + const uint32_t rxChannel = 0, txChannel = 0; // the DMAMUX routes the requests +#else + const uint32_t rxChannel = dma->rxChannel, txChannel = dma->txChannel; +#endif + spiDmaStreamStart(dma->rx, rxChannel | DMA_SxCR_MINC | DMA_SxCR_PL_1 | DMA_SxCR_TCIE | DMA_SxCR_TEIE, rxReg, rx, n); + spiDmaStreamStart(dma->tx, txChannel | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PL_0, txReg, tx, n); } void spiDataReadyDmaStop(const spiDataReadyDma_t *dma) diff --git a/src/main/drivers/bus_spi_data_ready_impl.h b/src/main/drivers/bus_spi_data_ready_impl.h index 216219f9187..ce0f18a6001 100644 --- a/src/main/drivers/bus_spi_data_ready_impl.h +++ b/src/main/drivers/bus_spi_data_ready_impl.h @@ -40,13 +40,17 @@ void spiTimeoutUserCallback(SPI_TypeDef *instance); uint32_t spiTimeoutUserCallback(SPI_TypeDef *instance); #endif -#if defined(STM32H7) +#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) #include "drivers/dma.h" // Reads longer than the SPI FIFO go through two DMA streams (bus_spi_data_ready_dma.c) typedef struct { DMA_t rx; DMA_t tx; +#if defined(STM32F4) || defined(STM32F7) + uint32_t rxChannel; // the stream's channel for this SPI + uint32_t txChannel; +#endif } spiDataReadyDma_t; // Takes a free stream for each direction. done() runs at the end of each read, or when the diff --git a/src/main/drivers/bus_spi_hal_ll.c b/src/main/drivers/bus_spi_hal_ll.c index 60a760ff294..1f2ab33e5d4 100644 --- a/src/main/drivers/bus_spi_hal_ll.c +++ b/src/main/drivers/bus_spi_hal_ll.c @@ -494,7 +494,7 @@ bool spiTransfer(SPI_TypeDef *instance, uint8_t *rxData, const uint8_t *txData, #if defined(USE_SPI_DATA_READY) // Data-ready reads (see bus_spi_data_ready.c). On H7 a read that fits the SPI FIFO (16 bytes on // SPI1-3, 8 on SPI4-6) needs no DMA: the end-of-transfer interrupt takes it all back. Longer -// reads use two DMA streams +// reads, and all on F7 (4-byte FIFO), use two DMA streams // Longest read, address included #define SPI_DATA_READY_MAX 32 @@ -541,6 +541,7 @@ static bool spiDataReadyDmaSetup(SPIDevice device) return true; } +#if defined(STM32H7) static const IRQn_Type spiIrq[SPIDEV_COUNT] = { SPI1_IRQn, SPI2_IRQn, SPI3_IRQn, SPI4_IRQn }; static uint8_t spiFifoSize(SPI_TypeDef *instance) @@ -647,6 +648,57 @@ void SPI3_IRQHandler(void) { spiDataReadyIrqHandler(SPIDEV_3); } void SPI4_IRQHandler(void) { spiDataReadyIrqHandler(SPIDEV_4); } #endif +#else // STM32F7 + +bool spiDataReadyHwInit(SPIDevice device, uint8_t reg, uint8_t len) +{ + SPI_TypeDef *instance = spiHardwareMap[device].dev; + spiDataReadyHw_t *h = &spiDataReadyHw[device]; + if (!instance || len + 1 > SPI_DATA_READY_MAX) { + return false; + } + + h->reg = reg; + h->len = len; + return spiDataReadyDmaSetup(device); +} + +// Setting the DMA requests starts the read: receive first, as the reference manual has it +void spiDataReadyHwStart(SPIDevice device) +{ + const spiDataReadyHw_t *h = &spiDataReadyHw[device]; + SPI_TypeDef *instance = spiHardwareMap[device].dev; + + // A byte left in the receive FIFO would be taken for the first one of this read + for (int n = 0; n < 8 && LL_SPI_GetRxFIFOLevel(instance) != LL_SPI_RX_FIFO_EMPTY; n++) { + (void)LL_SPI_ReceiveData8(instance); + } + spiDataReadyDmaStart(&h->streams, &instance->DR, &instance->DR, spiDataReadyTx[device], spiDataReadyRx[device], h->len + 1); + SET_BIT(instance->CR2, SPI_CR2_RXDMAEN); + SET_BIT(instance->CR2, SPI_CR2_TXDMAEN); +} + +void spiDataReadyHwStop(SPIDevice device) +{ + const spiDataReadyHw_t *h = &spiDataReadyHw[device]; + SPI_TypeDef *instance = spiHardwareMap[device].dev; + + spiDataReadyDmaStop(&h->streams); + CLEAR_BIT(instance->CR2, SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); + + // A read stopped half way leaves bytes behind: send them and drop what comes back, or the main + // loop's next transfer would take it for its own + for (int timeout = 1000; timeout && (LL_SPI_GetTxFIFOLevel(instance) != LL_SPI_TX_FIFO_EMPTY || LL_SPI_IsActiveFlag_BSY(instance)); timeout--); + for (int n = 0; n < 8 && LL_SPI_GetRxFIFOLevel(instance) != LL_SPI_RX_FIFO_EMPTY; n++) { + (void)LL_SPI_ReceiveData8(instance); + } +} + +void spiDataReadyHwDisable(SPIDevice device) +{ + spiDataReadyDmaDisable(&spiDataReadyHw[device].streams); +} +#endif #endif void spiSetSpeed(SPI_TypeDef *instance, SPIClockSpeed_e speed) diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 149922dd18c..c5ab8f34ed3 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -353,7 +353,7 @@ groups: field: gyro_secondary_enabled type: bool - name: gyro_data_ready - description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU (ICM-42605, ICM-42688-P) and a target that declares the interrupt pin. AUTO and ON do it, OFF polls the gyro." + description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU (ICM-42605, ICM-42688-P) and a target that declares the interrupt pin. AUTO does it on H7. On F4 and F7 the read goes through DMA and is new: set ON to try it, and please report how it works. OFF polls the gyro everywhere." default_value: "AUTO" condition: USE_SPI_DATA_READY field: gyro_data_ready diff --git a/src/main/target/common.h b/src/main/target/common.h index b2c31746e48..59bc211aa0d 100644 --- a/src/main/target/common.h +++ b/src/main/target/common.h @@ -18,7 +18,7 @@ #pragma once // SPI reads started by a device's data-ready interrupt (drivers/bus_spi_data_ready.c) -#if defined(STM32H7) +#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) #define USE_SPI_DATA_READY #endif From 697e995e50d37a3aa8281a1a5d7a9c87f1a75628 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 12:24:09 +0200 Subject: [PATCH 02/24] targets: gyro data-ready pins on F4 and F7 boards Pins added where INAV and Betaflight's config for the same board agree on the gyro's CS pin and SPI bus. In a folder with several targets the pin goes only to those Betaflight confirms. Two targets had a pin that disagreed with Betaflight and is fixed: KAKUTEF4WING (PB12, now PB2) and AOCODARCF405AIO (PC5, now PC4, as on the rest of the Aocoda F405 family, where PC5 is a PINIO). INAV never read those pins, so the wrong values never showed. --- src/main/target/AIKONF4V2/target.h | 1 + src/main/target/AOCODARCF405AIO/target.h | 6 +++--- src/main/target/AOCODARCF722AIO/target.c | 2 +- src/main/target/AXISFLYINGF7PRO/target.h | 1 + src/main/target/BETAFPVF722/target.h | 1 + src/main/target/BLADE_F4/target.h | 1 + src/main/target/BOTWINGF405/target.h | 1 + src/main/target/BOTWINGF722/target.h | 1 + src/main/target/BROTHERHOBBYF405V3/target.h | 1 + src/main/target/CADDXF4_AIO_ELRS/target.h | 1 + src/main/target/DAKEFPVF405/target.h | 1 + src/main/target/DAKEFPVF722/target.h | 1 + src/main/target/FLASHHOBBYF405/target.h | 1 + src/main/target/FLASHHOBBYF722/target.h | 1 + src/main/target/FLYWOOF405PRO/target.h | 1 + src/main/target/FLYWOOF722PRO/target.c | 2 +- src/main/target/FLYWOOF722PRO/target.h | 1 + src/main/target/FLYWOOF745/target.h | 1 + src/main/target/FOXEERF405V2/target.h | 1 + src/main/target/FOXEERF722V4/target.h | 1 + src/main/target/FOXEERF745AIO/target.h | 1 + src/main/target/FURYF4OSD/target.h | 3 +++ src/main/target/GEPRCF405/target.h | 1 + src/main/target/GEPRCF405_BT_HD/target.h | 1 + src/main/target/GEPRCF722/target.h | 1 + src/main/target/GEPRCF722_BT_HD/target.h | 1 + src/main/target/GEPRCF745_BT_HD/target.c | 8 ++++---- src/main/target/GEPRCF745_BT_HD/target.h | 2 ++ src/main/target/GEPRC_F722_AIO/target.h | 1 + src/main/target/HAKRCF405D/target.c | 2 +- src/main/target/HAKRCF405D/target.h | 1 + src/main/target/HAKRCF405V2/target.h | 1 + src/main/target/HAKRCF411D/target.h | 1 + src/main/target/HAKRCF722V2/target.c | 12 ++++++------ src/main/target/HAKRCF722V2/target.h | 2 ++ src/main/target/HGLRCF405V2/target.h | 1 + src/main/target/HUMMINGBIRD_FC305/target.c | 2 +- src/main/target/HUMMINGBIRD_FC305/target.h | 1 + src/main/target/IFLIGHT_BLITZ_F722/target.h | 1 + src/main/target/IFLIGHT_BLITZ_F722_X1/target.h | 1 + src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h | 1 + src/main/target/JHEF405PRO/target.h | 1 + src/main/target/KAKUTEF4/target.h | 3 +++ src/main/target/KAKUTEF4WING/target.h | 2 +- src/main/target/MAMBAF405_2022A/target.h | 1 + src/main/target/MAMBAF722_2022A/target.h | 1 + src/main/target/MATEKF405SE/target.h | 1 + src/main/target/MATEKF405TE/target.h | 1 + src/main/target/PRINCIPIOTF7/target.h | 1 + src/main/target/RADIOLINKF405/target.h | 1 + src/main/target/RADIOLINKF722/target.c | 2 +- src/main/target/RADIOLINKF722/target.h | 1 + src/main/target/SKYSTARSF405HD/target.h | 3 +++ src/main/target/SKYSTARSF405V2/target.h | 1 + src/main/target/SOLOGOODF722/target.h | 1 + src/main/target/SPEDIXF405/target.h | 1 + src/main/target/SPEDIXF722/target.h | 1 + src/main/target/SPEEDYBEEF405AIO/target.h | 1 + src/main/target/SPEEDYBEEF405MINI/target.h | 1 + src/main/target/SPEEDYBEEF405V4/target.c | 2 +- src/main/target/SPEEDYBEEF405V4/target.h | 1 + src/main/target/TAKERF722SE/target.h | 1 + src/main/target/TMOTORF7/target.h | 3 +++ src/main/target/TMOTORF7V2/target.h | 1 + src/main/target/TMOTORVELOXF7V2/target.h | 1 + src/main/target/WARPF7/target.h | 1 + 66 files changed, 86 insertions(+), 20 deletions(-) diff --git a/src/main/target/AIKONF4V2/target.h b/src/main/target/AIKONF4V2/target.h index a93415371bd..d2c2ff7c0bc 100644 --- a/src/main/target/AIKONF4V2/target.h +++ b/src/main/target/AIKONF4V2/target.h @@ -96,6 +96,7 @@ #define IMU_MPU6000_ALIGN CW0_DEG #define USE_IMU_ICM42605 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 #define IMU_ICM42605_ALIGN CW90_DEG // OSD diff --git a/src/main/target/AOCODARCF405AIO/target.h b/src/main/target/AOCODARCF405AIO/target.h index d732ebdd042..f7593f11ffd 100644 --- a/src/main/target/AOCODARCF405AIO/target.h +++ b/src/main/target/AOCODARCF405AIO/target.h @@ -65,19 +65,19 @@ #define USE_IMU_MPU6500 #define MPU6500_CS_PIN PA4 #define MPU6500_SPI_BUS BUS_SPI1 -#define MPU6500_EXTI_PIN PC5 +#define MPU6500_EXTI_PIN PC4 #define IMU_MPU6500_ALIGN CW90_DEG #define USE_IMU_MPU6000 #define MPU6000_CS_PIN PA4 #define MPU6000_SPI_BUS BUS_SPI1 -#define MPU6000_EXTI_PIN PC5 +#define MPU6000_EXTI_PIN PC4 #define IMU_MPU6000_ALIGN CW90_DEG #define USE_IMU_BMI270 #define BMI270_CS_PIN PA4 #define BMI270_SPI_BUS BUS_SPI1 -#define BMI270_EXTI_PIN PC5 +#define BMI270_EXTI_PIN PC4 #define IMU_BMI270_ALIGN CW90_DEG /*** I2C (Baro & Mag) ***/ diff --git a/src/main/target/AOCODARCF722AIO/target.c b/src/main/target/AOCODARCF722AIO/target.c index 84ccbfd6708..7ec1ee6880a 100644 --- a/src/main/target/AOCODARCF722AIO/target.c +++ b/src/main/target/AOCODARCF722AIO/target.c @@ -26,7 +26,7 @@ BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_icm42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); timerHardware_t timerHardware[] = { // DEF_TIM(TIM9, CH2, PA3, TIM_USE_PPM, 0, 0), // PPM diff --git a/src/main/target/AXISFLYINGF7PRO/target.h b/src/main/target/AXISFLYINGF7PRO/target.h index 39c94e47e9a..d40c74483f8 100644 --- a/src/main/target/AXISFLYINGF7PRO/target.h +++ b/src/main/target/AXISFLYINGF7PRO/target.h @@ -57,6 +57,7 @@ #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW0_DEG diff --git a/src/main/target/BETAFPVF722/target.h b/src/main/target/BETAFPVF722/target.h index cab6d2ff146..886b2659036 100755 --- a/src/main/target/BETAFPVF722/target.h +++ b/src/main/target/BETAFPVF722/target.h @@ -44,6 +44,7 @@ #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG diff --git a/src/main/target/BLADE_F4/target.h b/src/main/target/BLADE_F4/target.h index 71cf76cc0cf..125f1327897 100644 --- a/src/main/target/BLADE_F4/target.h +++ b/src/main/target/BLADE_F4/target.h @@ -69,6 +69,7 @@ #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 //BMI270 #define USE_IMU_BMI270 diff --git a/src/main/target/BOTWINGF405/target.h b/src/main/target/BOTWINGF405/target.h index f4860c653a5..7e4312c753f 100644 --- a/src/main/target/BOTWINGF405/target.h +++ b/src/main/target/BOTWINGF405/target.h @@ -73,6 +73,7 @@ */ #define USE_IMU_ICM42605 #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 #define IMU_ICM42605_ALIGN CW0_DEG diff --git a/src/main/target/BOTWINGF722/target.h b/src/main/target/BOTWINGF722/target.h index 2d3823f2a04..e31d6859074 100644 --- a/src/main/target/BOTWINGF722/target.h +++ b/src/main/target/BOTWINGF722/target.h @@ -46,6 +46,7 @@ // #define ICM42605_CS_PIN SPI3_NSS_PIN #define ICM42605_CS_PIN PD2 +#define ICM42605_EXTI_PIN PC13 #define ICM42605_SPI_BUS BUS_SPI3 #define USE_BEEPER diff --git a/src/main/target/BROTHERHOBBYF405V3/target.h b/src/main/target/BROTHERHOBBYF405V3/target.h index 9a9115bbf36..d01b4789af9 100644 --- a/src/main/target/BROTHERHOBBYF405V3/target.h +++ b/src/main/target/BROTHERHOBBYF405V3/target.h @@ -97,6 +97,7 @@ // Gyro & ACC #define USE_IMU_ICM42605 #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 #define IMU_ICM42605_ALIGN CW90_DEG diff --git a/src/main/target/CADDXF4_AIO_ELRS/target.h b/src/main/target/CADDXF4_AIO_ELRS/target.h index 85a1718f684..0a46b81eb4a 100644 --- a/src/main/target/CADDXF4_AIO_ELRS/target.h +++ b/src/main/target/CADDXF4_AIO_ELRS/target.h @@ -35,6 +35,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 #define USE_BARO diff --git a/src/main/target/DAKEFPVF405/target.h b/src/main/target/DAKEFPVF405/target.h index 30834b7682b..9f6c37cbf95 100644 --- a/src/main/target/DAKEFPVF405/target.h +++ b/src/main/target/DAKEFPVF405/target.h @@ -66,6 +66,7 @@ #define IMU_ICM42605_ALIGN CW90_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW90_DEG diff --git a/src/main/target/DAKEFPVF722/target.h b/src/main/target/DAKEFPVF722/target.h index 7d993971a40..ddf980860ca 100644 --- a/src/main/target/DAKEFPVF722/target.h +++ b/src/main/target/DAKEFPVF722/target.h @@ -66,6 +66,7 @@ #define IMU_ICM42605_ALIGN CW90_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW90_DEG diff --git a/src/main/target/FLASHHOBBYF405/target.h b/src/main/target/FLASHHOBBYF405/target.h index 937917c95c1..8f71f0967f1 100644 --- a/src/main/target/FLASHHOBBYF405/target.h +++ b/src/main/target/FLASHHOBBYF405/target.h @@ -49,6 +49,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/FLASHHOBBYF722/target.h b/src/main/target/FLASHHOBBYF722/target.h index f0cc7881352..7a816fc85f4 100644 --- a/src/main/target/FLASHHOBBYF722/target.h +++ b/src/main/target/FLASHHOBBYF722/target.h @@ -47,6 +47,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/FLYWOOF405PRO/target.h b/src/main/target/FLYWOOF405PRO/target.h index 22ddd0a6fd2..4fd4ee9fbfa 100644 --- a/src/main/target/FLYWOOF405PRO/target.h +++ b/src/main/target/FLYWOOF405PRO/target.h @@ -50,6 +50,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW180_DEG_FLIP #define ICM42605_CS_PIN PB12 +#define ICM42605_EXTI_PIN GYRO_INT_EXTI #define ICM42605_SPI_BUS BUS_SPI1 #define USE_EXTI diff --git a/src/main/target/FLYWOOF722PRO/target.c b/src/main/target/FLYWOOF722PRO/target.c index e8b78979f95..7eba2b3344e 100644 --- a/src/main/target/FLYWOOF722PRO/target.c +++ b/src/main/target/FLYWOOF722PRO/target.c @@ -27,7 +27,7 @@ BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_ICM42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_ICM42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_BMI270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/FLYWOOF722PRO/target.h b/src/main/target/FLYWOOF722PRO/target.h index 3f11b44e317..0db06779723 100644 --- a/src/main/target/FLYWOOF722PRO/target.h +++ b/src/main/target/FLYWOOF722PRO/target.h @@ -42,6 +42,7 @@ #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC3 #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG diff --git a/src/main/target/FLYWOOF745/target.h b/src/main/target/FLYWOOF745/target.h index d00c2455945..a54899f5f02 100644 --- a/src/main/target/FLYWOOF745/target.h +++ b/src/main/target/FLYWOOF745/target.h @@ -49,6 +49,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_CS_PIN SPI4_NSS_PIN +#define ICM42605_EXTI_PIN PE1 #define ICM42605_SPI_BUS BUS_SPI4 #define USB_IO diff --git a/src/main/target/FOXEERF405V2/target.h b/src/main/target/FOXEERF405V2/target.h index 1b0a3e65134..93b787cf418 100644 --- a/src/main/target/FOXEERF405V2/target.h +++ b/src/main/target/FOXEERF405V2/target.h @@ -76,6 +76,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 diff --git a/src/main/target/FOXEERF722V4/target.h b/src/main/target/FOXEERF722V4/target.h index fe6d4279d26..d764f3399d8 100644 --- a/src/main/target/FOXEERF722V4/target.h +++ b/src/main/target/FOXEERF722V4/target.h @@ -31,6 +31,7 @@ #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PB2 +#define ICM42605_EXTI_PIN PC4 #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG diff --git a/src/main/target/FOXEERF745AIO/target.h b/src/main/target/FOXEERF745AIO/target.h index 860ea18d861..43886731db3 100644 --- a/src/main/target/FOXEERF745AIO/target.h +++ b/src/main/target/FOXEERF745AIO/target.h @@ -32,6 +32,7 @@ #define IMU_ICM42605_ALIGN CW90_DEG #define ICM42605_SPI_BUS BUS_SPI3 #define ICM42605_CS_PIN PA15 +#define ICM42605_EXTI_PIN PD0 #else diff --git a/src/main/target/FURYF4OSD/target.h b/src/main/target/FURYF4OSD/target.h index 71abc9a8c68..6b6b3f6d8a9 100644 --- a/src/main/target/FURYF4OSD/target.h +++ b/src/main/target/FURYF4OSD/target.h @@ -50,6 +50,9 @@ #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 +#ifndef MAMBAF405 +#define ICM42605_EXTI_PIN PC4 +#endif #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT #define USE_SPI_DEVICE_3 diff --git a/src/main/target/GEPRCF405/target.h b/src/main/target/GEPRCF405/target.h index 0b96d5b8b1e..f35a4bd7e8c 100644 --- a/src/main/target/GEPRCF405/target.h +++ b/src/main/target/GEPRCF405/target.h @@ -54,6 +54,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_CS_PIN PA15 +#define ICM42605_EXTI_PIN PC3 #define ICM42605_SPI_BUS BUS_SPI3 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/GEPRCF405_BT_HD/target.h b/src/main/target/GEPRCF405_BT_HD/target.h index 185a3970a11..e76ce06e305 100644 --- a/src/main/target/GEPRCF405_BT_HD/target.h +++ b/src/main/target/GEPRCF405_BT_HD/target.h @@ -52,6 +52,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_CS_PIN PA15 +#define ICM42605_EXTI_PIN PC3 #define ICM42605_SPI_BUS BUS_SPI3 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/GEPRCF722/target.h b/src/main/target/GEPRCF722/target.h index df7cc6d3eca..a0ca42a6bbc 100644 --- a/src/main/target/GEPRCF722/target.h +++ b/src/main/target/GEPRCF722/target.h @@ -51,6 +51,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_CS_PIN PA15 +#define ICM42605_EXTI_PIN PC3 #define ICM42605_SPI_BUS BUS_SPI3 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/GEPRCF722_BT_HD/target.h b/src/main/target/GEPRCF722_BT_HD/target.h index e388203c6aa..450324aff43 100644 --- a/src/main/target/GEPRCF722_BT_HD/target.h +++ b/src/main/target/GEPRCF722_BT_HD/target.h @@ -49,6 +49,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_CS_PIN PA15 +#define ICM42605_EXTI_PIN PA8 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/GEPRCF745_BT_HD/target.c b/src/main/target/GEPRCF745_BT_HD/target.c index 91f9957fefc..de23e37be15 100644 --- a/src/main/target/GEPRCF745_BT_HD/target.c +++ b/src/main/target/GEPRCF745_BT_HD/target.c @@ -26,11 +26,11 @@ #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, IMU1_SPI_BUS, IMU1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU1_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_2, DEVHW_MPU6000, IMU2_SPI_BUS, IMU2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU2_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, IMU1_SPI_BUS, IMU1_CS_PIN, IMU1_EXTI_PIN, 0, DEVFLAGS_NONE, IMU1_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_2, DEVHW_MPU6000, IMU2_SPI_BUS, IMU2_CS_PIN, IMU2_EXTI_PIN, 1, DEVFLAGS_NONE, IMU2_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, IMU1_SPI_BUS, IMU1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU1_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688_2, DEVHW_ICM42605, IMU2_SPI_BUS, IMU2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU2_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, IMU1_SPI_BUS, IMU1_CS_PIN, IMU1_EXTI_PIN, 0, DEVFLAGS_NONE, IMU1_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688_2, DEVHW_ICM42605, IMU2_SPI_BUS, IMU2_CS_PIN, IMU2_EXTI_PIN, 1, DEVFLAGS_NONE, IMU2_ALIGN); diff --git a/src/main/target/GEPRCF745_BT_HD/target.h b/src/main/target/GEPRCF745_BT_HD/target.h index c6c84a32ad3..dbd5772c40e 100644 --- a/src/main/target/GEPRCF745_BT_HD/target.h +++ b/src/main/target/GEPRCF745_BT_HD/target.h @@ -65,6 +65,7 @@ #define IMU1_ALIGN CW180_DEG #define IMU1_SPI_BUS BUS_SPI1 #define IMU1_CS_PIN PA4 +#define IMU1_EXTI_PIN PD0 @@ -72,6 +73,7 @@ #define IMU2_ALIGN CW0_DEG #define IMU2_SPI_BUS BUS_SPI2 #define IMU2_CS_PIN PB12 +#define IMU2_EXTI_PIN PD8 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/GEPRC_F722_AIO/target.h b/src/main/target/GEPRC_F722_AIO/target.h index ee2b9330552..eed916d473f 100644 --- a/src/main/target/GEPRC_F722_AIO/target.h +++ b/src/main/target/GEPRC_F722_AIO/target.h @@ -53,6 +53,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW90_DEG #define ICM42605_CS_PIN PA15 +#define ICM42605_EXTI_PIN PA8 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/HAKRCF405D/target.c b/src/main/target/HAKRCF405D/target.c index 14447efed4b..ffdecfc6c64 100644 --- a/src/main/target/HAKRCF405D/target.c +++ b/src/main/target/HAKRCF405D/target.c @@ -25,7 +25,7 @@ #include "drivers/sensor.h" BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); diff --git a/src/main/target/HAKRCF405D/target.h b/src/main/target/HAKRCF405D/target.h index d47ec61dc99..f626ab22d85 100644 --- a/src/main/target/HAKRCF405D/target.h +++ b/src/main/target/HAKRCF405D/target.h @@ -67,6 +67,7 @@ #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC3 //BMI270 #define USE_IMU_BMI270 diff --git a/src/main/target/HAKRCF405V2/target.h b/src/main/target/HAKRCF405V2/target.h index 85cc164230b..e48a6e7c3a2 100644 --- a/src/main/target/HAKRCF405V2/target.h +++ b/src/main/target/HAKRCF405V2/target.h @@ -68,6 +68,7 @@ #define IMU_ICM42605_ALIGN CW90_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 //BMI270 #define USE_IMU_BMI270 diff --git a/src/main/target/HAKRCF411D/target.h b/src/main/target/HAKRCF411D/target.h index 5b3a479ed19..a67932cb9c5 100644 --- a/src/main/target/HAKRCF411D/target.h +++ b/src/main/target/HAKRCF411D/target.h @@ -59,6 +59,7 @@ #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PA1 //BMI270 #define USE_IMU_BMI270 diff --git a/src/main/target/HAKRCF722V2/target.c b/src/main/target/HAKRCF722V2/target.c index 9738db56d0c..14ef569f08f 100644 --- a/src/main/target/HAKRCF722V2/target.c +++ b/src/main/target/HAKRCF722V2/target.c @@ -23,14 +23,14 @@ #include "drivers/sensor.h" #include "drivers/pwm_mapping.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, GYRO_SPI_BUS, GYRO1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_2, DEVHW_MPU6000, GYRO_SPI_BUS, GYRO2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, GYRO_SPI_BUS, GYRO1_CS_PIN, GYRO1_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_2, DEVHW_MPU6000, GYRO_SPI_BUS, GYRO2_CS_PIN, GYRO2_EXTI_PIN, 1, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, GYRO_SPI_BUS, GYRO1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688_2, DEVHW_ICM42605, GYRO_SPI_BUS, GYRO2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, GYRO_SPI_BUS, GYRO1_CS_PIN, GYRO1_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688_2, DEVHW_ICM42605, GYRO_SPI_BUS, GYRO2_CS_PIN, GYRO2_EXTI_PIN, 1, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, GYRO_SPI_BUS, GYRO1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270_2, DEVHW_BMI270, GYRO_SPI_BUS, GYRO2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, GYRO_SPI_BUS, GYRO1_CS_PIN, GYRO1_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270_2, DEVHW_BMI270, GYRO_SPI_BUS, GYRO2_CS_PIN, GYRO2_EXTI_PIN, 1, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), // S1 diff --git a/src/main/target/HAKRCF722V2/target.h b/src/main/target/HAKRCF722V2/target.h index 52c07b6545a..814cfa65d5a 100644 --- a/src/main/target/HAKRCF722V2/target.h +++ b/src/main/target/HAKRCF722V2/target.h @@ -63,7 +63,9 @@ #define GYRO_SPI_BUS BUS_SPI1 #define GYRO1_CS_PIN SPI1_NSS1_PIN +#define GYRO1_EXTI_PIN PC4 #define GYRO2_CS_PIN SPI1_NSS2_PIN +#define GYRO2_EXTI_PIN PB10 // MPU6000 #define USE_IMU_MPU6000 diff --git a/src/main/target/HGLRCF405V2/target.h b/src/main/target/HGLRCF405V2/target.h index 9f3a02b48f7..8d427eedb2c 100644 --- a/src/main/target/HGLRCF405V2/target.h +++ b/src/main/target/HGLRCF405V2/target.h @@ -66,6 +66,7 @@ #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 /*** OSD ***/ #define USE_MAX7456 diff --git a/src/main/target/HUMMINGBIRD_FC305/target.c b/src/main/target/HUMMINGBIRD_FC305/target.c index 275d3f27935..f97f1e1e549 100644 --- a/src/main/target/HUMMINGBIRD_FC305/target.c +++ b/src/main/target/HUMMINGBIRD_FC305/target.c @@ -24,7 +24,7 @@ #include "drivers/bus.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); BUSDEV_REGISTER_SPI(busdev_sdcard_spi, DEVHW_SDCARD, SDCARD_SPI_BUS, SDCARD_CS_PIN, NONE, DEVFLAGS_SPI_MODE_0, 0); BUSDEV_REGISTER_SPI(busdev_max7456, DEVHW_MAX7456, MAX7456_SPI_BUS, MAX7456_CS_PIN, NONE, DEVFLAGS_USE_RAW_REGISTERS, 0); BUSDEV_REGISTER_I2C(busdev_dps310, DEVHW_DPS310, BARO_I2C_BUS, DPS310_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); diff --git a/src/main/target/HUMMINGBIRD_FC305/target.h b/src/main/target/HUMMINGBIRD_FC305/target.h index 7b121a775b2..52fd3e7fddf 100644 --- a/src/main/target/HUMMINGBIRD_FC305/target.h +++ b/src/main/target/HUMMINGBIRD_FC305/target.h @@ -46,6 +46,7 @@ #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_SPI_BUS BUS_SPI2 #define ICM42605_CS_PIN SPI2_NSS_PIN +#define ICM42605_EXTI_PIN PB6 // *************** I2C /Baro/Mag ********************* #define USE_I2C diff --git a/src/main/target/IFLIGHT_BLITZ_F722/target.h b/src/main/target/IFLIGHT_BLITZ_F722/target.h index cea6b4422ac..bac54b97841 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F722/target.h @@ -46,6 +46,7 @@ #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 // *************** I2C /Baro/Mag ********************* #define USE_I2C diff --git a/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h index 03196254420..200ec9c14c7 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h @@ -42,6 +42,7 @@ #define IMU_ICM42605_ALIGN CW90_DEG_FLIP #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 // *************** I2C /Baro/Mag ********************* #define USE_I2C diff --git a/src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h b/src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h index 69ea37e5357..aac23727644 100644 --- a/src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h @@ -67,6 +67,7 @@ #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PD0 // *************** I2C/Baro/Mag ********************* #define USE_I2C diff --git a/src/main/target/JHEF405PRO/target.h b/src/main/target/JHEF405PRO/target.h index 43547cd2efa..4d288f83a44 100644 --- a/src/main/target/JHEF405PRO/target.h +++ b/src/main/target/JHEF405PRO/target.h @@ -33,6 +33,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW90_DEG #define ICM42605_CS_PIN PB12 +#define ICM42605_EXTI_PIN GYRO_INT_EXTI #define ICM42605_SPI_BUS BUS_SPI1 #define USE_EXTI diff --git a/src/main/target/KAKUTEF4/target.h b/src/main/target/KAKUTEF4/target.h index 92cbcf13414..345b3fa5a3a 100644 --- a/src/main/target/KAKUTEF4/target.h +++ b/src/main/target/KAKUTEF4/target.h @@ -60,6 +60,9 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_CS_PIN PC4 +#if defined(KAKUTEF4) || defined(KAKUTEF4V2) +#define ICM42605_EXTI_PIN PC5 +#endif #define ICM42605_SPI_BUS BUS_SPI1 #if defined(KAKUTEF4V2) || defined(KAKUTEF4V23) || defined(KAKUTEF4V24) diff --git a/src/main/target/KAKUTEF4WING/target.h b/src/main/target/KAKUTEF4WING/target.h index 70eb125646a..fde9f45fbd8 100644 --- a/src/main/target/KAKUTEF4WING/target.h +++ b/src/main/target/KAKUTEF4WING/target.h @@ -37,7 +37,7 @@ #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 -#define ICM42605_EXTI_PIN PB12 +#define ICM42605_EXTI_PIN PB2 // *************** I2C **************** #define USE_I2C diff --git a/src/main/target/MAMBAF405_2022A/target.h b/src/main/target/MAMBAF405_2022A/target.h index 5a24771288d..8f836ff378e 100644 --- a/src/main/target/MAMBAF405_2022A/target.h +++ b/src/main/target/MAMBAF405_2022A/target.h @@ -60,6 +60,7 @@ #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #endif diff --git a/src/main/target/MAMBAF722_2022A/target.h b/src/main/target/MAMBAF722_2022A/target.h index cf834b11ea6..617aae32305 100644 --- a/src/main/target/MAMBAF722_2022A/target.h +++ b/src/main/target/MAMBAF722_2022A/target.h @@ -64,6 +64,7 @@ #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #endif diff --git a/src/main/target/MATEKF405SE/target.h b/src/main/target/MATEKF405SE/target.h index 38c8f56f5d9..3a5cbb58142 100644 --- a/src/main/target/MATEKF405SE/target.h +++ b/src/main/target/MATEKF405SE/target.h @@ -46,6 +46,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG_FLIP #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C /Baro/Mag ********************* diff --git a/src/main/target/MATEKF405TE/target.h b/src/main/target/MATEKF405TE/target.h index fc7c1ad0ce9..2cdc3aadb57 100644 --- a/src/main/target/MATEKF405TE/target.h +++ b/src/main/target/MATEKF405TE/target.h @@ -45,6 +45,7 @@ #define IMU_ICM42605_ALIGN CW270_DEG_FLIP #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PC14 +#define ICM42605_EXTI_PIN PC15 #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW270_DEG_FLIP diff --git a/src/main/target/PRINCIPIOTF7/target.h b/src/main/target/PRINCIPIOTF7/target.h index 0208f55a361..5e241023fde 100644 --- a/src/main/target/PRINCIPIOTF7/target.h +++ b/src/main/target/PRINCIPIOTF7/target.h @@ -113,6 +113,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW90_DEG #define ICM42605_CS_PIN PB2 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // BARO diff --git a/src/main/target/RADIOLINKF405/target.h b/src/main/target/RADIOLINKF405/target.h index 9a1afd47739..270a6f6309e 100644 --- a/src/main/target/RADIOLINKF405/target.h +++ b/src/main/target/RADIOLINKF405/target.h @@ -39,6 +39,7 @@ #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW90_DEG diff --git a/src/main/target/RADIOLINKF722/target.c b/src/main/target/RADIOLINKF722/target.c index 6ebb384b046..8da44a3497c 100644 --- a/src/main/target/RADIOLINKF722/target.c +++ b/src/main/target/RADIOLINKF722/target.c @@ -29,7 +29,7 @@ #include "drivers/sensor.h" BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42688_SPI_BUS, ICM42688_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42688_SPI_BUS, ICM42688_CS_PIN, ICM42688_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/RADIOLINKF722/target.h b/src/main/target/RADIOLINKF722/target.h index efa3bdea750..e7345bfee38 100644 --- a/src/main/target/RADIOLINKF722/target.h +++ b/src/main/target/RADIOLINKF722/target.h @@ -76,6 +76,7 @@ #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42688_SPI_BUS BUS_SPI1 #define ICM42688_CS_PIN PB2 +#define ICM42688_EXTI_PIN PC4 //BMI270 #define USE_IMU_BMI270 diff --git a/src/main/target/SKYSTARSF405HD/target.h b/src/main/target/SKYSTARSF405HD/target.h index c3711fcb4c2..65767a4332d 100644 --- a/src/main/target/SKYSTARSF405HD/target.h +++ b/src/main/target/SKYSTARSF405HD/target.h @@ -46,6 +46,9 @@ #define USE_IMU_ICM42605 #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 +#if defined(SKYSTARSF405AIO) +#define ICM42605_EXTI_PIN PC4 +#endif // *************** M25P256 flash ******************** #define USE_FLASHFS diff --git a/src/main/target/SKYSTARSF405V2/target.h b/src/main/target/SKYSTARSF405V2/target.h index 1fe4e2614c4..1591e4ff3e3 100644 --- a/src/main/target/SKYSTARSF405V2/target.h +++ b/src/main/target/SKYSTARSF405V2/target.h @@ -37,6 +37,7 @@ #define SPI1_MOSI_PIN PA7 #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW270_DEG diff --git a/src/main/target/SOLOGOODF722/target.h b/src/main/target/SOLOGOODF722/target.h index dd017691ef3..b89527a7b71 100644 --- a/src/main/target/SOLOGOODF722/target.h +++ b/src/main/target/SOLOGOODF722/target.h @@ -49,6 +49,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/SPEDIXF405/target.h b/src/main/target/SPEDIXF405/target.h index 3f46890b48d..0140dfebd03 100644 --- a/src/main/target/SPEDIXF405/target.h +++ b/src/main/target/SPEDIXF405/target.h @@ -48,6 +48,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/SPEDIXF722/target.h b/src/main/target/SPEDIXF722/target.h index 511381587a0..c6d9ab071c7 100644 --- a/src/main/target/SPEDIXF722/target.h +++ b/src/main/target/SPEDIXF722/target.h @@ -49,6 +49,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_CS_PIN SPI1_NSS_PIN +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/SPEEDYBEEF405AIO/target.h b/src/main/target/SPEEDYBEEF405AIO/target.h index a6abdfcc37f..ca1991a018b 100644 --- a/src/main/target/SPEEDYBEEF405AIO/target.h +++ b/src/main/target/SPEEDYBEEF405AIO/target.h @@ -92,6 +92,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PE9 #define ICM42605_SPI_BUS BUS_SPI1 /* diff --git a/src/main/target/SPEEDYBEEF405MINI/target.h b/src/main/target/SPEEDYBEEF405MINI/target.h index c20ee9aa0ff..52541254a31 100644 --- a/src/main/target/SPEEDYBEEF405MINI/target.h +++ b/src/main/target/SPEEDYBEEF405MINI/target.h @@ -94,6 +94,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 /* diff --git a/src/main/target/SPEEDYBEEF405V4/target.c b/src/main/target/SPEEDYBEEF405V4/target.c index 2d398bd1bbe..926589f4482 100644 --- a/src/main/target/SPEEDYBEEF405V4/target.c +++ b/src/main/target/SPEEDYBEEF405V4/target.c @@ -32,7 +32,7 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); timerHardware_t timerHardware[] = { DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 1, 0), // S1 diff --git a/src/main/target/SPEEDYBEEF405V4/target.h b/src/main/target/SPEEDYBEEF405V4/target.h index 1c5c847597f..2130ddde499 100644 --- a/src/main/target/SPEEDYBEEF405V4/target.h +++ b/src/main/target/SPEEDYBEEF405V4/target.h @@ -88,6 +88,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW90_DEG #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C(Baro & I2C) ************************** diff --git a/src/main/target/TAKERF722SE/target.h b/src/main/target/TAKERF722SE/target.h index 599d5610ad4..09007ab930e 100644 --- a/src/main/target/TAKERF722SE/target.h +++ b/src/main/target/TAKERF722SE/target.h @@ -104,6 +104,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/TMOTORF7/target.h b/src/main/target/TMOTORF7/target.h index a62b42d0990..109b998f134 100644 --- a/src/main/target/TMOTORF7/target.h +++ b/src/main/target/TMOTORF7/target.h @@ -47,6 +47,9 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_CS_PIN PA4 +#ifdef TMOTORF7 +#define ICM42605_EXTI_PIN PC4 +#endif #define ICM42605_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/TMOTORF7V2/target.h b/src/main/target/TMOTORF7V2/target.h index f5def98a403..2a37231dff3 100644 --- a/src/main/target/TMOTORF7V2/target.h +++ b/src/main/target/TMOTORF7V2/target.h @@ -70,6 +70,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // OSD -- SPI2 diff --git a/src/main/target/TMOTORVELOXF7V2/target.h b/src/main/target/TMOTORVELOXF7V2/target.h index 09f30857ec8..9207e5e88e5 100644 --- a/src/main/target/TMOTORVELOXF7V2/target.h +++ b/src/main/target/TMOTORVELOXF7V2/target.h @@ -50,6 +50,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_CS_PIN PB2 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 diff --git a/src/main/target/WARPF7/target.h b/src/main/target/WARPF7/target.h index e06d6e2ae1d..b535af98f33 100644 --- a/src/main/target/WARPF7/target.h +++ b/src/main/target/WARPF7/target.h @@ -107,6 +107,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_CS_PIN PA4 +#define ICM42605_EXTI_PIN PC4 #define ICM42605_SPI_BUS BUS_SPI1 // BARO From b9d32b6a0c26caba552995ef37e12d1ac0607bd1 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 12:24:09 +0200 Subject: [PATCH 03/24] gyro: BMI270 and ICM-45686 read on data-ready too Both drivers already route data-ready to INT1; they now describe their read to accgyro_data_ready.c. The BMI270 read starts at ACC_DATA_X_LSB (a dummy byte, accelerometer, gyro), for the secondary too, as the driver's own read does; its pin signals new data of either sensor. The ICM-45686 read starts at ACCEL_DATA_X1_UI (accelerometer, gyro, temperature); its secondary reads the gyro only. Neither has been tested on a board yet, so gyro_data_ready AUTO leaves them polled: ON turns them on. --- docs/Settings.md | 2 +- src/main/drivers/accgyro/accgyro_bmi270.c | 41 ++++++++++++++++ src/main/drivers/accgyro/accgyro_icm45686.c | 52 +++++++++++++++++++++ src/main/fc/settings.yaml | 2 +- 4 files changed, 95 insertions(+), 2 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index f608fdc6c92..c45f641f429 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2140,7 +2140,7 @@ Gyro processing anti-aliasing filter cutoff frequency. In normal operation this ### gyro_data_ready -Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU (ICM-42605, ICM-42688-P) and a target that declares the interrupt pin. AUTO does it on H7. On F4 and F7 the read goes through DMA and is new: set ON to try it, and please report how it works. OFF polls the gyro everywhere. +Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a target that declares the IMU's interrupt pin. AUTO does it where it has been tested: the ICM-42605 and ICM-42688-P on H7. Elsewhere, and with the BMI270 and ICM-45686, it is new: set ON to try it, and please report how it works. OFF polls the gyro everywhere. | Allowed Values | | | --- | --- | diff --git a/src/main/drivers/accgyro/accgyro_bmi270.c b/src/main/drivers/accgyro/accgyro_bmi270.c index 1dc4d3fc590..1663858d1a4 100644 --- a/src/main/drivers/accgyro/accgyro_bmi270.c +++ b/src/main/drivers/accgyro/accgyro_bmi270.c @@ -38,6 +38,7 @@ #include "drivers/sensor.h" #include "drivers/accgyro/accgyro.h" +#include "drivers/accgyro/accgyro_data_ready.h" #include "drivers/accgyro/accgyro_bmi270.h" #define BMI270_CONFIG_SIZE 328 @@ -257,6 +258,17 @@ static bool bmi270yroReadScratchpad(gyroDev_t *gyro) static bool bmi270AccReadScratchpad(accDev_t *acc) { +#if defined(USE_SPI_DATA_READY) + // The read on data-ready brought the accelerometer too + int16_t v[XYZ_AXIS_COUNT]; + if (gyroDataReadyAcc(acc->busDev, v)) { + acc->ADCRaw[X] = v[X]; + acc->ADCRaw[Y] = v[Y]; + acc->ADCRaw[Z] = v[Z]; + return true; + } +#endif + bmi270ContextData_t * ctx = busDeviceGetScratchpadMemory(acc->busDev); if (ctx->lastReadStatus) { @@ -284,9 +296,38 @@ static bool bmi270TemperatureRead(gyroDev_t *gyro, int16_t * data) return false; } +#if defined(USE_SPI_DATA_READY) +// After a dummy byte, from ACC_DATA_X_LSB: accelerometer X, Y, Z and gyro X, Y, Z, little-endian. +// INT1 flags new data of either sensor, so the gyro-only read takes the accelerometer too +static void bmi270DataReadyParse(const uint8_t *data, bool withAccAndTemp, int16_t *gyro, int16_t *acc, int16_t *temp) +{ + UNUSED(temp); + data++; + if (withAccAndTemp) { + acc[X] = int16_val_little_endian(data, 0); + acc[Y] = int16_val_little_endian(data, 1); + acc[Z] = int16_val_little_endian(data, 2); + } + gyro[X] = int16_val_little_endian(data, 3); + gyro[Y] = int16_val_little_endian(data, 4); + gyro[Z] = int16_val_little_endian(data, 5); +} + +// Not tested on any board yet: gyro_data_ready AUTO leaves it off +static const gyroDataReadyDriver_t bmi270DataReady = { + .withAccAndTemp = { BMI270_REG_ACC_DATA_X_LSB | 0x80, 13 }, + .gyroOnly = { BMI270_REG_ACC_DATA_X_LSB | 0x80, 13 }, + .parse = bmi270DataReadyParse, + .registerRead = bmi270yroReadScratchpad, +}; +#endif + static void bmi270GyroInit(gyroDev_t *gyro) { bmi270AccAndGyroInit(gyro); +#if defined(USE_SPI_DATA_READY) + gyro->dataReadyDriver = &bmi270DataReady; +#endif } static void bmi270AccInit(accDev_t *acc) diff --git a/src/main/drivers/accgyro/accgyro_icm45686.c b/src/main/drivers/accgyro/accgyro_icm45686.c index 9b249fb607f..6d5fb701605 100644 --- a/src/main/drivers/accgyro/accgyro_icm45686.c +++ b/src/main/drivers/accgyro/accgyro_icm45686.c @@ -34,6 +34,7 @@ #include "drivers/sensor.h" #include "drivers/accgyro/accgyro_mpu.h" #include "drivers/accgyro/accgyro.h" +#include "drivers/accgyro/accgyro_data_ready.h" #include "accgyro_icm45686.h" #if defined(USE_IMU_ICM45686) @@ -309,6 +310,17 @@ static void icm45686AccInit(accDev_t *acc) static bool icm45686AccRead(accDev_t *acc) { +#if defined(USE_SPI_DATA_READY) + // The read on data-ready brought the accelerometer too + int16_t v[XYZ_AXIS_COUNT]; + if (gyroDataReadyAcc(acc->busDev, v)) { + acc->ADCRaw[X] = v[X]; + acc->ADCRaw[Y] = v[Y]; + acc->ADCRaw[Z] = v[Z]; + return true; + } +#endif + uint8_t data[6]; const bool ack = busReadBuf(acc->busDev, ICM456XX_ACCEL_DATA_X1_UI, data, 6); @@ -341,6 +353,14 @@ static bool icm45686GyroRead(gyroDev_t *gyro) static bool icm45686ReadTemperature(gyroDev_t *gyro, int16_t * temp) { +#if defined(USE_SPI_DATA_READY) + int16_t raw; + if (gyroDataReadyTemperature(gyro->busDev, &raw)) { + *temp = (raw / 12.8f) + 250.0f; // as below, degC*10 + return true; + } +#endif + uint8_t data[2]; const bool ack = busReadBuf(gyro->busDev, ICM456XX_TEMP_DATA1, data, 2); @@ -353,6 +373,34 @@ static bool icm45686ReadTemperature(gyroDev_t *gyro, int16_t * temp) return true; } +#if defined(USE_SPI_DATA_READY) +// From ACCEL_DATA_X1_UI: accelerometer X, Y, Z, gyro X, Y, Z and temperature, little-endian +static void icm45686DataReadyParse(const uint8_t *data, bool withAccAndTemp, int16_t *gyro, int16_t *acc, int16_t *temp) +{ + if (withAccAndTemp) { + acc[X] = int16_val_little_endian(data, 0); + acc[Y] = int16_val_little_endian(data, 1); + acc[Z] = int16_val_little_endian(data, 2); + data += 6; + } + gyro[X] = int16_val_little_endian(data, 0); + gyro[Y] = int16_val_little_endian(data, 1); + gyro[Z] = int16_val_little_endian(data, 2); + if (withAccAndTemp) { + *temp = int16_val_little_endian(data, 3); + } +} + +// Not tested on any board yet: gyro_data_ready AUTO leaves it off +static const gyroDataReadyDriver_t icm45686DataReady = { + .withAccAndTemp = { ICM456XX_ACCEL_DATA_X1_UI | 0x80, 14 }, + .gyroOnly = { ICM456XX_GYRO_DATA_X1_UI | 0x80, 6 }, + .hasTemp = true, + .parse = icm45686DataReadyParse, + .registerRead = icm45686GyroRead, +}; +#endif + static void icm45686AccAndGyroInit(gyroDev_t *gyro) { busDevice_t * dev = gyro->busDev; @@ -402,6 +450,10 @@ static void icm45686AccAndGyroInit(gyroDev_t *gyro) delay(ICM456XX_INT_CONFIG_DELAY_MS); busSetSpeed(dev, BUS_SPEED_FAST); + +#if defined(USE_SPI_DATA_READY) + gyro->dataReadyDriver = &icm45686DataReady; +#endif } static bool icm45686DeviceDetect(busDevice_t * dev) diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index c5ab8f34ed3..d90d187cf65 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -353,7 +353,7 @@ groups: field: gyro_secondary_enabled type: bool - name: gyro_data_ready - description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU (ICM-42605, ICM-42688-P) and a target that declares the interrupt pin. AUTO does it on H7. On F4 and F7 the read goes through DMA and is new: set ON to try it, and please report how it works. OFF polls the gyro everywhere." + description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a target that declares the IMU's interrupt pin. AUTO does it where it has been tested: the ICM-42605 and ICM-42688-P on H7. Elsewhere, and with the BMI270 and ICM-45686, it is new: set ON to try it, and please report how it works. OFF polls the gyro everywhere." default_value: "AUTO" condition: USE_SPI_DATA_READY field: gyro_data_ready From 140552c3dd4185d9cec9cf1ecbe8e1c7bf9b4eb0 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 12:24:09 +0200 Subject: [PATCH 04/24] targets: BMI270 data-ready pins common_hardware.c passes BMI270_EXTI_PIN and ICM45686_EXTI_PIN to their registrations when the target defines them. BMI270 pins added where INAV and Betaflight's config for the same board agree on the CS pin and SPI bus; in a folder with several targets, only those Betaflight confirms. --- src/main/target/AOCODARCF7DUAL/target.c | 2 +- src/main/target/AOCODARCF7DUAL/target.h | 1 + src/main/target/AXISFLYINGF7PRO/target.h | 1 + src/main/target/BETAFPVF411/target.h | 1 + src/main/target/BETAFPVF722/target.h | 1 + src/main/target/BLADE_F4/target.h | 1 + src/main/target/DAKEFPVF405/target.h | 1 + src/main/target/DAKEFPVF722/target.h | 1 + src/main/target/FLASHHOBBYF405/target.h | 1 + src/main/target/FLASHHOBBYF722/target.h | 1 + src/main/target/FLYWOOF405PRO/target.h | 1 + src/main/target/FLYWOOF405S_AIO/target.h | 1 + src/main/target/FLYWOOF722PRO/target.c | 2 +- src/main/target/FLYWOOF722PRO/target.h | 1 + src/main/target/FLYWOOF745/target.h | 1 + src/main/target/GEPRCF405/target.h | 1 + src/main/target/GEPRCF405_BT_HD/target.h | 1 + src/main/target/GEPRCF722/target.h | 1 + src/main/target/GEPRCF722_BT_HD/target.h | 1 + src/main/target/GEPRC_F722_AIO/target.h | 1 + src/main/target/HAKRCF405D/target.c | 2 +- src/main/target/HAKRCF405D/target.h | 1 + src/main/target/HAKRCF405V2/target.h | 1 + src/main/target/HAKRCF411D/target.h | 1 + src/main/target/HGLRCF722/target.c | 2 +- src/main/target/HGLRCF722/target.h | 1 + src/main/target/IFLIGHT_BLITZ_F722/target.h | 1 + src/main/target/IFLIGHT_BLITZ_F722_X1/target.h | 1 + src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h | 1 + src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c | 2 +- src/main/target/IFLIGHT_BLITZ_F7_PRO/target.h | 1 + src/main/target/IFLIGHT_H743_AIO_V2/target.h | 1 + src/main/target/KAKUTEH7/target.h | 1 + src/main/target/MAMBAF405_2022A/target.h | 1 + src/main/target/MAMBAF722_2022A/target.h | 1 + src/main/target/MAMBAH743/target.c | 2 +- src/main/target/MAMBAH743/target.h | 1 + src/main/target/MATEKF405TE/target.h | 1 + src/main/target/RADIOLINKF405/target.h | 1 + src/main/target/RADIOLINKF722/target.c | 2 +- src/main/target/RADIOLINKF722/target.h | 1 + src/main/target/SKYSTARSF405HD/target.h | 3 +++ src/main/target/SOLOGOODF722/target.h | 1 + src/main/target/SPEDIXF405/target.h | 1 + src/main/target/SPEDIXF722/target.h | 1 + src/main/target/SPEEDYBEEF405V3/target.c | 2 +- src/main/target/SPEEDYBEEF405V3/target.h | 1 + src/main/target/SPEEDYBEEF745AIO/target.h | 1 + src/main/target/SPEEDYBEEF7MINI/target.c | 2 +- src/main/target/SPEEDYBEEF7MINI/target.h | 1 + src/main/target/SPEEDYBEEF7V3/target.c | 2 +- src/main/target/SPEEDYBEEF7V3/target.h | 1 + src/main/target/TMOTORF7/target.h | 3 +++ src/main/target/TUNERCF405/target.h | 1 + src/main/target/common_hardware.c | 10 ++++++++-- 55 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/main/target/AOCODARCF7DUAL/target.c b/src/main/target/AOCODARCF7DUAL/target.c index 395d985f8d1..377ce803d76 100644 --- a/src/main/target/AOCODARCF7DUAL/target.c +++ b/src/main/target/AOCODARCF7DUAL/target.c @@ -27,7 +27,7 @@ #include "drivers/sensor.h" BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { // DEF_TIM(TIM1, CH3, PA10, TIM_USE_PPM, 0, 0), //PPM diff --git a/src/main/target/AOCODARCF7DUAL/target.h b/src/main/target/AOCODARCF7DUAL/target.h index 5d4b0fda527..774789ac898 100644 --- a/src/main/target/AOCODARCF7DUAL/target.h +++ b/src/main/target/AOCODARCF7DUAL/target.h @@ -46,6 +46,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_CS_PIN PA13 +#define BMI270_EXTI_PIN PA8 #define BMI270_SPI_BUS BUS_SPI2 // *************** I2C /Baro/Mag ********************* diff --git a/src/main/target/AXISFLYINGF7PRO/target.h b/src/main/target/AXISFLYINGF7PRO/target.h index d40c74483f8..0ec0e9a42ff 100644 --- a/src/main/target/AXISFLYINGF7PRO/target.h +++ b/src/main/target/AXISFLYINGF7PRO/target.h @@ -63,6 +63,7 @@ #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 // *************** SPI2 OSD ***************// #define USE_MAX7456 diff --git a/src/main/target/BETAFPVF411/target.h b/src/main/target/BETAFPVF411/target.h index 1f57281d2f4..81b7c862513 100644 --- a/src/main/target/BETAFPVF411/target.h +++ b/src/main/target/BETAFPVF411/target.h @@ -47,6 +47,7 @@ #define IMU_BMI270_ALIGN CW90_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PA1 // *************** Baro ***************************** diff --git a/src/main/target/BETAFPVF722/target.h b/src/main/target/BETAFPVF722/target.h index 886b2659036..3ac2ea0c7e3 100755 --- a/src/main/target/BETAFPVF722/target.h +++ b/src/main/target/BETAFPVF722/target.h @@ -50,6 +50,7 @@ #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC4 // *************** I2C/Baro/Mag ********************* #define USE_I2C diff --git a/src/main/target/BLADE_F4/target.h b/src/main/target/BLADE_F4/target.h index 125f1327897..5501d81b3df 100644 --- a/src/main/target/BLADE_F4/target.h +++ b/src/main/target/BLADE_F4/target.h @@ -76,6 +76,7 @@ #define IMU_BMI270_ALIGN CW270_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 /*** OSD ***/ diff --git a/src/main/target/DAKEFPVF405/target.h b/src/main/target/DAKEFPVF405/target.h index 9f6c37cbf95..aa66c89a5a0 100644 --- a/src/main/target/DAKEFPVF405/target.h +++ b/src/main/target/DAKEFPVF405/target.h @@ -72,6 +72,7 @@ #define IMU_BMI270_ALIGN CW90_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC4 #define USE_IMU_LSM6DXX #define IMU_LSM6DXX_ALIGN CW90_DEG diff --git a/src/main/target/DAKEFPVF722/target.h b/src/main/target/DAKEFPVF722/target.h index ddf980860ca..2423d91b06e 100644 --- a/src/main/target/DAKEFPVF722/target.h +++ b/src/main/target/DAKEFPVF722/target.h @@ -72,6 +72,7 @@ #define IMU_BMI270_ALIGN CW90_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC4 #define USE_IMU_LSM6DXX #define IMU_LSM6DXX_ALIGN CW90_DEG diff --git a/src/main/target/FLASHHOBBYF405/target.h b/src/main/target/FLASHHOBBYF405/target.h index 8f71f0967f1..843cdbd0f6b 100644 --- a/src/main/target/FLASHHOBBYF405/target.h +++ b/src/main/target/FLASHHOBBYF405/target.h @@ -44,6 +44,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/FLASHHOBBYF722/target.h b/src/main/target/FLASHHOBBYF722/target.h index 7a816fc85f4..c52b7b763ff 100644 --- a/src/main/target/FLASHHOBBYF722/target.h +++ b/src/main/target/FLASHHOBBYF722/target.h @@ -42,6 +42,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/FLYWOOF405PRO/target.h b/src/main/target/FLYWOOF405PRO/target.h index 4fd4ee9fbfa..60240859ef6 100644 --- a/src/main/target/FLYWOOF405PRO/target.h +++ b/src/main/target/FLYWOOF405PRO/target.h @@ -45,6 +45,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG_FLIP #define BMI270_CS_PIN PB12 +#define BMI270_EXTI_PIN GYRO_INT_EXTI #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/FLYWOOF405S_AIO/target.h b/src/main/target/FLYWOOF405S_AIO/target.h index 4250943633e..2257720b7a3 100644 --- a/src/main/target/FLYWOOF405S_AIO/target.h +++ b/src/main/target/FLYWOOF405S_AIO/target.h @@ -41,6 +41,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW270_DEG #define BMI270_CS_PIN PB12 +#define BMI270_EXTI_PIN GYRO_INT_EXTI #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/FLYWOOF722PRO/target.c b/src/main/target/FLYWOOF722PRO/target.c index 7eba2b3344e..311a07a0cdf 100644 --- a/src/main/target/FLYWOOF722PRO/target.c +++ b/src/main/target/FLYWOOF722PRO/target.c @@ -28,7 +28,7 @@ BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_ICM42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_BMI270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_BMI270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { //DEF_TIM(TIM8, CH1, PC6, TIM_USE_PPM,0, 0), // PPM&SBUS diff --git a/src/main/target/FLYWOOF722PRO/target.h b/src/main/target/FLYWOOF722PRO/target.h index 0db06779723..69119763877 100644 --- a/src/main/target/FLYWOOF722PRO/target.h +++ b/src/main/target/FLYWOOF722PRO/target.h @@ -48,6 +48,7 @@ #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC3 #define USE_SPI_DEVICE_2 // MAX7456 diff --git a/src/main/target/FLYWOOF745/target.h b/src/main/target/FLYWOOF745/target.h index a54899f5f02..e32bd544c5a 100644 --- a/src/main/target/FLYWOOF745/target.h +++ b/src/main/target/FLYWOOF745/target.h @@ -44,6 +44,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW270_DEG #define BMI270_CS_PIN SPI4_NSS_PIN +#define BMI270_EXTI_PIN PE1 #define BMI270_SPI_BUS BUS_SPI4 #define USE_IMU_ICM42605 diff --git a/src/main/target/GEPRCF405/target.h b/src/main/target/GEPRCF405/target.h index f35a4bd7e8c..f6b4e4eaa10 100644 --- a/src/main/target/GEPRCF405/target.h +++ b/src/main/target/GEPRCF405/target.h @@ -49,6 +49,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_CS_PIN PA15 +#define BMI270_EXTI_PIN PC3 #define BMI270_SPI_BUS BUS_SPI3 #define USE_IMU_ICM42605 diff --git a/src/main/target/GEPRCF405_BT_HD/target.h b/src/main/target/GEPRCF405_BT_HD/target.h index e76ce06e305..b0b33db2f5f 100644 --- a/src/main/target/GEPRCF405_BT_HD/target.h +++ b/src/main/target/GEPRCF405_BT_HD/target.h @@ -47,6 +47,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_CS_PIN PA15 +#define BMI270_EXTI_PIN PC3 #define BMI270_SPI_BUS BUS_SPI3 #define USE_IMU_ICM42605 diff --git a/src/main/target/GEPRCF722/target.h b/src/main/target/GEPRCF722/target.h index a0ca42a6bbc..5a6cfc08e2e 100644 --- a/src/main/target/GEPRCF722/target.h +++ b/src/main/target/GEPRCF722/target.h @@ -46,6 +46,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_CS_PIN PA15 +#define BMI270_EXTI_PIN PC3 #define BMI270_SPI_BUS BUS_SPI3 #define USE_IMU_ICM42605 diff --git a/src/main/target/GEPRCF722_BT_HD/target.h b/src/main/target/GEPRCF722_BT_HD/target.h index 450324aff43..2309a5b1c19 100644 --- a/src/main/target/GEPRCF722_BT_HD/target.h +++ b/src/main/target/GEPRCF722_BT_HD/target.h @@ -44,6 +44,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_CS_PIN PA15 +#define BMI270_EXTI_PIN PA8 #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/GEPRC_F722_AIO/target.h b/src/main/target/GEPRC_F722_AIO/target.h index eed916d473f..ea0230b7173 100644 --- a/src/main/target/GEPRC_F722_AIO/target.h +++ b/src/main/target/GEPRC_F722_AIO/target.h @@ -48,6 +48,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW90_DEG #define BMI270_CS_PIN PA15 +#define BMI270_EXTI_PIN PA8 #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/HAKRCF405D/target.c b/src/main/target/HAKRCF405D/target.c index ffdecfc6c64..5d1ed7acefe 100644 --- a/src/main/target/HAKRCF405D/target.c +++ b/src/main/target/HAKRCF405D/target.c @@ -24,7 +24,7 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); diff --git a/src/main/target/HAKRCF405D/target.h b/src/main/target/HAKRCF405D/target.h index f626ab22d85..43349a06823 100644 --- a/src/main/target/HAKRCF405D/target.h +++ b/src/main/target/HAKRCF405D/target.h @@ -74,6 +74,7 @@ #define IMU_BMI270_ALIGN CW270_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC3 /*** OSD ***/ #define USE_MAX7456 diff --git a/src/main/target/HAKRCF405V2/target.h b/src/main/target/HAKRCF405V2/target.h index e48a6e7c3a2..9c498777b4f 100644 --- a/src/main/target/HAKRCF405V2/target.h +++ b/src/main/target/HAKRCF405V2/target.h @@ -75,6 +75,7 @@ #define IMU_BMI270_ALIGN CW90_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 /*** OSD ***/ diff --git a/src/main/target/HAKRCF411D/target.h b/src/main/target/HAKRCF411D/target.h index a67932cb9c5..33b48a137d4 100644 --- a/src/main/target/HAKRCF411D/target.h +++ b/src/main/target/HAKRCF411D/target.h @@ -66,6 +66,7 @@ #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PA1 /*** OSD ***/ #define USE_MAX7456 diff --git a/src/main/target/HGLRCF722/target.c b/src/main/target/HGLRCF722/target.c index e0e4a73e2ad..db20f4f2676 100644 --- a/src/main/target/HGLRCF722/target.c +++ b/src/main/target/HGLRCF722/target.c @@ -34,7 +34,7 @@ #include "drivers/sensor.h" BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // S1 UP1-2 D(1, 4, 5) diff --git a/src/main/target/HGLRCF722/target.h b/src/main/target/HGLRCF722/target.h index 348f30d2416..17bea753c84 100644 --- a/src/main/target/HGLRCF722/target.h +++ b/src/main/target/HGLRCF722/target.h @@ -54,6 +54,7 @@ #define IMU_BMI270_ALIGN CW180_DEG_FLIP #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PB2 +#define BMI270_EXTI_PIN PC4 // *************** I2C /Baro/Mag ********************* #define USE_I2C diff --git a/src/main/target/IFLIGHT_BLITZ_F722/target.h b/src/main/target/IFLIGHT_BLITZ_F722/target.h index bac54b97841..94834fd6171 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F722/target.h @@ -35,6 +35,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h index 200ec9c14c7..3f346faa721 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h @@ -35,6 +35,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW90_DEG_FLIP #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 // ICM42605 diff --git a/src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h b/src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h index aac23727644..e88ae211504 100644 --- a/src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F7_AIO/target.h @@ -62,6 +62,7 @@ #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PD0 #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG diff --git a/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c b/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c index 664ff354b4c..cd4bfd84494 100644 --- a/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c +++ b/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c @@ -27,7 +27,7 @@ #include "drivers/sensor.h" BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { // DEF_TIM(TIM9, CH2, PA3, TIM_USE_PPM, 0, 0), // PPM diff --git a/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.h b/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.h index a5361a51904..7cb714798d8 100644 --- a/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.h @@ -47,6 +47,7 @@ #define IMU_BMI270_ALIGN CW0_DEG_FLIP #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA15 +#define BMI270_EXTI_PIN PA8 // *************** I2C/Baro/Mag ********************* #define USE_I2C diff --git a/src/main/target/IFLIGHT_H743_AIO_V2/target.h b/src/main/target/IFLIGHT_H743_AIO_V2/target.h index a5257993798..d790e6a95ea 100644 --- a/src/main/target/IFLIGHT_H743_AIO_V2/target.h +++ b/src/main/target/IFLIGHT_H743_AIO_V2/target.h @@ -44,6 +44,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PD0 #define BMI270_SPI_BUS BUS_SPI1 // *************** I2C1 Baro/Mag ********************* diff --git a/src/main/target/KAKUTEH7/target.h b/src/main/target/KAKUTEH7/target.h index 2265abd509a..22fbe6312de 100644 --- a/src/main/target/KAKUTEH7/target.h +++ b/src/main/target/KAKUTEH7/target.h @@ -106,6 +106,7 @@ #define USE_IMU_BMI270 #define BMI270_SPI_BUS BUS_SPI4 #define BMI270_CS_PIN PE4 +#define BMI270_EXTI_PIN PE1 #ifdef KAKUTEH7MINI #define IMU_BMI270_ALIGN CW270_DEG diff --git a/src/main/target/MAMBAF405_2022A/target.h b/src/main/target/MAMBAF405_2022A/target.h index 8f836ff378e..35f04063893 100644 --- a/src/main/target/MAMBAF405_2022A/target.h +++ b/src/main/target/MAMBAF405_2022A/target.h @@ -53,6 +53,7 @@ #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 #ifdef MAMBAF405_2022B diff --git a/src/main/target/MAMBAF722_2022A/target.h b/src/main/target/MAMBAF722_2022A/target.h index 617aae32305..74d46951498 100644 --- a/src/main/target/MAMBAF722_2022A/target.h +++ b/src/main/target/MAMBAF722_2022A/target.h @@ -57,6 +57,7 @@ #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 #ifdef MAMBAF722_2022B diff --git a/src/main/target/MAMBAH743/target.c b/src/main/target/MAMBAH743/target.c index 30db292ae9f..a5c96fc27d5 100644 --- a/src/main/target/MAMBAH743/target.c +++ b/src/main/target/MAMBAH743/target.c @@ -27,7 +27,7 @@ #include "drivers/sensor.h" BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); #ifdef USE_IMU_ICM42605 BUSDEV_REGISTER_SPI_TAG(busdev_icm42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); diff --git a/src/main/target/MAMBAH743/target.h b/src/main/target/MAMBAH743/target.h index cac57dfe6f6..fab5a29ac22 100644 --- a/src/main/target/MAMBAH743/target.h +++ b/src/main/target/MAMBAH743/target.h @@ -62,6 +62,7 @@ #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC4 #define USE_SPI_DEVICE_4 #define SPI4_SCK_PIN PE12 diff --git a/src/main/target/MATEKF405TE/target.h b/src/main/target/MATEKF405TE/target.h index 2cdc3aadb57..808f26607e1 100644 --- a/src/main/target/MATEKF405TE/target.h +++ b/src/main/target/MATEKF405TE/target.h @@ -51,6 +51,7 @@ #define IMU_BMI270_ALIGN CW270_DEG_FLIP #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PC14 +#define BMI270_EXTI_PIN PC15 diff --git a/src/main/target/RADIOLINKF405/target.h b/src/main/target/RADIOLINKF405/target.h index 270a6f6309e..f3a7b3294e8 100644 --- a/src/main/target/RADIOLINKF405/target.h +++ b/src/main/target/RADIOLINKF405/target.h @@ -45,6 +45,7 @@ #define IMU_BMI270_ALIGN CW90_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW90_DEG diff --git a/src/main/target/RADIOLINKF722/target.c b/src/main/target/RADIOLINKF722/target.c index 8da44a3497c..18e99f1182d 100644 --- a/src/main/target/RADIOLINKF722/target.c +++ b/src/main/target/RADIOLINKF722/target.c @@ -28,7 +28,7 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42688_SPI_BUS, ICM42688_CS_PIN, ICM42688_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/RADIOLINKF722/target.h b/src/main/target/RADIOLINKF722/target.h index e7345bfee38..ff8532f90b7 100644 --- a/src/main/target/RADIOLINKF722/target.h +++ b/src/main/target/RADIOLINKF722/target.h @@ -83,6 +83,7 @@ #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PB2 +#define BMI270_EXTI_PIN PC4 // *************** I2C(Baro & I2C) ************************** #define USE_I2C diff --git a/src/main/target/SKYSTARSF405HD/target.h b/src/main/target/SKYSTARSF405HD/target.h index 65767a4332d..6dad1b8a18e 100644 --- a/src/main/target/SKYSTARSF405HD/target.h +++ b/src/main/target/SKYSTARSF405HD/target.h @@ -42,6 +42,9 @@ #define USE_IMU_BMI270 #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 +#if defined(SKYSTARSF405AIO) +#define BMI270_EXTI_PIN PC4 +#endif #define USE_IMU_ICM42605 #define ICM42605_SPI_BUS BUS_SPI1 diff --git a/src/main/target/SOLOGOODF722/target.h b/src/main/target/SOLOGOODF722/target.h index b89527a7b71..281d2127357 100644 --- a/src/main/target/SOLOGOODF722/target.h +++ b/src/main/target/SOLOGOODF722/target.h @@ -44,6 +44,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/SPEDIXF405/target.h b/src/main/target/SPEDIXF405/target.h index 0140dfebd03..6c9ddbff793 100644 --- a/src/main/target/SPEDIXF405/target.h +++ b/src/main/target/SPEDIXF405/target.h @@ -43,6 +43,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/SPEDIXF722/target.h b/src/main/target/SPEDIXF722/target.h index c6d9ab071c7..2f5e85b477b 100644 --- a/src/main/target/SPEDIXF722/target.h +++ b/src/main/target/SPEDIXF722/target.h @@ -44,6 +44,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/SPEEDYBEEF405V3/target.c b/src/main/target/SPEEDYBEEF405V3/target.c index 2a7b6272dae..633f36454f4 100644 --- a/src/main/target/SPEEDYBEEF405V3/target.c +++ b/src/main/target/SPEEDYBEEF405V3/target.c @@ -32,7 +32,7 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), // S1 diff --git a/src/main/target/SPEEDYBEEF405V3/target.h b/src/main/target/SPEEDYBEEF405V3/target.h index 6653ea56c0c..d3a6c5c05d0 100644 --- a/src/main/target/SPEEDYBEEF405V3/target.h +++ b/src/main/target/SPEEDYBEEF405V3/target.h @@ -80,6 +80,7 @@ #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC4 // *************** I2C(Baro & I2C) ************************** #define USE_I2C diff --git a/src/main/target/SPEEDYBEEF745AIO/target.h b/src/main/target/SPEEDYBEEF745AIO/target.h index 3e82678f552..7064da7ec72 100644 --- a/src/main/target/SPEEDYBEEF745AIO/target.h +++ b/src/main/target/SPEEDYBEEF745AIO/target.h @@ -81,6 +81,7 @@ #define IMU_BMI270_ALIGN CW90_DEG #define BMI270_SPI_BUS BUS_SPI4 #define BMI270_CS_PIN PE4 +#define BMI270_EXTI_PIN PE1 // *************** I2C(Baro & I2C) ************************** #define USE_I2C diff --git a/src/main/target/SPEEDYBEEF7MINI/target.c b/src/main/target/SPEEDYBEEF7MINI/target.c index 2b0777ab573..c521d758ae2 100644 --- a/src/main/target/SPEEDYBEEF7MINI/target.c +++ b/src/main/target/SPEEDYBEEF7MINI/target.c @@ -27,7 +27,7 @@ #include "drivers/sensor.h" #ifdef SPEEDYBEEF7MINIV2 -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); #else BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); #endif diff --git a/src/main/target/SPEEDYBEEF7MINI/target.h b/src/main/target/SPEEDYBEEF7MINI/target.h index d267ade336d..49bad659f6c 100644 --- a/src/main/target/SPEEDYBEEF7MINI/target.h +++ b/src/main/target/SPEEDYBEEF7MINI/target.h @@ -45,6 +45,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_CS_PIN PB2 +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 #else diff --git a/src/main/target/SPEEDYBEEF7V3/target.c b/src/main/target/SPEEDYBEEF7V3/target.c index 5d5b064f81d..b8af59ba015 100644 --- a/src/main/target/SPEEDYBEEF7V3/target.c +++ b/src/main/target/SPEEDYBEEF7V3/target.c @@ -28,7 +28,7 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/SPEEDYBEEF7V3/target.h b/src/main/target/SPEEDYBEEF7V3/target.h index 87eeb7114f7..f35d716844b 100644 --- a/src/main/target/SPEEDYBEEF7V3/target.h +++ b/src/main/target/SPEEDYBEEF7V3/target.h @@ -81,6 +81,7 @@ #define IMU_BMI270_ALIGN CW0_DEG_FLIP #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PC15 +#define BMI270_EXTI_PIN PC3 // *************** I2C(Baro & I2C) ************************** #define USE_I2C diff --git a/src/main/target/TMOTORF7/target.h b/src/main/target/TMOTORF7/target.h index 109b998f134..cb462f1c303 100644 --- a/src/main/target/TMOTORF7/target.h +++ b/src/main/target/TMOTORF7/target.h @@ -55,6 +55,9 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_CS_PIN PA4 +#ifdef TMOTORF7 +#define BMI270_EXTI_PIN PC4 +#endif #define BMI270_SPI_BUS BUS_SPI1 // *************** I2C Mag ********************* diff --git a/src/main/target/TUNERCF405/target.h b/src/main/target/TUNERCF405/target.h index b359545e697..48ad9e90604 100644 --- a/src/main/target/TUNERCF405/target.h +++ b/src/main/target/TUNERCF405/target.h @@ -43,6 +43,7 @@ #define USE_IMU_BMI270 #define IMU_BMI270_ALIGN CW180_DEG #define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 // OSD diff --git a/src/main/target/common_hardware.c b/src/main/target/common_hardware.c index 92888602ac9..ba6fd38271c 100755 --- a/src/main/target/common_hardware.c +++ b/src/main/target/common_hardware.c @@ -78,7 +78,10 @@ #endif #if defined(USE_IMU_BMI270) - BUSDEV_REGISTER_SPI(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, DEVFLAGS_NONE, IMU_BMI270_ALIGN); + #if !defined(BMI270_EXTI_PIN) + #define BMI270_EXTI_PIN NONE + #endif + BUSDEV_REGISTER_SPI(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, DEVFLAGS_NONE, IMU_BMI270_ALIGN); #endif #if defined(USE_IMU_LSM6DXX) @@ -86,7 +89,10 @@ #endif #if defined(USE_IMU_ICM45686) - BUSDEV_REGISTER_SPI(busdev_icm45686, DEVHW_ICM45686, ICM45686_SPI_BUS, ICM45686_CS_PIN, NONE, DEVFLAGS_NONE, IMU_ICM45686_ALIGN); + #if !defined(ICM45686_EXTI_PIN) + #define ICM45686_EXTI_PIN NONE + #endif + BUSDEV_REGISTER_SPI(busdev_icm45686, DEVHW_ICM45686, ICM45686_SPI_BUS, ICM45686_CS_PIN, ICM45686_EXTI_PIN, DEVFLAGS_NONE, IMU_ICM45686_ALIGN); #endif #endif From 608b4b8419e37993b33523354cb4bf99afa84ac2 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 15:08:35 +0200 Subject: [PATCH 05/24] gyro: a data-ready that came during the last read starts nothing before a flash write --- src/main/drivers/accgyro/accgyro_data_ready.c | 1 + src/main/drivers/bus_spi.h | 2 ++ src/main/drivers/bus_spi_data_ready.c | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/src/main/drivers/accgyro/accgyro_data_ready.c b/src/main/drivers/accgyro/accgyro_data_ready.c index 4eed429779f..a09fa06278c 100644 --- a/src/main/drivers/accgyro/accgyro_data_ready.c +++ b/src/main/drivers/accgyro/accgyro_data_ready.c @@ -175,6 +175,7 @@ void gyroDataReadySuspend(void) } const SPIDevice bus = d->gyro->busDev->busdev.spi.spiBus; spiBusAcquire(bus); + spiDataReadyCancelPending(bus); spiBusRelease(bus); } } diff --git a/src/main/drivers/bus_spi.h b/src/main/drivers/bus_spi.h index 34fdf15ccef..aa0ca8df494 100644 --- a/src/main/drivers/bus_spi.h +++ b/src/main/drivers/bus_spi.h @@ -139,6 +139,8 @@ bool spiInitDevice(SPIDevice device, bool leadingEdge); // The main loop's transfers on a bus take turns with those reads void spiBusAcquire(SPIDevice device); void spiBusRelease(SPIDevice device); + // Between the two: forgets a data-ready that came meanwhile, so the release starts no read + void spiDataReadyCancelPending(SPIDevice device); #else // Nothing to take turns with: the argument is not even evaluated #define spiBusAcquire(device) do { } while (0) diff --git a/src/main/drivers/bus_spi_data_ready.c b/src/main/drivers/bus_spi_data_ready.c index c610bfbed6f..f727d4b4383 100644 --- a/src/main/drivers/bus_spi_data_ready.c +++ b/src/main/drivers/bus_spi_data_ready.c @@ -161,6 +161,16 @@ void spiBusAcquire(SPIDevice device) } } +void spiDataReadyCancelPending(SPIDevice device) +{ + if ((unsigned)device >= SPIDEV_COUNT) { + return; + } + ATOMIC_BLOCK(NVIC_PRIO_GYRO_DATA_READY) { + spiDataReady[device].pending = false; + } +} + void spiBusRelease(SPIDevice device) { if ((unsigned)device >= SPIDEV_COUNT || !spiDataReady[device].dev) { From 52b95e8526f91cd4285025952ed672ccd4cc0c04 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 15:08:36 +0200 Subject: [PATCH 06/24] spi: an H7 data-ready read clears the EOT a polled transfer left behind --- src/main/drivers/bus_spi_hal_ll.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/drivers/bus_spi_hal_ll.c b/src/main/drivers/bus_spi_hal_ll.c index 1f2ab33e5d4..18272632b2f 100644 --- a/src/main/drivers/bus_spi_hal_ll.c +++ b/src/main/drivers/bus_spi_hal_ll.c @@ -574,6 +574,8 @@ void spiDataReadyHwStart(SPIDevice device) SPI_TypeDef *instance = spiHardwareMap[device].dev; LL_SPI_Disable(instance); + // A polled transfer leaves EOT set: this read would look over before it began + WRITE_REG(instance->IFCR, SPI_IFCR_EOTC | SPI_IFCR_TXTFC); LL_SPI_SetTransferSize(instance, h->len + 1); if (h->dma) { spiDataReadyDmaStart(&h->streams, &instance->TXDR, &instance->RXDR, spiDataReadyTx[device], spiDataReadyRx[device], h->len + 1); From 6c9c0f9ed75d722286f8b00b2aa0b3acfde59088 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 15:05:43 +0200 Subject: [PATCH 07/24] spi: on F7 an aborted transfer waits for its queued bytes by time, not by a count --- src/main/drivers/bus_spi_hal_ll.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/drivers/bus_spi_hal_ll.c b/src/main/drivers/bus_spi_hal_ll.c index 18272632b2f..83e58200214 100644 --- a/src/main/drivers/bus_spi_hal_ll.c +++ b/src/main/drivers/bus_spi_hal_ll.c @@ -32,6 +32,7 @@ #include "drivers/io.h" #include "io_impl.h" #include "drivers/nvic.h" +#include "drivers/time.h" #include "rcc.h" #ifndef SPI1_SCK_PIN @@ -400,8 +401,12 @@ static void spiTransferAbort(SPI_TypeDef *instance) WRITE_REG(instance->IFCR, SPI_IFCR_EOTC | SPI_IFCR_TXTFC | SPI_IFCR_UDRC | SPI_IFCR_OVRC | SPI_IFCR_CRCEC | SPI_IFCR_TIFREC | SPI_IFCR_MODFC | SPI_IFCR_TSERFC | SPI_IFCR_SUSPC); #else - // F7 stays enabled: drain what is left, or the next transfer would take it for its own - for (int spiTimeout = 1000; spiTimeout && (LL_SPI_GetTxFIFOLevel(instance) != LL_SPI_TX_FIFO_EMPTY || LL_SPI_IsActiveFlag_BSY(instance)); spiTimeout--); + // F7 stays enabled: drain what is left, or the next transfer would take it for its own. + // Timed, not counted: the 5 bytes still queued take 0.2 ms at the slowest clock + const timeUs_t start = micros(); + while ((LL_SPI_GetTxFIFOLevel(instance) != LL_SPI_TX_FIFO_EMPTY || LL_SPI_IsActiveFlag_BSY(instance)) + && cmpTimeUs(micros(), start) < 1000) { + } for (int n = 0; n < 8 && LL_SPI_GetRxFIFOLevel(instance) != LL_SPI_RX_FIFO_EMPTY; n++) { (void)LL_SPI_ReceiveData8(instance); } From cfd0513640a54a96803dd3e62ad566421b428a35 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 15:09:42 +0200 Subject: [PATCH 08/24] spi: register reads and writes report a transfer that failed --- src/main/drivers/bus_busdev_spi.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/drivers/bus_busdev_spi.c b/src/main/drivers/bus_busdev_spi.c index 1ec5261200b..aa3cdf50d9b 100644 --- a/src/main/drivers/bus_busdev_spi.c +++ b/src/main/drivers/bus_busdev_spi.c @@ -129,16 +129,16 @@ bool spiBusTransferMultiple(const busDevice_t * dev, busTransferDescriptor_t * d // Address and data in one transfer: on H7 starting and ending one costs about as much as the bytes #if defined(AT32F43x) -static void spiBusTransferRegister(spi_type * instance, uint8_t reg, uint8_t * rxData, const uint8_t * txData, int len) +static bool spiBusTransferRegister(spi_type * instance, uint8_t reg, uint8_t * rxData, const uint8_t * txData, int len) #else -static void spiBusTransferRegister(SPI_TypeDef * instance, uint8_t reg, uint8_t * rxData, const uint8_t * txData, int len) +static bool spiBusTransferRegister(SPI_TypeDef * instance, uint8_t reg, uint8_t * rxData, const uint8_t * txData, int len) #endif { #if defined(STM32H7) || defined(STM32F7) - spiTransferRegister(instance, reg, rxData, txData, len); + return spiTransferRegister(instance, reg, rxData, txData, len); #else spiTransferByte(instance, reg); - spiTransfer(instance, rxData, txData, len); + return spiTransfer(instance, rxData, txData, len); #endif } @@ -154,13 +154,13 @@ bool spiBusWriteRegister(const busDevice_t * dev, uint8_t reg, uint8_t data) spiBusSelectDevice(dev); } - spiBusTransferRegister(instance, reg, NULL, &data, 1); + const bool ok = spiBusTransferRegister(instance, reg, NULL, &data, 1); if (!(dev->flags & DEVFLAGS_USE_MANUAL_DEVICE_SELECT)) { spiBusDeselectDevice(dev); } - return true; + return ok; } bool spiBusWriteBuffer(const busDevice_t * dev, uint8_t reg, const uint8_t * data, uint8_t length) @@ -175,13 +175,13 @@ bool spiBusWriteBuffer(const busDevice_t * dev, uint8_t reg, const uint8_t * dat spiBusSelectDevice(dev); } - spiBusTransferRegister(instance, reg, NULL, data, length); + const bool ok = spiBusTransferRegister(instance, reg, NULL, data, length); if (!(dev->flags & DEVFLAGS_USE_MANUAL_DEVICE_SELECT)) { spiBusDeselectDevice(dev); } - return true; + return ok; } bool spiBusReadBuffer(const busDevice_t * dev, uint8_t reg, uint8_t * data, uint8_t length) @@ -196,13 +196,13 @@ bool spiBusReadBuffer(const busDevice_t * dev, uint8_t reg, uint8_t * data, uint spiBusSelectDevice(dev); } - spiBusTransferRegister(instance, reg, data, NULL, length); + const bool ok = spiBusTransferRegister(instance, reg, data, NULL, length); if (!(dev->flags & DEVFLAGS_USE_MANUAL_DEVICE_SELECT)) { spiBusDeselectDevice(dev); } - return true; + return ok; } bool spiBusReadRegister(const busDevice_t * dev, uint8_t reg, uint8_t * data) @@ -217,13 +217,13 @@ bool spiBusReadRegister(const busDevice_t * dev, uint8_t reg, uint8_t * data) spiBusSelectDevice(dev); } - spiBusTransferRegister(instance, reg, data, NULL, 1); + const bool ok = spiBusTransferRegister(instance, reg, data, NULL, 1); if (!(dev->flags & DEVFLAGS_USE_MANUAL_DEVICE_SELECT)) { spiBusDeselectDevice(dev); } - return true; + return ok; } bool spiBusIsBusy(const busDevice_t * dev) From 6339fabc6244abb0262d09a1ea542b4ab7c3ff86 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 15:10:30 +0200 Subject: [PATCH 09/24] gyro: on F4 the data-ready interrupt is on the rising edge, not on no edge at all --- src/main/drivers/accgyro/accgyro_data_ready.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/drivers/accgyro/accgyro_data_ready.c b/src/main/drivers/accgyro/accgyro_data_ready.c index a09fa06278c..6cb81674dc7 100644 --- a/src/main/drivers/accgyro/accgyro_data_ready.c +++ b/src/main/drivers/accgyro/accgyro_data_ready.c @@ -217,7 +217,11 @@ void gyroDataReadyStart(gyroDev_t *gyro) IOInit(dev->irqPin, OWNER_MPU, RESOURCE_EXTI, RESOURCE_INDEX(gyro->imuSensorToUse)); EXTIHandlerInit(&d->exti, gyroDataReadyExti); - EXTIConfig(dev->irqPin, &d->exti, NVIC_PRIO_GYRO_DATA_READY, IOCFG_IN_FLOATING); +#if defined(STM32F7) || defined(STM32H7) + EXTIConfig(dev->irqPin, &d->exti, NVIC_PRIO_GYRO_DATA_READY, IOCFG_IN_FLOATING); // always on the rising edge +#else + EXTIConfig(dev->irqPin, &d->exti, NVIC_PRIO_GYRO_DATA_READY, EXTI_Trigger_Rising); +#endif EXTIEnable(dev->irqPin, true); gyro->dataReadyState = d; From 6cf11aa043692619edca3fd8a60cf934a2d07231 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 15:10:30 +0200 Subject: [PATCH 10/24] spi: a data-ready read stopped on F4 clears the overrun it may leave --- src/main/drivers/bus_spi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/drivers/bus_spi.c b/src/main/drivers/bus_spi.c index 18f7a489cec..634772b285e 100644 --- a/src/main/drivers/bus_spi.c +++ b/src/main/drivers/bus_spi.c @@ -318,9 +318,11 @@ void spiDataReadyHwStop(SPIDevice device) spiDataReadyDmaStop(&h->streams); instance->CR2 &= ~(SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); - // A read stopped half way may leave a byte going out: let it finish and drop the echo + // A read stopped half way may leave a byte going out: let it finish and drop the echo. + // DR then SR also clears an overrun, which would hand the next transfer a stale byte for (int timeout = 1000; timeout && (!(instance->SR & SPI_SR_TXE) || (instance->SR & SPI_SR_BSY)); timeout--); (void)instance->DR; + (void)instance->SR; } void spiDataReadyHwDisable(SPIDevice device) From 55c6af5b0f2045b21ee4bd2199be9216a7f34344 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 16:45:57 +0200 Subject: [PATCH 11/24] targets: no data-ready pin on SPEEDYBEEF405AIO, whose port E the target does not enable --- src/main/target/SPEEDYBEEF405AIO/target.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/target/SPEEDYBEEF405AIO/target.h b/src/main/target/SPEEDYBEEF405AIO/target.h index ca1991a018b..a6abdfcc37f 100644 --- a/src/main/target/SPEEDYBEEF405AIO/target.h +++ b/src/main/target/SPEEDYBEEF405AIO/target.h @@ -92,7 +92,6 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_CS_PIN PA4 -#define ICM42605_EXTI_PIN PE9 #define ICM42605_SPI_BUS BUS_SPI1 /* From 122b0dc5c19dc7f2dc08b7a9756a7ffea5ddaf2d Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 18:39:38 +0200 Subject: [PATCH 12/24] gyro: new config version for gyro_data_ready --- src/main/sensors/gyro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index 0d315a5f9d6..3fb34d08477 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -121,7 +121,7 @@ EXTENDED_FASTRAM secondaryDynamicGyroNotchState_t secondaryDynamicGyroNotchState #endif -PG_REGISTER_WITH_RESET_TEMPLATE(gyroConfig_t, gyroConfig, PG_GYRO_CONFIG, 12); +PG_REGISTER_WITH_RESET_TEMPLATE(gyroConfig_t, gyroConfig, PG_GYRO_CONFIG, 13); PG_RESET_TEMPLATE(gyroConfig_t, gyroConfig, .gyro_anti_aliasing_lpf_hz = SETTING_GYRO_ANTI_ALIASING_LPF_HZ_DEFAULT, From 7cec776834cc1093d2f4a71c4577e1f1d992d825 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 21:19:54 +0200 Subject: [PATCH 13/24] gyro, spi: shorter comments --- src/main/drivers/accgyro/accgyro_data_ready.c | 5 ++--- src/main/drivers/bus_spi_data_ready.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/drivers/accgyro/accgyro_data_ready.c b/src/main/drivers/accgyro/accgyro_data_ready.c index 6cb81674dc7..4b898c26895 100644 --- a/src/main/drivers/accgyro/accgyro_data_ready.c +++ b/src/main/drivers/accgyro/accgyro_data_ready.c @@ -159,9 +159,8 @@ static bool gyroDataReadyRead(gyroDev_t *gyro) return false; } -// Before a flash write, which stalls every interrupt running from flash (over a second on H7): -// no reads meanwhile. With a DMA read around a flash write and the host closing the USB port, -// an H7 has stopped entirely +// No reads during a flash write: with a DMA read in flight and the USB port closing, an H7 has +// stopped entirely void gyroDataReadySuspend(void) { for (unsigned i = 0; i < ARRAYLEN(gyroDataReady); i++) { diff --git a/src/main/drivers/bus_spi_data_ready.c b/src/main/drivers/bus_spi_data_ready.c index f727d4b4383..ef8a9b8ea74 100644 --- a/src/main/drivers/bus_spi_data_ready.c +++ b/src/main/drivers/bus_spi_data_ready.c @@ -35,9 +35,8 @@ #include "drivers/nvic.h" #include "drivers/time.h" -// Reads started by a data-ready interrupt take turns with the main loop's transfers: -// spiBusAcquire() waits for one on its way, and one asked for meanwhile starts at the last -// spiBusRelease(). The two nest: a speed change can come while a device is selected +// Data-ready reads take turns with the main loop's transfers: acquire waits for one on its way, +// the last release starts one asked for meanwhile (they nest: speed changes come mid-select) typedef struct { const busDevice_t *dev; // NULL: no reads started by a data-ready on this bus From 683d24fdbef39e3a33199251b3e0efa23c24902a Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 21:19:54 +0200 Subject: [PATCH 14/24] gyro: data-ready on by default for the ICM426xx on F4 and F7 too AUTO now reads the ICM-42605 and ICM-42688-P on their data-ready interrupt on every family. Where no interrupt arrives the gyro is read from its registers as before. --- docs/Settings.md | 2 +- src/main/drivers/accgyro/accgyro.h | 2 +- src/main/drivers/accgyro/accgyro_icm42605.c | 2 -- src/main/fc/settings.yaml | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index c45f641f429..eff5848031f 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2140,7 +2140,7 @@ Gyro processing anti-aliasing filter cutoff frequency. In normal operation this ### gyro_data_ready -Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a target that declares the IMU's interrupt pin. AUTO does it where it has been tested: the ICM-42605 and ICM-42688-P on H7. Elsewhere, and with the BMI270 and ICM-45686, it is new: set ON to try it, and please report how it works. OFF polls the gyro everywhere. +Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO does it with the ICM-42605 and ICM-42688-P; with the BMI270 and ICM-45686 it is new: set ON to try it, and please report how it works. OFF polls the gyro. | Allowed Values | | | --- | --- | diff --git a/src/main/drivers/accgyro/accgyro.h b/src/main/drivers/accgyro/accgyro.h index 310696517f0..7bf8ac1eb01 100644 --- a/src/main/drivers/accgyro/accgyro.h +++ b/src/main/drivers/accgyro/accgyro.h @@ -42,7 +42,7 @@ typedef struct { // Whether a driver that can reads its gyro on the data-ready interrupt (gyro_data_ready) typedef enum { GYRO_DEV_DATA_READY_OFF = 0, - GYRO_DEV_DATA_READY_WHERE_TESTED, // only where that driver has been tested + GYRO_DEV_DATA_READY_WHERE_TESTED, // where the driver turns it on for AUTO GYRO_DEV_DATA_READY_ON, } gyroDevDataReady_e; diff --git a/src/main/drivers/accgyro/accgyro_icm42605.c b/src/main/drivers/accgyro/accgyro_icm42605.c index 1c657aa8b87..4b70849c3a1 100644 --- a/src/main/drivers/accgyro/accgyro_icm42605.c +++ b/src/main/drivers/accgyro/accgyro_icm42605.c @@ -183,9 +183,7 @@ static const gyroDataReadyDriver_t icm426xxDataReady = { .hasTemp = true, .parse = icm426xxDataReadyParse, .registerRead = icm42605GyroRead, -#if defined(STM32H7) .tested = true, -#endif }; #endif diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index d90d187cf65..343f5895e00 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -353,7 +353,7 @@ groups: field: gyro_secondary_enabled type: bool - name: gyro_data_ready - description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a target that declares the IMU's interrupt pin. AUTO does it where it has been tested: the ICM-42605 and ICM-42688-P on H7. Elsewhere, and with the BMI270 and ICM-45686, it is new: set ON to try it, and please report how it works. OFF polls the gyro everywhere." + description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO does it with the ICM-42605 and ICM-42688-P; with the BMI270 and ICM-45686 it is new: set ON to try it, and please report how it works. OFF polls the gyro." default_value: "AUTO" condition: USE_SPI_DATA_READY field: gyro_data_ready From dcef64b84d9bee9b3eb94b34c36cce5eb59c3477 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 21:19:54 +0200 Subject: [PATCH 15/24] gyro: data-ready on by default for the BMI270 and ICM-45686 too AUTO now reads them on their data-ready interrupt as it does the ICM426xx; where no interrupt arrives the gyro is read from its registers as before. --- docs/Settings.md | 2 +- src/main/drivers/accgyro/accgyro_bmi270.c | 2 +- src/main/drivers/accgyro/accgyro_icm45686.c | 2 +- src/main/fc/settings.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index eff5848031f..8c24c0b5f2f 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2140,7 +2140,7 @@ Gyro processing anti-aliasing filter cutoff frequency. In normal operation this ### gyro_data_ready -Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO does it with the ICM-42605 and ICM-42688-P; with the BMI270 and ICM-45686 it is new: set ON to try it, and please report how it works. OFF polls the gyro. +Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270 and ICM-45686, OFF polls the gyro. | Allowed Values | | | --- | --- | diff --git a/src/main/drivers/accgyro/accgyro_bmi270.c b/src/main/drivers/accgyro/accgyro_bmi270.c index 1663858d1a4..84f48fc4290 100644 --- a/src/main/drivers/accgyro/accgyro_bmi270.c +++ b/src/main/drivers/accgyro/accgyro_bmi270.c @@ -313,12 +313,12 @@ static void bmi270DataReadyParse(const uint8_t *data, bool withAccAndTemp, int16 gyro[Z] = int16_val_little_endian(data, 5); } -// Not tested on any board yet: gyro_data_ready AUTO leaves it off static const gyroDataReadyDriver_t bmi270DataReady = { .withAccAndTemp = { BMI270_REG_ACC_DATA_X_LSB | 0x80, 13 }, .gyroOnly = { BMI270_REG_ACC_DATA_X_LSB | 0x80, 13 }, .parse = bmi270DataReadyParse, .registerRead = bmi270yroReadScratchpad, + .tested = true, }; #endif diff --git a/src/main/drivers/accgyro/accgyro_icm45686.c b/src/main/drivers/accgyro/accgyro_icm45686.c index 6d5fb701605..5d57d4a2042 100644 --- a/src/main/drivers/accgyro/accgyro_icm45686.c +++ b/src/main/drivers/accgyro/accgyro_icm45686.c @@ -391,13 +391,13 @@ static void icm45686DataReadyParse(const uint8_t *data, bool withAccAndTemp, int } } -// Not tested on any board yet: gyro_data_ready AUTO leaves it off static const gyroDataReadyDriver_t icm45686DataReady = { .withAccAndTemp = { ICM456XX_ACCEL_DATA_X1_UI | 0x80, 14 }, .gyroOnly = { ICM456XX_GYRO_DATA_X1_UI | 0x80, 6 }, .hasTemp = true, .parse = icm45686DataReadyParse, .registerRead = icm45686GyroRead, + .tested = true, }; #endif diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 343f5895e00..a4fc4a952f3 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -353,7 +353,7 @@ groups: field: gyro_secondary_enabled type: bool - name: gyro_data_ready - description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO does it with the ICM-42605 and ICM-42688-P; with the BMI270 and ICM-45686 it is new: set ON to try it, and please report how it works. OFF polls the gyro." + description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270 and ICM-45686, OFF polls the gyro." default_value: "AUTO" condition: USE_SPI_DATA_READY field: gyro_data_ready From a785ce4073646fe49a056e7ade3c19fd1ef4d692 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 21:19:54 +0200 Subject: [PATCH 16/24] gyro: MPU6000, MPU6500 and ICM-20689 read on data-ready too The three share the register layout of accgyro_mpu.c: one read from ACCEL_XOUT_H brings accelerometer, temperature and gyro. INT gives a 50 us pulse at each new sample. --- docs/Settings.md | 2 +- src/main/drivers/accgyro/accgyro_icm20689.c | 4 ++ src/main/drivers/accgyro/accgyro_mpu.c | 57 +++++++++++++++++++++ src/main/drivers/accgyro/accgyro_mpu.h | 4 ++ src/main/drivers/accgyro/accgyro_mpu6000.c | 4 ++ src/main/drivers/accgyro/accgyro_mpu6500.c | 4 ++ src/main/fc/settings.yaml | 2 +- 7 files changed, 75 insertions(+), 2 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 8c24c0b5f2f..8feafd9bb80 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2140,7 +2140,7 @@ Gyro processing anti-aliasing filter cutoff frequency. In normal operation this ### gyro_data_ready -Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270 and ICM-45686, OFF polls the gyro. +Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270, ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives) and ICM-20689, OFF polls the gyro. | Allowed Values | | | --- | --- | diff --git a/src/main/drivers/accgyro/accgyro_icm20689.c b/src/main/drivers/accgyro/accgyro_icm20689.c index bd78f161332..161ff2d3433 100644 --- a/src/main/drivers/accgyro/accgyro_icm20689.c +++ b/src/main/drivers/accgyro/accgyro_icm20689.c @@ -109,6 +109,10 @@ static void icm20689AccAndGyroInit(gyroDev_t *gyro) busWrite(busDev, MPU_RA_SMPLRT_DIV, config->gyroConfigValues[1]); // Get Divider Drops delay(100); +#if defined(USE_SPI_DATA_READY) + mpuDataReadySetup(gyro); +#endif + // Switch SPI to fast speed busSetSpeed(busDev, BUS_SPEED_FAST); } diff --git a/src/main/drivers/accgyro/accgyro_mpu.c b/src/main/drivers/accgyro/accgyro_mpu.c index a52606946b1..d766b4e29cf 100644 --- a/src/main/drivers/accgyro/accgyro_mpu.c +++ b/src/main/drivers/accgyro/accgyro_mpu.c @@ -39,6 +39,7 @@ #include "drivers/sensor.h" #include "drivers/accgyro/accgyro.h" #include "drivers/accgyro/accgyro_mpu.h" +#include "drivers/accgyro/accgyro_data_ready.h" // Check busDevice scratchpad memory size STATIC_ASSERT(sizeof(mpuContextData_t) < BUS_SCRATCHPAD_MEMORY_SIZE, busDevice_scratchpad_memory_too_small); @@ -96,6 +97,17 @@ bool mpuGyroReadScratchpad(gyroDev_t *gyro) bool mpuAccReadScratchpad(accDev_t *acc) { +#if defined(USE_SPI_DATA_READY) + // The read on data-ready brought the accelerometer too + int16_t v[XYZ_AXIS_COUNT]; + if (gyroDataReadyAcc(acc->busDev, v)) { + acc->ADCRaw[X] = v[X]; + acc->ADCRaw[Y] = v[Y]; + acc->ADCRaw[Z] = v[Z]; + return true; + } +#endif + mpuContextData_t * ctx = busDeviceGetScratchpadMemory(acc->busDev); if (ctx->lastReadStatus) { @@ -110,6 +122,14 @@ bool mpuAccReadScratchpad(accDev_t *acc) bool mpuTemperatureReadScratchpad(gyroDev_t *gyro, int16_t * data) { +#if defined(USE_SPI_DATA_READY) + int16_t raw; + if (gyroDataReadyTemperature(gyro->busDev, &raw)) { + *data = raw / 34 + 365; + return true; + } +#endif + mpuContextData_t * ctx = busDeviceGetScratchpadMemory(gyro->busDev); if (ctx->lastReadStatus) { @@ -120,3 +140,40 @@ bool mpuTemperatureReadScratchpad(gyroDev_t *gyro, int16_t * data) return false; } + +#if defined(USE_SPI_DATA_READY) +// From ACCEL_XOUT_H: accelerometer X, Y, Z, temperature, gyro X, Y, Z, big-endian +static void mpuDataReadyParse(const uint8_t *data, bool withAccAndTemp, int16_t *gyro, int16_t *acc, int16_t *temp) +{ + if (withAccAndTemp) { + acc[X] = int16_val_big_endian(data, 0); + acc[Y] = int16_val_big_endian(data, 1); + acc[Z] = int16_val_big_endian(data, 2); + *temp = int16_val_big_endian(data, 3); + data += 8; + } + gyro[X] = int16_val_big_endian(data, 0); + gyro[Y] = int16_val_big_endian(data, 1); + gyro[Z] = int16_val_big_endian(data, 2); +} + +static const gyroDataReadyDriver_t mpuDataReady = { + .withAccAndTemp = { MPU_RA_ACCEL_XOUT_H | 0x80, 14 }, + .gyroOnly = { MPU_RA_GYRO_XOUT_H | 0x80, 6 }, + .hasTemp = true, + .parse = mpuDataReadyParse, + .registerRead = mpuGyroReadScratchpad, + .tested = true, +}; + +// A 50 us pulse on INT at each new sample. Written at the initialisation speed: the MPU6000 takes +// register writes at 1 MHz at most +void mpuDataReadySetup(gyroDev_t *gyro) +{ + busWrite(gyro->busDev, MPU_RA_INT_PIN_CFG, MPU_INT_ANYRD_2CLEAR); + delayMicroseconds(15); + busWrite(gyro->busDev, MPU_RA_INT_ENABLE, MPU_RF_DATA_RDY_EN); + delayMicroseconds(15); + gyro->dataReadyDriver = &mpuDataReady; +} +#endif diff --git a/src/main/drivers/accgyro/accgyro_mpu.h b/src/main/drivers/accgyro/accgyro_mpu.h index b382c2c331c..0db604aee42 100644 --- a/src/main/drivers/accgyro/accgyro_mpu.h +++ b/src/main/drivers/accgyro/accgyro_mpu.h @@ -128,6 +128,7 @@ // RF = Register Flag #define MPU_RF_DATA_RDY_EN (1 << 0) +#define MPU_INT_ANYRD_2CLEAR (1 << 4) #define MPU_DLPF_10HZ 0x05 #define MPU_DLPF_20HZ 0x04 @@ -185,3 +186,6 @@ bool mpuGyroRead(struct gyroDev_s *gyro); bool mpuGyroReadScratchpad(struct gyroDev_s *gyro); bool mpuAccReadScratchpad(struct accDev_s *acc); bool mpuTemperatureReadScratchpad(struct gyroDev_s *gyro, int16_t * data); +#if defined(USE_SPI_DATA_READY) +void mpuDataReadySetup(struct gyroDev_s *gyro); +#endif diff --git a/src/main/drivers/accgyro/accgyro_mpu6000.c b/src/main/drivers/accgyro/accgyro_mpu6000.c index 4ad6d99b5de..f25593a6f59 100644 --- a/src/main/drivers/accgyro/accgyro_mpu6000.c +++ b/src/main/drivers/accgyro/accgyro_mpu6000.c @@ -111,6 +111,10 @@ static void mpu6000AccAndGyroInit(gyroDev_t *gyro) busWrite(busDev, MPU_RA_CONFIG, config->gyroConfigValues[0]); delayMicroseconds(1); +#if defined(USE_SPI_DATA_READY) + mpuDataReadySetup(gyro); +#endif + busSetSpeed(busDev, BUS_SPEED_FAST); mpuGyroRead(gyro); diff --git a/src/main/drivers/accgyro/accgyro_mpu6500.c b/src/main/drivers/accgyro/accgyro_mpu6500.c index 5a2207a498b..31e74a92118 100644 --- a/src/main/drivers/accgyro/accgyro_mpu6500.c +++ b/src/main/drivers/accgyro/accgyro_mpu6500.c @@ -96,6 +96,10 @@ static void mpu6500AccAndGyroInit(gyroDev_t *gyro) busWrite(dev, MPU_RA_SMPLRT_DIV, config->gyroConfigValues[1]); delay(100); +#if defined(USE_SPI_DATA_READY) + mpuDataReadySetup(gyro); +#endif + busSetSpeed(dev, BUS_SPEED_FAST); } diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index a4fc4a952f3..56c3ac352f0 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -353,7 +353,7 @@ groups: field: gyro_secondary_enabled type: bool - name: gyro_data_ready - description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270 and ICM-45686, OFF polls the gyro." + description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270, ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives) and ICM-20689, OFF polls the gyro." default_value: "AUTO" condition: USE_SPI_DATA_READY field: gyro_data_ready From e82cc310a9c0d834ab375a259e9647c5229a05c5 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 28 Sep 2026 21:19:54 +0200 Subject: [PATCH 17/24] targets: MPU6000, MPU6500 and ICM-20689 data-ready pins From Betaflight's config for the same board, where it agrees with INAV on the IMU's bus and chip select, the pin is free and the target is F4, F7 or H7. --- src/main/target/AIKONF4/target.h | 2 ++ src/main/target/AIRBOTF4/target.h | 2 ++ src/main/target/ALIENFLIGHTF4/target.h | 1 + src/main/target/AOCODARCF7DUAL/target.c | 2 +- src/main/target/AXISFLYINGF7PRO/target.h | 1 + src/main/target/BETAFPVF722/target.h | 1 + src/main/target/BLADE_F4/target.h | 1 + src/main/target/BLUEJAYF4/target.h | 1 + src/main/target/CADDXF4_AIO_ELRS/target.h | 1 + src/main/target/COLIBRI/target.h | 3 +++ src/main/target/DAKEFPVF405/target.h | 2 ++ src/main/target/DAKEFPVF722/target.h | 2 ++ src/main/target/DAKEFPVH743/target.c | 4 ++-- src/main/target/DALRCF405/target.h | 2 ++ src/main/target/DALRCF722DUAL/target.h | 1 + src/main/target/DYSF4/target.h | 3 +++ src/main/target/F4BY/target.h | 1 + src/main/target/FF_FORTINIF4/target.h | 1 + src/main/target/FLASHHOBBYF405/target.h | 1 + src/main/target/FLASHHOBBYF722/target.h | 1 + src/main/target/FLYCOLORF4/target.h | 1 + src/main/target/FLYCOLORF7MINI/target.c | 2 +- src/main/target/FLYCOLORF7V2/target.h | 1 + src/main/target/FLYWOOF405PRO/target.h | 3 +++ src/main/target/FLYWOOF405S_AIO/target.h | 1 + src/main/target/FLYWOOF722PRO/target.c | 2 +- src/main/target/FLYWOOF745/target.h | 1 + src/main/target/FLYWOOF7DUAL/target.c | 8 ++++---- src/main/target/FOXEERF405/target.h | 2 ++ src/main/target/FOXEERF722DUAL/target.c | 2 +- src/main/target/FOXEERF722V4/target.h | 6 ++++++ src/main/target/FOXEERF745AIO/target.h | 3 +++ src/main/target/FOXEERH743/target.h | 1 + src/main/target/FURYF4OSD/target.h | 6 ++++++ src/main/target/GEPRCF405/target.h | 1 + src/main/target/GEPRCF405_BT_HD/target.h | 1 + src/main/target/GEPRCF722/target.h | 1 + src/main/target/GEPRCF722_BT_HD/target.h | 1 + src/main/target/GEPRC_F722_AIO/target.h | 3 +++ src/main/target/HAKRCF405D/target.c | 2 +- src/main/target/HAKRCF405V2/target.h | 1 + src/main/target/HAKRCF411D/target.h | 1 + src/main/target/HGLRCF405V2/target.h | 1 + src/main/target/HGLRCF722/target.c | 2 +- src/main/target/IFLIGHT_BLITZ_F722/target.h | 1 + src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c | 2 +- src/main/target/IFLIGHT_H743_AIO_V2/target.h | 1 + src/main/target/KAKUTEF4/target.h | 6 ++++++ src/main/target/KAKUTEF7/target.h | 2 ++ src/main/target/KAKUTEF7MINIV3/target.h | 1 + src/main/target/KAKUTEH7/target.h | 1 + src/main/target/MAMBAF405US/target.h | 6 ++++++ src/main/target/MAMBAF405_2022A/target.h | 2 ++ src/main/target/MAMBAF722_2022A/target.h | 2 ++ src/main/target/MATEKF405/target.h | 6 ++++++ src/main/target/MATEKF405SE/target.h | 3 +++ src/main/target/MATEKF411/target.h | 6 ++++++ src/main/target/MATEKF411SE/target.h | 3 +++ src/main/target/MATEKF722/target.h | 1 + src/main/target/MATEKF722SE/target.c | 4 ++-- src/main/target/OMNIBUSF4/target.h | 1 + src/main/target/RADIOLINKF405/target.h | 1 + src/main/target/REVO/target.h | 1 + src/main/target/SKYSTARSF405HD/target.h | 3 +++ src/main/target/SOLOGOODF722/target.h | 1 + src/main/target/SPEDIXF405/target.h | 1 + src/main/target/SPEDIXF722/target.h | 1 + src/main/target/SPEEDYBEEF7/target.h | 1 + src/main/target/SPEEDYBEEF745AIO/target.h | 1 + src/main/target/SPEEDYBEEF7MINI/target.c | 2 +- src/main/target/SPEEDYBEEF7V2/target.h | 1 + src/main/target/SPEEDYBEEF7V3/target.c | 2 +- src/main/target/SPRACINGF4EVO/target.h | 1 + src/main/target/SPRACINGF7DUAL/target.c | 2 +- src/main/target/TAKERF722SE/target.h | 1 + src/main/target/TMOTORF7/target.h | 3 +++ src/main/target/TMOTORF7V2/target.h | 1 + src/main/target/common_hardware.c | 15 ++++++++++++--- 78 files changed, 151 insertions(+), 21 deletions(-) diff --git a/src/main/target/AIKONF4/target.h b/src/main/target/AIKONF4/target.h index cd057f8b871..3fe4a0e8aee 100644 --- a/src/main/target/AIKONF4/target.h +++ b/src/main/target/AIKONF4/target.h @@ -30,11 +30,13 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW0_DEG #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 #define SERIAL_PORT_COUNT 7 //VCP, UART1, UART2, UART3, UART4, SOFTSERIAL1, SOFTSERIAL2 diff --git a/src/main/target/AIRBOTF4/target.h b/src/main/target/AIRBOTF4/target.h index 9d5b0eef8bb..f4a3a5e784f 100644 --- a/src/main/target/AIRBOTF4/target.h +++ b/src/main/target/AIRBOTF4/target.h @@ -32,11 +32,13 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW270_DEG #define MPU6500_CS_PIN PA4 +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 #define USE_MAG diff --git a/src/main/target/ALIENFLIGHTF4/target.h b/src/main/target/ALIENFLIGHTF4/target.h index 52cd4cf4a9d..d6c7fd3e149 100644 --- a/src/main/target/ALIENFLIGHTF4/target.h +++ b/src/main/target/ALIENFLIGHTF4/target.h @@ -33,6 +33,7 @@ #define INVERTER_PIN_USART2 PC15 #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PC14 #define MPU6500_SPI_BUS BUS_SPI1 #define MPU9250_CS_PIN SPI1_NSS_PIN diff --git a/src/main/target/AOCODARCF7DUAL/target.c b/src/main/target/AOCODARCF7DUAL/target.c index 377ce803d76..c810fb09270 100644 --- a/src/main/target/AOCODARCF7DUAL/target.c +++ b/src/main/target/AOCODARCF7DUAL/target.c @@ -26,7 +26,7 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/AXISFLYINGF7PRO/target.h b/src/main/target/AXISFLYINGF7PRO/target.h index 0ec0e9a42ff..56359dea6ce 100644 --- a/src/main/target/AXISFLYINGF7PRO/target.h +++ b/src/main/target/AXISFLYINGF7PRO/target.h @@ -52,6 +52,7 @@ #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW0_DEG diff --git a/src/main/target/BETAFPVF722/target.h b/src/main/target/BETAFPVF722/target.h index 3ac2ea0c7e3..6a07e63cf0b 100755 --- a/src/main/target/BETAFPVF722/target.h +++ b/src/main/target/BETAFPVF722/target.h @@ -35,6 +35,7 @@ #define SPI1_MOSI_PIN PA7 #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/BLADE_F4/target.h b/src/main/target/BLADE_F4/target.h index 5501d81b3df..0bd267d760a 100644 --- a/src/main/target/BLADE_F4/target.h +++ b/src/main/target/BLADE_F4/target.h @@ -62,6 +62,7 @@ #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 // ICM42605/ICM42688P diff --git a/src/main/target/BLUEJAYF4/target.h b/src/main/target/BLUEJAYF4/target.h index e62120bdc86..52710e6fdcd 100644 --- a/src/main/target/BLUEJAYF4/target.h +++ b/src/main/target/BLUEJAYF4/target.h @@ -35,6 +35,7 @@ // MPU6500 #define MPU6500_CS_PIN PC4 +#define MPU6500_EXTI_PIN PC5 #define MPU6500_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW0_DEG diff --git a/src/main/target/CADDXF4_AIO_ELRS/target.h b/src/main/target/CADDXF4_AIO_ELRS/target.h index 0a46b81eb4a..d6fd6f4520c 100644 --- a/src/main/target/CADDXF4_AIO_ELRS/target.h +++ b/src/main/target/CADDXF4_AIO_ELRS/target.h @@ -30,6 +30,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/COLIBRI/target.h b/src/main/target/COLIBRI/target.h index 6898448809d..7b2f72f3990 100755 --- a/src/main/target/COLIBRI/target.h +++ b/src/main/target/COLIBRI/target.h @@ -37,6 +37,9 @@ #define BEEPER PC5 #define MPU6000_CS_PIN PC4 +#if defined(COLIBRI) +#define MPU6000_EXTI_PIN PC0 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/DAKEFPVF405/target.h b/src/main/target/DAKEFPVF405/target.h index aa66c89a5a0..91acfd158d6 100644 --- a/src/main/target/DAKEFPVF405/target.h +++ b/src/main/target/DAKEFPVF405/target.h @@ -55,11 +55,13 @@ #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW90_DEG #define MPU6500_CS_PIN PA4 +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW90_DEG #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/DAKEFPVF722/target.h b/src/main/target/DAKEFPVF722/target.h index 2423d91b06e..b3239446d26 100644 --- a/src/main/target/DAKEFPVF722/target.h +++ b/src/main/target/DAKEFPVF722/target.h @@ -55,11 +55,13 @@ #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW90_DEG #define MPU6500_CS_PIN PA4 +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW90_DEG #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/DAKEFPVH743/target.c b/src/main/target/DAKEFPVH743/target.c index 4040aa0fcaa..9aeef364505 100644 --- a/src/main/target/DAKEFPVH743/target.c +++ b/src/main/target/DAKEFPVH743/target.c @@ -35,8 +35,8 @@ BUSDEV_REGISTER_SPI_TAG(busdev_1_BMI270, DEVHW_BMI270, IMU_1_SPI_BUS, IMU_ BUSDEV_REGISTER_SPI_TAG(busdev_1_lsm6dxx, DEVHW_LSM6D, IMU_1_SPI_BUS, IMU_1_CS_PIN, IMU_1_IRQ_PIN, 0, DEVFLAGS_NONE, IMU_1_ALIGN); // // Board hardware definitions - IMU2 slot -BUSDEV_REGISTER_SPI_TAG(busdev_2_mpu6000, DEVHW_MPU6000, IMU_2_SPI_BUS, IMU_2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_2_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_2_mpu6500, DEVHW_MPU6500, IMU_2_SPI_BUS, IMU_2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_2_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_2_mpu6000, DEVHW_MPU6000, IMU_2_SPI_BUS, IMU_2_CS_PIN, PB2, 1, DEVFLAGS_NONE, IMU_2_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_2_mpu6500, DEVHW_MPU6500, IMU_2_SPI_BUS, IMU_2_CS_PIN, PB2, 1, DEVFLAGS_NONE, IMU_2_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_2_ICM42605, DEVHW_ICM42605, IMU_2_SPI_BUS, IMU_2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_2_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_2_BMI270, DEVHW_BMI270, IMU_2_SPI_BUS, IMU_2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_2_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_2_lsm6dxx, DEVHW_LSM6D , IMU_2_SPI_BUS, IMU_2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_2_ALIGN); diff --git a/src/main/target/DALRCF405/target.h b/src/main/target/DALRCF405/target.h index 6a9a5494ffe..f051f93a0ee 100644 --- a/src/main/target/DALRCF405/target.h +++ b/src/main/target/DALRCF405/target.h @@ -33,11 +33,13 @@ #define SPI1_MOSI_PIN PA7 #define MPU6500_CS_PIN PA4 +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW90_DEG #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW90_DEG diff --git a/src/main/target/DALRCF722DUAL/target.h b/src/main/target/DALRCF722DUAL/target.h index 5c6dc15a3d7..eba741ae7d2 100644 --- a/src/main/target/DALRCF722DUAL/target.h +++ b/src/main/target/DALRCF722DUAL/target.h @@ -30,6 +30,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN PB0 +#define MPU6000_EXTI_PIN PB10 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_VCP diff --git a/src/main/target/DYSF4/target.h b/src/main/target/DYSF4/target.h index 76e79106afa..4fd4f3abf0b 100644 --- a/src/main/target/DYSF4/target.h +++ b/src/main/target/DYSF4/target.h @@ -48,6 +48,9 @@ #define UG2864_I2C_BUS I2C_EXT_BUS #define MPU6000_CS_PIN PA4 +#if defined(DYSF4PRO) +#define MPU6000_EXTI_PIN PC4 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/F4BY/target.h b/src/main/target/F4BY/target.h index 21f91c1d49b..5fa535a5ff5 100644 --- a/src/main/target/F4BY/target.h +++ b/src/main/target/F4BY/target.h @@ -30,6 +30,7 @@ #define MPU6000_CS_PIN PA4 #define MPU6000_SPI_BUS BUS_SPI1 #define ICM20689_CS_PIN PA4 +#define ICM20689_EXTI_PIN PB0 #define ICM20689_SPI_BUS BUS_SPI1 diff --git a/src/main/target/FF_FORTINIF4/target.h b/src/main/target/FF_FORTINIF4/target.h index 5af579aba89..38d43dde1ec 100644 --- a/src/main/target/FF_FORTINIF4/target.h +++ b/src/main/target/FF_FORTINIF4/target.h @@ -35,6 +35,7 @@ /*---------------------------------*/ #define MPU6500_CS_PIN PA8 +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 diff --git a/src/main/target/FLASHHOBBYF405/target.h b/src/main/target/FLASHHOBBYF405/target.h index 843cdbd0f6b..dc384e6bcd0 100644 --- a/src/main/target/FLASHHOBBYF405/target.h +++ b/src/main/target/FLASHHOBBYF405/target.h @@ -39,6 +39,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/FLASHHOBBYF722/target.h b/src/main/target/FLASHHOBBYF722/target.h index c52b7b763ff..c8f622e9423 100644 --- a/src/main/target/FLASHHOBBYF722/target.h +++ b/src/main/target/FLASHHOBBYF722/target.h @@ -37,6 +37,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/FLYCOLORF4/target.h b/src/main/target/FLYCOLORF4/target.h index 42112ee297f..5729fa84fb7 100644 --- a/src/main/target/FLYCOLORF4/target.h +++ b/src/main/target/FLYCOLORF4/target.h @@ -51,6 +51,7 @@ #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW180_DEG #define MPU6500_CS_PIN PA4 +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 /*** Onboard flash ***/ diff --git a/src/main/target/FLYCOLORF7MINI/target.c b/src/main/target/FLYCOLORF7MINI/target.c index 411a4fbe403..f178d09a4a3 100644 --- a/src/main/target/FLYCOLORF7MINI/target.c +++ b/src/main/target/FLYCOLORF7MINI/target.c @@ -26,7 +26,7 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, PC3, 0, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); timerHardware_t timerHardware[] = { DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S1 diff --git a/src/main/target/FLYCOLORF7V2/target.h b/src/main/target/FLYCOLORF7V2/target.h index 8222e379d8d..bf593287764 100644 --- a/src/main/target/FLYCOLORF7V2/target.h +++ b/src/main/target/FLYCOLORF7V2/target.h @@ -37,6 +37,7 @@ #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW180_DEG_FLIP #define MPU6500_CS_PIN PA4 +#define MPU6500_EXTI_PIN PC3 #define MPU6500_SPI_BUS BUS_SPI1 // *************** I2C /Baro/Mag ********************* diff --git a/src/main/target/FLYWOOF405PRO/target.h b/src/main/target/FLYWOOF405PRO/target.h index 60240859ef6..c28f8ee0f73 100644 --- a/src/main/target/FLYWOOF405PRO/target.h +++ b/src/main/target/FLYWOOF405PRO/target.h @@ -40,6 +40,9 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW90_DEG #define MPU6000_CS_PIN PB12 +#if defined(FLYWOOF405PRO) +#define MPU6000_EXTI_PIN PB13 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/FLYWOOF405S_AIO/target.h b/src/main/target/FLYWOOF405S_AIO/target.h index 2257720b7a3..b8132f52566 100644 --- a/src/main/target/FLYWOOF405S_AIO/target.h +++ b/src/main/target/FLYWOOF405S_AIO/target.h @@ -36,6 +36,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN PB12 +#define MPU6000_EXTI_PIN PB13 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/FLYWOOF722PRO/target.c b/src/main/target/FLYWOOF722PRO/target.c index 311a07a0cdf..0b9b1a7f2c4 100644 --- a/src/main/target/FLYWOOF722PRO/target.c +++ b/src/main/target/FLYWOOF722PRO/target.c @@ -26,7 +26,7 @@ #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC3, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_ICM42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_BMI270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); diff --git a/src/main/target/FLYWOOF745/target.h b/src/main/target/FLYWOOF745/target.h index e32bd544c5a..2efc3790296 100644 --- a/src/main/target/FLYWOOF745/target.h +++ b/src/main/target/FLYWOOF745/target.h @@ -39,6 +39,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN SPI4_NSS_PIN +#define MPU6000_EXTI_PIN PE1 #define MPU6000_SPI_BUS BUS_SPI4 #define USE_IMU_BMI270 diff --git a/src/main/target/FLYWOOF7DUAL/target.c b/src/main/target/FLYWOOF7DUAL/target.c index 28d5a2ee471..67be532ce9b 100644 --- a/src/main/target/FLYWOOF7DUAL/target.c +++ b/src/main/target/FLYWOOF7DUAL/target.c @@ -30,12 +30,12 @@ #include "io/piniobox.h" // IMU 1 -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_1, DEVHW_MPU6000, GYRO_1_SPI_BUS, GYRO_1_CS_PIN, NONE, 0, DEVFLAGS_NONE, GYRO_1_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_1, DEVHW_MPU6500, GYRO_1_SPI_BUS, GYRO_1_CS_PIN, NONE, 0, DEVFLAGS_NONE, GYRO_1_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_1, DEVHW_MPU6000, GYRO_1_SPI_BUS, GYRO_1_CS_PIN, PC3, 0, DEVFLAGS_NONE, GYRO_1_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_1, DEVHW_MPU6500, GYRO_1_SPI_BUS, GYRO_1_CS_PIN, PC3, 0, DEVFLAGS_NONE, GYRO_1_ALIGN); // IMU 2 -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_2, DEVHW_MPU6000, GYRO_2_SPI_BUS, GYRO_2_CS_PIN, NONE, 1, DEVFLAGS_NONE, GYRO_2_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_2, DEVHW_MPU6500, GYRO_2_SPI_BUS, GYRO_2_CS_PIN, NONE, 1, DEVFLAGS_NONE, GYRO_2_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_2, DEVHW_MPU6000, GYRO_2_SPI_BUS, GYRO_2_CS_PIN, PC4, 1, DEVFLAGS_NONE, GYRO_2_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_2, DEVHW_MPU6500, GYRO_2_SPI_BUS, GYRO_2_CS_PIN, PC4, 1, DEVFLAGS_NONE, GYRO_2_ALIGN); timerHardware_t timerHardware[] = { // DEF_TIM(TIM8, CH1, PC6, TIM_USE_PPM, 0, 0), // PPM&SBUS diff --git a/src/main/target/FOXEERF405/target.h b/src/main/target/FOXEERF405/target.h index a5b74bcd3b5..6ceb0d48361 100644 --- a/src/main/target/FOXEERF405/target.h +++ b/src/main/target/FOXEERF405/target.h @@ -29,12 +29,14 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW90_DEG #define MPU6000_CS_PIN PB2 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 // ICM20689 - handled by MPU6500 driver #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW90_DEG #define MPU6500_CS_PIN PB2 +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 /*** SPI/I2C bus ***/ diff --git a/src/main/target/FOXEERF722DUAL/target.c b/src/main/target/FOXEERF722DUAL/target.c index e81731651e3..7a2ac090aba 100644 --- a/src/main/target/FOXEERF722DUAL/target.c +++ b/src/main/target/FOXEERF722DUAL/target.c @@ -24,7 +24,7 @@ #include "drivers/pwm_mapping.h" #include "drivers/pinio.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); #if defined(FOXEERF722DUAL) BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); #endif diff --git a/src/main/target/FOXEERF722V4/target.h b/src/main/target/FOXEERF722V4/target.h index d764f3399d8..14c24e33e66 100644 --- a/src/main/target/FOXEERF722V4/target.h +++ b/src/main/target/FOXEERF722V4/target.h @@ -36,11 +36,17 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN PB2 +#if defined(FOXEERF722V4) +#define MPU6000_EXTI_PIN PC4 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW270_DEG #define MPU6500_CS_PIN PB2 +#if defined(FOXEERF722V4) +#define MPU6500_EXTI_PIN PC4 +#endif #define MPU6500_SPI_BUS BUS_SPI1 /*** SPI/I2C bus ***/ diff --git a/src/main/target/FOXEERF745AIO/target.h b/src/main/target/FOXEERF745AIO/target.h index 43886731db3..f725ba7b318 100644 --- a/src/main/target/FOXEERF745AIO/target.h +++ b/src/main/target/FOXEERF745AIO/target.h @@ -40,6 +40,9 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN PA15 +#if defined(FOXEERF745AIO) +#define MPU6000_EXTI_PIN PD0 +#endif #define MPU6000_SPI_BUS BUS_SPI3 #endif diff --git a/src/main/target/FOXEERH743/target.h b/src/main/target/FOXEERH743/target.h index f2e2f83eb40..40692c17c26 100644 --- a/src/main/target/FOXEERH743/target.h +++ b/src/main/target/FOXEERH743/target.h @@ -48,6 +48,7 @@ #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_SPI_BUS BUS_SPI2 #define MPU6000_CS_PIN PB12 +#define MPU6000_EXTI_PIN PD0 // *************** SPI3 FLASH *********************** #define USE_SPI_DEVICE_3 diff --git a/src/main/target/FURYF4OSD/target.h b/src/main/target/FURYF4OSD/target.h index 6b6b3f6d8a9..85ce3ab2c1c 100644 --- a/src/main/target/FURYF4OSD/target.h +++ b/src/main/target/FURYF4OSD/target.h @@ -38,11 +38,17 @@ #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW180_DEG #define MPU6500_CS_PIN PA4 +#if defined(FURYF4OSD) +#define MPU6500_EXTI_PIN PC4 +#endif #define MPU6500_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN PA4 +#if defined(FURYF4OSD) +#define MPU6000_EXTI_PIN PC4 +#endif #define MPU6000_SPI_BUS BUS_SPI1 // ICM42605/ICM42688P diff --git a/src/main/target/GEPRCF405/target.h b/src/main/target/GEPRCF405/target.h index f6b4e4eaa10..e13bae3ce9f 100644 --- a/src/main/target/GEPRCF405/target.h +++ b/src/main/target/GEPRCF405/target.h @@ -44,6 +44,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN PA15 +#define MPU6000_EXTI_PIN PC3 #define MPU6000_SPI_BUS BUS_SPI3 #define USE_IMU_BMI270 diff --git a/src/main/target/GEPRCF405_BT_HD/target.h b/src/main/target/GEPRCF405_BT_HD/target.h index b0b33db2f5f..d1e5676559e 100644 --- a/src/main/target/GEPRCF405_BT_HD/target.h +++ b/src/main/target/GEPRCF405_BT_HD/target.h @@ -42,6 +42,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN PA15 +#define MPU6000_EXTI_PIN PC3 #define MPU6000_SPI_BUS BUS_SPI3 #define USE_IMU_BMI270 diff --git a/src/main/target/GEPRCF722/target.h b/src/main/target/GEPRCF722/target.h index 5a6cfc08e2e..27949faa381 100644 --- a/src/main/target/GEPRCF722/target.h +++ b/src/main/target/GEPRCF722/target.h @@ -41,6 +41,7 @@ #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN PA15 +#define MPU6000_EXTI_PIN PC3 #define MPU6000_SPI_BUS BUS_SPI3 #define USE_IMU_BMI270 diff --git a/src/main/target/GEPRCF722_BT_HD/target.h b/src/main/target/GEPRCF722_BT_HD/target.h index 2309a5b1c19..d0b4a76ab3e 100644 --- a/src/main/target/GEPRCF722_BT_HD/target.h +++ b/src/main/target/GEPRCF722_BT_HD/target.h @@ -39,6 +39,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN PA15 +#define MPU6000_EXTI_PIN PA8 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/GEPRC_F722_AIO/target.h b/src/main/target/GEPRC_F722_AIO/target.h index ea0230b7173..9f964084933 100644 --- a/src/main/target/GEPRC_F722_AIO/target.h +++ b/src/main/target/GEPRC_F722_AIO/target.h @@ -43,6 +43,9 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW90_DEG #define MPU6000_CS_PIN PA15 +#if defined(GEPRC_F722_AIO) +#define MPU6000_EXTI_PIN PA8 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/HAKRCF405D/target.c b/src/main/target/HAKRCF405D/target.c index 5d1ed7acefe..cda185ce71a 100644 --- a/src/main/target/HAKRCF405D/target.c +++ b/src/main/target/HAKRCF405D/target.c @@ -26,7 +26,7 @@ BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC3, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/HAKRCF405V2/target.h b/src/main/target/HAKRCF405V2/target.h index 9c498777b4f..81f34522f10 100644 --- a/src/main/target/HAKRCF405V2/target.h +++ b/src/main/target/HAKRCF405V2/target.h @@ -61,6 +61,7 @@ #define IMU_MPU6000_ALIGN CW90_DEG #define MPU6000_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 // ICM42605/ICM42688P diff --git a/src/main/target/HAKRCF411D/target.h b/src/main/target/HAKRCF411D/target.h index 33b48a137d4..db6dfe9f201 100644 --- a/src/main/target/HAKRCF411D/target.h +++ b/src/main/target/HAKRCF411D/target.h @@ -53,6 +53,7 @@ #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PA1 // ICM42605/ICM42688P #define USE_IMU_ICM42605 diff --git a/src/main/target/HGLRCF405V2/target.h b/src/main/target/HGLRCF405V2/target.h index 8d427eedb2c..fa4afebf8bd 100644 --- a/src/main/target/HGLRCF405V2/target.h +++ b/src/main/target/HGLRCF405V2/target.h @@ -60,6 +60,7 @@ #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 // ICM42605/ICM42688P #define USE_IMU_ICM42605 diff --git a/src/main/target/HGLRCF722/target.c b/src/main/target/HGLRCF722/target.c index db20f4f2676..41ecf6315f0 100644 --- a/src/main/target/HGLRCF722/target.c +++ b/src/main/target/HGLRCF722/target.c @@ -33,7 +33,7 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/IFLIGHT_BLITZ_F722/target.h b/src/main/target/IFLIGHT_BLITZ_F722/target.h index 94834fd6171..4ca8a4eaef4 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F722/target.h @@ -41,6 +41,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c b/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c index cd4bfd84494..e6245d39288 100644 --- a/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c +++ b/src/main/target/IFLIGHT_BLITZ_F7_PRO/target.c @@ -26,7 +26,7 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PA8, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/IFLIGHT_H743_AIO_V2/target.h b/src/main/target/IFLIGHT_H743_AIO_V2/target.h index d790e6a95ea..90bfae915de 100644 --- a/src/main/target/IFLIGHT_H743_AIO_V2/target.h +++ b/src/main/target/IFLIGHT_H743_AIO_V2/target.h @@ -39,6 +39,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PD0 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/KAKUTEF4/target.h b/src/main/target/KAKUTEF4/target.h index 345b3fa5a3a..7dd557ed32b 100644 --- a/src/main/target/KAKUTEF4/target.h +++ b/src/main/target/KAKUTEF4/target.h @@ -50,11 +50,17 @@ #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW270_DEG #define MPU6500_CS_PIN PC4 +#if defined(KAKUTEF4) || defined(KAKUTEF4V2) +#define MPU6500_EXTI_PIN PC5 +#endif #define MPU6500_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN PC4 +#if defined(KAKUTEF4) || defined(KAKUTEF4V2) +#define MPU6000_EXTI_PIN PC5 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/KAKUTEF7/target.h b/src/main/target/KAKUTEF7/target.h index 79f9d079353..45c2b6f2eef 100644 --- a/src/main/target/KAKUTEF7/target.h +++ b/src/main/target/KAKUTEF7/target.h @@ -42,11 +42,13 @@ #define USE_IMU_ICM20689 #define IMU_ICM20689_ALIGN CW270_DEG #define ICM20689_CS_PIN SPI4_NSS_PIN +#define ICM20689_EXTI_PIN PE1 #define ICM20689_SPI_BUS BUS_SPI4 #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN SPI4_NSS_PIN +#define MPU6000_EXTI_PIN PE1 #define MPU6000_SPI_BUS BUS_SPI4 diff --git a/src/main/target/KAKUTEF7MINIV3/target.h b/src/main/target/KAKUTEF7MINIV3/target.h index 89ba7c632b5..3cfb1039921 100644 --- a/src/main/target/KAKUTEF7MINIV3/target.h +++ b/src/main/target/KAKUTEF7MINIV3/target.h @@ -87,6 +87,7 @@ #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN PB2 +#define MPU6000_EXTI_PIN PA4 // ICM42688 #define USE_IMU_ICM42605 diff --git a/src/main/target/KAKUTEH7/target.h b/src/main/target/KAKUTEH7/target.h index 22fbe6312de..d218efd36ec 100644 --- a/src/main/target/KAKUTEH7/target.h +++ b/src/main/target/KAKUTEH7/target.h @@ -101,6 +101,7 @@ #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_SPI_BUS BUS_SPI4 #define MPU6000_CS_PIN PE4 +#define MPU6000_EXTI_PIN PE1 //BMI270 #define USE_IMU_BMI270 diff --git a/src/main/target/MAMBAF405US/target.h b/src/main/target/MAMBAF405US/target.h index 1b21fe60e3d..00bfb36523e 100644 --- a/src/main/target/MAMBAF405US/target.h +++ b/src/main/target/MAMBAF405US/target.h @@ -39,11 +39,17 @@ #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN PA4 +#if defined(MAMBAF405US) +#define MPU6000_EXTI_PIN PC4 +#endif #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW180_DEG #define MPU6500_SPI_BUS BUS_SPI1 #define MPU6500_CS_PIN PA4 +#if defined(MAMBAF405US) +#define MPU6500_EXTI_PIN PC4 +#endif // *************** Baro ************************** #define USE_I2C diff --git a/src/main/target/MAMBAF405_2022A/target.h b/src/main/target/MAMBAF405_2022A/target.h index 35f04063893..843b9440cae 100644 --- a/src/main/target/MAMBAF405_2022A/target.h +++ b/src/main/target/MAMBAF405_2022A/target.h @@ -41,11 +41,13 @@ #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 //MPU6500 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW180_DEG #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 //BMI270 diff --git a/src/main/target/MAMBAF722_2022A/target.h b/src/main/target/MAMBAF722_2022A/target.h index 74d46951498..474e304b377 100644 --- a/src/main/target/MAMBAF722_2022A/target.h +++ b/src/main/target/MAMBAF722_2022A/target.h @@ -44,12 +44,14 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 //MPU6500 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW180_DEG #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 //BMI270 diff --git a/src/main/target/MATEKF405/target.h b/src/main/target/MATEKF405/target.h index a33807c06a5..3c308b63e13 100644 --- a/src/main/target/MATEKF405/target.h +++ b/src/main/target/MATEKF405/target.h @@ -36,9 +36,15 @@ #define SPI1_MOSI_PIN PA7 #define MPU6500_CS_PIN PC2 +#if defined(MATEKF405MINI) +#define MPU6500_EXTI_PIN PC3 +#endif #define MPU6500_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN PC2 +#if defined(MATEKF405MINI) +#define MPU6000_EXTI_PIN PC3 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 diff --git a/src/main/target/MATEKF405SE/target.h b/src/main/target/MATEKF405SE/target.h index 3a5cbb58142..c31dab3f058 100644 --- a/src/main/target/MATEKF405SE/target.h +++ b/src/main/target/MATEKF405SE/target.h @@ -40,6 +40,9 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN PA4 +#if defined(MATEKF405SE) +#define MPU6000_EXTI_PIN PC4 +#endif #define MPU6000_SPI_BUS BUS_SPI1 // ICM42688P diff --git a/src/main/target/MATEKF411/target.h b/src/main/target/MATEKF411/target.h index 6be5949419c..40d5f6143da 100755 --- a/src/main/target/MATEKF411/target.h +++ b/src/main/target/MATEKF411/target.h @@ -38,11 +38,17 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN PA4 +#if defined(MATEKF411) +#define MPU6000_EXTI_PIN PA1 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW180_DEG #define MPU6500_CS_PIN PA4 +#if defined(MATEKF411) +#define MPU6500_EXTI_PIN PA1 +#endif #define MPU6500_SPI_BUS BUS_SPI1 // *************** SPI2 OSD ***************************** diff --git a/src/main/target/MATEKF411SE/target.h b/src/main/target/MATEKF411SE/target.h index db5652e0cac..371937184cd 100755 --- a/src/main/target/MATEKF411SE/target.h +++ b/src/main/target/MATEKF411SE/target.h @@ -37,6 +37,9 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN PA4 +#if defined(MATEKF411SE) +#define MPU6000_EXTI_PIN PA14 +#endif #define MPU6000_SPI_BUS BUS_SPI1 // *************** SPI2 OSD ***************************** diff --git a/src/main/target/MATEKF722/target.h b/src/main/target/MATEKF722/target.h index 1908c6a5b4c..8b535d644ca 100644 --- a/src/main/target/MATEKF722/target.h +++ b/src/main/target/MATEKF722/target.h @@ -38,6 +38,7 @@ #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW180_DEG #define MPU6500_CS_PIN PC2 +#define MPU6500_EXTI_PIN PC3 #define MPU6500_SPI_BUS BUS_SPI1 // *************** I2C/Baro/Mag ********************* diff --git a/src/main/target/MATEKF722SE/target.c b/src/main/target/MATEKF722SE/target.c index 585f3bb3994..2358427f8e2 100644 --- a/src/main/target/MATEKF722SE/target.c +++ b/src/main/target/MATEKF722SE/target.c @@ -26,8 +26,8 @@ #include "drivers/pinio.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, PC3, 1, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); timerHardware_t timerHardware[] = { DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // S1 UP1-2 D(1, 4, 5) diff --git a/src/main/target/OMNIBUSF4/target.h b/src/main/target/OMNIBUSF4/target.h index af906bb8b12..1abedae9ac1 100644 --- a/src/main/target/OMNIBUSF4/target.h +++ b/src/main/target/OMNIBUSF4/target.h @@ -34,6 +34,7 @@ #define UG2864_I2C_BUS I2C_EXT_BUS #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/RADIOLINKF405/target.h b/src/main/target/RADIOLINKF405/target.h index f3a7b3294e8..44a170e420d 100644 --- a/src/main/target/RADIOLINKF405/target.h +++ b/src/main/target/RADIOLINKF405/target.h @@ -51,6 +51,7 @@ #define IMU_MPU6500_ALIGN CW90_DEG #define MPU6500_SPI_BUS BUS_SPI1 #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PC4 // *************** SPI2 OSD **************** #define USE_SPI_DEVICE_2 diff --git a/src/main/target/REVO/target.h b/src/main/target/REVO/target.h index 713c1a8ce38..1eeff29fbb1 100644 --- a/src/main/target/REVO/target.h +++ b/src/main/target/REVO/target.h @@ -35,6 +35,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_MAG diff --git a/src/main/target/SKYSTARSF405HD/target.h b/src/main/target/SKYSTARSF405HD/target.h index 6dad1b8a18e..166cc332d70 100644 --- a/src/main/target/SKYSTARSF405HD/target.h +++ b/src/main/target/SKYSTARSF405HD/target.h @@ -38,6 +38,9 @@ #define USE_IMU_MPU6000 #define MPU6000_SPI_BUS BUS_SPI1 #define MPU6000_CS_PIN PA4 +#if defined(SKYSTARSF405AIO) +#define MPU6000_EXTI_PIN PC4 +#endif #define USE_IMU_BMI270 #define BMI270_SPI_BUS BUS_SPI1 diff --git a/src/main/target/SOLOGOODF722/target.h b/src/main/target/SOLOGOODF722/target.h index 281d2127357..efeec61a896 100644 --- a/src/main/target/SOLOGOODF722/target.h +++ b/src/main/target/SOLOGOODF722/target.h @@ -39,6 +39,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW180_DEG #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/SPEDIXF405/target.h b/src/main/target/SPEDIXF405/target.h index 6c9ddbff793..7b484c5a554 100644 --- a/src/main/target/SPEDIXF405/target.h +++ b/src/main/target/SPEDIXF405/target.h @@ -38,6 +38,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/SPEDIXF722/target.h b/src/main/target/SPEDIXF722/target.h index 2f5e85b477b..c9c4edfbda8 100644 --- a/src/main/target/SPEDIXF722/target.h +++ b/src/main/target/SPEDIXF722/target.h @@ -39,6 +39,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_BMI270 diff --git a/src/main/target/SPEEDYBEEF7/target.h b/src/main/target/SPEEDYBEEF7/target.h index 032f7479b5b..c5d94cb27ec 100644 --- a/src/main/target/SPEEDYBEEF7/target.h +++ b/src/main/target/SPEEDYBEEF7/target.h @@ -63,6 +63,7 @@ #define IMU_ICM20689_ALIGN CW0_DEG #define ICM20689_CS_PIN PA4 +#define ICM20689_EXTI_PIN PC4 #define ICM20689_SPI_BUS BUS_SPI1 #define SPI1_SCK_PIN PA5 diff --git a/src/main/target/SPEEDYBEEF745AIO/target.h b/src/main/target/SPEEDYBEEF745AIO/target.h index 7064da7ec72..f090069f462 100644 --- a/src/main/target/SPEEDYBEEF745AIO/target.h +++ b/src/main/target/SPEEDYBEEF745AIO/target.h @@ -74,6 +74,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW90_DEG #define MPU6000_CS_PIN PE4 +#define MPU6000_EXTI_PIN PE1 #define MPU6000_SPI_BUS BUS_SPI4 //BMI270 diff --git a/src/main/target/SPEEDYBEEF7MINI/target.c b/src/main/target/SPEEDYBEEF7MINI/target.c index c521d758ae2..b5291e4a968 100644 --- a/src/main/target/SPEEDYBEEF7MINI/target.c +++ b/src/main/target/SPEEDYBEEF7MINI/target.c @@ -29,7 +29,7 @@ #ifdef SPEEDYBEEF7MINIV2 BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); #else -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); #endif timerHardware_t timerHardware[] = { diff --git a/src/main/target/SPEEDYBEEF7V2/target.h b/src/main/target/SPEEDYBEEF7V2/target.h index 9dfcdf232b8..222cb1775df 100644 --- a/src/main/target/SPEEDYBEEF7V2/target.h +++ b/src/main/target/SPEEDYBEEF7V2/target.h @@ -70,6 +70,7 @@ #define SPI1_MOSI_PIN PA7 #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_BEEPER diff --git a/src/main/target/SPEEDYBEEF7V3/target.c b/src/main/target/SPEEDYBEEF7V3/target.c index b8af59ba015..a10d7d924f0 100644 --- a/src/main/target/SPEEDYBEEF7V3/target.c +++ b/src/main/target/SPEEDYBEEF7V3/target.c @@ -29,7 +29,7 @@ #include "drivers/sensor.h" BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, BMI270_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/SPRACINGF4EVO/target.h b/src/main/target/SPRACINGF4EVO/target.h index 8af6981e54f..68cec262ef7 100755 --- a/src/main/target/SPRACINGF4EVO/target.h +++ b/src/main/target/SPRACINGF4EVO/target.h @@ -116,6 +116,7 @@ #define SDCARD_CS_PIN SPI2_NSS_PIN #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PC13 #define MPU6500_SPI_BUS BUS_SPI1 #define MPU9250_CS_PIN SPI1_NSS_PIN diff --git a/src/main/target/SPRACINGF7DUAL/target.c b/src/main/target/SPRACINGF7DUAL/target.c index ead356956a4..0c213e14076 100644 --- a/src/main/target/SPRACINGF7DUAL/target.c +++ b/src/main/target/SPRACINGF7DUAL/target.c @@ -31,7 +31,7 @@ // Register both MPU6500 BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_1, DEVHW_MPU6500, MPU6500_1_SPI_BUS, MPU6500_1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_1_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_2, DEVHW_MPU6500, MPU6500_2_SPI_BUS, MPU6500_2_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_2_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_2, DEVHW_MPU6500, MPU6500_2_SPI_BUS, MPU6500_2_CS_PIN, PC14, 0, DEVFLAGS_NONE, IMU_2_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/TAKERF722SE/target.h b/src/main/target/TAKERF722SE/target.h index 09007ab930e..f2da5225824 100644 --- a/src/main/target/TAKERF722SE/target.h +++ b/src/main/target/TAKERF722SE/target.h @@ -98,6 +98,7 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 diff --git a/src/main/target/TMOTORF7/target.h b/src/main/target/TMOTORF7/target.h index cb462f1c303..acbaaaa45e2 100644 --- a/src/main/target/TMOTORF7/target.h +++ b/src/main/target/TMOTORF7/target.h @@ -42,6 +42,9 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG #define MPU6000_CS_PIN PA4 +#if defined(TMOTORF7) +#define MPU6000_EXTI_PIN PC4 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/TMOTORF7V2/target.h b/src/main/target/TMOTORF7V2/target.h index 2a37231dff3..fe42ebc07e4 100644 --- a/src/main/target/TMOTORF7V2/target.h +++ b/src/main/target/TMOTORF7V2/target.h @@ -62,6 +62,7 @@ #define SPI1_MOSI_PIN PA7 #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/common_hardware.c b/src/main/target/common_hardware.c index ba6fd38271c..64547f6b505 100755 --- a/src/main/target/common_hardware.c +++ b/src/main/target/common_hardware.c @@ -30,12 +30,18 @@ #endif #if defined(USE_IMU_MPU6000) - BUSDEV_REGISTER_SPI(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); + #if !defined(MPU6000_EXTI_PIN) + #define MPU6000_EXTI_PIN NONE + #endif + BUSDEV_REGISTER_SPI(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, MPU6000_EXTI_PIN, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); #endif #if defined(USE_IMU_MPU6500) #if defined(MPU6500_SPI_BUS) - BUSDEV_REGISTER_SPI(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, NONE, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); + #if !defined(MPU6500_EXTI_PIN) + #define MPU6500_EXTI_PIN NONE + #endif + BUSDEV_REGISTER_SPI(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, MPU6500_EXTI_PIN, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); #elif defined(MPU6500_I2C_BUS) BUSDEV_REGISTER_I2C(busdev_mpu6500, DEVHW_MPU6500, MPU6500_I2C_BUS, MPU_ADDRESS, NONE, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); #endif @@ -50,7 +56,10 @@ #endif #if defined(USE_IMU_ICM20689) - BUSDEV_REGISTER_SPI(busdev_icm20689, DEVHW_ICM20689, ICM20689_SPI_BUS, ICM20689_CS_PIN, NONE, DEVFLAGS_NONE, IMU_ICM20689_ALIGN); + #if !defined(ICM20689_EXTI_PIN) + #define ICM20689_EXTI_PIN NONE + #endif + BUSDEV_REGISTER_SPI(busdev_icm20689, DEVHW_ICM20689, ICM20689_SPI_BUS, ICM20689_CS_PIN, ICM20689_EXTI_PIN, DEVFLAGS_NONE, IMU_ICM20689_ALIGN); #endif #if defined(USE_IMU_ICM42605) From e2a7aeb98a39c2a5eb9c160d54af490024c23eb2 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Tue, 29 Sep 2026 00:43:29 +0200 Subject: [PATCH 18/24] gyro: MPU9250 and LSM6DXX read on data-ready too The MPU9250 has the MPU6500's registers and takes the same read. The LSM6DXX drivers already route gyro data-ready, pulsed, to INT1; the read takes the gyro and the accelerometer from OUTX_L_G. The LSM6DSO and LSM6DSL run at 6664 Hz whatever is asked, so with data-ready the gyro task and its first filter run at that rate instead of the MPU table's. --- docs/Settings.md | 2 +- src/main/drivers/accgyro/accgyro_data_ready.c | 11 ++++- src/main/drivers/accgyro/accgyro_data_ready.h | 2 + src/main/drivers/accgyro/accgyro_lsm6dxx.c | 47 +++++++++++++++++++ src/main/drivers/accgyro/accgyro_mpu9250.c | 4 ++ src/main/fc/settings.yaml | 2 +- src/main/target/common_hardware.c | 10 +++- 7 files changed, 72 insertions(+), 6 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 8feafd9bb80..c6cf8358a09 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2140,7 +2140,7 @@ Gyro processing anti-aliasing filter cutoff frequency. In normal operation this ### gyro_data_ready -Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270, ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives) and ICM-20689, OFF polls the gyro. +Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270, ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives), MPU9250, ICM-20689 and LSM6DXX, OFF polls the gyro. | Allowed Values | | | --- | --- | diff --git a/src/main/drivers/accgyro/accgyro_data_ready.c b/src/main/drivers/accgyro/accgyro_data_ready.c index 4b898c26895..37e9cd32d67 100644 --- a/src/main/drivers/accgyro/accgyro_data_ready.c +++ b/src/main/drivers/accgyro/accgyro_data_ready.c @@ -179,12 +179,19 @@ void gyroDataReadySuspend(void) } } +bool gyroDataReadyWanted(const gyroDev_t *gyro) +{ + const gyroDataReadyDriver_t *driver = gyro->dataReadyDriver; + const busDevice_t *dev = gyro->busDev; + return driver && dev && dev->irqPin && gyro->readOnDataReady != GYRO_DEV_DATA_READY_OFF && + (gyro->readOnDataReady != GYRO_DEV_DATA_READY_WHERE_TESTED || driver->tested); +} + void gyroDataReadyStart(gyroDev_t *gyro) { const gyroDataReadyDriver_t *driver = gyro->dataReadyDriver; busDevice_t *dev = gyro->busDev; - if (!driver || !dev || !dev->irqPin || gyro->readOnDataReady == GYRO_DEV_DATA_READY_OFF || - (gyro->readOnDataReady == GYRO_DEV_DATA_READY_WHERE_TESTED && !driver->tested)) { + if (!gyroDataReadyWanted(gyro)) { return; } // A pin already owned stays with its owner; a wrong but free pin only means polling as before diff --git a/src/main/drivers/accgyro/accgyro_data_ready.h b/src/main/drivers/accgyro/accgyro_data_ready.h index 721817c74e0..ff10c03ae5b 100644 --- a/src/main/drivers/accgyro/accgyro_data_ready.h +++ b/src/main/drivers/accgyro/accgyro_data_ready.h @@ -45,6 +45,8 @@ typedef struct gyroDataReadyDriver_s { typedef struct gyroDataReady_s gyroDataReady_t; #if defined(USE_SPI_DATA_READY) +// Whether gyroDataReadyStart() will try, for a driver whose rate depends on it +bool gyroDataReadyWanted(const gyroDev_t *gyro); void gyroDataReadyStart(gyroDev_t *gyro); void gyroDataReadySuspend(void); // For the driver's acc and temperature reads: true when the last data-ready read brought them diff --git a/src/main/drivers/accgyro/accgyro_lsm6dxx.c b/src/main/drivers/accgyro/accgyro_lsm6dxx.c index d00df7442d7..e2d53880ebf 100644 --- a/src/main/drivers/accgyro/accgyro_lsm6dxx.c +++ b/src/main/drivers/accgyro/accgyro_lsm6dxx.c @@ -35,6 +35,7 @@ #include "drivers/accgyro/accgyro.h" #include "drivers/accgyro/accgyro_mpu.h" #include "drivers/accgyro/accgyro_lsm6dxx.h" +#include "drivers/accgyro/accgyro_data_ready.h" #if defined(USE_IMU_LSM6DXX) @@ -180,6 +181,12 @@ static void lsm6dxxConfig(gyroDev_t *gyro) busDevice_t * dev = gyro->busDev; const gyroFilterAndRateConfig_t * config = mpuChooseGyroConfig(gyro->lpf, 1000000 / gyro->requestedSampleIntervalUs); gyro->sampleRateIntervalUs = 1000000 / config->gyroRateHz; +#if defined(USE_SPI_DATA_READY) + // On data-ready every sample reaches the gyro task and its first filter, so they run at the 6664 Hz set below + if (gyroDataReadyWanted(gyro)) { + gyro->sampleRateIntervalUs = 150; + } +#endif busSetSpeed(dev, BUS_SPEED_INITIALIZATION); // Reset the device (wait 100ms before continuing config) @@ -271,6 +278,17 @@ static void lsm6dxxSpiAccInit(accDev_t *acc) static bool lsm6dxxAccRead(accDev_t *acc) { +#if defined(USE_SPI_DATA_READY) + // The read on data-ready brought the accelerometer too + int16_t v[XYZ_AXIS_COUNT]; + if (gyroDataReadyAcc(acc->busDev, v)) { + acc->ADCRaw[X] = v[X]; + acc->ADCRaw[Y] = v[Y]; + acc->ADCRaw[Z] = v[Z]; + return true; + } +#endif + uint8_t data[6]; const bool ack = busReadBuf(acc->busDev, LSM6DXX_REG_OUTX_L_A, data, 6); if (!ack) { @@ -295,6 +313,31 @@ static bool lsm6dxxGyroRead(gyroDev_t *gyro) return true; } +#if defined(USE_SPI_DATA_READY) +// From OUTX_L_G: gyro X, Y, Z, then accelerometer X, Y, Z, little-endian +static void lsm6dxxDataReadyParse(const uint8_t *data, bool withAccAndTemp, int16_t *gyro, int16_t *acc, int16_t *temp) +{ + UNUSED(temp); + gyro[X] = int16_val_little_endian(data, 0); + gyro[Y] = int16_val_little_endian(data, 1); + gyro[Z] = int16_val_little_endian(data, 2); + if (withAccAndTemp) { + acc[X] = int16_val_little_endian(data, 3); + acc[Y] = int16_val_little_endian(data, 4); + acc[Z] = int16_val_little_endian(data, 5); + } +} + +static const gyroDataReadyDriver_t lsm6dxxDataReady = { + .withAccAndTemp = { LSM6DXX_REG_OUTX_L_G | 0x80, 12 }, + .gyroOnly = { LSM6DXX_REG_OUTX_L_G | 0x80, 6 }, + .hasTemp = false, + .parse = lsm6dxxDataReadyParse, + .registerRead = lsm6dxxGyroRead, + .tested = true, +}; +#endif + // Init Gyro first,then Acc bool lsm6dGyroDetect(gyroDev_t *gyro) { @@ -316,6 +359,10 @@ bool lsm6dGyroDetect(gyroDev_t *gyro) gyro->intStatusFn = gyroCheckDataReady; gyro->gyroAlign = gyro->busDev->param; gyro->scale = 1.0f / 16.4f; // 2000 dps +#if defined(USE_SPI_DATA_READY) + // Both register maps configure gyro data-ready, pulsed, on INT1 + gyro->dataReadyDriver = &lsm6dxxDataReady; +#endif return true; } diff --git a/src/main/drivers/accgyro/accgyro_mpu9250.c b/src/main/drivers/accgyro/accgyro_mpu9250.c index 1e9360f4b36..5b82e0abae7 100644 --- a/src/main/drivers/accgyro/accgyro_mpu9250.c +++ b/src/main/drivers/accgyro/accgyro_mpu9250.c @@ -96,6 +96,10 @@ static void mpu9250AccAndGyroInit(gyroDev_t *gyro) busWrite(dev, MPU_RA_SMPLRT_DIV, config->gyroConfigValues[1]); delay(100); +#if defined(USE_SPI_DATA_READY) + mpuDataReadySetup(gyro); +#endif + busSetSpeed(dev, BUS_SPEED_FAST); } diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 56c3ac352f0..860802a7bb4 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -353,7 +353,7 @@ groups: field: gyro_secondary_enabled type: bool - name: gyro_data_ready - description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270, ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives) and ICM-20689, OFF polls the gyro." + description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270, ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives), MPU9250, ICM-20689 and LSM6DXX, OFF polls the gyro." default_value: "AUTO" condition: USE_SPI_DATA_READY field: gyro_data_ready diff --git a/src/main/target/common_hardware.c b/src/main/target/common_hardware.c index 64547f6b505..8186da96d65 100755 --- a/src/main/target/common_hardware.c +++ b/src/main/target/common_hardware.c @@ -49,7 +49,10 @@ #if defined(USE_IMU_MPU9250) #if defined(MPU9250_SPI_BUS) - BUSDEV_REGISTER_SPI(busdev_mpu9250, DEVHW_MPU9250, MPU9250_SPI_BUS, MPU9250_CS_PIN, NONE, DEVFLAGS_NONE, IMU_MPU9250_ALIGN); + #if !defined(MPU9250_EXTI_PIN) + #define MPU9250_EXTI_PIN NONE + #endif + BUSDEV_REGISTER_SPI(busdev_mpu9250, DEVHW_MPU9250, MPU9250_SPI_BUS, MPU9250_CS_PIN, MPU9250_EXTI_PIN, DEVFLAGS_NONE, IMU_MPU9250_ALIGN); #elif defined(MPU9250_I2C_BUS) BUSDEV_REGISTER_I2C(busdev_mpu9250, DEVHW_MPU9250, MPU9250_I2C_BUS, MPU_ADDRESS, NONE, DEVFLAGS_NONE, IMU_MPU9250_ALIGN); #endif @@ -94,7 +97,10 @@ #endif #if defined(USE_IMU_LSM6DXX) - BUSDEV_REGISTER_SPI(busdev_lsm6dxx, DEVHW_LSM6D, LSM6DXX_SPI_BUS, LSM6DXX_CS_PIN, NONE, DEVFLAGS_NONE, IMU_LSM6DXX_ALIGN); + #if !defined(LSM6DXX_EXTI_PIN) + #define LSM6DXX_EXTI_PIN NONE + #endif + BUSDEV_REGISTER_SPI(busdev_lsm6dxx, DEVHW_LSM6D, LSM6DXX_SPI_BUS, LSM6DXX_CS_PIN, LSM6DXX_EXTI_PIN, DEVFLAGS_NONE, IMU_LSM6DXX_ALIGN); #endif #if defined(USE_IMU_ICM45686) From 7fb0a2f2cb8560d38ddbacb7dea44cac677edda3 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Tue, 29 Sep 2026 00:43:29 +0200 Subject: [PATCH 19/24] targets: MPU9250 and LSM6DXX data-ready pins From Betaflight's config for the same board, where both agree on the CS pin and SPI bus. DAKEFPVF722X8 already declared LSM6DXX_EXTI_PIN PC4, which matches; the registration now passes it. --- src/main/target/ALIENFLIGHTF4/target.h | 1 + src/main/target/ALIENFLIGHTNGF7/target.h | 1 + src/main/target/DAKEFPVF405/target.h | 1 + src/main/target/DAKEFPVF722/target.h | 1 + src/main/target/FISHDRONEF4/target.h | 1 + src/main/target/SPARKY2/target.h | 1 + src/main/target/SPRACINGF4EVO/target.h | 1 + 7 files changed, 7 insertions(+) diff --git a/src/main/target/ALIENFLIGHTF4/target.h b/src/main/target/ALIENFLIGHTF4/target.h index d6c7fd3e149..d3e8c116ff6 100644 --- a/src/main/target/ALIENFLIGHTF4/target.h +++ b/src/main/target/ALIENFLIGHTF4/target.h @@ -37,6 +37,7 @@ #define MPU6500_SPI_BUS BUS_SPI1 #define MPU9250_CS_PIN SPI1_NSS_PIN +#define MPU9250_EXTI_PIN PC14 #define MPU9250_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 diff --git a/src/main/target/ALIENFLIGHTNGF7/target.h b/src/main/target/ALIENFLIGHTNGF7/target.h index 1c8e0f901ef..ccee52a78a2 100644 --- a/src/main/target/ALIENFLIGHTNGF7/target.h +++ b/src/main/target/ALIENFLIGHTNGF7/target.h @@ -34,6 +34,7 @@ #define MPU6500_SPI_BUS BUS_SPI1 #define MPU9250_CS_PIN SPI1_NSS_PIN +#define MPU9250_EXTI_PIN PC14 #define MPU9250_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 diff --git a/src/main/target/DAKEFPVF405/target.h b/src/main/target/DAKEFPVF405/target.h index 91acfd158d6..2d855d6c78c 100644 --- a/src/main/target/DAKEFPVF405/target.h +++ b/src/main/target/DAKEFPVF405/target.h @@ -80,6 +80,7 @@ #define IMU_LSM6DXX_ALIGN CW90_DEG #define LSM6DXX_SPI_BUS BUS_SPI1 #define LSM6DXX_CS_PIN PA4 +#define LSM6DXX_EXTI_PIN PC4 // ICM42688P driver handled by USE_IMU_ICM42605 above (shares WHO_AM_I detection) // LSM6DSV16X / LSM6DSK320X driver handled by USE_IMU_LSM6DXX above (shares WHO_AM_I detection) diff --git a/src/main/target/DAKEFPVF722/target.h b/src/main/target/DAKEFPVF722/target.h index b3239446d26..0111e1b65b7 100644 --- a/src/main/target/DAKEFPVF722/target.h +++ b/src/main/target/DAKEFPVF722/target.h @@ -80,6 +80,7 @@ #define IMU_LSM6DXX_ALIGN CW90_DEG #define LSM6DXX_SPI_BUS BUS_SPI1 #define LSM6DXX_CS_PIN PA4 +#define LSM6DXX_EXTI_PIN PC4 // LSM6DSV16X / LSM6DSK320X driver handled by USE_IMU_LSM6DXX above (shares WHO_AM_I detection) diff --git a/src/main/target/FISHDRONEF4/target.h b/src/main/target/FISHDRONEF4/target.h index 86206826c38..47e87cf8be5 100644 --- a/src/main/target/FISHDRONEF4/target.h +++ b/src/main/target/FISHDRONEF4/target.h @@ -36,6 +36,7 @@ #define MPU6500_CS_PIN PA4 #define MPU6500_SPI_BUS BUS_SPI1 #define MPU9250_CS_PIN PA4 +#define MPU9250_EXTI_PIN PC4 #define MPU9250_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 diff --git a/src/main/target/SPARKY2/target.h b/src/main/target/SPARKY2/target.h index 78f80cd609d..037055d32d8 100644 --- a/src/main/target/SPARKY2/target.h +++ b/src/main/target/SPARKY2/target.h @@ -34,6 +34,7 @@ #define MPU9250_SPI_BUS BUS_SPI1 #define MPU9250_CS_PIN PC4 +#define MPU9250_EXTI_PIN PC5 #define USE_MAG diff --git a/src/main/target/SPRACINGF4EVO/target.h b/src/main/target/SPRACINGF4EVO/target.h index 68cec262ef7..1201f18af46 100755 --- a/src/main/target/SPRACINGF4EVO/target.h +++ b/src/main/target/SPRACINGF4EVO/target.h @@ -120,6 +120,7 @@ #define MPU6500_SPI_BUS BUS_SPI1 #define MPU9250_CS_PIN SPI1_NSS_PIN +#define MPU9250_EXTI_PIN PC13 #define MPU9250_SPI_BUS BUS_SPI1 #define USE_ADC From 14535f7726ac978c4e3fb689357c12132d254187 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Tue, 29 Sep 2026 01:34:10 +0200 Subject: [PATCH 20/24] targets: data-ready pins the first Betaflight comparison missed The comparison script read a #define without a value as swallowing the next line, so some CS and interrupt pins were never compared. With that fixed, the same rule adds these: Betaflight's config for the same board agrees on CS and bus, the pin is free, and its port is enabled. None of the pins added before changes. --- src/main/target/AIKONF4V2/target.h | 1 + src/main/target/AIKONF7/target.h | 2 ++ src/main/target/ALIENFLIGHTNGF7/target.h | 1 + src/main/target/ANYFCF7/target.h | 3 +++ src/main/target/ANYFCM7/target.h | 1 + src/main/target/AOCODARCF405AIO/target.c | 6 +++--- src/main/target/AOCODARCF722AIO/target.c | 4 ++-- src/main/target/BEEROTORF4/target.h | 1 + src/main/target/BETAFLIGHTF4/target.h | 1 + src/main/target/BETAFPVF411/target.h | 1 + src/main/target/BRAHMA_F405/target.h | 1 + src/main/target/F4BY/target.h | 1 + src/main/target/FISHDRONEF4/target.h | 1 + src/main/target/FLYWOOF411/target.h | 6 ++++++ src/main/target/FOXEERF405V2/target.h | 2 ++ src/main/target/FRSKYF4/target.h | 1 + src/main/target/MAMBAF722/target.h | 2 ++ src/main/target/MAMBAF722_X8/target.h | 1 + src/main/target/SEQUREH7/target.h | 1 + src/main/target/SPEEDYBEEF4/target.h | 3 +++ src/main/target/SPRACINGF7DUAL/target.c | 2 +- 21 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/main/target/AIKONF4V2/target.h b/src/main/target/AIKONF4V2/target.h index d2c2ff7c0bc..121e908ed4f 100644 --- a/src/main/target/AIKONF4V2/target.h +++ b/src/main/target/AIKONF4V2/target.h @@ -92,6 +92,7 @@ // Gyro & ACC #define USE_IMU_MPU6000 #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define IMU_MPU6000_ALIGN CW0_DEG #define USE_IMU_ICM42605 diff --git a/src/main/target/AIKONF7/target.h b/src/main/target/AIKONF7/target.h index b29a2c9366c..8b2c3e5ef4e 100644 --- a/src/main/target/AIKONF7/target.h +++ b/src/main/target/AIKONF7/target.h @@ -87,10 +87,12 @@ // Gyro & ACC #define USE_IMU_BMI270 #define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC4 #define BMI270_SPI_BUS BUS_SPI1 #define IMU_BMI270_ALIGN CW0_DEG #define USE_IMU_MPU6000 #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define IMU_MPU6000_ALIGN CW0_DEG // BARO diff --git a/src/main/target/ALIENFLIGHTNGF7/target.h b/src/main/target/ALIENFLIGHTNGF7/target.h index ccee52a78a2..a5ed2c92ad4 100644 --- a/src/main/target/ALIENFLIGHTNGF7/target.h +++ b/src/main/target/ALIENFLIGHTNGF7/target.h @@ -31,6 +31,7 @@ #define BEEPER_INVERTED #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PC14 #define MPU6500_SPI_BUS BUS_SPI1 #define MPU9250_CS_PIN SPI1_NSS_PIN diff --git a/src/main/target/ANYFCF7/target.h b/src/main/target/ANYFCF7/target.h index 179a7211f02..aa2625f1044 100644 --- a/src/main/target/ANYFCF7/target.h +++ b/src/main/target/ANYFCF7/target.h @@ -28,6 +28,9 @@ #define BEEPER_INVERTED #define MPU6000_CS_PIN PA4 +#if defined(ANYFCF7) +#define MPU6000_EXTI_PIN PC4 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/ANYFCM7/target.h b/src/main/target/ANYFCM7/target.h index 2013ca40cb5..19e51904cb6 100644 --- a/src/main/target/ANYFCM7/target.h +++ b/src/main/target/ANYFCM7/target.h @@ -28,6 +28,7 @@ #define BEEPER_INVERTED #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/AOCODARCF405AIO/target.c b/src/main/target/AOCODARCF405AIO/target.c index d2f3d67c427..a8e8607180a 100644 --- a/src/main/target/AOCODARCF405AIO/target.c +++ b/src/main/target/AOCODARCF405AIO/target.c @@ -24,9 +24,9 @@ #include "drivers/timer.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); timerHardware_t timerHardware[] = { // DEF_TIM(TIM2, CH2, PA10, TIM_USE_PPM, 0, 0), // PPM diff --git a/src/main/target/AOCODARCF722AIO/target.c b/src/main/target/AOCODARCF722AIO/target.c index 7ec1ee6880a..6633a275959 100644 --- a/src/main/target/AOCODARCF722AIO/target.c +++ b/src/main/target/AOCODARCF722AIO/target.c @@ -24,8 +24,8 @@ #include "drivers/timer.h" #include "drivers/sensor.h" -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500, DEVHW_MPU6500, MPU6500_SPI_BUS, MPU6500_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6500_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, PC4, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_icm42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, ICM42605_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); timerHardware_t timerHardware[] = { diff --git a/src/main/target/BEEROTORF4/target.h b/src/main/target/BEEROTORF4/target.h index 73f9e029116..4b13357b8fe 100644 --- a/src/main/target/BEEROTORF4/target.h +++ b/src/main/target/BEEROTORF4/target.h @@ -26,6 +26,7 @@ #define BEEPER_INVERTED #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PA8 #define MPU6500_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 diff --git a/src/main/target/BETAFLIGHTF4/target.h b/src/main/target/BETAFLIGHTF4/target.h index 05f35872986..a929804c04b 100755 --- a/src/main/target/BETAFLIGHTF4/target.h +++ b/src/main/target/BETAFLIGHTF4/target.h @@ -28,6 +28,7 @@ #define BEEPER_INVERTED #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/BETAFPVF411/target.h b/src/main/target/BETAFPVF411/target.h index 81b7c862513..8f0d8e4f732 100644 --- a/src/main/target/BETAFPVF411/target.h +++ b/src/main/target/BETAFPVF411/target.h @@ -40,6 +40,7 @@ // *************** SPI Gyro & ACC ********************** #define USE_IMU_MPU6000 #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PA1 #define MPU6000_SPI_BUS BUS_SPI1 #define IMU_MPU6000_ALIGN CW180_DEG diff --git a/src/main/target/BRAHMA_F405/target.h b/src/main/target/BRAHMA_F405/target.h index f9e59ea3ef9..f6896b09007 100644 --- a/src/main/target/BRAHMA_F405/target.h +++ b/src/main/target/BRAHMA_F405/target.h @@ -36,6 +36,7 @@ #define IMU_BMI270_ALIGN CW0_DEG #define BMI270_SPI_BUS BUS_SPI3 #define BMI270_CS_PIN SPI3_NSS_PIN +#define BMI270_EXTI_PIN PB8 // *************** Baro ************************** #define USE_I2C diff --git a/src/main/target/F4BY/target.h b/src/main/target/F4BY/target.h index 5fa535a5ff5..b36d2a2e91c 100644 --- a/src/main/target/F4BY/target.h +++ b/src/main/target/F4BY/target.h @@ -28,6 +28,7 @@ #define BEEPER_INVERTED #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PB0 #define MPU6000_SPI_BUS BUS_SPI1 #define ICM20689_CS_PIN PA4 #define ICM20689_EXTI_PIN PB0 diff --git a/src/main/target/FISHDRONEF4/target.h b/src/main/target/FISHDRONEF4/target.h index 47e87cf8be5..483b47440fc 100644 --- a/src/main/target/FISHDRONEF4/target.h +++ b/src/main/target/FISHDRONEF4/target.h @@ -34,6 +34,7 @@ // *************** ICM20608 ***************************** #define USE_SPI_DEVICE_1 #define MPU6500_CS_PIN PA4 +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 #define MPU9250_CS_PIN PA4 #define MPU9250_EXTI_PIN PC4 diff --git a/src/main/target/FLYWOOF411/target.h b/src/main/target/FLYWOOF411/target.h index ed263d5ee3d..242c88e9759 100644 --- a/src/main/target/FLYWOOF411/target.h +++ b/src/main/target/FLYWOOF411/target.h @@ -48,11 +48,17 @@ #define USE_IMU_MPU6000 #define MPU6000_CS_PIN PA4 +#if defined(FLYWOOF411_V2) +#define MPU6000_EXTI_PIN PB5 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define IMU_MPU6000_ALIGN CW180_DEG #define USE_IMU_ICM20689 #define ICM20689_CS_PIN PA4 +#if defined(FLYWOOF411_V2) +#define ICM20689_EXTI_PIN PB5 +#endif #define ICM20689_SPI_BUS BUS_SPI1 #define IMU_ICM20689_ALIGN CW180_DEG diff --git a/src/main/target/FOXEERF405V2/target.h b/src/main/target/FOXEERF405V2/target.h index 93b787cf418..c0c30322272 100644 --- a/src/main/target/FOXEERF405V2/target.h +++ b/src/main/target/FOXEERF405V2/target.h @@ -66,11 +66,13 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW270_DEG #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 #define USE_IMU_ICM42605 diff --git a/src/main/target/FRSKYF4/target.h b/src/main/target/FRSKYF4/target.h index c014283f33e..5e3b47efe59 100755 --- a/src/main/target/FRSKYF4/target.h +++ b/src/main/target/FRSKYF4/target.h @@ -23,6 +23,7 @@ #define BEEPER_INVERTED #define MPU6000_CS_PIN PA4 +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW270_DEG diff --git a/src/main/target/MAMBAF722/target.h b/src/main/target/MAMBAF722/target.h index 20e907fa87c..0d8d4d905cd 100644 --- a/src/main/target/MAMBAF722/target.h +++ b/src/main/target/MAMBAF722/target.h @@ -35,6 +35,7 @@ #define BEEPER_INVERTED #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 @@ -44,6 +45,7 @@ #define USE_IMU_MPU6500 #define IMU_MPU6500_ALIGN CW180_DEG #define MPU6500_CS_PIN SPI1_NSS_PIN +#define MPU6500_EXTI_PIN PC4 #define MPU6500_SPI_BUS BUS_SPI1 #define USE_I2C diff --git a/src/main/target/MAMBAF722_X8/target.h b/src/main/target/MAMBAF722_X8/target.h index 1a89d3bf31f..12048c2dd28 100644 --- a/src/main/target/MAMBAF722_X8/target.h +++ b/src/main/target/MAMBAF722_X8/target.h @@ -31,6 +31,7 @@ #define BEEPER_INVERTED #define MPU6000_CS_PIN SPI1_NSS_PIN +#define MPU6000_EXTI_PIN PC4 #define MPU6000_SPI_BUS BUS_SPI1 #define USE_IMU_MPU6000 diff --git a/src/main/target/SEQUREH7/target.h b/src/main/target/SEQUREH7/target.h index 1502aa82cbd..0fc50b0e715 100644 --- a/src/main/target/SEQUREH7/target.h +++ b/src/main/target/SEQUREH7/target.h @@ -121,6 +121,7 @@ #else #define USE_IMU_MPU6000 #define MPU6000_CS_PIN PB12 +#define MPU6000_EXTI_PIN PD0 #define MPU6000_SPI_BUS BUS_SPI2 #define IMU_MPU6000_ALIGN CW0_DEG #endif diff --git a/src/main/target/SPEEDYBEEF4/target.h b/src/main/target/SPEEDYBEEF4/target.h index 310f6e9b456..9352a9f6ec3 100644 --- a/src/main/target/SPEEDYBEEF4/target.h +++ b/src/main/target/SPEEDYBEEF4/target.h @@ -30,6 +30,9 @@ /*** MPU6000 ***/ #define USE_IMU_MPU6000 #define MPU6000_CS_PIN PB11 +#if defined(SPEEDYBEEF4) +#define MPU6000_EXTI_PIN PC4 +#endif #define MPU6000_SPI_BUS BUS_SPI1 #define IMU_MPU6000_ALIGN CW0_DEG diff --git a/src/main/target/SPRACINGF7DUAL/target.c b/src/main/target/SPRACINGF7DUAL/target.c index 0c213e14076..94231637271 100644 --- a/src/main/target/SPRACINGF7DUAL/target.c +++ b/src/main/target/SPRACINGF7DUAL/target.c @@ -30,7 +30,7 @@ #include "drivers/sensor.h" // Register both MPU6500 -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_1, DEVHW_MPU6500, MPU6500_1_SPI_BUS, MPU6500_1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_1_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_1, DEVHW_MPU6500, MPU6500_1_SPI_BUS, MPU6500_1_CS_PIN, PC13, 0, DEVFLAGS_NONE, IMU_1_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_mpu6500_2, DEVHW_MPU6500, MPU6500_2_SPI_BUS, MPU6500_2_CS_PIN, PC14, 0, DEVFLAGS_NONE, IMU_2_ALIGN); timerHardware_t timerHardware[] = { From 7971db0ad198116db120f2a013922e986ffd19b8 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Tue, 29 Sep 2026 01:40:24 +0200 Subject: [PATCH 21/24] targets: FLYWOOF405S_AIO's ICM-42605 data-ready pin, which the first Betaflight comparison missed --- src/main/target/FLYWOOF405S_AIO/target.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/target/FLYWOOF405S_AIO/target.h b/src/main/target/FLYWOOF405S_AIO/target.h index b8132f52566..60231587a79 100644 --- a/src/main/target/FLYWOOF405S_AIO/target.h +++ b/src/main/target/FLYWOOF405S_AIO/target.h @@ -48,6 +48,7 @@ #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_CS_PIN PB12 +#define ICM42605_EXTI_PIN PB13 #define ICM42605_SPI_BUS BUS_SPI1 #define USE_EXTI From 5106b6e821c0abff65043b6f6f88c92f547b3ce1 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Tue, 29 Sep 2026 16:51:58 +0200 Subject: [PATCH 22/24] spi: clean the data-ready transmit buffer from the cache before DMA reads it Written once at setup, so cleaned once there: nothing at run time. A no-op today: DMA_RAM is Shareable in the H7 MPU setup and the Cortex-M7 does not cache it, and on F7, which runs the same setup, INAV leaves the D-cache off. It matches the invalidate on the reply and stays right should either change. (cherry picked from commit 42874294ca38444c6d60bb95b076354feeea5a65) --- src/main/drivers/bus_spi_hal_ll.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/drivers/bus_spi_hal_ll.c b/src/main/drivers/bus_spi_hal_ll.c index 83e58200214..a1971523d8c 100644 --- a/src/main/drivers/bus_spi_hal_ll.c +++ b/src/main/drivers/bus_spi_hal_ll.c @@ -542,6 +542,8 @@ static bool spiDataReadyDmaSetup(SPIDevice device) } memset(spiDataReadyTx[device], 0xFF, SPI_DATA_READY_MAX); spiDataReadyTx[device][0] = h->reg; + // A no-op while DMA_RAM stays uncached, as the invalidate on the reply is + SCB_CleanDCache_by_Addr((uint32_t *)spiDataReadyTx[device], SPI_DATA_READY_MAX); h->dma = true; return true; } From c9053d0a884e87015831cb351a05f78cde0ecf56 Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Tue, 6 Oct 2026 01:04:26 +0200 Subject: [PATCH 23/24] gyro: keep PG_GYRO_CONFIG at version 12 The new fields are appended with a zero default, so stored settings load as they are: pgLoad copies the stored bytes over the defaults. On H7 without USE_DUAL_GYRO gyro_data_ready takes the old record's tail padding, which the reset template leaves at zero. --- src/main/sensors/gyro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index 3fb34d08477..0d315a5f9d6 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -121,7 +121,7 @@ EXTENDED_FASTRAM secondaryDynamicGyroNotchState_t secondaryDynamicGyroNotchState #endif -PG_REGISTER_WITH_RESET_TEMPLATE(gyroConfig_t, gyroConfig, PG_GYRO_CONFIG, 13); +PG_REGISTER_WITH_RESET_TEMPLATE(gyroConfig_t, gyroConfig, PG_GYRO_CONFIG, 12); PG_RESET_TEMPLATE(gyroConfig_t, gyroConfig, .gyro_anti_aliasing_lpf_hz = SETTING_GYRO_ANTI_ALIASING_LPF_HZ_DEFAULT, From 66761544f2a1c47c466c572c4fd7b6547993107c Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 19 Oct 2026 19:07:17 +0200 Subject: [PATCH 24/24] gyro: ICM-45686 and MPU data-ready with ON only, until run on hardware Neither has run on data-ready yet, so their drivers are not marked tested: AUTO keeps polling them and ON still turns it on. The MPU drivers write INT_PIN_CFG and INT_ENABLE only when data-ready will read the pin, so with AUTO an MPU is configured as before this PR. --- docs/Settings.md | 2 +- src/main/drivers/accgyro/accgyro_icm45686.c | 2 +- src/main/drivers/accgyro/accgyro_mpu.c | 11 +++++++---- src/main/fc/settings.yaml | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 7c97a46d370..7376041e511 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2140,7 +2140,7 @@ Gyro processing anti-aliasing filter cutoff frequency. In normal operation this ### gyro_data_ready -Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270, ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives), MPU9250, ICM-20689 and LSM6DXX, OFF polls the gyro. +Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO does it with the ICM-42605, ICM-42688-P, BMI270 and LSM6DXX; ON also with the ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives), MPU9250 and ICM-20689, not yet run on hardware. OFF polls the gyro. | Allowed Values | | | --- | --- | diff --git a/src/main/drivers/accgyro/accgyro_icm45686.c b/src/main/drivers/accgyro/accgyro_icm45686.c index 5d57d4a2042..18d99aa275b 100644 --- a/src/main/drivers/accgyro/accgyro_icm45686.c +++ b/src/main/drivers/accgyro/accgyro_icm45686.c @@ -397,7 +397,7 @@ static const gyroDataReadyDriver_t icm45686DataReady = { .hasTemp = true, .parse = icm45686DataReadyParse, .registerRead = icm45686GyroRead, - .tested = true, + .tested = false, // not run on hardware yet }; #endif diff --git a/src/main/drivers/accgyro/accgyro_mpu.c b/src/main/drivers/accgyro/accgyro_mpu.c index d766b4e29cf..b9daf344302 100644 --- a/src/main/drivers/accgyro/accgyro_mpu.c +++ b/src/main/drivers/accgyro/accgyro_mpu.c @@ -163,17 +163,20 @@ static const gyroDataReadyDriver_t mpuDataReady = { .hasTemp = true, .parse = mpuDataReadyParse, .registerRead = mpuGyroReadScratchpad, - .tested = true, + .tested = false, // not run on hardware yet }; -// A 50 us pulse on INT at each new sample. Written at the initialisation speed: the MPU6000 takes -// register writes at 1 MHz at most +// A 50 us pulse on INT at each new sample, only where data-ready will read it: otherwise the MPU stays as it was. +// Written at the initialisation speed: the MPU6000 takes register writes at 1 MHz at most void mpuDataReadySetup(gyroDev_t *gyro) { + gyro->dataReadyDriver = &mpuDataReady; + if (!gyroDataReadyWanted(gyro)) { + return; + } busWrite(gyro->busDev, MPU_RA_INT_PIN_CFG, MPU_INT_ANYRD_2CLEAR); delayMicroseconds(15); busWrite(gyro->busDev, MPU_RA_INT_ENABLE, MPU_RF_DATA_RDY_EN); delayMicroseconds(15); - gyro->dataReadyDriver = &mpuDataReady; } #endif diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 771ec4debae..db3f48d7bc8 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -353,7 +353,7 @@ groups: field: gyro_secondary_enabled type: bool - name: gyro_data_ready - description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO and ON do it with the ICM-42605, ICM-42688-P, BMI270, ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives), MPU9250, ICM-20689 and LSM6DXX, OFF polls the gyro." + description: "Read the gyro when it signals a new sample, on its data-ready interrupt, instead of polling it: every sample once, and the CPU no longer waits on the bus. Needs a supported IMU and a target that declares the interrupt pin; without interrupts the gyro is read as before. AUTO does it with the ICM-42605, ICM-42688-P, BMI270 and LSM6DXX; ON also with the ICM-45686, MPU6000, MPU6500 (and the ICM-20602 and ICM-20608 it drives), MPU9250 and ICM-20689, not yet run on hardware. OFF polls the gyro." default_value: "AUTO" condition: USE_SPI_DATA_READY field: gyro_data_ready