From 482992d4790af9ffc40ecb5cb3655b6bd56ebd3e Mon Sep 17 00:00:00 2001 From: Raphael Hunziker Date: Thu, 10 Sep 2026 20:04:34 +0200 Subject: [PATCH 1/3] baro: detect the DPS310 on both of its I2C addresses The DPS310 answers on 0x77 when its SDO pin is pulled high and on 0x76 when it is pulled low. Both wirings are shipped on real boards, so the fixed default of 0x76 left every board of the other kind without a barometer. Register both addresses and probe them in the driver, the same way the IST8310 compass is handled. A target that pins the address down with DPS310_I2C_ADDR keeps using only that address. Fixes #9958 --- src/main/drivers/barometer/barometer_dps310.c | 23 +++++++++++-------- src/main/drivers/bus.h | 3 ++- src/main/target/HUMMINGBIRD_FC305/target.c | 2 +- src/main/target/common_hardware.c | 12 ++++++---- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/main/drivers/barometer/barometer_dps310.c b/src/main/drivers/barometer/barometer_dps310.c index 663dcb27117..7b4fa7579eb 100644 --- a/src/main/drivers/barometer/barometer_dps310.c +++ b/src/main/drivers/barometer/barometer_dps310.c @@ -343,18 +343,23 @@ static bool deviceDetect(busDevice_t * busDev) bool baroDPS310Detect(baroDev_t *baro) { - baro->busDev = busDeviceInit(BUSTYPE_ANY, DEVHW_DPS310, 0, OWNER_BARO); - if (baro->busDev == NULL) { - return false; - } + // The sensor may sit on either of its two I2C addresses, depending on how SDO is wired + bool detected = false; - if (!deviceDetect(baro->busDev)) { - busDeviceDeInit(baro->busDev); - return false; + for (uint8_t index = 0; index < 2 && !detected; index++) { + baro->busDev = busDeviceInit(BUSTYPE_ANY, DEVHW_DPS310_0 + index, 0, OWNER_BARO); + if (baro->busDev == NULL) { + continue; + } + + if (deviceDetect(baro->busDev) && deviceConfigure(baro->busDev)) { + detected = true; + } else { + busDeviceDeInit(baro->busDev); + } } - if (!deviceConfigure(baro->busDev)) { - busDeviceDeInit(baro->busDev); + if (!detected) { return false; } diff --git a/src/main/drivers/bus.h b/src/main/drivers/bus.h index 75da648427b..0416f516ea1 100644 --- a/src/main/drivers/bus.h +++ b/src/main/drivers/bus.h @@ -98,7 +98,8 @@ typedef enum { DEVHW_LPS25H, DEVHW_SPL06, DEVHW_BMP388, - DEVHW_DPS310, + DEVHW_DPS310_0, + DEVHW_DPS310_1, DEVHW_B2SMPB, /* Compass chips */ diff --git a/src/main/target/HUMMINGBIRD_FC305/target.c b/src/main/target/HUMMINGBIRD_FC305/target.c index 275d3f27935..476d31c71b3 100644 --- a/src/main/target/HUMMINGBIRD_FC305/target.c +++ b/src/main/target/HUMMINGBIRD_FC305/target.c @@ -27,7 +27,7 @@ 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_dps310, DEVHW_DPS310, BARO_I2C_BUS, DPS310_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); +BUSDEV_REGISTER_I2C(busdev_dps310_0, DEVHW_DPS310_0, BARO_I2C_BUS, DPS310_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); 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); diff --git a/src/main/target/common_hardware.c b/src/main/target/common_hardware.c index f59d87c0be2..a8a85336259 100755 --- a/src/main/target/common_hardware.c +++ b/src/main/target/common_hardware.c @@ -175,15 +175,19 @@ #if defined(USE_BARO_DPS310) #if defined(DPS310_SPI_BUS) - BUSDEV_REGISTER_SPI(busdev_dps310, DEVHW_DPS310, DPS310_SPI_BUS, DPS310_CS_PIN, NONE, DEVFLAGS_NONE, 0); + BUSDEV_REGISTER_SPI(busdev_dps310_0, DEVHW_DPS310_0, DPS310_SPI_BUS, DPS310_CS_PIN, NONE, DEVFLAGS_NONE, 0); #elif defined(DPS310_I2C_BUS) || defined(BARO_I2C_BUS) #if !defined(DPS310_I2C_BUS) #define DPS310_I2C_BUS BARO_I2C_BUS #endif - #if !defined(DPS310_I2C_ADDR) - #define DPS310_I2C_ADDR (0x76) + #if defined(DPS310_I2C_ADDR) + BUSDEV_REGISTER_I2C(busdev_dps310_0, DEVHW_DPS310_0, DPS310_I2C_BUS, DPS310_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); + #else + // The DPS310 answers on 0x77 when SDO is pulled high and on 0x76 when it is pulled low. + // Both wirings are in use, so register both and let the driver probe them + BUSDEV_REGISTER_I2C(busdev_dps310_0, DEVHW_DPS310_0, DPS310_I2C_BUS, 0x76, NONE, DEVFLAGS_NONE, 0); + BUSDEV_REGISTER_I2C(busdev_dps310_1, DEVHW_DPS310_1, DPS310_I2C_BUS, 0x77, NONE, DEVFLAGS_NONE, 0); #endif - BUSDEV_REGISTER_I2C(busdev_dps310, DEVHW_DPS310, DPS310_I2C_BUS, DPS310_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); #endif #endif From 7719c72ff79b8b95c521b0d387a8226baba779a4 Mon Sep 17 00:00:00 2001 From: Raffi1202 Date: Fri, 11 Sep 2026 18:04:41 +0200 Subject: [PATCH 2/3] Regenerate hardware enum reference for both DPS310 addresses --- docs/development/msp/inav_enums.json | 85 +++++++++++++------------- docs/development/msp/inav_enums_ref.md | 85 +++++++++++++------------- 2 files changed, 86 insertions(+), 84 deletions(-) diff --git a/docs/development/msp/inav_enums.json b/docs/development/msp/inav_enums.json index 7f5e0f6f1cb..45b94ae26ca 100644 --- a/docs/development/msp/inav_enums.json +++ b/docs/development/msp/inav_enums.json @@ -833,48 +833,49 @@ "DEVHW_LPS25H": "17", "DEVHW_SPL06": "18", "DEVHW_BMP388": "19", - "DEVHW_DPS310": "20", - "DEVHW_B2SMPB": "21", - "DEVHW_HMC5883": "22", - "DEVHW_AK8963": "23", - "DEVHW_AK8975": "24", - "DEVHW_IST8310_0": "25", - "DEVHW_IST8310_1": "26", - "DEVHW_IST8308": "27", - "DEVHW_QMC5883": "28", - "DEVHW_QMC5883P": "29", - "DEVHW_MAG3110": "30", - "DEVHW_LIS3MDL": "31", - "DEVHW_RM3100": "32", - "DEVHW_VCM5883": "33", - "DEVHW_MLX90393": "34", - "DEVHW_LIS2MDL": "35", - "DEVHW_LM75_0": "36", - "DEVHW_LM75_1": "37", - "DEVHW_LM75_2": "38", - "DEVHW_LM75_3": "39", - "DEVHW_LM75_4": "40", - "DEVHW_LM75_5": "41", - "DEVHW_LM75_6": "42", - "DEVHW_LM75_7": "43", - "DEVHW_DS2482": "44", - "DEVHW_MAX7456": "45", - "DEVHW_SRF10": "46", - "DEVHW_VL53L0X": "47", - "DEVHW_VL53L1X": "48", - "DEVHW_US42": "49", - "DEVHW_TOF10120_I2C": "50", - "DEVHW_TERARANGER_EVO_I2C": "51", - "DEVHW_MS4525": "52", - "DEVHW_MS5525": "53", - "DEVHW_DLVR": "54", - "DEVHW_M25P16": "55", - "DEVHW_W25N": "56", - "DEVHW_UG2864": "57", - "DEVHW_SDCARD": "58", - "DEVHW_IRLOCK": "59", - "DEVHW_PCF8574": "60", - "DEVHW_INA226": "61" + "DEVHW_DPS310_0": "20", + "DEVHW_DPS310_1": "21", + "DEVHW_B2SMPB": "22", + "DEVHW_HMC5883": "23", + "DEVHW_AK8963": "24", + "DEVHW_AK8975": "25", + "DEVHW_IST8310_0": "26", + "DEVHW_IST8310_1": "27", + "DEVHW_IST8308": "28", + "DEVHW_QMC5883": "29", + "DEVHW_QMC5883P": "30", + "DEVHW_MAG3110": "31", + "DEVHW_LIS3MDL": "32", + "DEVHW_RM3100": "33", + "DEVHW_VCM5883": "34", + "DEVHW_MLX90393": "35", + "DEVHW_LIS2MDL": "36", + "DEVHW_LM75_0": "37", + "DEVHW_LM75_1": "38", + "DEVHW_LM75_2": "39", + "DEVHW_LM75_3": "40", + "DEVHW_LM75_4": "41", + "DEVHW_LM75_5": "42", + "DEVHW_LM75_6": "43", + "DEVHW_LM75_7": "44", + "DEVHW_DS2482": "45", + "DEVHW_MAX7456": "46", + "DEVHW_SRF10": "47", + "DEVHW_VL53L0X": "48", + "DEVHW_VL53L1X": "49", + "DEVHW_US42": "50", + "DEVHW_TOF10120_I2C": "51", + "DEVHW_TERARANGER_EVO_I2C": "52", + "DEVHW_MS4525": "53", + "DEVHW_MS5525": "54", + "DEVHW_DLVR": "55", + "DEVHW_M25P16": "56", + "DEVHW_W25N": "57", + "DEVHW_UG2864": "58", + "DEVHW_SDCARD": "59", + "DEVHW_IRLOCK": "60", + "DEVHW_PCF8574": "61", + "DEVHW_INA226": "62" }, "deviceFlags_e": { "_source": "inav/src/main/drivers/bus.h", diff --git a/docs/development/msp/inav_enums_ref.md b/docs/development/msp/inav_enums_ref.md index 87168663713..763911dc171 100644 --- a/docs/development/msp/inav_enums_ref.md +++ b/docs/development/msp/inav_enums_ref.md @@ -1460,48 +1460,49 @@ | `DEVHW_LPS25H` | 17 | | | `DEVHW_SPL06` | 18 | | | `DEVHW_BMP388` | 19 | | -| `DEVHW_DPS310` | 20 | | -| `DEVHW_B2SMPB` | 21 | | -| `DEVHW_HMC5883` | 22 | | -| `DEVHW_AK8963` | 23 | | -| `DEVHW_AK8975` | 24 | | -| `DEVHW_IST8310_0` | 25 | | -| `DEVHW_IST8310_1` | 26 | | -| `DEVHW_IST8308` | 27 | | -| `DEVHW_QMC5883` | 28 | | -| `DEVHW_QMC5883P` | 29 | | -| `DEVHW_MAG3110` | 30 | | -| `DEVHW_LIS3MDL` | 31 | | -| `DEVHW_RM3100` | 32 | | -| `DEVHW_VCM5883` | 33 | | -| `DEVHW_MLX90393` | 34 | | -| `DEVHW_LIS2MDL` | 35 | | -| `DEVHW_LM75_0` | 36 | | -| `DEVHW_LM75_1` | 37 | | -| `DEVHW_LM75_2` | 38 | | -| `DEVHW_LM75_3` | 39 | | -| `DEVHW_LM75_4` | 40 | | -| `DEVHW_LM75_5` | 41 | | -| `DEVHW_LM75_6` | 42 | | -| `DEVHW_LM75_7` | 43 | | -| `DEVHW_DS2482` | 44 | | -| `DEVHW_MAX7456` | 45 | | -| `DEVHW_SRF10` | 46 | | -| `DEVHW_VL53L0X` | 47 | | -| `DEVHW_VL53L1X` | 48 | | -| `DEVHW_US42` | 49 | | -| `DEVHW_TOF10120_I2C` | 50 | | -| `DEVHW_TERARANGER_EVO_I2C` | 51 | | -| `DEVHW_MS4525` | 52 | | -| `DEVHW_MS5525` | 53 | | -| `DEVHW_DLVR` | 54 | | -| `DEVHW_M25P16` | 55 | | -| `DEVHW_W25N` | 56 | | -| `DEVHW_UG2864` | 57 | | -| `DEVHW_SDCARD` | 58 | | -| `DEVHW_IRLOCK` | 59 | | -| `DEVHW_PCF8574` | 60 | | -| `DEVHW_INA226` | 61 | | +| `DEVHW_DPS310_0` | 20 | | +| `DEVHW_DPS310_1` | 21 | | +| `DEVHW_B2SMPB` | 22 | | +| `DEVHW_HMC5883` | 23 | | +| `DEVHW_AK8963` | 24 | | +| `DEVHW_AK8975` | 25 | | +| `DEVHW_IST8310_0` | 26 | | +| `DEVHW_IST8310_1` | 27 | | +| `DEVHW_IST8308` | 28 | | +| `DEVHW_QMC5883` | 29 | | +| `DEVHW_QMC5883P` | 30 | | +| `DEVHW_MAG3110` | 31 | | +| `DEVHW_LIS3MDL` | 32 | | +| `DEVHW_RM3100` | 33 | | +| `DEVHW_VCM5883` | 34 | | +| `DEVHW_MLX90393` | 35 | | +| `DEVHW_LIS2MDL` | 36 | | +| `DEVHW_LM75_0` | 37 | | +| `DEVHW_LM75_1` | 38 | | +| `DEVHW_LM75_2` | 39 | | +| `DEVHW_LM75_3` | 40 | | +| `DEVHW_LM75_4` | 41 | | +| `DEVHW_LM75_5` | 42 | | +| `DEVHW_LM75_6` | 43 | | +| `DEVHW_LM75_7` | 44 | | +| `DEVHW_DS2482` | 45 | | +| `DEVHW_MAX7456` | 46 | | +| `DEVHW_SRF10` | 47 | | +| `DEVHW_VL53L0X` | 48 | | +| `DEVHW_VL53L1X` | 49 | | +| `DEVHW_US42` | 50 | | +| `DEVHW_TOF10120_I2C` | 51 | | +| `DEVHW_TERARANGER_EVO_I2C` | 52 | | +| `DEVHW_MS4525` | 53 | | +| `DEVHW_MS5525` | 54 | | +| `DEVHW_DLVR` | 55 | | +| `DEVHW_M25P16` | 56 | | +| `DEVHW_W25N` | 57 | | +| `DEVHW_UG2864` | 58 | | +| `DEVHW_SDCARD` | 59 | | +| `DEVHW_IRLOCK` | 60 | | +| `DEVHW_PCF8574` | 61 | | +| `DEVHW_INA226` | 62 | | --- ## `deviceFlags_e` From 59da43c5e8c4b485e1cc60a71f6118689f03c997 Mon Sep 17 00:00:00 2001 From: Raffi1202 Date: Wed, 23 Sep 2026 00:10:17 +0200 Subject: [PATCH 3/3] Complete the MSP catalogue required by the current CI check --- docs/development/msp/README.md | 43 ++++++++++++++ docs/development/msp/msp_messages.json | 77 ++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) diff --git a/docs/development/msp/README.md b/docs/development/msp/README.md index f35a79211b4..5ec4d1be69d 100644 --- a/docs/development/msp/README.md +++ b/docs/development/msp/README.md @@ -461,6 +461,9 @@ When the MSP JSON specification changes, bump `msp_messages.json` version: [8744 - MSP2_INAV_TIMESYNC](#msp2_inav_timesync) [8752 - MSP2_INAV_SET_AUX_RC](#msp2_inav_set_aux_rc) [8753 - MSP2_INAV_WIND](#msp2_inav_wind) +[8754 - MSP2_INAV_MAG_UNALIGNED](#msp2_inav_mag_unaligned) +[8755 - MSP2_INAV_ESC_SRXL2_STATUS](#msp2_inav_esc_srxl2_status) +[8756 - MSP2_INAV_ESC_SRXL2_CALIBRATE](#msp2_inav_esc_srxl2_calibrate) [12288 - MSP2_BETAFLIGHT_BIND](#msp2_betaflight_bind) [12289 - MSP2_RX_BIND](#msp2_rx_bind) @@ -4878,6 +4881,46 @@ When the MSP JSON specification changes, bump `msp_messages.json` version: **Notes:** Requires `USE_WIND_ESTIMATOR`; returns zeroes when wind estimation is not compiled in or not yet valid. Check bit 0 of `flags` before using speed/angle values. +## `MSP2_INAV_MAG_UNALIGNED (8754 / 0x2232)` +**Description:** Reads the unaligned magnetometer vector. + +**Request Payload:** **None** + +**Reply Payload:** +|Field|C Type|Size (Bytes)|Description| +|---|---|---|---| +| `magADCUnaligned` | `int16_t[3]` | 6 | X, Y and Z components, rounded to signed 16-bit values. | + +**Notes:** Returns rounded mag.magADCUnaligned values before board alignment. Returns three zeroes without USE_MAG. + +## `MSP2_INAV_ESC_SRXL2_STATUS (8755 / 0x2233)` +**Description:** Reads SRXL2 ESC calibration and connection status. + +**Request Payload:** **None** + +**Reply Payload:** +|Field|C Type|Size (Bytes)|Description| +|---|---|---|---| +| `phase` | `uint8_t` | 1 | Calibration phase (srxl2CalPhase_e). | +| `connected` | `uint8_t` | 1 | 1 when every opened ESC is connected; otherwise 0. | +| `lastResult` | `uint8_t` | 1 | Last calibration start result (srxl2CalResult_e). | +| `portCount` | `uint8_t` | 1 | Number of opened SRXL2 motor ports. | +| `motorCount` | `uint8_t` | 1 | Number of motors in the current mixer. | + +**Notes:** Requires USE_MOTOR_SRXL2. Counts report opened motor ports and the current mixer motor count, not hardware capacity. + +## `MSP2_INAV_ESC_SRXL2_CALIBRATE (8756 / 0x2234)` +**Description:** Controls SRXL2 ESC throttle-range calibration. + +**Request Payload:** +|Field|C Type|Size (Bytes)|Description| +|---|---|---|---| +| `phase` | `uint8_t` | 1 | Requested calibration action (srxl2CalPhase_e): 0, 1, 4 or 5. | + +**Reply Payload:** **None** + +**Notes:** Requires USE_MOTOR_SRXL2 and at least one request byte. Accepted commands: 0 abort, 1 automatic start, 4 manual high, 5 manual low. Driver safety checks can reject start requests; read MSP2_INAV_ESC_SRXL2_STATUS for the reason. Other command values return an MSP error. Remove propellers before calibration. + ## `MSP2_BETAFLIGHT_BIND (12288 / 0x3000)` **Description:** Initiates the receiver binding procedure for supported serial protocols (CRSF, SRXL2). diff --git a/docs/development/msp/msp_messages.json b/docs/development/msp/msp_messages.json index 176833915ad..9416201ebcc 100644 --- a/docs/development/msp/msp_messages.json +++ b/docs/development/msp/msp_messages.json @@ -11674,6 +11674,83 @@ }, "notes": "Requires a receiver using MSP as the protocol, sends MSP2_RX_BIND to the receiver.", "description": "Initiates binding for MSP receivers (mLRS)." + }, + "MSP2_INAV_MAG_UNALIGNED": { + "code": 8754, + "mspv": 2, + "request": null, + "reply": { + "payload": [ + { + "name": "magADCUnaligned", + "ctype": "int16_t", + "desc": "X, Y and Z components, rounded to signed 16-bit values.", + "units": "", + "array": true, + "array_size": 3 + } + ] + }, + "notes": "Returns rounded mag.magADCUnaligned values before board alignment. Returns three zeroes without USE_MAG.", + "description": "Reads the unaligned magnetometer vector." + }, + "MSP2_INAV_ESC_SRXL2_STATUS": { + "code": 8755, + "mspv": 2, + "request": null, + "reply": { + "payload": [ + { + "name": "phase", + "ctype": "uint8_t", + "desc": "Calibration phase (srxl2CalPhase_e).", + "units": "" + }, + { + "name": "connected", + "ctype": "uint8_t", + "desc": "1 when every opened ESC is connected; otherwise 0.", + "units": "" + }, + { + "name": "lastResult", + "ctype": "uint8_t", + "desc": "Last calibration start result (srxl2CalResult_e).", + "units": "" + }, + { + "name": "portCount", + "ctype": "uint8_t", + "desc": "Number of opened SRXL2 motor ports.", + "units": "" + }, + { + "name": "motorCount", + "ctype": "uint8_t", + "desc": "Number of motors in the current mixer.", + "units": "" + } + ] + }, + "notes": "Requires USE_MOTOR_SRXL2. Counts report opened motor ports and the current mixer motor count, not hardware capacity.", + "description": "Reads SRXL2 ESC calibration and connection status." + }, + "MSP2_INAV_ESC_SRXL2_CALIBRATE": { + "code": 8756, + "mspv": 2, + "request": { + "payload": [ + { + "name": "phase", + "ctype": "uint8_t", + "desc": "Requested calibration action (srxl2CalPhase_e): 0, 1, 4 or 5.", + "units": "" + } + ] + }, + "reply": null, + "notes": "Requires USE_MOTOR_SRXL2 and at least one request byte. Accepted commands: 0 abort, 1 automatic start, 4 manual high, 5 manual low. Driver safety checks can reject start requests; read MSP2_INAV_ESC_SRXL2_STATUS for the reason. Other command values return an MSP error. Remove propellers before calibration.", + "description": "Controls SRXL2 ESC throttle-range calibration." } } }