Feature/bmp580 barometer - #14925
Feature/bmp580 barometer#14925
Conversation
Add support for Bosch BMP580/BMP581 next-gen barometer: - New driver barometer_bmp580.c/h with I2C protocol - 128X oversampling for pressure (lowest noise) - 4X oversampling for temperature - IIR filter coefficient 4 - Normal power mode continuous measurement - Compatible with BMP580 and BMP581 variants Specifications: - Pressure range: 300-1250 hPa - Relative accuracy: ±0.06 hPa (±0.5m) - Temperature range: -40 to +85°C - I2C address: 0x46 or 0x47 Tested on RP2350B (Raspberry Pi Pico 2) at I2C address 0x47.
|
Do you want to test this code? You can flash it directly from the Betaflight App:
WARNING: It may be unstable. Use only for testing! |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a new BMP580/BMP581 barometer driver (I2C/SPI), registers it in the build, integrates detection/initialization into the barometer subsystem, exposes Changes
Sequence Diagram(s)sequenceDiagram
participant Init as System Init
participant Baro as Baro Subsystem
participant Bus as I2C/SPI Bus
participant BMP580 as BMP580 Device
Init->>Baro: request detection
Baro->>Bus: bmp580Detect -> busInit / probe
Bus->>BMP580: probe (I2C addr / SPI CS)
alt device responds
BMP580-->>Bus: chip id / ack
Bus-->>Baro: device detected
Baro->>BMP580: soft reset + configure (DSP/OSR/ODR/IRQ)
BMP580-->>Baro: ack
BMP580->>Baro: measurement ready (EXTI/IRQ)
Baro->>Bus: read 6 bytes (UT[3], UP[3])
Bus->>BMP580: read request
BMP580-->>Bus: raw bytes
Baro->>Baro: bmp580Calculate(raw) -> temperature, pressure
Baro-->>Init: register device & report readiness
else not found
Bus-->>Baro: not found
Baro-->>Init: detection failed / fallback
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/sensors/barometer.c (1)
82-135:⚠️ Potential issue | 🟠 MajorBMP580 missing from the default barometer auto-selection logic.
The preprocessor block that auto-defines
DEFAULT_BARO_xxxbased onUSE_BARO_xxxflags (lines 88–135) has no entry for BMP580. Additionally, BMP580 is missing from the SPI defaults condition (line 141).This means:
- A target that defines
USE_BARO_BMP580(without an explicitDEFAULT_BARO_BMP580) won't trigger the auto-selection logic, so the condition on line 147 will not match.- The barometer config will fall to the
#elsebranch (line 154), settingBARO_NONEandBUS_TYPE_NONE, preventing detection.- Similarly,
USE_BARO_SPI_BMP580won't get SPI bus defaults configured (line 141).BMP580 should be added to the auto-selection logic following the same pattern as BMP388:
Proposed fix
Add to the outer
#ifcondition on line 82:defined(DEFAULT_BARO_BMP580) || defined(DEFAULT_BARO_SPI_BMP580)Add to the
#elifchain after line 135:+#elif defined(USE_BARO_BMP580) || defined(USE_BARO_SPI_BMP580) +#if defined(USE_BARO_SPI_BMP580) +#define DEFAULT_BARO_SPI_BMP580 +#else +#define DEFAULT_BARO_BMP580 +#endifAdd to the SPI defaults condition on line 141:
|| defined(DEFAULT_BARO_SPI_BMP580)
🤖 Fix all issues with AI agents
In `@src/main/drivers/barometer/barometer_bmp580.c`:
- Around line 194-198: The temperature oversampling macro is set to 128× but the
PR description says pressure=128× and temperature=4×; update the
BMP580_TEMPERATURE_OSR definition to use the 4× constant (change
BMP580_TEMPERATURE_OSR from BMP580_OSR_TEMP_128X to BMP580_OSR_TEMP_4X) so the
conversion time and effective update rate match the documented 128×/4×
configuration; leave BMP580_PRESSURE_OSR as BMP580_OSR_PRESS_128X.
- Around line 363-390: The driver never sets the combined_read flag, so the
barometer state machine still runs the dummy UT states; set baro->combined_read
= true in the BMP580 init sequence right after you assign the UT/UP callbacks
(the block that sets baro->ut_delay, baro->start_ut, baro->get_ut, baro->read_ut
and baro->start_up, baro->get_up, baro->read_up) so the state machine skips
temperature-only states; locate the init function containing
bmp580StartUT/bmp580GetUT/bmp580ReadUT and
bmp580StartUP/bmp580GetUP/bmp580ReadUP and add the single assignment there.
In `@src/main/sensors/barometer.h`:
- Around line 38-39: Add a lookup entry for the new enum and preserve EEPROM
compatibility: insert [BARO_BMP580] = "BMP580" into the lookupTableBaroHardware
array so index 12 is initialized; then handle the BARO_VIRTUAL value change by
bumping the barometer config PG version (the PG version constant in barometer.c)
and add migration logic that maps old stored value 11 to the new BARO_VIRTUAL
enum value (or alternatively change enum assignments so BARO_BMP580=11 and
BARO_VIRTUAL=12 if you prefer not to migrate). Ensure references to BARO_BMP580
and BARO_VIRTUAL in settings.c and barometer.c are consistent after the change.
🧹 Nitpick comments (2)
src/main/drivers/barometer/barometer_bmp580.c (2)
227-240: VLA in embedded context; consider a fixed-size buffer.
uint8_t buf[length + 1]is a variable-length array. While the callers currently pass small lengths (≤6), VLAs are generally avoided in embedded firmware due to unpredictable stack usage and are undefined behavior in some C standards when the size is zero. A fixed-size local buffer based onBMP580_DATA_FRAME_SIZE + 1would be safer.Proposed fix
static bool bmp580ReadRegisterBuffer(const extDevice_t *dev, uint8_t reg, uint8_t *data, uint8_t length) { if (dev->bus->busType == BUS_TYPE_SPI) { - // For SPI: first byte is dummy on BMP5xx read - uint8_t buf[length + 1]; - bool ret = busReadRegisterBuffer(dev, reg, buf, length + 1); + // For SPI: first byte is dummy on BMP5xx read + uint8_t buf[BMP580_DATA_FRAME_SIZE + 1 + 1]; // max data + SPI dummy + chip ID read + if (length + 1 > (int)sizeof(buf)) { + return false; + } + bool ret = busReadRegisterBuffer(dev, reg, buf, length + 1); if (ret) { memcpy(data, buf + 1, length); }
203-216: Static global state limits driver to a single instance and leaves debug variables in production.The static globals (
bmp580_up,bmp580_ut,bmp580_chip_id,sensor_data,bmp580_last_raw_temp,bmp580_last_raw_press) are typical for Betaflight barometer drivers (single-instance design). However,bmp580_last_raw_tempandbmp580_last_raw_press(lines 215-216) are only assigned but never read — they are dead code unless a debugger is attached.Suggested: guard debug variables
+#ifdef DEBUG // Debug: last raw values for troubleshooting static uint32_t bmp580_last_raw_temp = 0; static uint32_t bmp580_last_raw_press = 0; +#endifAnd in
bmp580GetUP:+#ifdef DEBUG // Store for debug bmp580_last_raw_temp = bmp580_ut; bmp580_last_raw_press = bmp580_up; +#endif
haslinghuis
left a comment
There was a problem hiding this comment.
Also add here:
betaflight/src/main/cli/settings.c
Lines 203 to 217 in d70db64
42fa33a to
41dff12
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/main/drivers/barometer/barometer_bmp580.c`:
- Around line 385-388: Update the misleading comment and clarify why up_delay is
set to 15000: state the actual configured oversampling (128× pressure, 4×
temperature) and note that per the BMP580 datasheet that conversion time for
those OSR settings is ~100ms, but the code uses 15ms because the sensor runs in
continuous/normal mode and samples are available from shadow registers;
reference the baro->up_delay assignment and the BMP580 operating mode/OSR
configuration in this comment so future readers understand the discrepancy
between datasheet conversion time and the chosen delay.
- Around line 356-362: The DSP IIR output was enabled by writing
BMP580_DSP_SHDW_SEL_IIR to BMP580_REG_DSP_CONFIG but the DSP IIR coefficient
register (BMP580_REG_DSP_IIR) was never set (it stays at POR 0x00 bypass after
the soft reset), so enable the actual filter by writing the correct coefficient
value (select coefficient 4 as stated in the PR) into BMP580_REG_DSP_IIR after
the soft reset and before finalizing configuration; keep the existing writes to
BMP580_REG_DSP_CONFIG and BMP580_REG_OSR_CONFIG
(BMP580_PRESSURE_OSR/BMP580_TEMPERATURE_OSR/BMP580_OSR_PRESS_EN) but add a
busWriteRegister(dev, BMP580_REG_DSP_IIR,
<value-for-coef-4-for-pressure-and-temperature>) call to apply the IIR
coefficient for both pressure and temperature.
🧹 Nitpick comments (2)
src/main/drivers/barometer/barometer_bmp580.c (2)
228-241: Replace VLA with a fixed-size stack buffer.
uint8_t buf[length + 1](line 232) is a variable-length array. Whilelengthis always small here (1 or 6), VLAs are risky on resource-constrained MCUs and some compilers/configurations reject them. Use a fixed-size buffer based on the maximum expected read.Proposed fix
static bool bmp580ReadRegisterBuffer(const extDevice_t *dev, uint8_t reg, uint8_t *data, uint8_t length) { if (dev->bus->busType == BUS_TYPE_SPI) { - // For SPI: first byte is dummy on BMP5xx read - uint8_t buf[length + 1]; + // For SPI: first byte is dummy on BMP5xx read + uint8_t buf[BMP580_DATA_FRAME_SIZE + 1]; // max read size + SPI dummy byte + if (length > BMP580_DATA_FRAME_SIZE) { + return false; + } bool ret = busReadRegisterBuffer(dev, reg, buf, length + 1); if (ret) { memcpy(data, buf + 1, length); } return ret;
215-217: Dead stores: debug variables are written but never read.
bmp580_last_raw_tempandbmp580_last_raw_pressare set inbmp580GetUP(lines 449–450) but never consumed. They aren't guarded by#ifdef DEBUGeither. Consider removing them or wrapping in#ifdef DEBUGto avoid dead writes in release builds.
41dff12 to
84996b7
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (4)
src/main/drivers/barometer/barometer_bmp580.c (4)
243-256: VLA on constrained stack — prefer a fixed-size buffer.
uint8_t buf[length + 1]is a variable-length array. While callers in this file only pass small lengths (1 or 6), VLAs are fragile in embedded contexts and prohibited by MISRA C. Consider a fixed-size stack buffer based on the maximum expected read (data frame + 1 SPI dummy byte).Proposed fix
static bool bmp580ReadRegisterBuffer(const extDevice_t *dev, uint8_t reg, uint8_t *data, uint8_t length) { if (dev->bus->busType == BUS_TYPE_SPI) { - // For SPI: first byte is dummy on BMP5xx read - uint8_t buf[length + 1]; - bool ret = busReadRegisterBuffer(dev, reg, buf, length + 1); + // For SPI: first byte is dummy on BMP5xx read + uint8_t buf[BMP580_DATA_FRAME_SIZE + 1 + 1]; // max read size + SPI dummy + margin + if (length + 1 > (int)sizeof(buf)) { + return false; + } + bool ret = busReadRegisterBuffer(dev, reg, buf, length + 1); if (ret) { memcpy(data, buf + 1, length); }
230-232: Remove unused debug variables.
bmp580_last_raw_tempandbmp580_last_raw_pressare written (lines 472–473) but never read anywhere. They consume static RAM for no production benefit. Based on learnings, debug output was explicitly removed per Betaflight standards.Proposed fix
-// Debug: last raw values for troubleshooting -static uint32_t bmp580_last_raw_temp = 0; -static uint32_t bmp580_last_raw_press = 0;And remove the assignments at lines 472–473:
- // Store for debug - bmp580_last_raw_temp = bmp580_ut; - bmp580_last_raw_press = bmp580_up;
375-378: Ambiguous IIR coefficient comment — clarify register value vs. filter order.The comment says "coefficient 4" but the code uses
BMP580_IIR_COEF_15, which per the defines means register value0x04mapping to a filter coefficient of 15. The PR description also says "IIR filter coefficient 4" which adds to the confusion. Consider clarifying:- // Configure IIR filter coefficient 4 (gives coefficient ~15) for both pressure and temperature + // Configure IIR filter: register value 4 selects coefficient 15 for both pressure and temperature
220-228: Consider makingbmp580_chip_idlocal tobmp580Detect.
bmp580_chip_idis only used withinbmp580Detect. Keeping it as a file-scoped static wastes a byte of static RAM after detection completes. The same applies to thesensor_datapointer setup at line 329 which duplicates the SPI dummy-byte handling already done insidebmp580ReadRegisterBuffer.
4037092 to
974d1fe
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/sensors/barometer.c (1)
84-137:⚠️ Potential issue | 🟠 MajorBMP580 missing from the default barometer auto-define cascade.
The preprocessor cascade (lines 90–136) auto-defines
DEFAULT_BARO_xxxbased onUSE_BARO_xxxwhen no explicit default is set, but BMP580 is not included. This means boards that only defineUSE_BARO_BMP580(without any other baro) will fall through to the#elseat line 156, settingbaro_hardware = BARO_NONEandbaro_busType = BUS_TYPE_NONE, which prevents detection.Add BMP580 to the cascade, e.g.:
`#elif` defined(USE_BARO_BMP580) || defined(USE_BARO_SPI_BMP580) `#if` defined(USE_BARO_SPI_BMP580) `#define` DEFAULT_BARO_SPI_BMP580 `#else` `#define` DEFAULT_BARO_BMP580 `#endif`Also update the SPI guard at line 143 to include
DEFAULT_BARO_SPI_BMP580.
🤖 Fix all issues with AI agents
In `@src/main/sensors/barometer.c`:
- Around line 199-201: The UNUSED(dev) guard omits the SPI variant macro causing
false unused warnings when only USE_BARO_SPI_BMP580 is defined; update the
conditional in the `#if` that controls UNUSED(dev) to also check
!defined(USE_BARO_SPI_BMP580) so that the UNUSED(dev) macro is only emitted when
neither USE_BARO_BMP580 nor USE_BARO_SPI_BMP580 (and the other listed baro
macros) are defined; refer to the existing macros in the block (USE_BARO_BMP580,
USE_BARO_SPI_BMP580, USE_BARO_MS5611, etc.) to add the missing
!defined(USE_BARO_SPI_BMP580) check.
🧹 Nitpick comments (3)
src/main/drivers/barometer/barometer_bmp580.c (3)
254-257: VLA in embedded context.
uint8_t buf[length + 1]is a variable-length array on the stack. Whilelengthis always small in practice (1 or 6), VLAs are generally discouraged in embedded firmware due to unpredictable stack usage and potential issues with some compilers. Consider using a fixed-size buffer based onBMP580_DATA_FRAME_SIZE + 1.Proposed fix
static bool bmp580ReadRegisterBuffer(const extDevice_t *dev, uint8_t reg, uint8_t *data, uint8_t length) { if (dev->bus->busType == BUS_TYPE_SPI) { // For SPI: first byte is dummy on BMP5xx read - uint8_t buf[length + 1]; - bool ret = busReadRegisterBuffer(dev, reg, buf, length + 1); + uint8_t buf[BMP580_DATA_FRAME_SIZE + 1 + 1]; // Max read size + SPI dummy + bool ret = busReadRegisterBuffer(dev, reg, buf, MIN(length + 1, (uint8_t)sizeof(buf))); if (ret) { memcpy(data, buf + 1, length); }
398-401: Misleading comment — "coefficient 4" is the register value, not the filter coefficient.The comment says "IIR filter coefficient 4" but the actual IIR filter coefficient is 15 (register value 0x04 maps to coefficient 15 per the encoding at lines 169-177). The parenthetical "(gives coefficient ~15)" clarifies, but the leading text is confusing. The
@noteat line 325 correctly says "coefficient 15". Consider aligning the comment.Proposed fix
- // Configure IIR filter coefficient 4 (gives coefficient ~15) for both pressure and temperature + // Configure IIR filter coefficient 15 for both pressure and temperature + // (register value 0x04 = coefficient 15, per BMP580 datasheet)
230-232: Debug-only variables are always assigned but never consumed.
bmp580_last_raw_tempandbmp580_last_raw_pressare written on every sample (line 531-532) but never read anywhere. If intended for debugger inspection, wrap them in#ifdef DEBUGto avoid dead stores in release builds.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/main/drivers/barometer/barometer_bmp580.c`:
- Around line 390-401: The PR description is inconsistent with the code: update
the PR description to state "IIR filter coefficient 15 (register value 4)" to
match the implementation and the in-code comment; verify that references to
BMP580_REG_DSP_IIR, BMP580_IIR_PRESS(BMP580_IIR_COEF_15),
BMP580_IIR_TEMP(BMP580_IIR_COEF_15) and the comment about "register value 4
selects coefficient 15" remain consistent so reviewers understand the datasheet
encoding.
- Around line 262-274: The EXTI ISR bmp580_extiHandler must not perform blocking
I2C reads (bmp580ReadRegisterBuffer); remove that call and instead mark the baro
device for deferred handling by setting a flag on the baroDev_t (e.g., set
baro->int_pending = true or re-use an existing field) inside bmp580_extiHandler
(use container_of(cb, baroDev_t, exti) to access baro), then perform the
INT_STATUS read in the regular context such as bmp580ReadUP where bus IO is
safe; alternatively, if using pulsed interrupt mode, simply drop the read
entirely and rely on auto-clear of the INT pin.
Add support for Bosch BMP580/BMP581 next-gen barometer: - New driver barometer_bmp580.c/h with I2C protocol - 128X oversampling for pressure (lowest noise) - 4X oversampling for temperature (balanced) - IIR filter coefficient 4 - Normal power mode continuous measurement - Combined read mode (temp+pressure in single read) - Compatible with BMP580 and BMP581 variants Changes: - Add BARO_BMP580=11 to baroSensor_e enum - Add BMP580 to lookupTableBaroHardware - Bump PG_BAROMETER_CONFIG version to 4 (BARO_VIRTUAL moved to 12) - Set baro->combined_read = true to skip dummy UT states Specifications: - Pressure range: 300-1250 hPa - Relative accuracy: ±0.06 hPa (±0.5m) - Temperature range: -40 to +85°C - I2C address: 0x46 or 0x47 Tested on RP2350B (Raspberry Pi Pico 2) at I2C address 0x47.
974d1fe to
c7ab5f7
Compare
|
@coderabbitai please check committed all at once |
|
🧠 Learnings used✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (4)
src/main/drivers/barometer/barometer_bmp580.c (3)
246-260: Stack buffer in SPI read helper is silently bounded — consider a guard.
bufis fixed atBMP580_DATA_FRAME_SIZE + 1(7 bytes), butlengthis an uncheckeduint8_t. Currently all call sites passlength ≤ 6, so this is safe today. A defensive bounds check (or a_Static_assert/ comment) would prevent a future caller from overflowing the stack buffer.Optional: add a bounds check
static bool bmp580ReadRegisterBuffer(const extDevice_t *dev, uint8_t reg, uint8_t *data, uint8_t length) { if (dev->bus->busType == BUS_TYPE_SPI) { + if (length > BMP580_DATA_FRAME_SIZE) { + return false; + } // For SPI: first byte is dummy on BMP5xx read // Max read size: BMP580_DATA_FRAME_SIZE (6) + 1 dummy = 7 bytes uint8_t buf[BMP580_DATA_FRAME_SIZE + 1];
262-268: EXTI handler is a no-op, yet full interrupt infrastructure is configured.
bmp580_extiHandlerdoes nothing, butbmp580Detect(lines 320-326, 372-382) still sets up the EXTI pin, configures the BMP580INT_CONFIGregister, and enables the DRDY interrupt source. This means the sensor will fire hardware interrupts at 50 Hz that enter an empty ISR — unnecessary context switches. Consider either:
- Removing the interrupt configuration entirely (lines 320-326 and 372-382) since polling is used, or
- Keeping the infrastructure but skipping the sensor-side INT register writes.
This is consistent with other drivers that wire up EOC for future use, so not blocking, but worth noting the wasted cycles.
531-558: Verify that Betaflight's barometer subsystem expects pressure in Pa (not Pa×256 or hPa).The misleading comment on line 547 ("Betaflight expects Pa * 256 for some baros") may cause confusion. In
barometer.c,pressureToAltitude()divides by101325.0f(standard atmospheric pressure in Pa), confirming that Pa is expected. The calculation here (bmp580_up / 64) yields Pa, which is correct.However, the integer division on line 550 truncates fractional Pa. With 128× OSR, the BMP580's LSB resolution is ~0.016 Pa (1/64). Truncation to integer Pa loses this precision. Other Betaflight baro drivers (e.g., BMP388) also return integer Pa, so this is consistent, but worth documenting that the sub-Pa precision from the high OSR is discarded here.
Also, the comment on line 547 is misleading — consider removing the "Pa * 256" mention to avoid confusing future maintainers:
Clean up misleading comment
- // Pressure in Pa (Betaflight expects Pa * 256 for some baros, but using Pa directly) - // raw / 64 = pressure in Pa - // Betaflight barometer interface expects pressure in Pa + // Pressure in Pa (Betaflight barometer interface expects integer Pa) + // raw / 64 = pressure in Pa uint32_t press_pa = bmp580_up / 64;src/main/sensors/barometer.c (1)
84-137:DEFAULT_BARO_BMP580is recognized in the I2C bus config (line 149) but is missing from the default baro inference chain.Line 149 correctly enables I2C bus config when a target pre-defines
DEFAULT_BARO_BMP580. However, BMP580 is absent from both:
- The outer exclusion guard (line 84–88) — if a target defines
DEFAULT_BARO_BMP580, the inference block still runs and may additionally define a conflictingDEFAULT_BARO_*macro.- The inference chain (lines 90–136) —
USE_BARO_BMP580/USE_BARO_SPI_BMP580are never inferred as defaults.No target currently uses
DEFAULT_BARO_BMP580, so this doesn't break anything today. But when a target does define it, the conflicting double-definition from (1) could cause unexpected bus config. Consider adding BMP580 to the outer guard and the inference chain for completeness.Also applies to: 149-149
| // Read chip ID | ||
| bmp580ReadRegisterBuffer(dev, BMP580_REG_CHIP_ID, &chipId, 1); | ||
|
|
||
| if (chipId != BMP580_CHIP_ID && chipId != BMP581_CHIP_ID) { |
There was a problem hiding this comment.
Noticed this supports 580 and 581. Suggest use bmp5xx for driver - so we are able to identify device with whoami and could add more devices in this series in future when applicable. I have done the same for 426xx and QMC5883
There was a problem hiding this comment.
@gintaris thanks, Please also add BMP580 / BMP581 as independent devices. This way we can see the device used in status and setup tab.
Refactor naming to support future BMP5xx series devices (BMP580, BMP581, BMP582, etc.) similar to existing ICM426xx and QMC5883 driver naming conventions. Changes: - Rename barometer_bmp580.c/h → barometer_bmp5xx.c/h - Rename USE_BARO_BMP580 → USE_BARO_BMP5XX - Rename USE_BARO_SPI_BMP580 → USE_BARO_SPI_BMP5XX - Rename BARO_BMP580 enum → BARO_BMP5XX - Update CLI baro_hardware setting from BMP580 to BMP5XX - Preserve specific chip ID detection (BMP580_CHIP_ID, BMP581_CHIP_ID) Suggested-by: haslinghuis
- Add BARO_BMP580 (12) and BARO_BMP581 (13) to baroSensor_e enum - Add BMP580, BMP581 entries to lookupTableBaroHardware - Modify bmp5xxDetect() to return detected chip ID via parameter - Barometer detection now reports specific model (BMP580/BMP581) - Bump PG version to 5 for enum changes (BARO_VIRTUAL now 14) This allows users to see the exact sensor model in status/setup tabs. Auto-detection with BMP5XX still works and resolves to specific type. Requested-by: haslinghuis
- Remove BMP5XX from settings.c lookup table (keep BMP580/BMP581) - Use specific USE_BARO_BMP580/BMP581 defines instead of BMP5XX - Change unknown chip fallback to BARO_NONE instead of BARO_BMP5XX - Keep PG version at 4 (BMP580=13, BMP581=14 as new high values) - Keep BARO_BMP5XX=11 in enum for backward compat (deprecated)
- Remove deprecated BARO_BMP5XX from enum (use BMP580/BMP581 directly) - BMP580=11, BMP581=12, VIRTUAL=13 (VIRTUAL always last per haslinghuis) - Update all USE_BARO_BMP5XX references to USE_BARO_BMP580/BMP581 - Keep PG version 4 (old VIRTUAL=11 configs reset to auto-detect)
|
@blckmn how to recover from https://github.com/betaflight/betaflight/actions/runs/22068643616/job/63768883254?pr=14925 ? @gintaris try to update submodule(s) and push again.
|
Config PR pending: https://github.com/betaflight/config (MADFLIGHT_FC3 sensors)
|
@gintaris not sure if this works (out of office) https://www.betaflight.com/docs/development/Git#update-submodules-config |
Let's try I have updated |
- Add link to config PR betaflight#1030 - Document INA226 sensor defines added - Add dependency table for firmware PRs betaflight#14924, betaflight#14925, betaflight#14927 - Add merge coordination notes - Address reviewer comment about CURRENT_METER_INA226
One thing is clear, they block each other under certain conditions. Your tests confirm this.
In my case, the BMP580 driver I tested was also connected to the same I2C bus with INA226 and MMC5603, both when connected via USB and/or from the battery, all sensors work perfectly. |
* feat(driver): add BMP580/BMP581 barometer driver Add support for Bosch BMP580/BMP581 next-gen barometer: - New driver barometer_bmp580.c/h with I2C protocol - 128X oversampling for pressure (lowest noise) - 4X oversampling for temperature - IIR filter coefficient 4 - Normal power mode continuous measurement - Compatible with BMP580 and BMP581 variants Specifications: - Pressure range: 300-1250 hPa - Relative accuracy: ±0.06 hPa (±0.5m) - Temperature range: -40 to +85°C - I2C address: 0x46 or 0x47 Tested on RP2350B (Raspberry Pi Pico 2) at I2C address 0x47. * Rename BMP580 driver to BMP5xx for sensor family support Refactor naming to support future BMP5xx series devices (BMP580, BMP581, BMP582, etc.) similar to existing ICM426xx and QMC5883 driver naming conventions. Changes: - Rename barometer_bmp580.c/h → barometer_bmp5xx.c/h - Rename USE_BARO_BMP580 → USE_BARO_BMP5XX - Rename USE_BARO_SPI_BMP580 → USE_BARO_SPI_BMP5XX - Rename BARO_BMP580 enum → BARO_BMP5XX - Update CLI baro_hardware setting from BMP580 to BMP5XX - Preserve specific chip ID detection (BMP580_CHIP_ID, BMP581_CHIP_ID) Suggested-by: haslinghuis * Add BMP580 and BMP581 as separate barometer types - Add BARO_BMP580 (12) and BARO_BMP581 (13) to baroSensor_e enum - Add BMP580, BMP581 entries to lookupTableBaroHardware - Modify bmp5xxDetect() to return detected chip ID via parameter - Barometer detection now reports specific model (BMP580/BMP581) - Bump PG version to 5 for enum changes (BARO_VIRTUAL now 14) This allows users to see the exact sensor model in status/setup tabs. Auto-detection with BMP5XX still works and resolves to specific type. Requested-by: haslinghuis * BMP5xx: Address haslinghuis review comments - Remove BMP5XX from settings.c lookup table (keep BMP580/BMP581) - Use specific USE_BARO_BMP580/BMP581 defines instead of BMP5XX - Change unknown chip fallback to BARO_NONE instead of BARO_BMP5XX - Keep PG version at 4 (BMP580=13, BMP581=14 as new high values) - Keep BARO_BMP5XX=11 in enum for backward compat (deprecated) * BMP5xx: Remove BARO_BMP5XX enum, keep VIRTUAL last - Remove deprecated BARO_BMP5XX from enum (use BMP580/BMP581 directly) - BMP580=11, BMP581=12, VIRTUAL=13 (VIRTUAL always last per haslinghuis) - Update all USE_BARO_BMP5XX references to USE_BARO_BMP580/BMP581 - Keep PG version 4 (old VIRTUAL=11 configs reset to auto-detect) * Temporarily use official config submodule for CI Config PR pending: https://github.com/betaflight/config (MADFLIGHT_FC3 sensors) * BMP5xx: Keep PG version 3 (no version bump needed)
Adds BMP581 (also BMP580) support for the CORVON 743V2 board. Source: a433da0 'Feature/bmp580 barometer (betaflight#14925)' (gintaris) on master. Manually adapted to apply on tag 2025.12.2 — the upstream patch's barometer.h / settings.c context lines depend on a later BARO_HARDWARE_COUNT enum addition and a settings.c reorganisation that aren't in this maintenance line, so the patch was reduced to the BMP5xx-specific changes and applied by hand. Deviation from upstream PR betaflight#14925: Bosch BMP581 silicon ships with chip ID 0x50 (primary rev) or 0x51 (secondary rev) — both are the same BMP581 product (PX4's bmp581.h documents this as BMP581_CHIP_ID_PRIM and _SEC, both treated as BMP581). The upstream case block split 0x50 into BARO_BMP580 and 0x51 into BARO_BMP581 as if they were distinct products, which misidentifies common BMP581 silicon as BMP580. Aligned with PX4: both detected IDs report as BARO_BMP581. Files: - src/main/drivers/barometer/barometer_bmp5xx.{c,h}: new driver - src/main/sensors/barometer.h: add BARO_BMP580=11 / BMP581=12, renumber BARO_VIRTUAL=13 - src/main/cli/settings.c: extend lookupTableBaroHardware with BMP580 / BMP581 entries - src/main/sensors/barometer.c: add include, extend pgReset elif chain and the no-baro UNUSED guard, and add a BARO_BMP580 / BARO_BMP581 case that calls bmp5xxDetect and reports both 0x50 and 0x51 chip IDs as BMP581 (per PX4) - mk/source.mk: include barometer_bmp5xx.c in COMMON_SRC Original SPI_BMP388 fix from the upstream PR is intentionally dropped — out of scope for this backport.



BMP580/BMP581 Barometer Driver for Betaflight
Overview
This PR adds support for the Bosch BMP580/BMP581 next-generation barometer sensor to Betaflight.
Features
Hardware Specifications
Files Modified
src/main/drivers/barometer/barometer_bmp580.csrc/main/drivers/barometer/barometer_bmp580.hsrc/main/sensors/barometer.csrc/main/sensors/barometer.hmk/source.mkOversampling Configuration
Default configuration uses 128X pressure / 4X temperature oversampling:
Testing
Test Hardware:
Test Results:
Platform Compatibility
Note: Only RP2350B (MADFLIGHT_FC3) was tested on actual hardware. STM32 platforms should work but require community testing.
Commit Message
PR Checklist
Summary by CodeRabbit
New Features
Chores