mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 11:29:58 +03:00
Add support external clock for gyro ICM42688P (#13912)
This commit is contained in:
parent
866191dfad
commit
715c1671a8
6 changed files with 105 additions and 9 deletions
|
@ -50,6 +50,14 @@
|
|||
#define GYRO_2_EXTI_PIN NONE
|
||||
#endif
|
||||
|
||||
#ifndef GYRO_1_CLKIN_PIN
|
||||
#define GYRO_1_CLKIN_PIN NONE
|
||||
#endif
|
||||
|
||||
#ifndef GYRO_2_CLKIN_PIN
|
||||
#define GYRO_2_CLKIN_PIN NONE
|
||||
#endif
|
||||
|
||||
#ifdef MPU_ADDRESS
|
||||
#define GYRO_I2C_ADDRESS MPU_ADDRESS
|
||||
#else
|
||||
|
@ -68,7 +76,7 @@
|
|||
#endif
|
||||
|
||||
#if defined(USE_SPI_GYRO) && (defined(GYRO_1_SPI_INSTANCE) || defined(GYRO_2_SPI_INSTANCE))
|
||||
static void gyroResetSpiDeviceConfig(gyroDeviceConfig_t *devconf, SPI_TypeDef *instance, ioTag_t csnTag, ioTag_t extiTag, uint8_t alignment, sensorAlignment_t customAlignment)
|
||||
static void gyroResetSpiDeviceConfig(gyroDeviceConfig_t *devconf, SPI_TypeDef *instance, ioTag_t csnTag, ioTag_t extiTag, ioTag_t clkInTag, uint8_t alignment, sensorAlignment_t customAlignment)
|
||||
{
|
||||
devconf->busType = BUS_TYPE_SPI;
|
||||
devconf->spiBus = SPI_DEV_TO_CFG(spiDeviceByInstance(instance));
|
||||
|
@ -76,6 +84,7 @@ static void gyroResetSpiDeviceConfig(gyroDeviceConfig_t *devconf, SPI_TypeDef *i
|
|||
devconf->extiTag = extiTag;
|
||||
devconf->alignment = alignment;
|
||||
devconf->customAlignment = customAlignment;
|
||||
devconf->clkIn = clkInTag;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -91,7 +100,7 @@ static void gyroResetI2cDeviceConfig(gyroDeviceConfig_t *devconf, I2CDevice i2cb
|
|||
}
|
||||
#endif
|
||||
|
||||
PG_REGISTER_ARRAY_WITH_RESET_FN(gyroDeviceConfig_t, MAX_GYRODEV_COUNT, gyroDeviceConfig, PG_GYRO_DEVICE_CONFIG, 0);
|
||||
PG_REGISTER_ARRAY_WITH_RESET_FN(gyroDeviceConfig_t, MAX_GYRODEV_COUNT, gyroDeviceConfig, PG_GYRO_DEVICE_CONFIG, 1);
|
||||
|
||||
void pgResetFn_gyroDeviceConfig(gyroDeviceConfig_t *devconf)
|
||||
{
|
||||
|
@ -106,7 +115,7 @@ void pgResetFn_gyroDeviceConfig(gyroDeviceConfig_t *devconf)
|
|||
// All multi-gyro boards use SPI based gyros.
|
||||
#ifdef USE_SPI_GYRO
|
||||
#ifdef GYRO_1_SPI_INSTANCE
|
||||
gyroResetSpiDeviceConfig(&devconf[0], GYRO_1_SPI_INSTANCE, IO_TAG(GYRO_1_CS_PIN), IO_TAG(GYRO_1_EXTI_PIN), GYRO_1_ALIGN, customAlignment1);
|
||||
gyroResetSpiDeviceConfig(&devconf[0], GYRO_1_SPI_INSTANCE, IO_TAG(GYRO_1_CS_PIN), IO_TAG(GYRO_1_EXTI_PIN), IO_TAG(GYRO_1_CLKIN_PIN), GYRO_1_ALIGN, customAlignment1);
|
||||
#else
|
||||
devconf[0].busType = BUS_TYPE_NONE;
|
||||
#endif
|
||||
|
@ -120,7 +129,8 @@ void pgResetFn_gyroDeviceConfig(gyroDeviceConfig_t *devconf)
|
|||
#endif // GYRO_2_CUSTOM_ALIGN
|
||||
|
||||
#ifdef GYRO_2_SPI_INSTANCE
|
||||
gyroResetSpiDeviceConfig(&devconf[1], GYRO_2_SPI_INSTANCE, IO_TAG(GYRO_2_CS_PIN), IO_TAG(GYRO_2_EXTI_PIN), GYRO_2_ALIGN, customAlignment2);
|
||||
// TODO: CLKIN gyro 2 on separate pin is not supported yet. need to implement it
|
||||
gyroResetSpiDeviceConfig(&devconf[1], GYRO_2_SPI_INSTANCE, IO_TAG(GYRO_2_CS_PIN), IO_TAG(GYRO_2_EXTI_PIN), IO_TAG(GYRO_2_CLKIN_PIN), GYRO_2_ALIGN, customAlignment2);
|
||||
#else
|
||||
devconf[1].busType = BUS_TYPE_NONE;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue