modm API documentation
modm::bmp581< Transport > Class Template Reference

#include <modm/driver/pressure/bmp581.hpp>

Inheritance diagram for modm::bmp581< Transport >:

Classes

struct  Data
 Measurement data container More...
 

Public Typedefs

typedef Configuration< OsrConfig_t, Osr,(Bit2|Bit1|Bit0), 0 > TemperatureOsr
 Configuration types for OSR settings.
 
typedef Configuration< OsrConfig_t, Osr,(Bit2|Bit1|Bit0), 3 > PressureOsr
 
typedef Configuration< OdrConfig_t, PowerMode,(Bit1|Bit0), 0 > PowerMode_t
 Configuration types for ODR settings.
 
typedef Configuration< OdrConfig_t, Odr,(Bit6|Bit5|Bit4|Bit3|Bit2), 2 > Odr_t
 
typedef Configuration< DspIir_t, IirFilter,(Bit2|Bit1|Bit0), 0 > TemperatureIir
 Configuration types for IIR filter settings.
 
typedef Configuration< DspIir_t, IirFilter,(Bit2|Bit1|Bit0), 3 > PressureIir
 

Public Types

enum  Register : uint8_t {
  ChipId = 0x01, RevId = 0x02, ChipStatus = 0x11, DriveConfig = 0x13,
  IntConfig = 0x14, IntSource = 0x15, FifoConfig = 0x16, FifoCount = 0x17,
  FifoSel = 0x18, TempDataXlsb = 0x1D, TempDataLsb = 0x1E, TempDataMsb = 0x1F,
  PressDataXlsb = 0x20, PressDataLsb = 0x21, PressDataMsb = 0x22, IntStatus = 0x27,
  Status = 0x28, FifoData = 0x29, NvmAddr = 0x2B, NvmDataLsb = 0x2C,
  NvmDataMsb = 0x2D, DspConfig = 0x30, DspIir = 0x31, OorThrPLsb = 0x32,
  OorThrPMsb = 0x33, OorRange = 0x34, OorConfig = 0x35, OsrConfig = 0x36,
  OdrConfig = 0x37, OsrEff = 0x38, Cmd = 0x7E
}
 Register addresses.
 
enum  PowerMode : uint8_t { Standby = 0b00, Normal = 0b01, Forced = 0b10, Continuous = 0b11 }
 Power modes.
 
enum  Odr : uint8_t {
  Hz240 = 0x00, Hz218 = 0x01, Hz199 = 0x02, Hz179 = 0x03,
  Hz160 = 0x04, Hz149 = 0x05, Hz140 = 0x06, Hz129 = 0x07,
  Hz120 = 0x08, Hz110 = 0x09, Hz100 = 0x0A, Hz89 = 0x0B,
  Hz80 = 0x0C, Hz70 = 0x0D, Hz60 = 0x0E, Hz50 = 0x0F,
  Hz45 = 0x10, Hz40 = 0x11, Hz35 = 0x12, Hz30 = 0x13,
  Hz25 = 0x14, Hz20 = 0x15, Hz15 = 0x16, Hz10 = 0x17,
  Hz5 = 0x18, Hz4 = 0x19, Hz3 = 0x1A, Hz2 = 0x1B,
  Hz1 = 0x1C, Hz0_5 = 0x1D, Hz0_25 = 0x1E, Hz0_125 = 0x1F
}
 Output data rate configuration.
 
enum  Osr : uint8_t {
  X1 = 0b000, X2 = 0b001, X4 = 0b010, X8 = 0b011,
  X16 = 0b100, X32 = 0b101, X64 = 0b110, X128 = 0b111
}
 Oversampling rate configuration.
 
enum  IirFilter : uint8_t {
  Bypass = 0b000, Coef1 = 0b001, Coef3 = 0b010, Coef7 = 0b011,
  Coef15 = 0b100, Coef31 = 0b101, Coef63 = 0b110, Coef127 = 0b111
}
 IIR filter coefficient.
 
enum  Status : uint8_t {
  CoreReady = Bit0, NvmReady = Bit1, NvmError = Bit2, NvmCmdError = Bit3,
  BootErrCorrected = Bit4, CrackPass = Bit7
}
 Status register (0x28) bit definitions.
 
enum  IntStatus : uint8_t {
  DataReady = Bit0, FifoFull = Bit1, FifoThreshold = Bit2, OorPressure = Bit3,
  PowerOnReset = Bit4
}
 Interrupt status register (0x27) bit definitions.
 
enum  IntSource : uint8_t { DataReadyEnable = Bit0, FifoFullEnable = Bit1, FifoThresholdEnable = Bit2, OorPressureEnable = Bit3 }
 Interrupt source enable register (0x15) bit definitions.
 
