2021-02-06 21:59:44 -08:00
|
|
|
/**
|
|
|
|
* @file lps25.h
|
2022-02-07 14:09:51 -08:00
|
|
|
* @brief Driver for the ST LPS22HB and LPS25HB pressure sensor
|
2021-02-06 21:59:44 -08:00
|
|
|
*
|
|
|
|
* @date February 6, 2020
|
|
|
|
* @author Matthew Kennedy, (c) 2020
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "i2c_bb.h"
|
|
|
|
|
|
|
|
class Lps25 {
|
|
|
|
public:
|
|
|
|
// Returns true if the sensor was initialized successfully.
|
|
|
|
bool init(brain_pin_e scl, brain_pin_e sda);
|
|
|
|
|
|
|
|
expected<float> readPressureKpa();
|
2021-05-14 11:56:45 -07:00
|
|
|
bool hasInit() const {
|
|
|
|
return m_hasInit;
|
|
|
|
}
|
2021-02-06 21:59:44 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
BitbangI2c m_i2c;
|
2021-05-14 11:56:45 -07:00
|
|
|
|
2022-02-07 14:09:51 -08:00
|
|
|
enum class Type {
|
|
|
|
Lps22,
|
|
|
|
Lps25,
|
|
|
|
};
|
|
|
|
|
|
|
|
Type m_type;
|
|
|
|
|
2021-05-14 11:56:45 -07:00
|
|
|
bool m_hasInit = false;
|
2022-02-07 14:09:51 -08:00
|
|
|
|
|
|
|
uint8_t regCr1() const;
|
2021-02-06 21:59:44 -08:00
|
|
|
};
|