BMP581 Driver 1.0.0
API reference
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
bmp581::Driver< BusT > Class Template Reference

BMP581 client. More...

#include <bmp581_driver.hpp>

Public Member Functions

 Driver (BusT &bus) noexcept
 
uint8_t ChipId () const noexcept
 Chip id read by the last successful Init() (0 before).
 
bool Initialized () const noexcept
 
DriverResult< void > Init () noexcept
 Verify chip id (0x50 / 0x51) and NVM readiness.
 
DriverResult< void > SoftReset () noexcept
 Soft reset: CMD = 0xB6, wait t_soft_res (2 ms), reselect SPI, verify.
 
DriverResult< void > Configure (const Config &cfg) noexcept
 Standby → OSR/ODR → IIR → power mode, in the order the device requires.
 
DriverResult< PowerMode > GetPowerMode () noexcept
 
DriverResult< void > SetPowerMode (PowerMode mode) noexcept
 Set power mode. Always hops through standby (t_standby 2.5 ms) as the data sheet requires before entering Normal/Forced/Continuous.
 
DriverResult< OsrOdrConfig > GetOsrOdr () noexcept
 
DriverResult< void > SetOsrOdr (const OsrOdrConfig &c) noexcept
 Write OSR_CONFIG / ODR_CONFIG preserving power-mode bits. ODR faster than 5 Hz is only valid with deep standby disabled; the driver forces the device to plain standby first in that case (Bosch API behaviour).
 
DriverResult< EffectiveOsr > GetEffectiveOsr () noexcept
 
DriverResult< IirConfig > GetIir () noexcept
 
DriverResult< void > SetIir (const IirConfig &c) noexcept
 IIR registers are writable in standby only; previous mode is restored.
 
DriverResult< void > ConfigureInterrupt (const InterruptConfig &c) noexcept
 Disable sources, clear status, then write mode/polarity/drive/enable.
 
DriverResult< void > SelectInterruptSources (const InterruptSources &s) noexcept
 
DriverResult< uint8_t > ReadInterruptStatus () noexcept
 INT_STATUS (read clears in pulsed mode).
 
DriverResult< bool > DataReady () noexcept
 Convenience: INT_STATUS.drdy_data_reg.
 
DriverResult< Sample > ReadSample (bool pressure_enabled=true) noexcept
 Burst-read 0x1D..0x22 → temperature (1/65536 °C) and pressure (1/64 Pa).
 
DriverResult< uint16_t > ReadNvm (uint8_t nvm_addr) noexcept
 Read one 16-bit NVM user word (0x20..0x22). Requires standby; previous mode is restored.
 
DriverResult< uint8_t > ReadRegister (uint8_t r) noexcept
 
DriverResult< void > WriteRegister (uint8_t r, uint8_t v) noexcept
 

Static Public Member Functions

static Sample DecodeSample (const uint8_t d[6], bool pressure_enabled) noexcept
 Decode a 6-byte data-register burst (also used by tests).
 

Detailed Description

template<typename BusT>
class bmp581::Driver< BusT >

BMP581 client.

Template Parameters
BusTConcrete type inheriting BusInterface<BusT>.

Constructor & Destructor Documentation

◆ Driver()

template<typename BusT >
bmp581::Driver< BusT >::Driver ( BusT &  bus)
inlineexplicitnoexcept

Member Function Documentation

◆ ChipId()

template<typename BusT >
uint8_t bmp581::Driver< BusT >::ChipId ( ) const
inlinenoexcept

Chip id read by the last successful Init() (0 before).

◆ Configure()

template<typename BusT >
DriverResult< void > bmp581::Driver< BusT >::Configure ( const Config &  cfg)
inlinenoexcept

Standby → OSR/ODR → IIR → power mode, in the order the device requires.

◆ ConfigureInterrupt()

template<typename BusT >
DriverResult< void > bmp581::Driver< BusT >::ConfigureInterrupt ( const InterruptConfig &  c)
inlinenoexcept

Disable sources, clear status, then write mode/polarity/drive/enable.

◆ DataReady()

template<typename BusT >
DriverResult< bool > bmp581::Driver< BusT >::DataReady ( )
inlinenoexcept

Convenience: INT_STATUS.drdy_data_reg.

◆ DecodeSample()

template<typename BusT >
static Sample bmp581::Driver< BusT >::DecodeSample ( const uint8_t  d[6],
bool  pressure_enabled 
)
inlinestaticnoexcept

