chore(v16): add support for more IMU hardware (#7482)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
14e6d6ce01
commit
19aa6d5f20
@@ -116,6 +116,8 @@ if (PCB STREQUAL X10)
|
||||
set(AUX2_SERIAL OFF)
|
||||
set(CSD203_SENSOR ON)
|
||||
set(FLYSKY_GIMBAL ON)
|
||||
add_definitions(-DIMU_ICM42627)
|
||||
add_definitions(-DIMU_SC7U22)
|
||||
if (BLUETOOTH)
|
||||
set(AUX_SERIAL OFF)
|
||||
endif()
|
||||
@@ -285,6 +287,7 @@ add_library(board OBJECT EXCLUDE_FROM_ALL
|
||||
targets/common/arm/stm32/heartbeat_driver.cpp
|
||||
drivers/lsm6ds.cpp
|
||||
drivers/icm42627.cpp
|
||||
drivers/sc7u22.cpp
|
||||
targets/common/arm/stm32/mixer_scheduler_driver.cpp
|
||||
targets/common/arm/stm32/module_timer_driver.cpp
|
||||
targets/common/arm/stm32/sticks_pwm_driver.cpp
|
||||
|
||||
@@ -52,8 +52,22 @@
|
||||
#include "csd203_sensor.h"
|
||||
#endif
|
||||
|
||||
#if defined(IMU) && defined(IMU_I2C_BUS) && defined(IMU_I2C_ADDRESS)
|
||||
#if defined(IMU) && defined(IMU_I2C_BUS) && \
|
||||
(defined(IMU_I2C_ADDRESS) || defined(IMU_ICM42627) || \
|
||||
defined(IMU_SC7U22) || defined(IMU_LSM6DS33))
|
||||
#define HAS_IMU
|
||||
#include "gyro.h"
|
||||
#include "stm32_i2c_driver.h"
|
||||
#if defined(IMU_ICM42627)
|
||||
#include "drivers/icm42627.h"
|
||||
#endif
|
||||
#if defined(IMU_SC7U22)
|
||||
#include "drivers/sc7u22.h"
|
||||
#endif
|
||||
#if defined(IMU_LSM6DS33) || \
|
||||
(!defined(IMU_ICM42627) && !defined(IMU_SC7U22) && defined(IMU_I2C_ADDRESS))
|
||||
#include "drivers/lsm6ds.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
HardwareOptions hardwareOptions;
|
||||
@@ -133,25 +147,26 @@ void audioInit()
|
||||
#endif
|
||||
|
||||
#if defined(HAS_IMU)
|
||||
#include "gyro.h"
|
||||
#include "stm32_i2c_driver.h"
|
||||
#include "drivers/icm42627.h"
|
||||
#include "drivers/lsm6ds.h"
|
||||
static const etx_imu_t _imu_candidates[] = {
|
||||
#if defined(IMU_ICM42627)
|
||||
{ &imu_icm42627_driver, IMU_I2C_BUS, ICM42627_I2C_BASE_ADDR },
|
||||
{ &imu_icm42627_driver, IMU_I2C_BUS, ICM42627_I2C_BASE_ADDR + 1 },
|
||||
#endif
|
||||
#if defined(IMU_SC7U22)
|
||||
{ &imu_sc7u22_driver, IMU_I2C_BUS, SC7U22_I2C_BASE_ADDR },
|
||||
{ &imu_sc7u22_driver, IMU_I2C_BUS, SC7U22_I2C_BASE_ADDR + 1 },
|
||||
#endif
|
||||
#if defined(IMU_LSM6DS33) || \
|
||||
(!defined(IMU_ICM42627) && !defined(IMU_SC7U22) && defined(IMU_I2C_ADDRESS))
|
||||
{ &imu_lsm6ds_driver, IMU_I2C_BUS, IMU_I2C_ADDRESS },
|
||||
#endif
|
||||
};
|
||||
|
||||
static void gyroInit()
|
||||
{
|
||||
#if defined(RADIO_V16)
|
||||
const etx_imu_driver_t *driver = &imu_icm42627_driver;
|
||||
#else
|
||||
const etx_imu_driver_t *driver = &imu_lsm6ds_driver;
|
||||
#endif
|
||||
|
||||
const etx_imu_t candidates[] = {
|
||||
{ driver, IMU_I2C_BUS, IMU_I2C_ADDRESS },
|
||||
};
|
||||
|
||||
gyroStart(imuDetect(candidates, DIM(candidates)));
|
||||
gyroStart(imuDetect(_imu_candidates, DIM(_imu_candidates)));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void boardInit()
|
||||
|
||||
@@ -466,7 +466,6 @@
|
||||
#define IMU_I2C_ADDRESS 0x6A
|
||||
#elif defined(RADIO_V16)
|
||||
#define IMU_I2C_BUS I2C_Bus_1
|
||||
#define IMU_I2C_ADDRESS 0x69
|
||||
#elif !defined(AUX_SERIAL) && defined(IMU_LSM6DS33)
|
||||
#define IMU_I2C_BUS I2C_Bus_2
|
||||
#define IMU_I2C_ADDRESS 0x6A
|
||||
|
||||
Reference in New Issue
Block a user