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: 1 addition & 1 deletion src/main/target/HUMMINGBIRD_FC305/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

void targetConfiguration(void)
{
barometerConfigMutable()->baro_hardware = BARO_SPL06;
barometerConfigMutable()->baro_hardware = BARO_AUTODETECT;
serialConfigMutable()->portConfigs[3].functionMask = FUNCTION_ESCSERIAL;
pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1;
}
3 changes: 2 additions & 1 deletion src/main/target/HUMMINGBIRD_FC305/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN);
BUSDEV_REGISTER_SPI(busdev_sdcard_spi, DEVHW_SDCARD, SDCARD_SPI_BUS, SDCARD_CS_PIN, NONE, DEVFLAGS_SPI_MODE_0, 0);
BUSDEV_REGISTER_SPI(busdev_max7456, DEVHW_MAX7456, MAX7456_SPI_BUS, MAX7456_CS_PIN, NONE, DEVFLAGS_USE_RAW_REGISTERS, 0);
BUSDEV_REGISTER_I2C(busdev_spl06, DEVHW_SPL06, SPL06_I2C_BUS, SPL06_I2C_ADDR, NONE, DEVFLAGS_NONE, 0);
BUSDEV_REGISTER_I2C(busdev_spl06, DEVHW_SPL06, BARO_I2C_BUS, SPL06_I2C_ADDR, NONE, DEVFLAGS_NONE, 0);
BUSDEV_REGISTER_I2C(busdev_dps310, DEVHW_DPS310, BARO_I2C_BUS, 0x76, NONE, DEVFLAGS_NONE, 0);
Comment on lines +30 to +31
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. busdev_dps310 uses hardcoded addr 📘 Rule violation ⚙ Maintainability

The new DPS310 registration hardcodes 0x76 instead of using a centralized *_I2C_ADDR macro,
making address/behavior easy to drift across modules/targets. This can break or confuse barometer
autodetection if the DPS310 address differs from the SPL06 address on a given board variant.
Agent Prompt
## Issue description
`busdev_dps310` is registered with a hardcoded I2C address (`0x76`) while other baro devices use named macros. This duplicates a shared mapping and increases the chance of drift/misconfiguration across modules/targets.

## Issue Context
This target now enables `USE_BARO_DPS310` and uses `BARO_AUTODETECT`. The address should be a target-level constant (like `SPL06_I2C_ADDR`) so hardware variants can adjust it without hunting for literals.

## Fix Focus Areas
- src/main/target/HUMMINGBIRD_FC305/target.h[56-61]
- src/main/target/HUMMINGBIRD_FC305/target.c[30-31]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +30 to +31
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

2. Dps310 masked by spl06 🐞 Bug ≡ Correctness

With BARO_AUTODETECT, barometer detection tries SPL06 before DPS310, and both drivers accept chip-id
0x10 from register 0x0D, so a DPS310 can be detected as SPL06 and the DPS310 driver will never run.
This can defeat the intended “automatic detection” fix and may run the wrong driver on DPS310
hardware.
Agent Prompt
### Issue description
HUMMINGBIRD_FC305 now enables `BARO_AUTODETECT` and registers both SPL06 and DPS310. However, `BARO_AUTODETECT` probes SPL06 before DPS310, and both SPL06 and DPS310 drivers treat chip-id `0x10` (read from reg `0x0D`) as a valid match. This means DPS310 hardware can be misdetected as SPL06, preventing DPS310 driver initialization.

### Issue Context
- Autodetect order is implemented in `baroDetect()`.
- SPL06 and DPS310 detection both read register `0x0D` and accept `0x10`.

### Fix Focus Areas
- src/main/sensors/barometer.c[73-185]
- src/main/drivers/barometer/barometer_spl06.c[161-174]
- src/main/drivers/barometer/barometer_dps310.c[328-374]

### Suggested fix approach
Implement deterministic disambiguation when both `USE_BARO_SPL06` and `USE_BARO_DPS310` are enabled:
1. In `BARO_AUTODETECT` mode, try `baroDPS310Detect()` before `spl06Detect()` **or**
2. Add a secondary probe in SPL06 detection to reject DPS310 (or vice-versa) based on an additional register/value that differs between the parts, and only then accept the device.

Ensure that whichever approach is used does not leave the sensor in a partially-configured state if the first probe fails and the second probe is attempted.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


BUSDEV_REGISTER_I2C(busdev_qmc5883, DEVHW_QMC5883, MAG_I2C_BUS, 0x0D, NONE, DEVFLAGS_NONE, 0);
BUSDEV_REGISTER_I2C(busdev_hmc5883, DEVHW_HMC5883, MAG_I2C_BUS, 0x1E, NONE, DEVFLAGS_NONE, 0);
Expand Down
3 changes: 2 additions & 1 deletion src/main/target/HUMMINGBIRD_FC305/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@
#define I2C1_SDA PB9

#define USE_BARO
#define BARO_I2C_BUS BUS_I2C1
#define USE_BARO_SPL06
#define USE_BARO_DPS310
#define SPL06_I2C_ADDR (0x76)
#define SPL06_I2C_BUS BUS_I2C1

#define USE_MAG
#define MAG_I2C_BUS BUS_I2C1
Expand Down
Loading