BMP581 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
bmp581_types.hpp File Reference

Public types of the BMP581 driver: errors, Result<T>, configuration, measurements and the datasheet's timing and range constants. More...

#include <array>
#include <cstdint>
#include "bmp581_detail.hpp"
#include "bmp581_version.h"

Go to the source code of this file.

Classes

struct  bmp581::Result< T >
 The value of a call, or why there is none. More...
 
struct  bmp581::Result< void >
 The result of a call that returns no value. More...
 
struct  bmp581::InterruptStatus
 The interrupt status flags, INT_STATUS (section 7.21), decoded. Reading INT_STATUS clears them on the chip (the FIFO flags stay while their condition holds, section 4.7.3.2). More...
 
struct  bmp581::Measurement
 One measurement in the chip's own units, as the data registers hold it (section 4.5). More...
 
struct  bmp581::FifoSample
 One FIFO frame, with its own validity: a multi-item read reports each item. More...
 
struct  bmp581::Config
 Everything EnsureInitialized() and ApplyConfig() write to the chip. More...
 
class  bmp581::CheckedConfig
 A configuration proven valid at build time. More...
 

Namespaces

namespace  bmp581
 The BMP581 driver: everything it declares lives here; internals in detail.
 

Enumerations

enum class  bmp581::Error : uint8_t {
  bmp581::Error::Ok = 0 , bmp581::Error::NotInitialized = 1 , bmp581::Error::InvalidArgument = 2 , bmp581::Error::Bus = 3 ,
  bmp581::Error::Timeout = 4 , bmp581::Error::DeviceIdMismatch = 5 , bmp581::Error::Crc = 6 , bmp581::Error::Busy = 7 ,
  bmp581::Error::DeviceFault = 8 , bmp581::Error::Unsupported = 9 , bmp581::Error::DeviceReset = 16 , bmp581::Error::InvalidReply = 17 ,
  bmp581::Error::NoDevice = 18 , bmp581::Error::NoData = 19 , bmp581::Error::OutOfRange = 20 , bmp581::Error::WriteMismatch = 21 ,
  bmp581::Error::StateUnknown = 22 , bmp581::Error::ConfigRejected = 23
}
 Why a call failed. Every call of the driver returns one of these in its Result. More...
 
enum class  bmp581::LogLevel : uint8_t { bmp581::LogLevel::Error = 0 , bmp581::LogLevel::Warning , bmp581::LogLevel::Info , bmp581::LogLevel::Debug }
 Severity passed to the optional Log() hook. More...
 
enum class  bmp581::Verify : uint8_t { bmp581::Verify::None = 0 , bmp581::Verify::ReadBack = 1 }
 Extra traffic a call may spend to check what it did (handbook KB-ARCH-041). More...
 
enum class  bmp581::PowerMode : uint8_t { bmp581::PowerMode::Standby = 0 , bmp581::PowerMode::Normal = 1 , bmp581::PowerMode::Forced = 2 , bmp581::PowerMode::Continuous = 3 }
 The power mode, ODR_CONFIG.pwr_mode (sections 4.3, 7.34). More...
 
enum class  bmp581::Oversampling : uint8_t {
  bmp581::Oversampling::X1 = 0 , bmp581::Oversampling::X2 , bmp581::Oversampling::X4 , bmp581::Oversampling::X8 ,
  bmp581::Oversampling::X16 , bmp581::Oversampling::X32 , bmp581::Oversampling::X64 , bmp581::Oversampling::X128
}
 Oversampling ratio, OSR_CONFIG.osr_p and osr_t (section 7.33). More...
 
enum class  bmp581::OutputDataRate : uint8_t {
  bmp581::OutputDataRate::Hz240 = 0x00 , bmp581::OutputDataRate::Hz218p5 = 0x01 , bmp581::OutputDataRate::Hz199p1 = 0x02 , bmp581::OutputDataRate::Hz179p2 = 0x03 ,
  bmp581::OutputDataRate::Hz160 = 0x04 , bmp581::OutputDataRate::Hz149p3 = 0x05 , bmp581::OutputDataRate::Hz140 = 0x06 , bmp581::OutputDataRate::Hz129p9 = 0x07 ,
  bmp581::OutputDataRate::Hz120 = 0x08 , bmp581::OutputDataRate::Hz110p2 = 0x09 , bmp581::OutputDataRate::Hz100p3 = 0x0A , bmp581::OutputDataRate::Hz89p6 = 0x0B ,
  bmp581::OutputDataRate::Hz80 = 0x0C , bmp581::OutputDataRate::Hz70 = 0x0D , bmp581::OutputDataRate::Hz60 = 0x0E , bmp581::OutputDataRate::Hz50p1 = 0x0F ,
  bmp581::OutputDataRate::Hz45 = 0x10 , bmp581::OutputDataRate::Hz40 = 0x11 , bmp581::OutputDataRate::Hz35 = 0x12 , bmp581::OutputDataRate::Hz30 = 0x13 ,
  bmp581::OutputDataRate::Hz25 = 0x14 , bmp581::OutputDataRate::Hz20 = 0x15 , bmp581::OutputDataRate::Hz15 = 0x16 , bmp581::OutputDataRate::Hz10 = 0x17 ,
  bmp581::OutputDataRate::Hz5 = 0x18 , bmp581::OutputDataRate::Hz4 = 0x19 , bmp581::OutputDataRate::Hz3 = 0x1A , bmp581::OutputDataRate::Hz2 = 0x1B ,
  bmp581::OutputDataRate::Hz1 = 0x1C , bmp581::OutputDataRate::Hz0p5 = 0x1D , bmp581::OutputDataRate::Hz0p25 = 0x1E , bmp581::OutputDataRate::Hz0p125 = 0x1F
}
 Output data rate in normal mode, ODR_CONFIG.odr (section 7.34). More...
 