enum  IntConfig : uint8_t { Mode = Bit0, Polarity = Bit1, OpenDrain = Bit2, Enable = Bit3 }
 Interrupt configuration register (0x14) bit definitions.
 
enum  OsrConfig : uint8_t {
  OsrT0 = Bit0, OsrT1 = Bit1, OsrT2 = Bit2, OsrP0 = Bit3,
  OsrP1 = Bit4, OsrP2 = Bit5, PressEn = Bit6
}
 OSR configuration register (0x36) bit definitions.
 
enum  OdrConfig : uint8_t {
  Mode0 = Bit0, Mode1 = Bit1, Odr0 = Bit2, Odr1 = Bit3,
  Odr2 = Bit4, Odr3 = Bit5, Odr4 = Bit6, DeepDis = Bit7
}
 ODR configuration register (0x37) bit definitions.
 
enum  DspConfig : uint8_t {
  CompPtEn = Bit0, CompPtSel = Bit1, IirFlushForced = Bit2, ShdwSelIir_T = Bit3,
  FifoSelIir_T = Bit4, ShdwSelIir_P = Bit5, FifoSelIir_P = Bit6, OorSelIir_P = Bit7
}
 DSP configuration register (0x30) bit definitions.
 
enum  DspIir : uint8_t {
  SetIir_T0 = Bit0, SetIir_T1 = Bit1, SetIir_T2 = Bit2, SetIir_P0 = Bit3,
  SetIir_P1 = Bit4, SetIir_P2 = Bit5
}
 DSP IIR register (0x31) bit definitions.
 
enum  FifoConfig : uint8_t {
  Mode = Bit0, Threshold0 = Bit1, Threshold1 = Bit2, Threshold2 = Bit3,
  Threshold3 = Bit4, Threshold4 = Bit5
}
 FIFO configuration register (0x16) bit definitions.
 
enum  FifoFrameSelect : uint8_t { Disabled = 0b00, TemperatureOnly = 0b01, PressureOnly = 0b10, PressureAndTemperature = 0b11 }
 FIFO frame selection (what data to store in FIFO)
 
enum  FifoDecimation : uint8_t {
  None = 0b000, By2 = 0b001, By4 = 0b010, By8 = 0b011,
  By16 = 0b100, By32 = 0b101, By64 = 0b110, By128 = 0b111
}
 FIFO decimation factor.
 

Public Member Functions

 MODM_FLAGS8 (Status)
 
 MODM_FLAGS8 (IntStatus)
 
 MODM_FLAGS8 (IntSource)
 
 MODM_FLAGS8 (IntConfig)
 
 MODM_FLAGS8 (OsrConfig)
 
 MODM_FLAGS8 (OdrConfig)
 
 MODM_FLAGS8 (DspConfig)
 
 MODM_FLAGS8 (DspIir)
 
 MODM_FLAGS8 (FifoConfig)
 
template<typename... Args>
 Bmp581 (Args...transportArgs)
 
bool initialize ()
 
bool reset ()
 
std::optional< uint8_t > readChipId ()
 
std::optional< Status_t > readStatus ()
 
std::optional< IntStatus_t > readIntStatus ()
 
bool setPowerMode (PowerMode mode)
 
bool setOdr (Odr odr)
 
bool setOversampling (Osr pressOsr, Osr tempOsr, bool enablePressure=true)
 
bool setIirFilter (IirFilter pressIir, IirFilter tempIir)
 
bool setIntConfig (IntConfig_t config)
 
bool setIntSource (IntSource_t sources)
 
bool readData (Data &data)
 
std::optional< float > readTemperature ()
 
std::optional< float > readPressure ()
 
bool isDataReady ()
 
bool setFifoEnabled (bool enable)
 
bool setFifoThreshold (uint8_t threshold)
 
bool setFifoSelect (FifoFrameSelect frameSelect, FifoDecimation decimation=FifoDecimation::None)
 
std::optional< uint8_t > getFifoCount ()
 
bool readFifoFrame (Data &data)
 
uint8_t readFifoFrames (Data *data, uint8_t count)
 
bool flushFifo ()
 

Static Public Attributes

static constexpr uint8_t ChipId = 0x50
 Chip ID value for BMP581.
 
static constexpr uint8_t ResetCommand = 0xB6
 Soft reset command value.
 
static constexpr uint8_t AddressLow = 0x46
 I2C addresses.
 
static constexpr uint8_t AddressHigh = 0x47
 
static constexpr uint8_t FifoMaxFrames = 32
 Maximum FIFO frame count.
 

