MEMS nano pressure sensor: 260-1260 hPa absolute digital output barometer.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: HelloWorld_ST_Sensors MOTENV_Mbed mbed-os-mqtt-client LPS22HB_JS ... more
Diff: LPS22HBSensor.h
- Revision:
- 1:33ddb62b31fd
- Parent:
- 0:3de9cb936fd1
- Child:
- 2:f7b403c70f6b
diff -r 3de9cb936fd1 -r 33ddb62b31fd LPS22HBSensor.h --- a/LPS22HBSensor.h Mon Sep 04 16:06:45 2017 +0000 +++ b/LPS22HBSensor.h Wed Sep 27 16:49:30 2017 +0200 @@ -48,6 +48,7 @@ #include "LPS22HB_driver.h" #include "PressureSensor.h" #include "TempSensor.h" +#include <assert.h> /* Class Declaration ---------------------------------------------------------*/ @@ -57,8 +58,7 @@ class LPS22HBSensor : public PressureSensor, public TempSensor { public: - LPS22HBSensor(DevI2C &i2c); - LPS22HBSensor(DevI2C &i2c, uint8_t address); + LPS22HBSensor(DevI2C *i2c, uint8_t address=LPS22HB_ADDRESS_HIGH, PinName int_pin=NC); virtual int init(void *init); virtual int read_id(uint8_t *id); virtual int get_pressure(float *pfData); @@ -80,7 +80,7 @@ */ uint8_t io_read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) { - return (uint8_t) _dev_i2c.i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead); + return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead); } /** @@ -92,7 +92,7 @@ */ uint8_t io_write(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) { - return (uint8_t) _dev_i2c.i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); + return (uint8_t) _dev_i2c->i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); } private: @@ -100,10 +100,12 @@ int Set_ODR_When_Disabled(float odr); /* Helper classes. */ - DevI2C &_dev_i2c; + DevI2C *_dev_i2c; /* Configuration */ uint8_t _address; + DigitalOut _cs_pin; + InterruptIn _int_pin; uint8_t _is_enabled; float _last_odr;