Skip to content

fw/drivers: add BMP390 barometer driver and pressure/altitude API#1068

Open
mkoperator wants to merge 3 commits intocoredevices:mainfrom
mkoperator:feature/barometer-altimeter
Open

fw/drivers: add BMP390 barometer driver and pressure/altitude API#1068
mkoperator wants to merge 3 commits intocoredevices:mainfrom
mkoperator:feature/barometer-altimeter

Conversation

@mkoperator
Copy link
Copy Markdown

Adds support for the BMP390 barometric pressure sensor and exposes pressure/altitude data to watchapps through a new applib service.

  • BMP390 driver: I2C init, forced-mode reads, calibration parsing, compensation math per Bosch datasheet
  • Pressure service applib: subscribe/unsubscribe, caching, ISA standard atmosphere altitude calculation
  • I2C burst read support for nRF5 platform
  • Console command for live pressure/altitude readout
  • Exported symbols added for native SDK integration

Mikhail Kozorovitskiy and others added 2 commits April 2, 2026 11:43
Implement full BMP390 barometer driver with I2C communication, calibration
data parsing, and configurable oversampling/filtering. Add pressure service
applib layer exposing barometric pressure (Pa) and altitude (cm) to
watchapps via the native SDK.

Includes:
- BMP390 driver: init, forced-mode reads, compensation math per datasheet
- Pressure service: subscribe/unsubscribe, caching, ISA altitude calc
- I2C burst read support for nRF5 platform
- Console command for live pressure/altitude readout
- Exported symbols for native SDK integration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pressure service functions are exported via the SDK jump table but ran
in unprivileged app context, crashing when stored apps tried to access
hardware drivers. Wrap all exported functions with DEFINE_SYSCALL and
add a sys_pressure_read_and_compute syscall for the timer callback path.

Also register the altimeter stored app in the system app registry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

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

split changes into small chunks that can be reviewed easily, and follow commit guidelines.

Comment on lines +66 to +70
// Buffer for combining register address + write data into a single TX transfer.
// TXTX (two-part TX) on nRF52840 can fail to transmit the secondary buffer
// correctly due to TWIM peripheral errata. Using a single TX avoids this.
#define I2C_WRITE_BUF_MAX 32
static uint8_t s_write_buf[I2C_WRITE_BUF_MAX];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

red flag: static buffer shared for all instances, "peripheral errata", please, explain which one, and why doesn't nrfx cover it?

@mkoperator
Copy link
Copy Markdown
Author

split changes into small chunks that can be reviewed easily, and follow commit guidelines.

I appreciate your warm welcome. Do you have anything more specific about how you would like these split? and as far as commit guidelines, only one I see is the signed off by on commits. Am I missing anything else?

- Protect BMP390 reads/writes with a mutex for thread safety
- Move nRF5 I2C write buffer from static global to per-bus state
  (errata coredevices#219 workaround now safe for multi-bus configs)
- Add PressureFilterMode enum and pressure_set_filter_mode() driver API
- Decouple IIR filter config from ODR presets — filter mode is now
  independently controllable
- Add pressure_service_set_filter_mode() applib syscall + SDK export
- Add BMP390 unit tests with fake I2C layer
- Add standalone altimeter app skeleton

Signed-off-by: Mikhail Kozorovitskiy <misha@mkoperator.com>
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.

2 participants