Detailed Description

template<Bmp581Transport Transport>
class modm::bmp581< Transport >

Bosch BMP581 Barometric Pressure Sensor Driver

The BMP581 is a high-performance barometric pressure sensor with:

  • Absolute pressure range: 30 to 125 kPa
  • Pressure resolution: 1/64 Pa
  • Temperature resolution: 1/65536 C
  • Low power consumption
  • FIFO buffer (32 frames)
  • Interrupt support

Unlike older BMP sensors like the BMP085, the BMP581 outputs calibrated data directly, which means no calibration coefficient compensation needs to be done in software.

Template Parameters
TransportTransport layer (use Bmp581I2cTransport or Bmp581SpiTransport)

Member Function Documentation

template<Bmp581Transport Transport>
template<typename... Args>
modm::bmp581< Transport >::Bmp581 ( Args...  transportArgs)
  • transportArgs Arguments to transport layer. Pass address for I2C, none for SPI.
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::flushFifo ( )

Flush FIFO (clear all data)

Returns
true on success, false on error
template<Bmp581Transport Transport>
std::optional<uint8_t> modm::bmp581< Transport >::getFifoCount ( )

Get current FIFO frame count

Returns
Number of frames in FIFO, or std::nullopt on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::initialize ( )

Initialize device. Call before any other member function.

Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::isDataReady ( )

Check if data is ready

Returns
true if data ready, false otherwise
template<Bmp581Transport Transport>
std::optional<uint8_t> modm::bmp581< Transport >::readChipId ( )

Read chip ID register

Returns
chip ID value, or std::nullopt on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::readData ( Data data)

Read temperature and pressure data

Parameters
dataReference to Data struct to fill
Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::readFifoFrame ( Data data)

Read single frame from FIFO

Parameters
dataReference to Data struct to fill
Returns
true on success, false on error
template<Bmp581Transport Transport>
uint8_t modm::bmp581< Transport >::readFifoFrames ( Data data,
uint8_t  count 
)

Read multiple frames from FIFO

Parameters
dataPointer to array of Data structs
countNumber of frames to read
Returns
Number of frames actually read, or 0 on error
template<Bmp581Transport Transport>
std::optional<IntStatus_t> modm::bmp581< Transport >::readIntStatus ( )

Read interrupt status register (clears latched interrupts)

Returns
interrupt status flags, or std::nullopt on error
template<Bmp581Transport Transport>
std::optional<float> modm::bmp581< Transport >::readPressure ( )

Read pressure only

Returns
Pressure in Pascals, or std::nullopt on error
template<Bmp581Transport Transport>
std::optional<Status_t> modm::bmp581< Transport >::readStatus ( )

Read status register

Returns
status flags, or std::nullopt on error
template<Bmp581Transport Transport>
std::optional<float> modm::bmp581< Transport >::readTemperature ( )

Read temperature only

Returns
Temperature in Celsius, or std::nullopt on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::reset ( )

Perform soft reset and wait for device ready

Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::setFifoEnabled ( bool  enable)

Enable or disable FIFO streaming mode

Parameters
enabletrue to enable FIFO, false for bypass mode
Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::setFifoSelect ( FifoFrameSelect  frameSelect,
FifoDecimation  decimation = FifoDecimation::None 
)

Configure FIFO frame selection and decimation

Parameters
frameSelectWhat data to store in FIFO
decimationDecimation factor (store every Nth sample)
Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::setFifoThreshold ( uint8_t  threshold)

Configure FIFO threshold for interrupt generation

Parameters
thresholdNumber of frames (0-31) to trigger threshold interrupt
Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::setIirFilter ( IirFilter  pressIir,
IirFilter  tempIir 
)

Configure IIR filter coefficients

Parameters
pressIirPressure IIR filter coefficient
tempIirTemperature IIR filter coefficient
Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::setIntConfig ( IntConfig_t  config)

Configure interrupt output

Parameters
configInterrupt configuration flags
Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::setIntSource ( IntSource_t  sources)

Configure interrupt sources

Parameters
sourcesInterrupt source enable flags
Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::setOdr ( Odr  odr)

Configure output data rate

Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::setOversampling ( Osr  pressOsr,
Osr  tempOsr,
bool  enablePressure = true 
)

Configure oversampling for pressure and temperature

Parameters
pressOsrPressure oversampling rate
tempOsrTemperature oversampling rate
enablePressureEnable pressure measurement (default true)
Returns
true on success, false on error
template<Bmp581Transport Transport>
bool modm::bmp581< Transport >::setPowerMode ( PowerMode  mode)

Configure power mode

Returns
true on success, false on error

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