BMP581 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
bmp581_registers.hpp
Go to the documentation of this file.
1
14#ifndef BMP581_REGISTERS_HPP
15#define BMP581_REGISTERS_HPP
16
17#include <cstdint>
18
19#include "bmp581_detail.hpp"
20
22namespace bmp581::reg {
23
24using detail::operator""_u8;
25using detail::operator""_u32;
26
33// Addresses (section 7, register map).
34inline constexpr uint8_t kChipId = 0x01;
35inline constexpr uint8_t kRevId = 0x02;
36inline constexpr uint8_t kChipStatus = 0x11;
38inline constexpr uint8_t kDriveConfig = 0x13;
40inline constexpr uint8_t kIntConfig = 0x14;
41inline constexpr uint8_t kIntSource = 0x15;
42inline constexpr uint8_t kFifoConfig = 0x16;
43inline constexpr uint8_t kFifoCount = 0x17;
44inline constexpr uint8_t kFifoSel = 0x18;
45inline constexpr uint8_t kReserved0 = 0x1C;
46inline constexpr uint8_t kTempXlsb = 0x1D;
47inline constexpr uint8_t kTempLsb = 0x1E;
48inline constexpr uint8_t kTempMsb = 0x1F;
49inline constexpr uint8_t kPressXlsb = 0x20;
50inline constexpr uint8_t kPressLsb = 0x21;
51inline constexpr uint8_t kPressMsb = 0x22;
52inline constexpr uint8_t kReserved1 = 0x23;
53inline constexpr uint8_t kReserved4 = 0x26;
54inline constexpr uint8_t kIntStatus = 0x27;
55inline constexpr uint8_t kStatus = 0x28;
56inline constexpr uint8_t kFifoData = 0x29;
57inline constexpr uint8_t kNvmAddr = 0x2B;
58inline constexpr uint8_t kNvmDataLsb = 0x2C;
59inline constexpr uint8_t kNvmDataMsb = 0x2D;
60inline constexpr uint8_t kDspConfig = 0x30;
61inline constexpr uint8_t kDspIir = 0x31;
62inline constexpr uint8_t kOorThrPLsb = 0x32;
63inline constexpr uint8_t kOorThrPMsb = 0x33;
64inline constexpr uint8_t kOorRange = 0x34;
65inline constexpr uint8_t kOorConfig = 0x35;
66inline constexpr uint8_t kOsrConfig = 0x36;
67inline constexpr uint8_t kOdrConfig = 0x37;
68inline constexpr uint8_t kOsrEff = 0x38;
69inline constexpr uint8_t kCmd = 0x7E;
70
71// Reset values (section 7, register map), and the values the chip reports at reset.
72inline constexpr uint8_t kChipIdValue = 0x50;
73inline constexpr uint8_t kIntConfigReset = 0x35;
75inline constexpr uint8_t kDspConfigReset = 0x03;
76inline constexpr uint8_t kOsrConfigReset = 0x00;
77inline constexpr uint8_t kOdrConfigReset = 0x70;
78inline constexpr uint8_t kStatusReset = 0x02;
79inline constexpr uint32_t kDataReset = 0x7F7F7FU;
81inline constexpr uint8_t kFifoEmpty = 0x7F;
82inline constexpr uint8_t kIntStatusAfterReset = 0x10;
84
85// CMD values (section 7.36).
86inline constexpr uint8_t kCmdSoftReset = 0xB6;
87
88// INT_CONFIG (section 7.5).
89using IntConfigMode = detail::Field<uint8_t, 0U, 1U>;
90using IntConfigPol = detail::Field<uint8_t, 1U, 1U>;
91using IntConfigOd = detail::Field<uint8_t, 2U, 1U>;
92using IntConfigEn = detail::Field<uint8_t, 3U, 1U>;
93using IntConfigPadDrv = detail::Field<uint8_t, 4U, 4U>;
94// INT_SOURCE and INT_STATUS share the bit positions of the four sources (sections 7.6, 7.21).
95inline constexpr uint8_t kIntDrdy = 1U << 0U;
96inline constexpr uint8_t kIntFifoFull = 1U << 1U;
97inline constexpr uint8_t kIntFifoThs = 1U << 2U;
98inline constexpr uint8_t kIntOorP = 1U << 3U;
99inline constexpr uint8_t kIntPor = 1U << 4U;
100inline constexpr uint8_t kIntSourceMask = 0x0FU;
101inline constexpr uint8_t kIntStatusMask = 0x1FU;
102
103// FIFO_CONFIG, FIFO_COUNT, FIFO_SEL (sections 7.7 to 7.9).
104using FifoThreshold = detail::Field<uint8_t, 0U, 5U>;
105using FifoModeBit = detail::Field<uint8_t, 5U, 1U>;
106using FifoCountField = detail::Field<uint8_t, 0U, 6U>;
107using FifoFrameSel = detail::Field<uint8_t, 0U, 2U>;
108using FifoDecSel = detail::Field<uint8_t, 2U, 3U>;
109inline constexpr uint8_t kFifoConfigMask = 0x3FU;
110inline constexpr uint8_t kFifoSelMask = 0x1FU;
111
112// STATUS (section 7.22). Bit 0 is status_core_rdy in the field list but reserved_0 in the register
113// map, and its reset value is 0 while the chip answers: the driver does not use it.
114inline constexpr uint8_t kStatusNvmRdy = 1U << 1U;
115inline constexpr uint8_t kStatusNvmErr = 1U << 2U;
116inline constexpr uint8_t kStatusNvmCmdErr = 1U << 3U;
117inline constexpr uint8_t kStatusReserved = 0x60U;
118
119// DSP_CONFIG (section 7.27).
120using DspCompPtEn = detail::Field<uint8_t, 0U, 2U>;
121inline constexpr uint8_t kDspIirFlushForced = 1U << 2U;
122inline constexpr uint8_t kDspShdwSelIirT = 1U << 3U;
123inline constexpr uint8_t kDspFifoSelIirT = 1U << 4U;
124inline constexpr uint8_t kDspShdwSelIirP = 1U << 5U;
125inline constexpr uint8_t kDspFifoSelIirP = 1U << 6U;
126inline constexpr uint8_t kDspOorSelIirP = 1U << 7U;
127inline constexpr uint8_t kDspShdwSelIir = 0x28U;
128inline constexpr uint8_t kDspFifoSelIir = 0x50U;
129static_assert(kDspShdwSelIir ==
130 (static_cast<uint32_t>(kDspShdwSelIirT) | static_cast<uint32_t>(kDspShdwSelIirP)));
131static_assert(kDspFifoSelIir ==
132 (static_cast<uint32_t>(kDspFifoSelIirT) | static_cast<uint32_t>(kDspFifoSelIirP)));
133
134// DSP_IIR (section 7.28). The register map puts set_iir_t in bits 2..0 and set_iir_p in bits 5..3;
135// the field list of section 7.28 gives both "bit offset 0" and marks bits 5..3 read-only. The
136// driver follows the register map; the read-back after each write would show the other reading as
137// WriteMismatch (**not verified on hardware**).
138using DspIirT = detail::Field<uint8_t, 0U, 3U>;
139using DspIirP = detail::Field<uint8_t, 3U, 3U>;
140inline constexpr uint8_t kDspIirMask = 0x3FU;
141
142// OOR_CONFIG (section 7.32).
143using OorThrP16 = detail::Field<uint8_t, 0U, 1U>;
144using OorCntLim = detail::Field<uint8_t, 6U, 2U>;
145inline constexpr uint8_t kOorConfigMask = 0xC1U;
146
147// OSR_CONFIG (section 7.33).
148using OsrT = detail::Field<uint8_t, 0U, 3U>;
149using OsrP = detail::Field<uint8_t, 3U, 3U>;
150inline constexpr uint8_t kOsrPressEn = 1U << 6U;
151inline constexpr uint8_t kOsrReserved = 0x80U;
152
153// ODR_CONFIG (section 7.34).
154using OdrPwrMode = detail::Field<uint8_t, 0U, 2U>;
155using OdrOdr = detail::Field<uint8_t, 2U, 5U>;
156inline constexpr uint8_t kOdrDeepDis = 1U << 7U;
157
158// OSR_EFF (section 7.35).
159using OsrEffT = detail::Field<uint8_t, 0U, 3U>;
160using OsrEffP = detail::Field<uint8_t, 3U, 3U>;
161inline constexpr uint8_t kOsrEffOdrValid = 1U << 7U;
162inline constexpr uint8_t kOsrEffReserved = 1U << 6U;
163
164// The typed fields are the register map above, proved at build time (KB-CPP20-012).
165static_assert(IntConfigPadDrv::kMask == 0xF0U);
166static_assert(IntConfigMode::Extract(kIntConfigReset) == 1U); // latched
167static_assert(IntConfigOd::Extract(kIntConfigReset) == 1U); // open drain
168static_assert(IntConfigEn::Extract(kIntConfigReset) == 0U); // pin disabled
169static_assert(IntConfigPadDrv::Extract(kIntConfigReset) == 3U);
170static_assert((FifoThreshold::kMask | FifoModeBit::kMask) == kFifoConfigMask);
171static_assert((FifoFrameSel::kMask | FifoDecSel::kMask) == kFifoSelMask);
172static_assert((DspIirT::kMask | DspIirP::kMask) == kDspIirMask);
173static_assert((OorThrP16::kMask | OorCntLim::kMask) == kOorConfigMask);
174static_assert(OdrOdr::Extract(kOdrConfigReset) == 0x1CU); // 1 Hz
175static_assert(OdrPwrMode::Extract(kOdrConfigReset) == 0U); // standby
176static_assert(DspCompPtEn::Extract(kDspConfigReset) == 3U);
177static_assert(OsrP::Insert(0x00_u8, 7_u32) == 0x38U);
178static_assert(OsrP::Extract(OsrP::Insert(0xFF_u8, 2_u32)) == 2U);
179static_assert((static_cast<uint32_t>(kIntDrdy) | static_cast<uint32_t>(kIntFifoFull) |
180 static_cast<uint32_t>(kIntFifoThs) | static_cast<uint32_t>(kIntOorP)) ==
181 static_cast<uint32_t>(kIntSourceMask));
182
185} // namespace bmp581::reg
186
187#endif // BMP581_REGISTERS_HPP
Compile-time helpers of the BMP581 driver: typed integer literals, exact hook matching,...
constexpr uint8_t kOsrEffReserved
reserved_6: reads 0.
Definition bmp581_registers.hpp:162
constexpr uint8_t kPressXlsb
PRESS_DATA_XLSB (R): pressure bits 7..0.
Definition bmp581_registers.hpp:49
constexpr uint8_t kFifoConfig
FIFO_CONFIG (R/W): threshold, mode (7.7).
Definition bmp581_registers.hpp:42
constexpr uint8_t kOsrConfigReset
OSR_CONFIG: x1, x1, pressure off.
Definition bmp581_registers.hpp:76
detail::Field< uint8_t, 2U, 1U > IntConfigOd
int_od: 0 push-pull, 1 open drain.
Definition bmp581_registers.hpp:91
constexpr uint8_t kFifoEmpty
FIFO_DATA of an empty or disabled FIFO (4.6.3).
Definition bmp581_registers.hpp:81
constexpr uint8_t kIntPor
INT_STATUS only: POR or soft reset complete.
Definition bmp581_registers.hpp:99
constexpr uint8_t kDspIirFlushForced
iir_flush_forced_en.
Definition bmp581_registers.hpp:121
constexpr uint8_t kOdrConfig
ODR_CONFIG (R/W): power mode, ODR (7.34).
Definition bmp581_registers.hpp:67
constexpr uint8_t kOorConfig
OOR_CONFIG (R/W): reference bit 16, count (7.32).
Definition bmp581_registers.hpp:65
constexpr uint8_t kStatusNvmErr
status_nvm_err: NVM error.
Definition bmp581_registers.hpp:115
detail::Field< uint8_t, 5U, 1U > FifoModeBit
fifo_mode: 0 streaming, 1 stop on full.
Definition bmp581_registers.hpp:105
constexpr uint8_t kDspShdwSelIirP
Pressure registers after the IIR.
Definition bmp581_registers.hpp:124
constexpr uint8_t kIntFifoThs
FIFO threshold reached.
Definition bmp581_registers.hpp:97
constexpr uint8_t kFifoSel
FIFO_SEL (R/W): frame type, decimation (7.9).
Definition bmp581_registers.hpp:44
constexpr uint8_t kOsrConfig
OSR_CONFIG (R/W): oversampling, press_en (7.33).
Definition bmp581_registers.hpp:66
constexpr uint8_t kDriveConfig
Definition bmp581_registers.hpp:38
constexpr uint8_t kTempLsb
TEMP_DATA_LSB (R): temperature bits 15..8.
Definition bmp581_registers.hpp:47
constexpr uint8_t kDspFifoSelIirT
Temperature FIFO after the IIR.
Definition bmp581_registers.hpp:123
constexpr uint8_t kOorThrPMsb
OOR_THR_P_MSB (R/W): reference bits 15..8.
Definition bmp581_registers.hpp:63
constexpr uint8_t kOsrEff
OSR_EFF (R): effective oversampling (7.35).
Definition bmp581_registers.hpp:68
detail::Field< uint8_t, 0U, 3U > OsrT
osr_t: 2^n temperature oversampling.
Definition bmp581_registers.hpp:148
constexpr uint8_t kChipIdValue
CHIP_ID of every BMP581 (section 7.1).
Definition bmp581_registers.hpp:72
detail::Field< uint8_t, 2U, 3U > FifoDecSel
fifo_dec_sel: keep every 2^n-th frame.
Definition bmp581_registers.hpp:108
detail::Field< uint8_t, 3U, 3U > DspIirP
set_iir_p: pressure IIR coefficient.
Definition bmp581_registers.hpp:139
constexpr uint8_t kPressMsb
PRESS_DATA_MSB (R): pressure bits 23..16.
Definition bmp581_registers.hpp:51
constexpr uint8_t kNvmDataMsb
NVM_DATA_MSB (R/W) (7.26).
Definition bmp581_registers.hpp:59
constexpr uint8_t kStatusNvmCmdErr
status_nvm_cmd_err: NVM command error.
Definition bmp581_registers.hpp:116
constexpr uint8_t kRevId
REV_ID (R): ASIC revision, 0x32 (section 7.2).
Definition bmp581_registers.hpp:35
detail::Field< uint8_t, 0U, 5U > FifoThreshold
fifo_threshold: 0 off, 1 to 31 frames.
Definition bmp581_registers.hpp:104
constexpr uint8_t kFifoCount
FIFO_COUNT (R): frames in the FIFO (7.8).
Definition bmp581_registers.hpp:43
detail::Field< uint8_t, 0U, 1U > OorThrP16
oor_thr_p_16: reference bit 16.
Definition bmp581_registers.hpp:143
constexpr uint8_t kPressLsb
PRESS_DATA_LSB (R): pressure bits 15..8.
Definition bmp581_registers.hpp:50
constexpr uint8_t kStatusNvmRdy
status_nvm_rdy: ready for NVM operations.
Definition bmp581_registers.hpp:114
constexpr uint8_t kOorThrPLsb
OOR_THR_P_LSB (R/W): reference bits 7..0.
Definition bmp581_registers.hpp:62
constexpr uint8_t kIntConfig
INT_CONFIG (R/W): the INT pin (section 7.5).
Definition bmp581_registers.hpp:40
constexpr uint8_t kDspIir
DSP_IIR (R/W): IIR coefficients (7.28).
Definition bmp581_registers.hpp:61
constexpr uint8_t kIntConfigReset
Definition bmp581_registers.hpp:73
detail::Field< uint8_t, 0U, 3U > DspIirT
set_iir_t: temperature IIR coefficient.
Definition bmp581_registers.hpp:138
constexpr uint8_t kIntStatusMask
INT_STATUS bits 4..0 (7..5 reserved).
Definition bmp581_registers.hpp:101
detail::Field< uint8_t, 1U, 1U > IntConfigPol
int_pol: 0 active low, 1 high.
Definition bmp581_registers.hpp:90
constexpr uint8_t kDspIirMask
DSP_IIR bits 5..0.
Definition bmp581_registers.hpp:140
constexpr uint8_t kReserved1
Reserved (R): always reads 0x00 (7.17).
Definition bmp581_registers.hpp:52
constexpr uint8_t kStatusReserved
reserved_6_5: read 0.
Definition bmp581_registers.hpp:117
constexpr uint8_t kDspOorSelIirP
Out-of-range check after the IIR.
Definition bmp581_registers.hpp:126
constexpr uint8_t kTempXlsb
TEMP_DATA_XLSB (R): temperature bits 7..0.
Definition bmp581_registers.hpp:46
constexpr uint8_t kReserved0
Reserved (R): always reads 0x00 (7.10).
Definition bmp581_registers.hpp:45
detail::Field< uint8_t, 3U, 3U > OsrEffP
osr_p_eff.
Definition bmp581_registers.hpp:160
constexpr uint8_t kNvmAddr
NVM_ADDR (R/W) (7.24).
Definition bmp581_registers.hpp:57
constexpr uint8_t kOsrReserved
reserved_7: reads 0.
Definition bmp581_registers.hpp:151
constexpr uint8_t kFifoConfigMask
FIFO_CONFIG bits 5..0 (7..6 reserved).
Definition bmp581_registers.hpp:109
constexpr uint32_t kDataReset
Definition bmp581_registers.hpp:79
constexpr uint8_t kOorRange
OOR_RANGE (R/W): window, Pa (7.31).
Definition bmp581_registers.hpp:64
detail::Field< uint8_t, 0U, 1U > IntConfigMode
int_mode: 0 pulsed, 1 latched.
Definition bmp581_registers.hpp:89
constexpr uint8_t kIntDrdy
Data ready (drdy_data_reg).
Definition bmp581_registers.hpp:95
constexpr uint8_t kOsrEffOdrValid
odr_is_valid.
Definition bmp581_registers.hpp:161
detail::Field< uint8_t, 6U, 2U > OorCntLim
cnt_lim: 1, 3, 7 or 15 samples.
Definition bmp581_registers.hpp:144
constexpr uint8_t kNvmDataLsb
NVM_DATA_LSB (R/W) (7.25).
Definition bmp581_registers.hpp:58
constexpr uint8_t kDspFifoSelIirP
Pressure FIFO after the IIR.
Definition bmp581_registers.hpp:125
constexpr uint8_t kDspConfigReset
DSP_CONFIG: both compensated, IIR off.
Definition bmp581_registers.hpp:75
constexpr uint8_t kOdrConfigReset
ODR_CONFIG: standby, 1 Hz, deep standby on.
Definition bmp581_registers.hpp:77
constexpr uint8_t kStatusReset
STATUS: NVM ready (section 7.22).
Definition bmp581_registers.hpp:78
detail::Field< uint8_t, 3U, 3U > OsrP
osr_p: 2^n pressure oversampling.
Definition bmp581_registers.hpp:149
constexpr uint8_t kCmdSoftReset
Soft reset; over I2C the data byte is NACKed.
Definition bmp581_registers.hpp:86
detail::Field< uint8_t, 0U, 3U > OsrEffT
osr_t_eff.
Definition bmp581_registers.hpp:159
constexpr uint8_t kReserved4
Reserved (R): always reads 0x00 (7.20).
Definition bmp581_registers.hpp:53
detail::Field< uint8_t, 0U, 2U > FifoFrameSel
fifo_frame_sel: off, T, P, P and T.
Definition bmp581_registers.hpp:107
constexpr uint8_t kFifoData
FIFO_DATA (R): FIFO output port (7.23).
Definition bmp581_registers.hpp:56
constexpr uint8_t kOorConfigMask
OOR_CONFIG bits 7..6 and 0 (5..1 reserved).
Definition bmp581_registers.hpp:145
constexpr uint8_t kFifoSelMask
FIFO_SEL bits 4..0 (7..5 reserved).
Definition bmp581_registers.hpp:110
constexpr uint8_t kDspShdwSelIirT
Temperature registers after the IIR.
Definition bmp581_registers.hpp:122
constexpr uint8_t kDspShdwSelIir
Both data registers after the IIR.
Definition bmp581_registers.hpp:127
constexpr uint8_t kIntSourceMask
INT_SOURCE bits 3..0 (7..4 reserved).
Definition bmp581_registers.hpp:100
constexpr uint8_t kDspFifoSelIir
Both FIFO values after the IIR.
Definition bmp581_registers.hpp:128
constexpr uint8_t kCmd
CMD (W): soft reset and NVM sequences (7.36).
Definition bmp581_registers.hpp:69
constexpr uint8_t kOdrDeepDis
deep_dis: deep standby disabled.
Definition bmp581_registers.hpp:156
constexpr uint8_t kIntStatus
INT_STATUS (R): clear-on-read (7.21).
Definition bmp581_registers.hpp:54
constexpr uint8_t kDspConfig
DSP_CONFIG (R/W): compensation, IIR routing.
Definition bmp581_registers.hpp:60
detail::Field< uint8_t, 0U, 2U > DspCompPtEn
comp_pt_en: 0b11 both compensated.
Definition bmp581_registers.hpp:120
constexpr uint8_t kTempMsb
TEMP_DATA_MSB (R): temperature bits 23..16.
Definition bmp581_registers.hpp:48
constexpr uint8_t kIntStatusAfterReset
Definition bmp581_registers.hpp:82
constexpr uint8_t kChipId
CHIP_ID (R): 0x50 (section 7.1).
Definition bmp581_registers.hpp:34
detail::Field< uint8_t, 3U, 1U > IntConfigEn
int_en: the INT pin enabled.
Definition bmp581_registers.hpp:92
constexpr uint8_t kIntFifoFull
FIFO full.
Definition bmp581_registers.hpp:96
constexpr uint8_t kChipStatus
Definition bmp581_registers.hpp:36
detail::Field< uint8_t, 4U, 4U > IntConfigPadDrv
pad_int_drv: INT pad drive.
Definition bmp581_registers.hpp:93
detail::Field< uint8_t, 0U, 6U > FifoCountField
fifo_count: frames in the FIFO.
Definition bmp581_registers.hpp:106
detail::Field< uint8_t, 0U, 2U > OdrPwrMode
pwr_mode: what the chip does now.
Definition bmp581_registers.hpp:154
constexpr uint8_t kIntSource
INT_SOURCE (R/W): interrupt sources (7.6).
Definition bmp581_registers.hpp:41
constexpr uint8_t kOsrPressEn
press_en: pressure measured as well.
Definition bmp581_registers.hpp:150
constexpr uint8_t kStatus
STATUS (R): NVM ready and errors (7.22).
Definition bmp581_registers.hpp:55
detail::Field< uint8_t, 2U, 5U > OdrOdr
odr: output data rate code.
Definition bmp581_registers.hpp:155
constexpr uint8_t kIntOorP
Pressure out of range.
Definition bmp581_registers.hpp:98
The BMP581 register map.
Definition bmp581_registers.hpp:22