|
BMP581 Driver 0.1.0
API reference
|
The BMP581 driver: everything it declares lives here; internals in detail.
More...
Namespaces | |
| namespace | i2c |
What the BMP581 needs from the I2C bus (sections 5.6, 6.2.3, table 4). A port and a board configuration check their settings against these with static_assert (handbook KB-CPP-123). | |
| namespace | reg |
| The BMP581 register map. | |
| namespace | spi |
What the BMP581 needs from the SPI bus (sections 5.2.1, 5.5, table 18). A port and a board configuration check their settings against these with static_assert (handbook KB-CPP-123). | |
Classes | |
| class | BMP581 |
| Driver for one BMP581 on a platform port. More... | |
| class | CheckedConfig |
| A configuration proven valid at build time. More... | |
| struct | Config |
Everything EnsureInitialized() and ApplyConfig() write to the chip. More... | |
| struct | FifoSample |
| One FIFO frame, with its own validity: a multi-item read reports each item. More... | |
| class | I2cInterface |
| CRTP base of the platform I2C port. More... | |
| struct | 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 | Measurement |
| One measurement in the chip's own units, as the data registers hold it (section 4.5). More... | |
| struct | Result |
| The value of a call, or why there is none. More... | |
| struct | Result< void > |
| The result of a call that returns no value. More... | |
| class | SpiInterface |
| CRTP base of the platform SPI port. More... | |
Concepts | |
| concept | BusPort |
A port the driver accepts: an I2cPort or an SpiPort, never both, so the bus framing is never ambiguous. | |
| concept | I2cPort |
Satisfied by a class that derives from I2cInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool. | |
| concept | SpiPort |
Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool (KB-CPP20-006). | |
Enumerations | |
| enum class | I2cFailure : uint8_t { Other = 0 , AddressNack = 1 , DataNack = 2 } |
Why an I2C transfer failed, as the optional GetLastFailure() hook reports it. More... | |
| enum class | Error : uint8_t { Error::Ok = 0 , Error::NotInitialized = 1 , Error::InvalidArgument = 2 , Error::Bus = 3 , Error::Timeout = 4 , Error::DeviceIdMismatch = 5 , Error::Crc = 6 , Error::Busy = 7 , Error::DeviceFault = 8 , Error::Unsupported = 9 , Error::DeviceReset = 16 , Error::InvalidReply = 17 , Error::NoDevice = 18 , Error::NoData = 19 , Error::OutOfRange = 20 , Error::WriteMismatch = 21 , Error::StateUnknown = 22 , Error::ConfigRejected = 23 } |
Why a call failed. Every call of the driver returns one of these in its Result. More... | |
| enum class | LogLevel : uint8_t { LogLevel::Error = 0 , LogLevel::Warning , LogLevel::Info , LogLevel::Debug } |
Severity passed to the optional Log() hook. More... | |
| enum class | Verify : uint8_t { Verify::None = 0 , Verify::ReadBack = 1 } |
| Extra traffic a call may spend to check what it did (handbook KB-ARCH-041). More... | |
| enum class | PowerMode : uint8_t { PowerMode::Standby = 0 , PowerMode::Normal = 1 , PowerMode::Forced = 2 , PowerMode::Continuous = 3 } |
| The power mode, ODR_CONFIG.pwr_mode (sections 4.3, 7.34). More... | |
| enum class | Oversampling : uint8_t { Oversampling::X1 = 0 , Oversampling::X2 , Oversampling::X4 , Oversampling::X8 , Oversampling::X16 , Oversampling::X32 , Oversampling::X64 , Oversampling::X128 } |
| Oversampling ratio, OSR_CONFIG.osr_p and osr_t (section 7.33). More... | |
| enum class | OutputDataRate : uint8_t { OutputDataRate::Hz240 = 0x00 , OutputDataRate::Hz218p5 = 0x01 , OutputDataRate::Hz199p1 = 0x02 , OutputDataRate::Hz179p2 = 0x03 , OutputDataRate::Hz160 = 0x04 , OutputDataRate::Hz149p3 = 0x05 , OutputDataRate::Hz140 = 0x06 , OutputDataRate::Hz129p9 = 0x07 , OutputDataRate::Hz120 = 0x08 , OutputDataRate::Hz110p2 = 0x09 , OutputDataRate::Hz100p3 = 0x0A , OutputDataRate::Hz89p6 = 0x0B , OutputDataRate::Hz80 = 0x0C , OutputDataRate::Hz70 = 0x0D , OutputDataRate::Hz60 = 0x0E , OutputDataRate::Hz50p1 = 0x0F , OutputDataRate::Hz45 = 0x10 , OutputDataRate::Hz40 = 0x11 , OutputDataRate::Hz35 = 0x12 , OutputDataRate::Hz30 = 0x13 , OutputDataRate::Hz25 = 0x14 , OutputDataRate::Hz20 = 0x15 , OutputDataRate::Hz15 = 0x16 , OutputDataRate::Hz10 = 0x17 , OutputDataRate::Hz5 = 0x18 , OutputDataRate::Hz4 = 0x19 , OutputDataRate::Hz3 = 0x1A , OutputDataRate::Hz2 = 0x1B , OutputDataRate::Hz1 = 0x1C , OutputDataRate::Hz0p5 = 0x1D , OutputDataRate::Hz0p25 = 0x1E , OutputDataRate::Hz0p125 = 0x1F } |
| Output data rate in normal mode, ODR_CONFIG.odr (section 7.34). More... | |
| enum class | IirFilter : uint8_t { IirFilter::Bypass = 0 , IirFilter::Coef1 , IirFilter::Coef3 , IirFilter::Coef7 , IirFilter::Coef15 , IirFilter::Coef31 , IirFilter::Coef63 , IirFilter::Coef127 } |
| IIR low-pass filter coefficient, DSP_IIR.set_iir_p and set_iir_t (table 10). More... | |
| enum class | FifoFrame : uint8_t { FifoFrame::Disabled = 0 , FifoFrame::Temperature = 1 , FifoFrame::Pressure = 2 , FifoFrame::PressureAndTemperature = 3 } |
| What the FIFO stores, FIFO_SEL.fifo_frame_sel (section 4.6.1). More... | |
| enum class | FifoMode : uint8_t { FifoMode::Streaming = 0 , FifoMode::StopOnFull = 1 } |
| What a full FIFO does with a new frame, FIFO_CONFIG.fifo_mode (section 4.6.1). More... | |
| enum class | IntMode : uint8_t { IntMode::Pulsed = 0 , IntMode::Latched = 1 } |
| INT pin timing, INT_CONFIG.int_mode (section 4.7.3.2). More... | |
| enum class | IntPolarity : uint8_t { IntPolarity::ActiveLow = 0 , IntPolarity::ActiveHigh = 1 } |
| INT pin polarity, INT_CONFIG.int_pol (section 7.5). More... | |
| enum class | IntDrive : uint8_t { IntDrive::PushPull = 0 , IntDrive::OpenDrain = 1 } |
| INT pin output stage, INT_CONFIG.int_od (section 7.5). More... | |
| enum class | OorCount : uint8_t { OorCount::Samples1 = 0 , OorCount::Samples3 , OorCount::Samples7 , OorCount::Samples15 } |
| Consecutive out-of-range samples before the interrupt, OOR_CONFIG.cnt_lim (7.32). More... | |
Functions | |
| constexpr Oversampling | OversamplingFromSamples (int32_t samples) noexcept |
| The oversampling setting for a number of samples, rounded down to a power of two. | |
| constexpr Config | KconfigDefaults () noexcept |
| The configuration menuconfig selected, on top of the datasheet defaults. | |
| constexpr const char * | ToString (Error error) noexcept |
| The name of an error, for logs. | |
| constexpr uint32_t | OdrMilliHz (OutputDataRate odr) noexcept |
| An output data rate in millihertz (section 7.34). | |
| constexpr uint32_t | MaxOdrMilliHz (Oversampling pressure, Oversampling temperature) noexcept |
| The fastest data rate normal mode accepts with this oversampling (table 7). | |
| constexpr uint32_t | 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 | 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 | ForcedMeasurementMaxUs (const Config &config) noexcept |
| The longest forced measurement: the start-up from (deep) standby, then the conversion (table 4). | |
| constexpr int32_t | 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 | PressurePa (int32_t raw) noexcept |
A pressure in pascals: raw / 2^6, exact (section 4.5). | |
| constexpr float | TemperatureC (int32_t raw) noexcept |
A temperature in degrees Celsius: raw / 2^16, exact (section 4.5). | |
| constexpr bool | PressureInRange (int32_t raw) noexcept |
| Whether a raw pressure lies in the measurement range, 30 to 125 kPa (table 1). | |
| constexpr bool | TemperatureInRange (int32_t raw) noexcept |
| Whether a raw temperature lies in the measurement range, -40 to 85 °C (table 2). | |
| constexpr Error | Validate (const Config &config) noexcept |
| Check a configuration without touching the chip. | |
| constexpr Config | ForcedPreset () noexcept |
Measurements on request: standby between MeasureOnce() calls, deep standby, the standard-resolution oversampling of table 9 (pressure x4, temperature x1). | |
| constexpr Config | LowPowerPreset () noexcept |
| Low power at 1 Hz in normal mode with deep standby between measurements (section 4.3.5). | |
| constexpr Config | HighResolutionPreset () noexcept |
| High resolution at 25 Hz: pressure x16 (table 9), the IIR on the data registers, data ready reported. | |
| constexpr Config | FifoPreset () noexcept |
| Pressure and temperature frames into the FIFO at 10 Hz, threshold at 8 frames. | |
| void | 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 * | GetDriverVersion () noexcept |
| constexpr uint32_t | GetDriverVersionMajor () noexcept |
| constexpr uint32_t | GetDriverVersionMinor () noexcept |
| constexpr uint32_t | GetDriverVersionPatch () noexcept |
Variables | |
| constexpr uint8_t | kChipId = 0x50 |
| CHIP_ID of every BMP581 (section 7.1). | |
| constexpr int32_t | kPressureCountsPerPa = 64 |
| Pressure LSBs per pascal: the registers hold Pa x 2^6 (section 4.5). | |
| constexpr int32_t | kTemperatureCountsPerDegreeC = 65536 |
| Temperature LSBs per degree Celsius: the registers hold °C x 2^16 (section 4.5). | |
| constexpr int32_t | kPressureMinPa = 30'000 |
| Lowest pressure the chip measures, in pascals (table 1). | |
| constexpr int32_t | kPressureMaxPa = 125'000 |
| Highest pressure the chip measures, in pascals (table 1). | |
| constexpr int32_t | kTemperatureMinC = -40 |
| Lowest temperature the chip measures, in °C (table 2). | |
| constexpr int32_t | kTemperatureMaxC = 85 |
| Highest temperature the chip measures, in °C (table 2). | |
| constexpr uint32_t | kOorReferenceMaxPa = 0x1'FFFF |
| Highest out-of-range reference: 17 bits of pascals (section 4.7.2.3). | |
| constexpr uint32_t | kFifoFramesSingle = 32 |
| Frames the FIFO holds with 3-byte frames (section 4.6). | |
| constexpr uint32_t | kFifoFramesBoth = 16 |
| Frames the FIFO holds with 6-byte frames (section 4.6). | |
| constexpr uint32_t | kFifoMaxBytes = 96 |
| Bytes of a full FIFO, either frame size. | |
| constexpr uint32_t | kPowerUpUs = 2000 |
| t_powup: power-up to the first communication, maximum (table 4). | |
| constexpr uint32_t | kSoftResetUs = 2000 |
| t_soft_res: soft reset to ready, maximum (table 4). | |
| constexpr uint32_t | kStandbyUs = 2500 |
| t_standby: any mode to standby, maximum (table 4). | |
| constexpr uint32_t | kStartupUs = 3000 |
| t_startup: standby to the start of a measurement, maximum (table 4). | |
| constexpr uint32_t | kStartupDeepUs = 4000 |
| t_startup_deep: deep standby to the start of a measurement, maximum (table 4). | |
| constexpr uint32_t | kReconfUs = 3000 |
| constexpr uint32_t | kReadBackIdleUs = 1 |
| Idle time before INT_CONFIG may be read back after a write (sections 5.5.4, 7.5). | |
| constexpr uint32_t | kPollUs = 500 |
| Time between two polls of the chip. | |
| constexpr uint32_t | kTimeoutMaxMs = 10'000 |
The BMP581 driver: everything it declares lives here; internals in detail.
|
strong |
|
constexprnoexcept |
The configuration menuconfig selected, on top of the datasheet defaults.
Config{} with the oversampling, the data-ready source and the timeouts from Kconfig.
|
constexprnoexcept |
The oversampling setting for a number of samples, rounded down to a power of two.
| samples | 1 to 128; below 1 is 1, above 128 is 128. |