Decode a 6-byte data-register burst (also used by tests).

◆ GetEffectiveOsr()

template<typename BusT >
DriverResult< EffectiveOsr > bmp581::Driver< BusT >::GetEffectiveOsr ( )
inlinenoexcept

◆ GetIir()

template<typename BusT >
DriverResult< IirConfig > bmp581::Driver< BusT >::GetIir ( )
inlinenoexcept

◆ GetOsrOdr()

template<typename BusT >
DriverResult< OsrOdrConfig > bmp581::Driver< BusT >::GetOsrOdr ( )
inlinenoexcept

◆ GetPowerMode()

template<typename BusT >
DriverResult< PowerMode > bmp581::Driver< BusT >::GetPowerMode ( )
inlinenoexcept

◆ Init()

template<typename BusT >
DriverResult< void > bmp581::Driver< BusT >::Init ( )
inlinenoexcept

Verify chip id (0x50 / 0x51) and NVM readiness.

On SPI (and for an adapter that does not declare kInterface) the first access is the dummy read that switches the chip from I2C to SPI (datasheet section 5.1); its data is discarded.

◆ Initialized()

template<typename BusT >
bool bmp581::Driver< BusT >::Initialized ( ) const
inlinenoexcept

◆ ReadInterruptStatus()

template<typename BusT >
DriverResult< uint8_t > bmp581::Driver< BusT >::ReadInterruptStatus ( )
inlinenoexcept

INT_STATUS (read clears in pulsed mode).

◆ ReadNvm()

template<typename BusT >
DriverResult< uint16_t > bmp581::Driver< BusT >::ReadNvm ( uint8_t  nvm_addr)
inlinenoexcept

Read one 16-bit NVM user word (0x20..0x22). Requires standby; previous mode is restored.

◆ ReadRegister()

template<typename BusT >
DriverResult< uint8_t > bmp581::Driver< BusT >::ReadRegister ( uint8_t  r)
inlinenoexcept

◆ ReadSample()

template<typename BusT >
DriverResult< Sample > bmp581::Driver< BusT >::ReadSample ( bool  pressure_enabled = true)
inlinenoexcept

Burst-read 0x1D..0x22 → temperature (1/65536 °C) and pressure (1/64 Pa).

◆ SelectInterruptSources()

template<typename BusT >
DriverResult< void > bmp581::Driver< BusT >::SelectInterruptSources ( const InterruptSources &  s)
inlinenoexcept

◆ SetIir()

template<typename BusT >
DriverResult< void > bmp581::Driver< BusT >::SetIir ( const IirConfig &  c)
inlinenoexcept

IIR registers are writable in standby only; previous mode is restored.

◆ SetOsrOdr()

template<typename BusT >
DriverResult< void > bmp581::Driver< BusT >::SetOsrOdr ( const OsrOdrConfig &  c)
inlinenoexcept

Write OSR_CONFIG / ODR_CONFIG preserving power-mode bits. ODR faster than 5 Hz is only valid with deep standby disabled; the driver forces the device to plain standby first in that case (Bosch API behaviour).

◆ SetPowerMode()

template<typename BusT >
DriverResult< void > bmp581::Driver< BusT >::SetPowerMode ( PowerMode  mode)
inlinenoexcept

Set power mode. Always hops through standby (t_standby 2.5 ms) as the data sheet requires before entering Normal/Forced/Continuous.

◆ SoftReset()

template<typename BusT >
DriverResult< void > bmp581::Driver< BusT >::SoftReset ( )
inlinenoexcept

Soft reset: CMD = 0xB6, wait t_soft_res (2 ms), reselect SPI, verify.

  • Over I2C the chip does not acknowledge the reset command (datasheet section 7.36), so a failed status from that one write is expected and not an error. With kInterface == Interface::Spi it is reported as Bus.
  • The reset returns the interface to I2C (section 5.1, Table 16); on SPI (or an undeclared interface) one dummy read selects SPI again.
  • The reset is then verified as section 4.3.9 recommends: CHIP_ID not 0 (InvalidChipId), STATUS nvm_rdy = 1 and nvm_err = 0 (NvmNotReady, NvmCommandError), INT_STATUS por = 1 (PorSoftReset). Every read after the reset command reports its own bus error as Bus.

◆ WriteRegister()

template<typename BusT >
DriverResult< void > bmp581::Driver< BusT >::WriteRegister ( uint8_t  r,
uint8_t  v 
)
inlinenoexcept

The documentation for this class was generated from the following file: