15static constexpr uint8_t
addr = 0x5C;
20#define LPS_CR1_PD (1 << 7)
21#define LPS_CR1_ODR_25hz (4 << 4)
22#define LPS_CR1_BDU (1 << 2)
25#define LPS_SR_P_DA (1 << 1)
27#define REG_WhoAmI 0x0F
30#define REG_Cr1_Lps22 0x10
31#define REG_Cr1_Lps25 0x20
32#define REG_Status 0x27
33#define REG_PressureOutXl 0x28
34#define REG_PressureOutL 0x29
35#define REG_PressureOutH 0x2A
84 constexpr uint8_t readAddr = REG_Status | 0x80;
88 bool hasPressure =
buffer[0] & LPS_SR_P_DA;
99 constexpr float ratio = 1 / 40960.0f;
101 float kilopascal = counts * ratio;
109 if (kilopascal > 120 || kilopascal < 50) {
120 return REG_Cr1_Lps22;
123 return REG_Cr1_Lps25;
void writeRegister(uint8_t addr, uint8_t reg, uint8_t val)
bool init(brain_pin_e scl, brain_pin_e sda)
uint8_t readRegister(uint8_t addr, uint8_t reg)
void writeRead(uint8_t addr, const uint8_t *writeData, size_t writeSize, uint8_t *readData, size_t readSize)
bool init(brain_pin_e scl, brain_pin_e sda)
expected< float > readPressureKpa()
static constexpr uint8_t expectedWhoAmILps25
static constexpr uint8_t addr
static constexpr uint8_t expectedWhoAmILps22
Driver for the ST LPS22HB and LPS25HB pressure sensor.
static BigBufferHandle buffer