Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions radio/src/drivers/icm42627.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include "hal/imu.h"

#define ICM42627_I2C_BASE_ADDR 0x68

#define ICM42627_WHO_AM_I_REG 0x75
#define ICM42627_WHO_AM_I 0x20

Expand Down
6 changes: 6 additions & 0 deletions radio/src/targets/horus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -296,6 +298,10 @@ add_library(board OBJECT EXCLUDE_FROM_ALL
)
set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:board>)

if(FLAVOUR STREQUAL v16)
target_sources(board PRIVATE drivers/sc7u22.cpp)
endif()

if(BLUETOOTH)
target_sources(board PRIVATE targets/common/arm/stm32/bluetooth_driver.cpp)
endif()
Expand Down
32 changes: 26 additions & 6 deletions radio/src/targets/horus/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
#include "csd203_sensor.h"
#endif

#if defined(IMU) && defined(IMU_I2C_BUS) && defined(IMU_I2C_ADDRESS)
#if defined(IMU) && defined(IMU_I2C_BUS) && \
(defined(RADIO_V16) || defined(IMU_I2C_ADDRESS))
#define HAS_IMU
#endif

Expand Down Expand Up @@ -137,21 +138,40 @@ void audioInit()
#include "stm32_i2c_driver.h"
#include "drivers/icm42627.h"
#include "drivers/lsm6ds.h"
#if defined(IMU_SC7U22)
#include "drivers/sc7u22.h"
#endif

#if defined(RADIO_V16)

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
};

static void gyroInit()
{
#if defined(RADIO_V16)
const etx_imu_driver_t *driver = &imu_icm42627_driver;
gyroStart(imuDetect(_imu_candidates, DIM(_imu_candidates)));
}

#else
const etx_imu_driver_t *driver = &imu_lsm6ds_driver;
#endif

static void gyroInit()
{
const etx_imu_t candidates[] = {
{ driver, IMU_I2C_BUS, IMU_I2C_ADDRESS },
{ &imu_lsm6ds_driver, IMU_I2C_BUS, IMU_I2C_ADDRESS },
};

gyroStart(imuDetect(candidates, DIM(candidates)));
}

#endif
#endif

void boardInit()
Expand Down
1 change: 0 additions & 1 deletion radio/src/targets/horus/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,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
Expand Down