enum class  bmp581::IirFilter : uint8_t {
  bmp581::IirFilter::Bypass = 0 , bmp581::IirFilter::Coef1 , bmp581::IirFilter::Coef3 , bmp581::IirFilter::Coef7 ,
  bmp581::IirFilter::Coef15 , bmp581::IirFilter::Coef31 , bmp581::IirFilter::Coef63 , bmp581::IirFilter::Coef127
}
 IIR low-pass filter coefficient, DSP_IIR.set_iir_p and set_iir_t (table 10). More...
 
enum class  bmp581::FifoFrame : uint8_t { bmp581::FifoFrame::Disabled = 0 , bmp581::FifoFrame::Temperature = 1 , bmp581::FifoFrame::Pressure = 2 , bmp581::FifoFrame::PressureAndTemperature = 3 }
 What the FIFO stores, FIFO_SEL.fifo_frame_sel (section 4.6.1). More...
 
enum class  bmp581::FifoMode : uint8_t { bmp581::FifoMode::Streaming = 0 , bmp581::FifoMode::StopOnFull = 1 }
 What a full FIFO does with a new frame, FIFO_CONFIG.fifo_mode (section 4.6.1). More...
 
enum class  bmp581::IntMode : uint8_t { bmp581::IntMode::Pulsed = 0 , bmp581::IntMode::Latched = 1 }
 INT pin timing, INT_CONFIG.int_mode (section 4.7.3.2). More...
 
enum class  bmp581::IntPolarity : uint8_t { bmp581::IntPolarity::ActiveLow = 0 , bmp581::IntPolarity::ActiveHigh = 1 }
 INT pin polarity, INT_CONFIG.int_pol (section 7.5). More...
 
enum class  bmp581::IntDrive : uint8_t { bmp581::IntDrive::PushPull = 0 , bmp581::IntDrive::OpenDrain = 1 }
 INT pin output stage, INT_CONFIG.int_od (section 7.5). More...
 
enum class  bmp581::OorCount : uint8_t { bmp581::OorCount::Samples1 = 0 , bmp581::OorCount::Samples3 , bmp581::OorCount::Samples7 , bmp581::OorCount::Samples15 }
 Consecutive out-of-range samples before the interrupt, OOR_CONFIG.cnt_lim (7.32). More...
 

Functions

constexpr const char * bmp581::ToString (Error error) noexcept
 The name of an error, for logs.
 
constexpr uint32_t bmp581::OdrMilliHz (OutputDataRate odr) noexcept
 An output data rate in millihertz (section 7.34).
 
constexpr uint32_t bmp581::MaxOdrMilliHz (Oversampling pressure, Oversampling temperature) noexcept
 The fastest data rate normal mode accepts with this oversampling (table 7).
 
constexpr uint32_t bmp581::ConversionTimeMaxUs (Oversampling pressure, Oversampling temperature) noexcept
 The longest pressure-and-temperature conversion, t_conv_p + t_conv_t, with the +5 % of table 4, rounded up.
 
constexpr bool bmp581::EntersDeepStandby (const Config &config) noexcept
 Whether the chip enters deep standby with this configuration (section 4.3.2): deep standby allowed, a data rate below 5 Hz, the FIFO off and both IIR filters bypassed.
 
constexpr uint32_t bmp581::ForcedMeasurementMaxUs (const Config &config) noexcept
 The longest forced measurement: the start-up from (deep) standby, then the conversion (table 4).
 
constexpr int32_t bmp581::SignExtend24 (uint32_t raw) noexcept
 A 24-bit two's complement register value as a signed integer, the one place the driver reinterprets wire bits as signed (KB-CPP20-024).
 
constexpr float bmp581::PressurePa (int32_t raw) noexcept
 A pressure in pascals: raw / 2^6, exact (section 4.5).
 
constexpr float bmp581::TemperatureC (int32_t raw) noexcept
 A temperature in degrees Celsius: raw / 2^16, exact (section 4.5).
 
