BMP581 Driver 1.0.0
API reference
Loading...
Searching...
No Matches
bmp581_types.hpp
Go to the documentation of this file.
1
7#pragma once
8
10
11#include <cstdint>
12#include <string_view>
13
14namespace bmp581 {
15
29
30constexpr std::string_view ToString(DriverError e) noexcept {
31 switch (e) {
32 case DriverError::None: return "None";
33 case DriverError::InvalidParameter: return "InvalidParameter";
34 case DriverError::NotInitialized: return "NotInitialized";
35 case DriverError::Bus: return "Bus";
36 case DriverError::InvalidChipId: return "InvalidChipId";
37 case DriverError::NvmNotReady: return "NvmNotReady";
38 case DriverError::PorSoftReset: return "PorSoftReset";
39 case DriverError::InvalidPowerMode: return "InvalidPowerMode";
40 case DriverError::NvmInvalidAddr: return "NvmInvalidAddr";
41 case DriverError::NvmCommandError: return "NvmCommandError";
42 }
43 return "?";
44}
45
46template <typename T>
50
51 constexpr bool ok() const noexcept { return error == DriverError::None; }
52 constexpr explicit operator bool() const noexcept { return ok(); }
53
54 static constexpr DriverResult success(T v) noexcept { return {v, DriverError::None}; }
55 static constexpr DriverResult failure(DriverError e) noexcept { return {T{}, e}; }
56};
57
58template <>
61 constexpr bool ok() const noexcept { return error == DriverError::None; }
62 constexpr explicit operator bool() const noexcept { return ok(); }
63 static constexpr DriverResult success() noexcept { return {DriverError::None}; }
64 static constexpr DriverResult failure(DriverError e) noexcept { return {e}; }
65};
66
67constexpr std::string_view ToString(PowerMode m) noexcept {
68 switch (m) {
69 case PowerMode::Standby: return "Standby";
70 case PowerMode::Normal: return "Normal";
71 case PowerMode::Forced: return "Forced";
72 case PowerMode::Continuous: return "Continuous";
73 case PowerMode::DeepStandby: return "DeepStandby";
74 }
75 return "?";
76}
77
85
94
101
109
112 bool data_ready{false};
113 bool fifo_full{false};
114 bool fifo_threshold{false};
116};
117
125
132
139 Config c{};
141 c.osr_odr.osr_temperature = Oversampling::X1;
142 c.osr_odr.pressure_enable = true;
143 c.osr_odr.odr = Odr::Hz100_2;
144 c.iir.pressure = IirFilter::Coeff3;
145 c.iir.temperature = IirFilter::Coeff3;
146 c.power_mode = PowerMode::Normal;
147 return c;
148}
149
150} // namespace bmp581
BMP581 register map, bit fields, enumerations and timing constants.
Definition bmp581.hpp:19
constexpr Interface kBusInterface
The interface adapter Bus declares, or Interface::Unspecified.
Definition bmp581_bus_interface.hpp:69
IirFilter
IIR filter coefficient (DSP_IIR).
Definition bmp581_registers.hpp:211
Odr
Output data rate (ODR_CONFIG bits 6:2). Codes ascend as rate descends.
Definition bmp581_registers.hpp:178
PowerMode
Power modes (ODR_CONFIG bits 1:0; deep standby = standby with deep_dis = 0).
Definition bmp581_registers.hpp:164
@ Continuous
back-to-back conversions
@ DeepStandby
pseudo-mode: standby + deep_dis cleared
@ Normal
periodic at ODR
@ Forced
one conversion then standby
DriverError
Driver-level error codes (stable for logging / telemetry).
Definition bmp581_types.hpp:17
@ NvmInvalidAddr
outside 0x20..0x22
@ NvmCommandError
STATUS.nvm_cmd_err set.
@ NvmNotReady
STATUS.nvm_rdy clear or nvm_err set.
@ Bus
register read/write failed
@ PorSoftReset
INT_STATUS.por_softreset_complete not set after reset.
@ NotInitialized
transport EnsureInitialized() failed
@ InvalidChipId
CHIP_ID not 0x50 / 0x51.
constexpr std::string_view ToString(DriverError e) noexcept
Definition bmp581_types.hpp:30
IntMode
Interrupt pin behaviour.
Definition bmp581_registers.hpp:217
constexpr Config BarometricReferencePreset() noexcept
Barometric preset for a ~100 Hz reference channel. OSR ×8 pressure / ×1 temperature keeps the ODR val...
Definition bmp581_types.hpp:138
IntDrive
Definition bmp581_registers.hpp:219
Oversampling
Oversampling (OSR_CONFIG).
Definition bmp581_registers.hpp:173
IntPolarity
Definition bmp581_registers.hpp:218
Convenience: one-call configuration for Driver::Configure().
Definition bmp581_types.hpp:127
PowerMode power_mode
Definition bmp581_types.hpp:130
OsrOdrConfig osr_odr
Definition bmp581_types.hpp:128
IirConfig iir
Definition bmp581_types.hpp:129
constexpr bool ok() const noexcept
Definition bmp581_types.hpp:61
static constexpr DriverResult failure(DriverError e) noexcept
Definition bmp581_types.hpp:64
static constexpr DriverResult success() noexcept
Definition bmp581_types.hpp:63
Definition bmp581_types.hpp:47
T value
Definition bmp581_types.hpp:48
DriverError error
Definition bmp581_types.hpp:49
static constexpr DriverResult success(T v) noexcept
Definition bmp581_types.hpp:54
static constexpr DriverResult failure(DriverError e) noexcept
Definition bmp581_types.hpp:55
constexpr bool ok() const noexcept
Definition bmp581_types.hpp:51
Effective oversampling and ODR validity (OSR_EFF).
Definition bmp581_types.hpp:96
Oversampling osr_pressure
Definition bmp581_types.hpp:98
Oversampling osr_temperature
Definition bmp581_types.hpp:97
bool odr_valid
false when the OSR combination cannot meet the ODR
Definition bmp581_types.hpp:99
IIR configuration (DSP_CONFIG + DSP_IIR). Writable in standby only.
Definition bmp581_types.hpp:87
bool shadow_iir_pressure
data registers show IIR-filtered pressure
Definition bmp581_types.hpp:91
bool flush_forced_enable
flush IIR on each forced-mode conversion
Definition bmp581_types.hpp:92
IirFilter pressure
Definition bmp581_types.hpp:89
IirFilter temperature
Definition bmp581_types.hpp:88
bool shadow_iir_temperature
data registers show IIR-filtered temperature
Definition bmp581_types.hpp:90
Interrupt pin configuration (INT_CONFIG).
Definition bmp581_types.hpp:103
bool enable
Definition bmp581_types.hpp:107
IntPolarity polarity
Definition bmp581_types.hpp:105
IntDrive drive
Definition bmp581_types.hpp:106
IntMode mode
Definition bmp581_types.hpp:104
Interrupt sources (INT_SOURCE).
Definition bmp581_types.hpp:111
bool data_ready
Definition bmp581_types.hpp:112
bool pressure_out_of_range
Definition bmp581_types.hpp:115
bool fifo_threshold
Definition bmp581_types.hpp:114
bool fifo_full
Definition bmp581_types.hpp:113
Oversampling / ODR / pressure-enable (OSR_CONFIG + ODR_CONFIG).
Definition bmp581_types.hpp:79
Odr odr
Definition bmp581_types.hpp:83
Oversampling osr_pressure
Definition bmp581_types.hpp:81
Oversampling osr_temperature
Definition bmp581_types.hpp:80
bool pressure_enable
Definition bmp581_types.hpp:82
One pressure / temperature sample.
Definition bmp581_types.hpp:119
int32_t temperature_raw
24-bit two's complement, 1/65536 °C
Definition bmp581_types.hpp:121
float pressure_pa
Definition bmp581_types.hpp:122
uint32_t pressure_raw
24-bit unsigned, 1/64 Pa
Definition bmp581_types.hpp:120
float temperature_c
Definition bmp581_types.hpp:123