Skip to content

chore(v16): add support for more IMU hardware#7482

Open
helloradiosky wants to merge 1 commit into
EdgeTX:mainfrom
helloradiosky:hrs_v16_gyro
Open

chore(v16): add support for more IMU hardware#7482
helloradiosky wants to merge 1 commit into
EdgeTX:mainfrom
helloradiosky:hrs_v16_gyro

Conversation

@helloradiosky

@helloradiosky helloradiosky commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

The gyroscope of V16 has been enhanced with multi-chip dynamic loading functionality
The future should support more devices

Summary by CodeRabbit

  • New Features
    • Added support for ICM42627 and SC7U22 inertial measurement sensors
    • Implemented automatic sensor detection for V16 hardware variants with dynamic address probing
    • Enhanced IMU compatibility and hardware detection robustness

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds ICM42627_I2C_BASE_ADDR (0x68) to the ICM42627 header, removes the fixed IMU_I2C_ADDRESS override for RADIO_V16 in hal.h, relaxes the HAS_IMU compile condition, rewrites gyroInit to probe ICM42627 and SC7U22 at consecutive I2C addresses on RADIO_V16, and wires both drivers into the CMake build.

Changes

ICM42627 & SC7U22 IMU wiring for Horus X10 V16

Layer / File(s) Summary
ICM42627 base address, HAL I2C config, HAS_IMU condition, and CMake build wiring
radio/src/drivers/icm42627.h, radio/src/targets/horus/hal.h, radio/src/targets/horus/CMakeLists.txt, radio/src/targets/horus/board.cpp
icm42627.h adds ICM42627_I2C_BASE_ADDR (0x68). hal.h drops the fixed IMU_I2C_ADDRESS 0x69 for RADIO_V16, keeping only IMU_I2C_BUS. board.cpp relaxes HAS_IMU to not require IMU_I2C_ADDRESS when RADIO_V16 is defined. CMakeLists.txt adds IMU_ICM42627/IMU_SC7U22 compile definitions for PCBREV V16 and gates sc7u22.cpp behind FLAVOUR v16.
gyroInit multi-driver detection for RADIO_V16
radio/src/targets/horus/board.cpp
Adds optional SC7U22 driver include under IMU_SC7U22. Rewrites gyroInit to build a candidate list of ICM42627 and/or SC7U22 entries at both base and base+1 I2C addresses on RADIO_V16, while preserving the single-driver LSM6DS path for other targets.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • EdgeTX/edgetx#7232: Directly related — introduces the initial Horus V16 gyro support in horus/hal.h and horus/board.cpp that this PR extends with multi-driver probing and removes the fixed I2C address from.

Suggested labels

enhancement ✨, hardware support

Suggested reviewers

  • pfeerick
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description lacks required sections from the template. Missing explicit fix reference and incomplete summary of changes. Add the 'Fixes #' section if applicable, and provide a more structured summary matching the template format.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding support for multiple IMU hardware options on V16 through multi-chip dynamic loading.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@radio/src/drivers/icm42627.cpp`:
- Around line 95-97: The reset command write failure in the if statement
checking write_cmd(ICM42627_DEVICE_CONFIG_REG, ICM42627_RESET) is currently only
logging a trace message and continuing execution, which leaves the sensor in a
partially configured state. Instead of just logging the error with TRACE, the
function gyro42627Init() should return a failure status immediately when
write_cmd returns a value less than 0, ensuring that a failed reset is treated
as a fatal error that prevents the initialization from succeeding.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 69dca07d-df01-4e69-9876-7b5e910f91fa

📥 Commits

Reviewing files that changed from the base of the PR and between 0f5bc9b and ff928de.

📒 Files selected for processing (5)
  • radio/src/drivers/icm42627.cpp
  • radio/src/drivers/icm42627.h
  • radio/src/targets/horus/CMakeLists.txt
  • radio/src/targets/horus/board.cpp
  • radio/src/targets/horus/hal.h

Comment thread radio/src/drivers/icm42627.cpp
@richardclli

Copy link
Copy Markdown
Member

Is this duplicated #7232?

@helloradiosky

Copy link
Copy Markdown
Contributor Author

Is this duplicated #7232?

Well, some modifications were made to make it compatible with more gyroscope models

@pfeerick

Copy link
Copy Markdown
Member

The problem is that it is a duplicate of #7232, while also extending it ... i.e. if I merge #7232 first (which I was intending to do before I saw Richard's mention of this PR), there would most likely be conflicts for merging this one. Because the intention was to enhance on #7232, I'll still merge that first and then update this so it can be merged after.

@pfeerick pfeerick changed the title Hrs v16 gyro chore(v16): add support for more IMU hardware Jun 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
radio/src/targets/horus/CMakeLists.txt (1)

119-120: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align SC7U22 source gating with macro gating.

Line 119-120 enables IMU_SC7U22 under PCBREV conditions, while Line 301-303 compiles drivers/sc7u22.cpp under FLAVOUR conditions. Keeping these predicates identical avoids config drift between symbol usage and source inclusion.

Suggested diff
-if(FLAVOUR STREQUAL v16)
+if(PCB STREQUAL X10 AND PCBREV STREQUAL V16)
   target_sources(board PRIVATE drivers/sc7u22.cpp)
 endif()

Also applies to: 301-303

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@radio/src/targets/horus/CMakeLists.txt` around lines 119 - 120, The SC7U22
macro definition and source file compilation are gated by different CMake
conditions, creating a mismatch between symbol definition and actual source
inclusion. The add_definitions(-DIMU_SC7U22) uses PCBREV conditions (line
119-120), while the drivers/sc7u22.cpp compilation uses FLAVOUR conditions
(around line 301-303). Update the conditional check for compiling
drivers/sc7u22.cpp to use the same PCBREV condition as the macro definition to
ensure consistency between when the symbol is defined and when the source is
actually compiled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@radio/src/targets/horus/CMakeLists.txt`:
- Around line 119-120: The SC7U22 macro definition and source file compilation
are gated by different CMake conditions, creating a mismatch between symbol
definition and actual source inclusion. The add_definitions(-DIMU_SC7U22) uses
PCBREV conditions (line 119-120), while the drivers/sc7u22.cpp compilation uses
FLAVOUR conditions (around line 301-303). Update the conditional check for
compiling drivers/sc7u22.cpp to use the same PCBREV condition as the macro
definition to ensure consistency between when the symbol is defined and when the
source is actually compiled.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ef937371-3c40-42dd-99ca-e65522192f7d

📥 Commits

Reviewing files that changed from the base of the PR and between ff928de and 627ae5f.

📒 Files selected for processing (4)
  • radio/src/drivers/icm42627.h
  • radio/src/targets/horus/CMakeLists.txt
  • radio/src/targets/horus/board.cpp
  • radio/src/targets/horus/hal.h
✅ Files skipped from review due to trivial changes (1)
  • radio/src/drivers/icm42627.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • radio/src/targets/horus/board.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants