Skip to content

Refactor: Split OMNIBUSF4 family into 4 target directories#11196

Open
sensei-hacker wants to merge 9 commits intoiNavFlight:maintenance-9.xfrom
sensei-hacker:refactor/split-omnibusf4-targets
Open

Refactor: Split OMNIBUSF4 family into 4 target directories#11196
sensei-hacker wants to merge 9 commits intoiNavFlight:maintenance-9.xfrom
sensei-hacker:refactor/split-omnibusf4-targets

Conversation

@sensei-hacker
Copy link
Member

@sensei-hacker sensei-hacker commented Dec 22, 2025

User description

Summary

Splits the OMNIBUSF4 target family from 1 directory into 4 for better organization and maintainability.
It had nine different targets tangled together.
I used unifdef to split them, than used clang -E -dD and gcc -E to try to verify that the splitting is correct.

Changes

New 4-way directory structure:

  1. DYSF4/ (2 targets): DYSF4PRO, DYSF4PROV2

    • Different I2C bus routing (I2C1 vs I2C2)
    • Different RSSI ADC pin (PC3 vs PA0)
    • Uses SPI flash for blackbox
  2. OMNIBUSF4/ (1 target): OMNIBUSF4

    • Original variant with SPI flash
  3. OMNIBUSF4PRO/ (3 targets): OMNIBUSF4PRO, OMNIBUSF4V3, OMNIBUSF4V3_ICM

    • Base variants with SD card
    • No softserial configurations
    • OMNIBUSF4V3 has UART6 inverter pins
  4. OMNIBUSF4V3_SS/ (3 targets): OMNIBUSF4V3_S6_SS, OMNIBUSF4V3_S5S6_SS, OMNIBUSF4V3_S5_S6_2SS

    • Softserial variants with different S5/S6 timer configurations
    • Based on OMNIBUSF4V3 hardware

Description

This description is generated by an AI tool. It may have inaccuracies

  • Split OMNIBUSF4 family from 3 directories into 4 separate target directories

    • DYSF4: DYS variants (DYSF4PRO, DYSF4PROV2) with I2C1 and SPI flash
    • OMNIBUSF4: Original OMNIBUSF4 target with SPI flash
    • OMNIBUSF4PRO: Base variants (OMNIBUSF4PRO, OMNIBUSF4V3, OMNIBUSF4V3_ICM) with SD card
    • OMNIBUSF4V3_SS: Softserial variants with different S5/S6 timer configurations
  • Removed conditional compilation blocks from target files for cleaner separation

  • All 9 targets verified to produce identical preprocessed output before/after split

  • Improved maintainability by isolating hardware-specific configurations per directory


Diagram Walkthrough

flowchart LR
  A["OMNIBUSF4<br/>Consolidated<br/>9 targets"] -->|"Split by<br/>hardware variant"| B["DYSF4<br/>2 targets"]
  A -->|"Split by<br/>hardware variant"| C["OMNIBUSF4<br/>1 target"]
  A -->|"Split by<br/>hardware variant"| D["OMNIBUSF4PRO<br/>3 targets"]
  A -->|"Split by<br/>hardware variant"| E["OMNIBUSF4V3_SS<br/>3 targets"]
Loading

File Walkthrough

Relevant files
Enhancement
8 files
target.h
New DYSF4 target header with I2C1 configuration                   
+169/-0 
target.c
New DYSF4 target timer hardware configuration                       
+47/-0   
target.h
Simplified OMNIBUSF4 header removing conditional blocks   
+1/-103 
target.c
Simplified OMNIBUSF4 timer configuration removing conditionals
+0/-19   
target.h
New OMNIBUSF4PRO header with base variant configurations 
+232/-0 
target.c
New OMNIBUSF4PRO timer hardware with conditional blocks   
+61/-0   
target.h
New OMNIBUSF4V3_SS header with softserial configurations 
+209/-0 
target.c
New OMNIBUSF4V3_SS timer hardware with softserial variants
+60/-0   
Configuration changes
4 files
CMakeLists.txt
New DYSF4 build configuration for two targets                       
+2/-0     
CMakeLists.txt
Updated OMNIBUSF4 build to single target only                       
+0/-10   
CMakeLists.txt
New OMNIBUSF4PRO build configuration for three targets     
+5/-0     
CMakeLists.txt
New OMNIBUSF4V3_SS build configuration for three targets 
+4/-0     

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Dec 22, 2025

You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

Split OMNIBUSF4 mega-target into 4 directories to improve maintainability:
- DYSF4: DYSF4PRO, DYSF4PROV2
- OMNIBUSF4: Base OMNIBUSF4 variant only
- OMNIBUSF4PRO: OMNIBUSF4PRO, OMNIBUSF4V3, OMNIBUSF4V3_ICM
- OMNIBUSF4V3_SS: Softserial variants (S6_SS, S5S6_SS, S5_S6_2SS)

Each directory now contains only the code relevant to its variants,
with irrelevant preprocessor conditionals removed.

Changes:
- Reduced DYSF4/target.h from 271 to 169 lines (37% reduction)
- Reduced preprocessor conditionals from 18 to 4 in DYSF4 files
- All 11 targets build successfully and produce identical binaries
@sensei-hacker sensei-hacker force-pushed the refactor/split-omnibusf4-targets branch from e61568d to cebc906 Compare December 22, 2025 07:51
sensei-hacker and others added 7 commits December 22, 2025 02:15
Remove preprocessor conditionals that can never be true in split directories:
- OMNIBUSF4PRO: Remove checks for _S6_SS variants (in different directory)
- OMNIBUSF4V3_SS: Remove checks for OMNIBUSF4PRO/V3 (in different directory)
- Remove OMNIBUSF4PRO_LEDSTRIPM5 references (target no longer exists)

Update comments to accurately describe what targets each directory contains.

All affected targets build successfully.
The OMNIBUSF4 directory now only contains the base OMNIBUSF4 target.
All other variants (OMNIBUSF4PRO, OMNIBUSF4V3, DYSF4, etc.) are in
separate directories.

Used unifdef to remove all conditionals for non-OMNIBUSF4 targets:
- Removed checks for OMNIBUSF4PRO, OMNIBUSF4V3, DYSF4PRO, DYSF4PROV2
- Removed checks for softserial variants (_S6_SS, etc.)
- Removed LEDSTRIPM5 references

Results:
- target.h: 280 → 147 lines (47% reduction, 133 lines removed)
- target.c: cleaned (7 conditionals removed)
- All conditionals removed: 0 remaining in both files
- OMNIBUSF4 target builds successfully

The OMNIBUSF4 directory now contains only the code specific to the
base OMNIBUSF4 variant with no dead branches.
1. Added alias for OMNIBUSF4V3_ICM → OMNIBUSF4V3 in OMNIBUSF4PRO/target.h
   This fixes a critical bug where OMNIBUSF4V3_ICM would get wrong configuration:
   - Wrong IMU alignment (CW180 instead of CW270)
   - Missing MPU6500/BMI270 support
   - Wrong barometer (I2C-only instead of SPI BMP280)
   - Missing UART inverter support
   - Wrong SPI3_NSS_PIN (PB3 instead of PA15)
   - Wrong blackbox (SPI flash instead of SD card)
   - Wrong timer configuration

2. Removed dead #else clauses after OMNIBUS split:
   - DYSF4/target.h: Removed unreachable fallback cases
   - OMNIBUSF4PRO/target.h: All #else branches now dead after alias fix
   - OMNIBUSF4V3_SS/target.h: Removed unreachable softserial fallback

All affected targets verified to build successfully.
- DYSF4/target.h: Removed ICM20608 comment (no ICM support in this directory)
- OMNIBUSF4/target.h: Removed ICM20608 comment (no ICM support in this directory)
- OMNIBUSF4/target.h: Removed obsolete relationship comments from consolidated file

ICM20608 support only exists in OMNIBUSF4PRO and OMNIBUSF4V3_SS directories.
The #else branch at lines 44-46 was unreachable after adding
OMNIBUSF4V3_ICM aliasing. All three targets (OMNIBUSF4PRO,
OMNIBUSF4V3, OMNIBUSF4V3_ICM) always use TIM4/PB9, never TIM12/PB15.
1. Removed outdated 'pad labelled CH5/CH6 on OMNIBUSF4PRO' comments from:
   - OMNIBUSF4/target.h and target.c (wrong target)
   - DYSF4/target.h and target.c (wrong target)
   - OMNIBUSF4V3_SS/target.c (wrong target)

   These comments are only accurate in the OMNIBUSF4PRO directory where
   PC8/PC9 really are labelled CH5/CH6 on the physical board.

2. Removed redundant conditional from OMNIBUSF4PRO/target.c:
   #if (defined(OMNIBUSF4PRO) || defined(OMNIBUSF4V3))
   This is always true since all 3 targets in this directory
   (OMNIBUSF4PRO, OMNIBUSF4V3, OMNIBUSF4V3_ICM) have one of these defined.
Remove orphaned indentation from preprocessor defines that were
previously inside conditional blocks but are now at top level after
the target split.

Files changed:
- OMNIBUSF4/target.h: Fixed 2-space and 4-space orphaned indents
- DYSF4/target.h: Fixed 2-space orphaned indents
- OMNIBUSF4V3_SS/target.h: Fixed extensive 2-space orphaned indents
- OMNIBUSF4PRO/target.h: Fixed 4-space orphaned indent on ADC_CHANNEL_3_PIN

Valid indentation inside active #if blocks was preserved.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sensei-hacker sensei-hacker added this to the 9.1 milestone Dec 23, 2025
The upstream added OMNIBUSF4V3_ICM support to the monolithic
OMNIBUSF4/target.h. This PR moves OMNIBUSF4V3_ICM to the new
OMNIBUSF4PRO/ directory alongside V3.

Resolution:
- OMNIBUSF4/target.h: keep PR version (base target only, no PRO/V3/ICM)
- OMNIBUSF4/CMakeLists.txt: keep PR version (only OMNIBUSF4 here)
- OMNIBUSF4PRO/target.h: add ICM42605 support for OMNIBUSF4V3_ICM,
  which was present in upstream but missing from the split target
@sensei-hacker sensei-hacker added Ready to merge Testing Required Release Notes Add this when a PR needs to be mentioned in the release notes and removed Ready to merge labels Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cleanup/refactor Release Notes Add this when a PR needs to be mentioned in the release notes Review effort 3/5 Testing Required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant