feat(driver): autodetect IMU, add support for SC7U22 (#7191)
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
raphaelcoeffic
Claude Opus 4.6
parent
5ea531d391
commit
0ce5c8f3f2
@@ -49,12 +49,21 @@
|
||||
#include "sdcard.h"
|
||||
#include "debug.h"
|
||||
#include "keys.h"
|
||||
#include "gyro.h"
|
||||
|
||||
#include "flysky_gimbal_driver.h"
|
||||
#include "timers_driver.h"
|
||||
|
||||
#include "touch_driver.h"
|
||||
|
||||
#if defined(IMU_ICM4207C)
|
||||
#include "drivers/icm42607C.h"
|
||||
#endif
|
||||
#if defined(IMU_SC7U22)
|
||||
#include "drivers/sc7u22.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// common ADC driver
|
||||
@@ -63,6 +72,22 @@ extern const etx_hal_adc_driver_t _adc_driver;
|
||||
// RGB LED timer
|
||||
extern const stm32_pulse_timer_t _led_timer;
|
||||
|
||||
static const etx_imu_t _imu_candidates[] = {
|
||||
#if defined(IMU_ICM4207C)
|
||||
{ &imu_icm42607_driver, IMU_I2C_BUS, ICM426xx_I2C_BASE_ADDR },
|
||||
{ &imu_icm42607_driver, IMU_I2C_BUS, ICM426xx_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
|
||||
};
|
||||
|
||||
static void gyroInit()
|
||||
{
|
||||
gyroStart(imuDetect(_imu_candidates, DIM(_imu_candidates)));
|
||||
}
|
||||
|
||||
static void led_strip_off()
|
||||
{
|
||||
for (uint8_t i = 0; i < LED_STRIP_LENGTH; i++) {
|
||||
@@ -178,6 +203,8 @@ void boardInit()
|
||||
|
||||
// RTC must be initialized before rambackupRestore() is called
|
||||
rtcInit();
|
||||
|
||||
gyroInit();
|
||||
}
|
||||
|
||||
extern void rtcDisableBackupReg();
|
||||
|
||||
Reference in New Issue
Block a user