constexpr bool bmp581::PressureInRange (int32_t raw) noexcept
 Whether a raw pressure lies in the measurement range, 30 to 125 kPa (table 1).
 
constexpr bool bmp581::TemperatureInRange (int32_t raw) noexcept
 Whether a raw temperature lies in the measurement range, -40 to 85 °C (table 2).
 
constexpr Error bmp581::Validate (const Config &config) noexcept
 Check a configuration without touching the chip.
 
constexpr Config bmp581::ForcedPreset () noexcept
 Measurements on request: standby between MeasureOnce() calls, deep standby, the standard-resolution oversampling of table 9 (pressure x4, temperature x1).
 
constexpr Config bmp581::LowPowerPreset () noexcept
 Low power at 1 Hz in normal mode with deep standby between measurements (section 4.3.5).
 
constexpr Config bmp581::HighResolutionPreset () noexcept
 High resolution at 25 Hz: pressure x16 (table 9), the IIR on the data registers, data ready reported.
 
constexpr Config bmp581::FifoPreset () noexcept
 Pressure and temperature frames into the FIFO at 10 Hz, threshold at 8 frames.
 
void bmp581::ConfigIsInvalid () noexcept
 Reached only when a CheckedConfig is built from an invalid configuration: it is never defined, so the build fails and names it (KB-CPP20-013).
 
constexpr const char * bmp581::GetDriverVersion () noexcept
 
constexpr uint32_t bmp581::GetDriverVersionMajor () noexcept
 
constexpr uint32_t bmp581::GetDriverVersionMinor () noexcept
 
constexpr uint32_t bmp581::GetDriverVersionPatch () noexcept
 

Variables

constexpr uint8_t bmp581::kChipId = 0x50
 CHIP_ID of every BMP581 (section 7.1).
 
constexpr int32_t bmp581::kPressureCountsPerPa = 64
 Pressure LSBs per pascal: the registers hold Pa x 2^6 (section 4.5).
 
constexpr int32_t bmp581::kTemperatureCountsPerDegreeC = 65536
 Temperature LSBs per degree Celsius: the registers hold °C x 2^16 (section 4.5).
 
constexpr int32_t bmp581::kPressureMinPa = 30'000
 Lowest pressure the chip measures, in pascals (table 1).
 
constexpr int32_t bmp581::kPressureMaxPa = 125'000
 Highest pressure the chip measures, in pascals (table 1).
 
constexpr int32_t bmp581::kTemperatureMinC = -40
 Lowest temperature the chip measures, in °C (table 2).
 
constexpr int32_t bmp581::kTemperatureMaxC = 85
 Highest temperature the chip measures, in °C (table 2).
 
constexpr uint32_t bmp581::kOorReferenceMaxPa = 0x1'FFFF
 Highest out-of-range reference: 17 bits of pascals (section 4.7.2.3).
 
constexpr uint32_t bmp581::kFifoFramesSingle = 32
 Frames the FIFO holds with 3-byte frames (section 4.6).
 
constexpr uint32_t bmp581::kFifoFramesBoth = 16
 Frames the FIFO holds with 6-byte frames (section 4.6).
 
constexpr uint32_t bmp581::kFifoMaxBytes = 96
 Bytes of a full FIFO, either frame size.
 
constexpr uint32_t bmp581::kPowerUpUs = 2000
 t_powup: power-up to the first communication, maximum (table 4).
 
constexpr uint32_t bmp581::kSoftResetUs = 2000
 t_soft_res: soft reset to ready, maximum (table 4).
 
constexpr uint32_t bmp581::kStandbyUs = 2500
 t_standby: any mode to standby, maximum (table 4).
 
constexpr uint32_t bmp581::kStartupUs = 3000
 t_startup: standby to the start of a measurement, maximum (table 4).
 
constexpr uint32_t bmp581::kStartupDeepUs = 4000
 t_startup_deep: deep standby to the start of a measurement, maximum (table 4).
 
constexpr uint32_t bmp581::kReconfUs = 3000
 
constexpr uint32_t bmp581::kReadBackIdleUs = 1
 Idle time before INT_CONFIG may be read back after a write (sections 5.5.4, 7.5).
 
constexpr uint32_t bmp581::kPollUs = 500
 Time between two polls of the chip.
 
constexpr uint32_t bmp581::kTimeoutMaxMs = 10'000
 

Detailed Description

Public types of the BMP581 driver: errors, Result<T>, configuration, measurements and the datasheet's timing and range constants.

Everything here is plain data with no platform dependency, so handlers, tests and tools can include it without the driver template. The configuration defaults are the chip's reset values (datasheet section 7), so Config{} describes a chip that was just reset, with one exception the driver always applies: pressure is measured (OSR_CONFIG.press_en = 1, see bmp581.hpp).

Section, table and figure numbers refer to the Bosch BMP581 datasheet, document BST-BMP581-DS004-13, revision 1.13.