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.cpp
- Revision:
- 2:f7b403c70f6b
- Parent:
- 1:33ddb62b31fd
--- a/LPS22HBSensor.cpp Wed Sep 27 16:49:30 2017 +0200 +++ b/LPS22HBSensor.cpp Mon Oct 02 09:29:15 2017 +0200 @@ -44,6 +44,26 @@ /* Class Implementation ------------------------------------------------------*/ +LPS22HBSensor::LPS22HBSensor(SPI *spi, PinName cs_pin, PinName int_pin, SPI_type_t spi_type) : _dev_spi(spi), _cs_pin(cs_pin), _int_pin(int_pin), _spi_type(spi_type) +{ + assert (spi); + if (cs_pin == NC) + { + printf ("ERROR LPS22HBSensor CS MUST NOT BE NC\n\r"); + _dev_spi = NULL; + _dev_i2c=NULL; + return; + } + + _cs_pin = 1; + _dev_i2c=NULL; + + if (_spi_type == SPI3W) LPS22HB_Set_SpiInterface ((void *)this, LPS22HB_SPI_3_WIRE); + else if (_spi_type == SPI4W) LPS22HB_Set_SpiInterface ((void *)this, LPS22HB_SPI_4_WIRE); + + LPS22HB_Set_I2C ((void *)this, LPS22HB_DISABLE); +} + /** Constructor * @param i2c object of an helper class which handles the I2C peripheral * @param address the address of the component's instance @@ -52,6 +72,8 @@ _dev_i2c(i2c), _address(address), _cs_pin(NC), _int_pin(int_pin) { assert (i2c); + _dev_spi = NULL; + LPS22HB_Set_I2C ((void *)this, LPS22HB_ENABLE); }; /**