BMP581 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
bmp581_types.hpp
Go to the documentation of this file.
1
16#ifndef BMP581_TYPES_HPP
17#define BMP581_TYPES_HPP
18
19#include <array>
20#include <cstdint>
21
22#include "bmp581_detail.hpp"
23#include "bmp581_version.h"
24
26namespace bmp581 {
27
40enum class [[nodiscard]] Error : uint8_t {
41 // Base set: the same names and values in every driver of the org (standards/driver.md).
42 Ok = 0,
43 NotInitialized = 1,
45 InvalidArgument = 2,
47 Bus = 3,
49 Timeout = 4,
53 Crc = 6,
54 Busy = 7,
56 DeviceFault = 8,
58 Unsupported = 9,
60 // Chip-specific values start at 16; each one is returned by some call (tests/test_errors.cpp).
61 DeviceReset = 16,
66 InvalidReply = 17,
70 NoDevice = 18,
73 NoData = 19,
75 OutOfRange = 20,
77 WriteMismatch = 21,
80 StateUnknown = 22,
83 ConfigRejected = 23,
86};
87
93constexpr const char* ToString(Error error) noexcept {
94 switch (error) {
95 case Error::Ok:
96 return "Ok";
98 return "NotInitialized";
100 return "InvalidArgument";
101 case Error::Bus:
102 return "Bus";
103 case Error::Timeout:
104 return "Timeout";
106 return "DeviceIdMismatch";
107 case Error::Crc:
108 return "Crc";
109 case Error::Busy:
110 return "Busy";
112 return "DeviceFault";
114 return "Unsupported";
116 return "DeviceReset";
118 return "InvalidReply";
119 case Error::NoDevice:
120 return "NoDevice";
121 case Error::NoData:
122 return "NoData";
124 return "OutOfRange";
126 return "WriteMismatch";
128 return "StateUnknown";
130 return "ConfigRejected";
131 default:
132 break;
133 }
134 return "Unknown";
135}
136
144template <typename T>
145struct [[nodiscard]] Result {
146 T value{};
147 Error error{Error::Ok};
148
150 [[nodiscard]] constexpr bool ok() const noexcept {
151 return error == Error::Ok;
152 }
154 constexpr explicit operator bool() const noexcept {
155 return ok();
156 }
157
163 static constexpr Result Success(T v) noexcept {
164 return {v, Error::Ok};
165 }
171 static constexpr Result Failure(Error e) noexcept {
172 return {T{}, e};
173 }
174};
175
177template <>
178struct [[nodiscard]] Result<void> {
179 Error error{Error::Ok};
180
182 [[nodiscard]] constexpr bool ok() const noexcept {
183 return error == Error::Ok;
184 }
186 constexpr explicit operator bool() const noexcept {
187 return ok();
188 }
189
191 static constexpr Result Success() noexcept {
192 return {Error::Ok};
193 }
199 static constexpr Result Failure(Error e) noexcept {
200 return {e};
201 }
202};
203
205enum class LogLevel : uint8_t {
206 Error = 0,
207 Warning,
208 Info,
209 Debug,
210};
211
213enum class Verify : uint8_t {
214 None = 0,
215 ReadBack = 1,
217};
218
220enum class PowerMode : uint8_t {
221 Standby = 0,
223 Normal = 1,
224 Forced = 2,
225 Continuous = 3,
226};
227
229enum class Oversampling : uint8_t {
230 X1 = 0,
231 X2,
232 X4,
233 X8,
234 X16,
235 X32,
236 X64,
237 X128,
238};
239
241enum class OutputDataRate : uint8_t {
242 Hz240 = 0x00,
243 Hz218p5 = 0x01,
244 Hz199p1 = 0x02,
245 Hz179p2 = 0x03,
246 Hz160 = 0x04,
247 Hz149p3 = 0x05,
248 Hz140 = 0x06,
249 Hz129p9 = 0x07,
250 Hz120 = 0x08,
251 Hz110p2 = 0x09,
252 Hz100p3 = 0x0A,
253 Hz89p6 = 0x0B,
254 Hz80 = 0x0C,
255 Hz70 = 0x0D,
256 Hz60 = 0x0E,
257 Hz50p1 = 0x0F,
258 Hz45 = 0x10,
259 Hz40 = 0x11,
260 Hz35 = 0x12,
261 Hz30 = 0x13,
262 Hz25 = 0x14,
263 Hz20 = 0x15,
264 Hz15 = 0x16,
265 Hz10 = 0x17,
266 Hz5 = 0x18,
267 Hz4 = 0x19,
268 Hz3 = 0x1A,
269 Hz2 = 0x1B,
270 Hz1 = 0x1C,
271 Hz0p5 = 0x1D,
272 Hz0p25 = 0x1E,
273 Hz0p125 = 0x1F,
274};
275
277enum class IirFilter : uint8_t {
278 Bypass = 0,
279 Coef1,
280 Coef3,
281 Coef7,
282 Coef15,
283 Coef31,
284 Coef63,
285 Coef127,
286};
287
289enum class FifoFrame : uint8_t {
290 Disabled = 0,
291 Temperature = 1,
292 Pressure = 2,
294};
295
297enum class FifoMode : uint8_t {
298 Streaming = 0,
299 StopOnFull = 1,
300};
301
303enum class IntMode : uint8_t {
304 Pulsed = 0,
305 Latched = 1,
306};
307
309enum class IntPolarity : uint8_t {
310 ActiveLow = 0,
311 ActiveHigh = 1,
312};
313
315enum class IntDrive : uint8_t {
316 PushPull = 0,
317 OpenDrain = 1,
318};
319
321enum class OorCount : uint8_t {
322 Samples1 = 0,
323 Samples3,
324 Samples7,
325 Samples15,
326};
327
333 bool data_ready{false};
334 bool fifo_full{false};
335 bool fifo_threshold{false};
336 bool out_of_range{false};
337 bool power_on_reset{false};
338};
339
347 int32_t pressure_raw{0};
348 int32_t temperature_raw{0};
349};
350
354 bool has_pressure{false};
355 bool has_temperature{false};
356 int32_t pressure_raw{0};
357 int32_t temperature_raw{0};
358};
359
361inline constexpr uint8_t kChipId = 0x50;
363inline constexpr int32_t kPressureCountsPerPa = 64;
365inline constexpr int32_t kTemperatureCountsPerDegreeC = 65536;
367inline constexpr int32_t kPressureMinPa = 30'000;
369inline constexpr int32_t kPressureMaxPa = 125'000;
371inline constexpr int32_t kTemperatureMinC = -40;
373inline constexpr int32_t kTemperatureMaxC = 85;
375inline constexpr uint32_t kOorReferenceMaxPa = 0x1'FFFF;
377inline constexpr uint32_t kFifoFramesSingle = 32;
379inline constexpr uint32_t kFifoFramesBoth = 16;
381inline constexpr uint32_t kFifoMaxBytes = 96;
382
384inline constexpr uint32_t kPowerUpUs = 2000;
386inline constexpr uint32_t kSoftResetUs = 2000;
388inline constexpr uint32_t kStandbyUs = 2500;
390inline constexpr uint32_t kStartupUs = 3000;
392inline constexpr uint32_t kStartupDeepUs = 4000;
395inline constexpr uint32_t kReconfUs = 3000;
397inline constexpr uint32_t kReadBackIdleUs = 1;
399inline constexpr uint32_t kPollUs = 500;
402inline constexpr uint32_t kTimeoutMaxMs = 10'000;
403
447
448namespace detail {
450template <>
451struct EnumLast<Verify> {
452 static constexpr Verify kValue = Verify::ReadBack;
453};
455template <>
456struct EnumLast<PowerMode> {
457 static constexpr PowerMode kValue = PowerMode::Continuous;
458};
460template <>
461struct EnumLast<Oversampling> {
462 static constexpr Oversampling kValue = Oversampling::X128;
463};
465template <>
466struct EnumLast<OutputDataRate> {
467 static constexpr OutputDataRate kValue = OutputDataRate::Hz0p125;
468};
470template <>
471struct EnumLast<IirFilter> {
472 static constexpr IirFilter kValue = IirFilter::Coef127;
473};
475template <>
476struct EnumLast<FifoFrame> {
477 static constexpr FifoFrame kValue = FifoFrame::PressureAndTemperature;
478};
480template <>
481struct EnumLast<FifoMode> {
482 static constexpr FifoMode kValue = FifoMode::StopOnFull;
483};
485template <>
486struct EnumLast<IntMode> {
487 static constexpr IntMode kValue = IntMode::Latched;
488};
490template <>
491struct EnumLast<IntPolarity> {
492 static constexpr IntPolarity kValue = IntPolarity::ActiveHigh;
493};
495template <>
496struct EnumLast<IntDrive> {
497 static constexpr IntDrive kValue = IntDrive::OpenDrain;
498};
500template <>
501struct EnumLast<OorCount> {
502 static constexpr OorCount kValue = OorCount::Samples15;
503};
504
506inline constexpr std::array<uint32_t, 32> kOdrMilliHz{
507 240'000U, 218'537U, 199'111U, 179'200U, 160'000U, 149'333U, 140'000U, 129'855U,
508 120'000U, 110'164U, 100'299U, 89'600U, 80'000U, 70'000U, 60'000U, 50'056U,
509 45'025U, 40'000U, 35'000U, 30'000U, 25'005U, 20'000U, 15'000U, 10'000U,
510 5'000U, 4'000U, 3'000U, 2'000U, 1'000U, 500U, 250U, 125U};
511
513inline constexpr std::array<std::array<uint16_t, 8>, 8> kMaxOdrHz{{
514 {240U, 240U, 240U, 240U, 200U, 130U, 80U, 40U},
515 {240U, 240U, 240U, 220U, 180U, 120U, 70U, 40U},
516 {220U, 220U, 200U, 180U, 140U, 100U, 70U, 40U},
517 {140U, 140U, 130U, 120U, 100U, 80U, 50U, 35U},
518 {80U, 80U, 80U, 70U, 70U, 50U, 45U, 30U},
519 {45U, 45U, 40U, 40U, 40U, 35U, 30U, 20U},
520 {20U, 20U, 20U, 20U, 20U, 20U, 15U, 15U},
521 {10U, 10U, 10U, 10U, 10U, 10U, 10U, 5U},
522}};
523
525inline constexpr std::array<uint32_t, 8> kConvPressureUs{1000U, 1700U, 2900U, 5400U,
526 10400U, 20400U, 40400U, 80400U};
528inline constexpr std::array<uint32_t, 8> kConvTemperatureUs{1000U, 1100U, 1500U, 2100U,
529 3300U, 5800U, 10800U, 20800U};
530} // namespace detail
531
537constexpr uint32_t OdrMilliHz(OutputDataRate odr) noexcept {
538 return detail::kOdrMilliHz[static_cast<uint32_t>(odr) & 0x1FU]; // masked: 32 codes
539}
540
547constexpr uint32_t MaxOdrMilliHz(Oversampling pressure, Oversampling temperature) noexcept {
548 const uint32_t p = static_cast<uint32_t>(pressure) & 0x07U; // masked: 8 settings
549 const uint32_t t = static_cast<uint32_t>(temperature) & 0x07U;
550 return static_cast<uint32_t>(detail::kMaxOdrHz[p][t]) * 1000U;
551}
552
560constexpr uint32_t ConversionTimeMaxUs(Oversampling pressure, Oversampling temperature) noexcept {
561 const uint32_t typical = detail::kConvPressureUs[static_cast<uint32_t>(pressure) & 0x07U] +
562 detail::kConvTemperatureUs[static_cast<uint32_t>(temperature) & 0x07U];
563 return ((typical * 105U) + 99U) / 100U;
564}
565
572constexpr bool EntersDeepStandby(const Config& config) noexcept {
573 return config.deep_standby &&
574 (static_cast<uint32_t>(config.odr) > static_cast<uint32_t>(OutputDataRate::Hz5)) &&
575 (config.fifo_frame == FifoFrame::Disabled) && (config.pressure_iir == IirFilter::Bypass) &&
576 (config.temperature_iir == IirFilter::Bypass);
577}
578
585constexpr uint32_t ForcedMeasurementMaxUs(const Config& config) noexcept {
586 const uint32_t startup = EntersDeepStandby(config) ? kStartupDeepUs : kStartupUs;
587 return startup +
588 ConversionTimeMaxUs(config.pressure_oversampling, config.temperature_oversampling);
589}
590
597constexpr int32_t SignExtend24(uint32_t raw) noexcept {
598 const uint32_t bits = raw & 0x00FF'FFFFU;
599 return static_cast<int32_t>(bits ^ 0x0080'0000U) - 0x0080'0000;
600}
601
607constexpr float PressurePa(int32_t raw) noexcept {
608 return static_cast<float>(raw) / static_cast<float>(kPressureCountsPerPa);
609}
610
616constexpr float TemperatureC(int32_t raw) noexcept {
617 return static_cast<float>(raw) / static_cast<float>(kTemperatureCountsPerDegreeC);
618}
619
625constexpr bool PressureInRange(int32_t raw) noexcept {
626 return (raw >= (kPressureMinPa * kPressureCountsPerPa)) &&
628}
629
635constexpr bool TemperatureInRange(int32_t raw) noexcept {
638}
639
640namespace detail {
642constexpr bool EnumeratorsValid(const Config& c) noexcept {
643 return IsEnumerator(c.mode) && IsEnumerator(c.pressure_oversampling) &&
644 IsEnumerator(c.temperature_oversampling) && IsEnumerator(c.odr) &&
645 IsEnumerator(c.pressure_iir) && IsEnumerator(c.temperature_iir) &&
646 IsEnumerator(c.fifo_frame) && IsEnumerator(c.fifo_mode) && IsEnumerator(c.int_mode) &&
647 IsEnumerator(c.int_polarity) && IsEnumerator(c.int_drive) && IsEnumerator(c.oor_count);
648}
649
654constexpr bool RangesValid(const Config& c) noexcept {
655 const uint32_t threshold_max = (c.fifo_frame == FifoFrame::PressureAndTemperature) ? 15U : 31U;
656 const bool fields =
657 (static_cast<uint32_t>(c.fifo_threshold) <= threshold_max) &&
658 (static_cast<uint32_t>(c.fifo_decimation) <= 7U) &&
659 (static_cast<uint32_t>(c.int_pad_drive) <= 15U) &&
660 ((c.int_drive == IntDrive::OpenDrain) || (static_cast<uint32_t>(c.int_pad_drive) <= 7U)) &&
661 (c.oor_reference_pa <= kOorReferenceMaxPa);
662 const bool timeouts = (c.startup_timeout_ms >= 1U) && (c.startup_timeout_ms <= kTimeoutMaxMs) &&
663 (c.data_ready_timeout_ms >= 1U) &&
664 (c.data_ready_timeout_ms <= kTimeoutMaxMs);
665 return fields && timeouts;
666}
667} // namespace detail
668
681constexpr Error Validate(const Config& config) noexcept {
682 if (!detail::EnumeratorsValid(config) || (config.mode == PowerMode::Forced) ||
683 !detail::RangesValid(config)) {
685 }
686 if ((config.mode == PowerMode::Normal) &&
687 (OdrMilliHz(config.odr) >
688 MaxOdrMilliHz(config.pressure_oversampling, config.temperature_oversampling))) {
690 }
691 return Error::Ok;
692}
693
699constexpr Config ForcedPreset() noexcept {
700 Config c{};
702 return c;
703}
704
709constexpr Config LowPowerPreset() noexcept {
710 Config c{};
712 c.odr = OutputDataRate::Hz1;
713 c.source_data_ready = true;
714 return c;
715}
716
722constexpr Config HighResolutionPreset() noexcept {
723 Config c{};
725 c.pressure_oversampling = Oversampling::X16;
726 c.odr = OutputDataRate::Hz25;
727 c.pressure_iir = IirFilter::Coef3;
728 c.iir_to_data_registers = true;
729 c.source_data_ready = true;
730 c.data_ready_timeout_ms = 200;
731 return c;
732}
733
738constexpr Config FifoPreset() noexcept {
739 Config c{};
741 c.pressure_oversampling = Oversampling::X8;
742 c.odr = OutputDataRate::Hz10;
744 c.fifo_threshold = 8;
745 c.source_fifo_threshold = true;
746 return c;
747}
748
749// Every preset is valid, proved at build time (KB-CPP20-012).
750static_assert(Validate(Config{}) == Error::Ok);
751static_assert(Validate(ForcedPreset()) == Error::Ok);
752static_assert(Validate(LowPowerPreset()) == Error::Ok);
753static_assert(Validate(HighResolutionPreset()) == Error::Ok);
754static_assert(Validate(FifoPreset()) == Error::Ok);
755// Table 7 and section 7.34 at their corners; the conversion times of table 4 with +5 %.
756static_assert(MaxOdrMilliHz(Oversampling::X1, Oversampling::X1) == 240'000U);
757static_assert(MaxOdrMilliHz(Oversampling::X128, Oversampling::X128) == 5'000U);
758static_assert(OdrMilliHz(OutputDataRate::Hz1) == 1'000U);
761static_assert(EntersDeepStandby(Config{}) && !EntersDeepStandby(FifoPreset()));
762static_assert(ForcedMeasurementMaxUs(Config{}) == 6100U);
763// The conversions of section 4.5, exact; the reset value is outside both ranges.
764static_assert(SignExtend24(0xFF'FFFFU) == -1);
765static_assert(SignExtend24(0x80'0000U) == -8'388'608);
766static_assert(SignExtend24(0x7F'FFFFU) == 8'388'607);
767static_assert(PressurePa(6'400'000) == 100'000.0F);
768static_assert(TemperatureC(-1) == -0.0000152587890625F);
769static_assert(!PressureInRange(SignExtend24(0x7F'7F7FU)) &&
770 !TemperatureInRange(SignExtend24(0x7F'7F7FU)));
771
776void ConfigIsInvalid() noexcept;
777
786public:
791 consteval explicit CheckedConfig(const Config& config) noexcept : config_(config) {
792 if (Validate(config) != Error::Ok) {
794 }
795 }
797 [[nodiscard]] constexpr const Config& Get() const& noexcept {
798 return config_;
799 }
801 void Get() const&& = delete;
802
803private:
804 Config config_;
805};
806
808constexpr const char* GetDriverVersion() noexcept {
809 return BMP581_VERSION_STRING;
810}
812constexpr uint32_t GetDriverVersionMajor() noexcept {
813 return BMP581_VERSION_MAJOR;
814}
816constexpr uint32_t GetDriverVersionMinor() noexcept {
817 return BMP581_VERSION_MINOR;
818}
820constexpr uint32_t GetDriverVersionPatch() noexcept {
821 return BMP581_VERSION_PATCH;
822}
823
826} // namespace bmp581
827
828#endif // BMP581_TYPES_HPP
Compile-time helpers of the BMP581 driver: typed integer literals, exact hook matching,...
A configuration proven valid at build time.
Definition bmp581_types.hpp:785
consteval CheckedConfig(const Config &config) noexcept
Check config at build time.
Definition bmp581_types.hpp:791
constexpr const Config & Get() const &noexcept
Definition bmp581_types.hpp:797
void Get() const &&=delete
Not on a temporary: the reference would dangle (KB-CPP20-044).
OutputDataRate
Output data rate in normal mode, ODR_CONFIG.odr (section 7.34).
Definition bmp581_types.hpp:241
constexpr float PressurePa(int32_t raw) noexcept
A pressure in pascals: raw / 2^6, exact (section 4.5).
Definition bmp581_types.hpp:607
constexpr bool TemperatureInRange(int32_t raw) noexcept
Whether a raw temperature lies in the measurement range, -40 to 85 °C (table 2).
Definition bmp581_types.hpp:635
constexpr uint32_t MaxOdrMilliHz(Oversampling pressure, Oversampling temperature) noexcept
The fastest data rate normal mode accepts with this oversampling (table 7).
Definition bmp581_types.hpp:547
constexpr bool EntersDeepStandby(const Config &config) noexcept
Whether the chip enters deep standby with this configuration (section 4.3.2): deep standby allowed,...
Definition bmp581_types.hpp:572
constexpr uint32_t ForcedMeasurementMaxUs(const Config &config) noexcept
The longest forced measurement: the start-up from (deep) standby, then the conversion (table 4).
Definition bmp581_types.hpp:585
constexpr Config HighResolutionPreset() noexcept
High resolution at 25 Hz: pressure x16 (table 9), the IIR on the data registers, data ready reported.
Definition bmp581_types.hpp:722
constexpr uint32_t kStandbyUs
t_standby: any mode to standby, maximum (table 4).
Definition bmp581_types.hpp:388
constexpr float TemperatureC(int32_t raw) noexcept
A temperature in degrees Celsius: raw / 2^16, exact (section 4.5).
Definition bmp581_types.hpp:616
LogLevel
Severity passed to the optional Log() hook.
Definition bmp581_types.hpp:205
constexpr uint32_t GetDriverVersionMajor() noexcept
Definition bmp581_types.hpp:812
constexpr int32_t kTemperatureMinC
Lowest temperature the chip measures, in °C (table 2).
Definition bmp581_types.hpp:371
void ConfigIsInvalid() noexcept
Reached only when a CheckedConfig is built from an invalid configuration: it is never defined,...
constexpr const char * GetDriverVersion() noexcept
Definition bmp581_types.hpp:808
constexpr uint8_t kChipId
CHIP_ID of every BMP581 (section 7.1).
Definition bmp581_types.hpp:361
FifoFrame
What the FIFO stores, FIFO_SEL.fifo_frame_sel (section 4.6.1).
Definition bmp581_types.hpp:289
constexpr bool PressureInRange(int32_t raw) noexcept
Whether a raw pressure lies in the measurement range, 30 to 125 kPa (table 1).
Definition bmp581_types.hpp:625
IirFilter
IIR low-pass filter coefficient, DSP_IIR.set_iir_p and set_iir_t (table 10).
Definition bmp581_types.hpp:277
constexpr Config FifoPreset() noexcept
Pressure and temperature frames into the FIFO at 10 Hz, threshold at 8 frames.
Definition bmp581_types.hpp:738
constexpr int32_t kTemperatureMaxC
Highest temperature the chip measures, in °C (table 2).
Definition bmp581_types.hpp:373
constexpr uint32_t kStartupDeepUs
t_startup_deep: deep standby to the start of a measurement, maximum (table 4).
Definition bmp581_types.hpp:392
constexpr uint32_t kTimeoutMaxMs
Definition bmp581_types.hpp:402
constexpr uint32_t kFifoMaxBytes
Bytes of a full FIFO, either frame size.
Definition bmp581_types.hpp:381
constexpr Error Validate(const Config &config) noexcept
Check a configuration without touching the chip.
Definition bmp581_types.hpp:681
constexpr uint32_t OdrMilliHz(OutputDataRate odr) noexcept
An output data rate in millihertz (section 7.34).
Definition bmp581_types.hpp:537
constexpr uint32_t kFifoFramesSingle
Frames the FIFO holds with 3-byte frames (section 4.6).
Definition bmp581_types.hpp:377
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,...
Definition bmp581_types.hpp:560
PowerMode
The power mode, ODR_CONFIG.pwr_mode (sections 4.3, 7.34).
Definition bmp581_types.hpp:220
constexpr uint32_t kSoftResetUs
t_soft_res: soft reset to ready, maximum (table 4).
Definition bmp581_types.hpp:386
constexpr const char * ToString(Error error) noexcept
The name of an error, for logs.
Definition bmp581_types.hpp:93
constexpr uint32_t kReadBackIdleUs
Idle time before INT_CONFIG may be read back after a write (sections 5.5.4, 7.5).
Definition bmp581_types.hpp:397
constexpr int32_t kTemperatureCountsPerDegreeC
Temperature LSBs per degree Celsius: the registers hold °C x 2^16 (section 4.5).
Definition bmp581_types.hpp:365
constexpr uint32_t GetDriverVersionPatch() noexcept
Definition bmp581_types.hpp:820
constexpr uint32_t kPollUs
Time between two polls of the chip.
Definition bmp581_types.hpp:399
constexpr int32_t kPressureMaxPa
Highest pressure the chip measures, in pascals (table 1).
Definition bmp581_types.hpp:369
constexpr uint32_t kStartupUs
t_startup: standby to the start of a measurement, maximum (table 4).
Definition bmp581_types.hpp:390
IntMode
INT pin timing, INT_CONFIG.int_mode (section 4.7.3.2).
Definition bmp581_types.hpp:303
Verify
Extra traffic a call may spend to check what it did (handbook KB-ARCH-041).
Definition bmp581_types.hpp:213
constexpr Config ForcedPreset() noexcept
Measurements on request: standby between MeasureOnce() calls, deep standby, the standard-resolution o...
Definition bmp581_types.hpp:699
OorCount
Consecutive out-of-range samples before the interrupt, OOR_CONFIG.cnt_lim (7.32).
Definition bmp581_types.hpp:321
constexpr uint32_t kFifoFramesBoth
Frames the FIFO holds with 6-byte frames (section 4.6).
Definition bmp581_types.hpp:379
constexpr uint32_t GetDriverVersionMinor() noexcept
Definition bmp581_types.hpp:816
constexpr uint32_t kPowerUpUs
t_powup: power-up to the first communication, maximum (table 4).
Definition bmp581_types.hpp:384
constexpr uint32_t kOorReferenceMaxPa
Highest out-of-range reference: 17 bits of pascals (section 4.7.2.3).
Definition bmp581_types.hpp:375
constexpr int32_t kPressureMinPa
Lowest pressure the chip measures, in pascals (table 1).
Definition bmp581_types.hpp:367
IntDrive
INT pin output stage, INT_CONFIG.int_od (section 7.5).
Definition bmp581_types.hpp:315
FifoMode
What a full FIFO does with a new frame, FIFO_CONFIG.fifo_mode (section 4.6.1).
Definition bmp581_types.hpp:297
Oversampling
Oversampling ratio, OSR_CONFIG.osr_p and osr_t (section 7.33).
Definition bmp581_types.hpp:229
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 w...
Definition bmp581_types.hpp:597
constexpr uint32_t kReconfUs
Definition bmp581_types.hpp:395
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition bmp581_types.hpp:40
constexpr int32_t kPressureCountsPerPa
Pressure LSBs per pascal: the registers hold Pa x 2^6 (section 4.5).
Definition bmp581_types.hpp:363
IntPolarity
INT pin polarity, INT_CONFIG.int_pol (section 7.5).
Definition bmp581_types.hpp:309
constexpr Config LowPowerPreset() noexcept
Low power at 1 Hz in normal mode with deep standby between measurements (section 4....
Definition bmp581_types.hpp:709
@ Hz1
1.000 Hz. Reset value.
@ Hz4
4.000 Hz: the fastest rate with deep standby between measurements.
@ Warning
Something unexpected that the driver recovered from.
@ Info
Lifecycle events: initialised, reset.
@ Debug
Detail for bring-up.
@ Pressure
3-byte pressure frames, up to 32.
@ Disabled
FIFO off. Reset value.
@ PressureAndTemperature
6-byte frames, temperature first, up to 16.
@ Temperature
3-byte temperature frames, up to 32.
@ Coef127
Coefficient 127.
@ Bypass
No filter. Reset value.
@ Coef3
Coefficient 3.
@ Coef15
Coefficient 15.
@ Coef31
Coefficient 31.
@ Coef63
Coefficient 63.
@ Coef7
Coefficient 7.
@ Coef1
Coefficient 1.
@ Continuous
Back-to-back measurements as fast as the oversampling allows.
@ Normal
One measurement per output data rate period.
@ Forced
One measurement, then standby: MeasureOnce(), never a Config mode.
@ Pulsed
A pulse of t_int_pulse per event.
@ Latched
Asserted while a condition holds. Reset value.
@ None
Only the traffic the datasheet needs.
@ Samples1
1 sample. Reset value.
@ Samples15
15 samples.
@ Samples7
7 samples.
@ Samples3
3 samples.
@ OpenDrain
Needs a pull-up. Reset value.
@ PushPull
Driven both ways.
@ StopOnFull
The new frame is dropped.
@ Streaming
The oldest frame is dropped. Reset value.
@ X128
128 samples.
@ X1
1 sample. Reset value.
@ Crc
Not returned by this driver (the bus carries no CRC).
@ Ok
The call succeeded.
@ ActiveLow
Reset value.
@ ActiveHigh
Asserted high.
The BMP581 driver: everything it declares lives here; internals in detail.
Definition bmp581.hpp:32
Everything EnsureInitialized() and ApplyConfig() write to the chip.
Definition bmp581_types.hpp:411
OutputDataRate odr
ODR_CONFIG.odr (normal mode).
Definition bmp581_types.hpp:415
uint8_t fifo_threshold
FIFO_CONFIG.fifo_threshold: 0 off, 1 to 31 (15 for PT frames).
Definition bmp581_types.hpp:425
uint32_t startup_timeout_ms
Definition bmp581_types.hpp:439
bool iir_to_fifo
DSP_CONFIG.fifo_sel_iir_t and _p: filtered FIFO frames.
Definition bmp581_types.hpp:420
IntMode int_mode
INT_CONFIG.int_mode.
Definition bmp581_types.hpp:428
bool source_fifo_threshold
INT_SOURCE.fifo_ths_en.
Definition bmp581_types.hpp:434
FifoFrame fifo_frame
FIFO_SEL.fifo_frame_sel.
Definition bmp581_types.hpp:423
IntDrive int_drive
INT_CONFIG.int_od.
Definition bmp581_types.hpp:430
uint32_t data_ready_timeout_ms
Definition bmp581_types.hpp:441
uint8_t fifo_decimation
FIFO_SEL.fifo_dec_sel: keep every 2^n-th frame, 0 to 7.
Definition bmp581_types.hpp:426
IntPolarity int_polarity
INT_CONFIG.int_pol.
Definition bmp581_types.hpp:429
PowerMode mode
Standby, Normal or Continuous.
Definition bmp581_types.hpp:412
IirFilter temperature_iir
DSP_IIR.set_iir_t.
Definition bmp581_types.hpp:418
FifoMode fifo_mode
FIFO_CONFIG.fifo_mode.
Definition bmp581_types.hpp:424
uint8_t oor_window_pa
OOR_RANGE: +/- this many pascals around the reference.
Definition bmp581_types.hpp:437
Oversampling pressure_oversampling
OSR_CONFIG.osr_p.
Definition bmp581_types.hpp:413
bool iir_to_out_of_range
DSP_CONFIG.oor_sel_iir_p: filtered OOR check.
Definition bmp581_types.hpp:421
bool source_fifo_full
INT_SOURCE.fifo_full_en.
Definition bmp581_types.hpp:433
Oversampling temperature_oversampling
OSR_CONFIG.osr_t.
Definition bmp581_types.hpp:414
bool int_pin_enable
INT_CONFIG.int_en.
Definition bmp581_types.hpp:427
uint8_t int_pad_drive
INT_CONFIG.pad_int_drv, 0 to 15; set bit 3 only with open drain.
Definition bmp581_types.hpp:431
friend constexpr bool operator==(const Config &lhs, const Config &rhs) noexcept=default
Exact comparison: every member is integral or an enumeration (KB-CPP20-033).
bool iir_flush_in_forced
DSP_CONFIG.iir_flush_forced_en.
Definition bmp581_types.hpp:422
bool iir_to_data_registers
DSP_CONFIG.shdw_sel_iir_t and _p: filtered data.
Definition bmp581_types.hpp:419
bool deep_standby
ODR_CONFIG.deep_dis = 0: deep standby where its conditions hold.
Definition bmp581_types.hpp:416
bool source_data_ready
INT_SOURCE.drdy_data_reg_en; WaitDataReady() needs it.
Definition bmp581_types.hpp:432
IirFilter pressure_iir
DSP_IIR.set_iir_p.
Definition bmp581_types.hpp:417
uint32_t oor_reference_pa
OOR_THR_P and OOR_CONFIG bit 0: 0 to kOorReferenceMaxPa.
Definition bmp581_types.hpp:436
bool source_out_of_range
INT_SOURCE.oor_p_en.
Definition bmp581_types.hpp:435
OorCount oor_count
OOR_CONFIG.cnt_lim.
Definition bmp581_types.hpp:438
One FIFO frame, with its own validity: a multi-item read reports each item.
Definition bmp581_types.hpp:352
bool has_pressure
The frame carries a pressure (P and PT frames).
Definition bmp581_types.hpp:354
int32_t temperature_raw
Temperature in 1/65536 °C.
Definition bmp581_types.hpp:357
bool has_temperature
The frame carries a temperature (T and PT frames).
Definition bmp581_types.hpp:355
Error error
Ok, NoData (0x7F7F7F) or OutOfRange; the values are 0 then.
Definition bmp581_types.hpp:353
int32_t pressure_raw
Pressure in 1/64 Pa.
Definition bmp581_types.hpp:356
The interrupt status flags, INT_STATUS (section 7.21), decoded. Reading INT_STATUS clears them on the...
Definition bmp581_types.hpp:332
bool out_of_range
oor_p: pressure outside the window.
Definition bmp581_types.hpp:336
bool data_ready
drdy_data_reg: new data in the data registers and the FIFO.
Definition bmp581_types.hpp:333
bool power_on_reset
por: a power-on or soft reset completed.
Definition bmp581_types.hpp:337
bool fifo_full
fifo_full.
Definition bmp581_types.hpp:334
bool fifo_threshold
fifo_ths: the FIFO holds at least the threshold.
Definition bmp581_types.hpp:335
One measurement in the chip's own units, as the data registers hold it (section 4....
Definition bmp581_types.hpp:346
int32_t temperature_raw
Temperature in 1/65536 °C.
Definition bmp581_types.hpp:348
int32_t pressure_raw
Pressure in 1/64 Pa.
Definition bmp581_types.hpp:347
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition bmp581_types.hpp:199
static constexpr Result Success() noexcept
Definition bmp581_types.hpp:191
constexpr bool ok() const noexcept
Definition bmp581_types.hpp:182
The value of a call, or why there is none.
Definition bmp581_types.hpp:145
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition bmp581_types.hpp:171
constexpr bool ok() const noexcept
Definition bmp581_types.hpp:150
static constexpr Result Success(T v) noexcept
A successful result.
Definition bmp581_types.hpp:163