MEMS nano pressure sensor: 260-1260 hPa absolute digital output barometer.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: X_NUCLEO_IKS01A3 X_NUCLEO_IKS01A3
Diff: LPS22HHSensor.cpp
- Revision:
- 1:978cae936ddb
- Parent:
- 0:c761bc6186e8
--- a/LPS22HHSensor.cpp Wed Mar 06 09:18:20 2019 +0000 +++ b/LPS22HHSensor.cpp Wed Jul 24 14:19:09 2019 +0000 @@ -4,7 +4,7 @@ * @author SRA * @version V1.0.0 * @date February 2019 - * @brief Implementation of a LPS22HH pressure sensor. + * @brief Implementation of a LPS22HH pressure sensor. ****************************************************************************** * @attention * @@ -51,28 +51,26 @@ */ LPS22HHSensor::LPS22HHSensor(SPI *spi, PinName cs_pin, PinName int_pin, SPI_type_t spi_type) : _dev_spi(spi), _cs_pin(cs_pin), _int_irq(int_pin), _spi_type(spi_type) { - assert (spi); - if (cs_pin == NC) - { - printf ("ERROR LPS22HH CS MUST NOT BE NC\n\r"); - _dev_spi = NULL; - _dev_i2c = NULL; - return; - } + assert(spi); + if (cs_pin == NC) { + printf("ERROR LPS22HH CS MUST NOT BE NC\n\r"); + _dev_spi = NULL; + _dev_i2c = NULL; + return; + } - _reg_ctx.write_reg = LPS22HH_io_write; - _reg_ctx.read_reg = LPS22HH_io_read; - _reg_ctx.handle = (void *)this; - _cs_pin = 1; - _dev_i2c = NULL; - _address = 0; - - if (_spi_type == SPI3W) - { - /* Enable SPI 3-Wires on the component */ - uint8_t data = 0x01; - lps22hh_write_reg(&_reg_ctx, LPS22HH_CTRL_REG1, &data, 1); - } + _reg_ctx.write_reg = LPS22HH_io_write; + _reg_ctx.read_reg = LPS22HH_io_read; + _reg_ctx.handle = (void *)this; + _cs_pin = 1; + _dev_i2c = NULL; + _address = 0; + + if (_spi_type == SPI3W) { + /* Enable SPI 3-Wires on the component */ + uint8_t data = 0x01; + lps22hh_write_reg(&_reg_ctx, LPS22HH_CTRL_REG1, &data, 1); + } } /** Constructor @@ -82,11 +80,11 @@ */ LPS22HHSensor::LPS22HHSensor(DevI2C *i2c, uint8_t address, PinName int_pin) : _dev_i2c(i2c), _address(address), _cs_pin(NC), _int_irq(int_pin) { - assert (i2c); - _dev_spi = NULL; - _reg_ctx.write_reg = LPS22HH_io_write; - _reg_ctx.read_reg = LPS22HH_io_read; - _reg_ctx.handle = (void *)this; + assert(i2c); + _dev_spi = NULL; + _reg_ctx.write_reg = LPS22HH_io_write; + _reg_ctx.read_reg = LPS22HH_io_read; + _reg_ctx.handle = (void *)this; } @@ -98,39 +96,34 @@ int LPS22HHSensor::init(void *init) { /* Disable MIPI I3C(SM) interface */ - if (lps22hh_i3c_interface_set(&_reg_ctx, LPS22HH_I3C_DISABLE) != 0) - { - return 1; - } + if (lps22hh_i3c_interface_set(&_reg_ctx, LPS22HH_I3C_DISABLE) != 0) { + return 1; + } - /* Power down the device, set Low Noise Enable (bit 5), clear One Shot (bit 4) */ - if (lps22hh_data_rate_set(&_reg_ctx, (lps22hh_odr_t)(LPS22HH_POWER_DOWN | 0x10)) != 0) - { - return 1; - } + /* Power down the device, set Low Noise Enable (bit 5), clear One Shot (bit 4) */ + if (lps22hh_data_rate_set(&_reg_ctx, (lps22hh_odr_t)(LPS22HH_POWER_DOWN | 0x10)) != 0) { + return 1; + } - /* Disable low-pass filter on LPS22HH pressure data */ - if (lps22hh_lp_bandwidth_set(&_reg_ctx, LPS22HH_LPF_ODR_DIV_2) != 0) - { - return 1; - } + /* Disable low-pass filter on LPS22HH pressure data */ + if (lps22hh_lp_bandwidth_set(&_reg_ctx, LPS22HH_LPF_ODR_DIV_2) != 0) { + return 1; + } - /* Set block data update mode */ - if (lps22hh_block_data_update_set(&_reg_ctx, PROPERTY_ENABLE) != 0) - { - return 1; - } + /* Set block data update mode */ + if (lps22hh_block_data_update_set(&_reg_ctx, PROPERTY_ENABLE) != 0) { + return 1; + } - /* Set autoincrement for multi-byte read/write */ - if (lps22hh_auto_increment_set(&_reg_ctx, PROPERTY_ENABLE) != 0) - { - return 1; - } + /* Set autoincrement for multi-byte read/write */ + if (lps22hh_auto_increment_set(&_reg_ctx, PROPERTY_ENABLE) != 0) { + return 1; + } - _last_odr = LPS22HH_25_Hz; - _is_enabled = 0; + _last_odr = LPS22HH_25_Hz; + _is_enabled = 0; - return 0; + return 0; } /** @@ -140,12 +133,11 @@ */ int LPS22HHSensor::read_id(uint8_t *id) { - if (lps22hh_device_id_get(&_reg_ctx, id) != 0) - { - return 1; - } + if (lps22hh_device_id_get(&_reg_ctx, id) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -154,21 +146,19 @@ */ int LPS22HHSensor::enable() { - /* Check if the component is already _is_enabled */ - if (_is_enabled == 1U) - { - return 0; - } + /* Check if the component is already _is_enabled */ + if (_is_enabled == 1U) { + return 0; + } - /* Output data rate selection. */ - if (lps22hh_data_rate_set(&_reg_ctx, _last_odr) != 0) - { - return 1; - } + /* Output data rate selection. */ + if (lps22hh_data_rate_set(&_reg_ctx, _last_odr) != 0) { + return 1; + } - _is_enabled = 1; + _is_enabled = 1; - return 0; + return 0; } /** @@ -177,27 +167,24 @@ */ int LPS22HHSensor::disable() { - /* Check if the component is already disabled */ - if (_is_enabled == 0U) - { - return 0; - } + /* Check if the component is already disabled */ + if (_is_enabled == 0U) { + return 0; + } - /* Get current output data rate. */ - if (lps22hh_data_rate_get(&_reg_ctx, &_last_odr) != 0) - { - return 1; - } - /* Output data rate selection - power down. */ - if (lps22hh_data_rate_set(&_reg_ctx, LPS22HH_POWER_DOWN) != 0) - { - return 1; - } + /* Get current output data rate. */ + if (lps22hh_data_rate_get(&_reg_ctx, &_last_odr) != 0) { + return 1; + } + /* Output data rate selection - power down. */ + if (lps22hh_data_rate_set(&_reg_ctx, LPS22HH_POWER_DOWN) != 0) { + return 1; + } - _is_enabled = 0; + _is_enabled = 0; - return 0; + return 0; } @@ -208,54 +195,52 @@ */ int LPS22HHSensor::get_odr(float *odr) { - int ret = 0; - lps22hh_odr_t odr_low_level; + int ret = 0; + lps22hh_odr_t odr_low_level; - if (lps22hh_data_rate_get(&_reg_ctx, &odr_low_level) != 0) - { - return 1; - } + if (lps22hh_data_rate_get(&_reg_ctx, &odr_low_level) != 0) { + return 1; + } - switch (odr_low_level) - { - case LPS22HH_POWER_DOWN: - *odr = 0.0f; - break; + switch (odr_low_level) { + case LPS22HH_POWER_DOWN: + *odr = 0.0f; + break; - case LPS22HH_1_Hz: - *odr = 1.0f; - break; + case LPS22HH_1_Hz: + *odr = 1.0f; + break; - case LPS22HH_10_Hz: - *odr = 10.0f; - break; + case LPS22HH_10_Hz: + *odr = 10.0f; + break; - case LPS22HH_25_Hz: - *odr = 25.0f; - break; + case LPS22HH_25_Hz: + *odr = 25.0f; + break; - case LPS22HH_50_Hz: - *odr = 50.0f; - break; + case LPS22HH_50_Hz: + *odr = 50.0f; + break; - case LPS22HH_75_Hz: - *odr = 75.0f; - break; + case LPS22HH_75_Hz: + *odr = 75.0f; + break; - case LPS22HH_100_Hz: - *odr = 100.0f; - break; + case LPS22HH_100_Hz: + *odr = 100.0f; + break; - case LPS22HH_200_Hz: - *odr = 200.0f; - break; + case LPS22HH_200_Hz: + *odr = 200.0f; + break; - default: - ret = 1; - break; - } + default: + ret = 1; + break; + } - return ret; + return ret; } /** @@ -265,15 +250,12 @@ */ int LPS22HHSensor::set_odr(float odr) { - /* Check if the component is _is_enabled */ - if (_is_enabled == 1U) - { - return set_odr_when_enabled(odr); - } - else - { - return set_odr_when_disabled(odr); - } + /* Check if the component is _is_enabled */ + if (_is_enabled == 1U) { + return set_odr_when_enabled(odr); + } else { + return set_odr_when_disabled(odr); + } } @@ -284,27 +266,25 @@ */ int LPS22HHSensor::set_odr_when_enabled(float odr) { - lps22hh_odr_t new_odr; + lps22hh_odr_t new_odr; - new_odr = (odr <= 1.0f) ? LPS22HH_1_Hz - : (odr <= 10.0f) ? LPS22HH_10_Hz - : (odr <= 25.0f) ? LPS22HH_25_Hz - : (odr <= 50.0f) ? LPS22HH_50_Hz - : (odr <= 75.0f) ? LPS22HH_75_Hz - : (odr <= 100.0f) ? LPS22HH_100_Hz - : LPS22HH_200_Hz; + new_odr = (odr <= 1.0f) ? LPS22HH_1_Hz + : (odr <= 10.0f) ? LPS22HH_10_Hz + : (odr <= 25.0f) ? LPS22HH_25_Hz + : (odr <= 50.0f) ? LPS22HH_50_Hz + : (odr <= 75.0f) ? LPS22HH_75_Hz + : (odr <= 100.0f) ? LPS22HH_100_Hz + : LPS22HH_200_Hz; - if (lps22hh_data_rate_set(&_reg_ctx, new_odr) != 0) - { - return 1; - } + if (lps22hh_data_rate_set(&_reg_ctx, new_odr) != 0) { + return 1; + } - if (lps22hh_data_rate_get(&_reg_ctx, &_last_odr) != 0) - { - return 1; - } + if (lps22hh_data_rate_get(&_reg_ctx, &_last_odr) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -314,15 +294,15 @@ */ int LPS22HHSensor::set_odr_when_disabled(float odr) { - _last_odr = (odr <= 1.0f) ? LPS22HH_1_Hz - : (odr <= 10.0f) ? LPS22HH_10_Hz - : (odr <= 25.0f) ? LPS22HH_25_Hz - : (odr <= 50.0f) ? LPS22HH_50_Hz - : (odr <= 75.0f) ? LPS22HH_75_Hz - : (odr <= 100.0f) ? LPS22HH_100_Hz - : LPS22HH_200_Hz; + _last_odr = (odr <= 1.0f) ? LPS22HH_1_Hz + : (odr <= 10.0f) ? LPS22HH_10_Hz + : (odr <= 25.0f) ? LPS22HH_25_Hz + : (odr <= 50.0f) ? LPS22HH_50_Hz + : (odr <= 75.0f) ? LPS22HH_75_Hz + : (odr <= 100.0f) ? LPS22HH_100_Hz + : LPS22HH_200_Hz; - return 0; + return 0; } /** @@ -332,17 +312,16 @@ */ int LPS22HHSensor::get_pressure(float *value) { - axis1bit32_t data_raw_pressure; + axis1bit32_t data_raw_pressure; - (void)memset(data_raw_pressure.u8bit, 0x00, sizeof(int32_t)); - if (lps22hh_pressure_raw_get(&_reg_ctx, data_raw_pressure.u8bit) != 0) - { - return 1; - } + (void)memset(data_raw_pressure.u8bit, 0x00, sizeof(int32_t)); + if (lps22hh_pressure_raw_get(&_reg_ctx, data_raw_pressure.u8bit) != 0) { + return 1; + } - *value = LPS22HH_FROM_LSB_TO_hPa((float)(data_raw_pressure.i32bit)); + *value = LPS22HH_FROM_LSB_TO_hPa((float)(data_raw_pressure.i32bit)); - return 0; + return 0; } /** @@ -352,12 +331,11 @@ */ int LPS22HHSensor::get_press_drdy_status(uint8_t *status) { - if (lps22hh_press_flag_data_ready_get(&_reg_ctx, status) != 0) - { - return 1; - } + if (lps22hh_press_flag_data_ready_get(&_reg_ctx, status) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -367,17 +345,16 @@ */ int LPS22HHSensor::get_temperature(float *value) { - axis1bit16_t data_raw_temperature; + axis1bit16_t data_raw_temperature; - (void)memset(data_raw_temperature.u8bit, 0x00, sizeof(int16_t)); - if (lps22hh_temperature_raw_get(&_reg_ctx, data_raw_temperature.u8bit) != 0) - { - return 1; - } + (void)memset(data_raw_temperature.u8bit, 0x00, sizeof(int16_t)); + if (lps22hh_temperature_raw_get(&_reg_ctx, data_raw_temperature.u8bit) != 0) { + return 1; + } - *value = LPS22HH_FROM_LSB_TO_degC((float)(data_raw_temperature.i16bit)); + *value = LPS22HH_FROM_LSB_TO_degC((float)(data_raw_temperature.i16bit)); - return 0; + return 0; } /** @@ -387,12 +364,11 @@ */ int LPS22HHSensor::get_temp_drdy_status(uint8_t *status) { - if (lps22hh_temp_flag_data_ready_get(&_reg_ctx, status) != 0) - { - return 1; - } + if (lps22hh_temp_flag_data_ready_get(&_reg_ctx, status) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -403,12 +379,11 @@ */ int LPS22HHSensor::read_reg(uint8_t reg, uint8_t *data) { - if (lps22hh_read_reg(&_reg_ctx, reg, data, 1) != 0) - { - return 1; - } + if (lps22hh_read_reg(&_reg_ctx, reg, data, 1) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -419,12 +394,11 @@ */ int LPS22HHSensor::write_reg(uint8_t reg, uint8_t data) { - if (lps22hh_write_reg(&_reg_ctx, reg, &data, 1) != 0) - { - return 1; - } + if (lps22hh_write_reg(&_reg_ctx, reg, &data, 1) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -435,26 +409,24 @@ */ int LPS22HHSensor::get_fifo_data(float *press, float *temp) { - axis1bit32_t data_raw_pressure; - axis1bit16_t data_raw_temperature; + axis1bit32_t data_raw_pressure; + axis1bit16_t data_raw_temperature; - (void)memset(data_raw_pressure.u8bit, 0x00, sizeof(int32_t)); - if (lps22hh_fifo_pressure_raw_get(&_reg_ctx, data_raw_pressure.u8bit) != 0) - { - return 1; - } + (void)memset(data_raw_pressure.u8bit, 0x00, sizeof(int32_t)); + if (lps22hh_fifo_pressure_raw_get(&_reg_ctx, data_raw_pressure.u8bit) != 0) { + return 1; + } - *press = LPS22HH_FROM_LSB_TO_hPa((float)(data_raw_pressure.i32bit)); + *press = LPS22HH_FROM_LSB_TO_hPa((float)(data_raw_pressure.i32bit)); - (void)memset(data_raw_temperature.u8bit, 0x00, sizeof(int16_t)); - if (lps22hh_fifo_temperature_raw_get(&_reg_ctx, data_raw_temperature.u8bit) != 0) - { - return 1; - } + (void)memset(data_raw_temperature.u8bit, 0x00, sizeof(int16_t)); + if (lps22hh_fifo_temperature_raw_get(&_reg_ctx, data_raw_temperature.u8bit) != 0) { + return 1; + } - *temp = LPS22HH_FROM_LSB_TO_degC((float)(data_raw_temperature.i16bit)); + *temp = LPS22HH_FROM_LSB_TO_degC((float)(data_raw_temperature.i16bit)); - return 0; + return 0; } /** @@ -464,12 +436,11 @@ */ int LPS22HHSensor::get_fifo_fth_status(uint8_t *status) { - if (lps22hh_fifo_wtm_flag_get(&_reg_ctx, status) != 0) - { - return 1; - } + if (lps22hh_fifo_wtm_flag_get(&_reg_ctx, status) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -479,12 +450,11 @@ */ int LPS22HHSensor::get_fifo_full_status(uint8_t *status) { - if (lps22hh_fifo_full_flag_get(&_reg_ctx, status) != 0) - { - return 1; - } + if (lps22hh_fifo_full_flag_get(&_reg_ctx, status) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -494,12 +464,11 @@ */ int LPS22HHSensor::get_fifo_ovr_status(uint8_t *status) { - if (lps22hh_fifo_ovr_flag_get(&_reg_ctx, status) != 0) - { - return 1; - } + if (lps22hh_fifo_ovr_flag_get(&_reg_ctx, status) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -509,12 +478,11 @@ */ int LPS22HHSensor::get_fifo_level(uint8_t *status) { - if (lps22hh_fifo_data_level_get(&_reg_ctx, status) != 0) - { - return 1; - } + if (lps22hh_fifo_data_level_get(&_reg_ctx, status) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -524,31 +492,27 @@ */ int LPS22HHSensor::reset_fifo_interrupt(uint8_t interrupt) { - switch (interrupt) - { - case 0: - if (lps22hh_fifo_threshold_on_int_set(&_reg_ctx, PROPERTY_DISABLE) != 0) - { - return 1; - } - break; - case 1: - if (lps22hh_fifo_full_on_int_set(&_reg_ctx, PROPERTY_DISABLE) != 0) - { - return 1; - } - break; - case 2: - if (lps22hh_fifo_ovr_on_int_set(&_reg_ctx, PROPERTY_DISABLE) != 0) - { - return 1; - } - break; - default: - return 1; - } + switch (interrupt) { + case 0: + if (lps22hh_fifo_threshold_on_int_set(&_reg_ctx, PROPERTY_DISABLE) != 0) { + return 1; + } + break; + case 1: + if (lps22hh_fifo_full_on_int_set(&_reg_ctx, PROPERTY_DISABLE) != 0) { + return 1; + } + break; + case 2: + if (lps22hh_fifo_ovr_on_int_set(&_reg_ctx, PROPERTY_DISABLE) != 0) { + return 1; + } + break; + default: + return 1; + } - return 0; + return 0; } /** @@ -558,31 +522,27 @@ */ int LPS22HHSensor::set_fifo_interrupt(uint8_t interrupt) { - switch (interrupt) - { - case 0: - if (lps22hh_fifo_threshold_on_int_set(&_reg_ctx, PROPERTY_ENABLE) != 0) - { - return 1; - } - break; - case 1: - if (lps22hh_fifo_full_on_int_set(&_reg_ctx, PROPERTY_ENABLE) != 0) - { - return 1; - } - break; - case 2: - if (lps22hh_fifo_ovr_on_int_set(&_reg_ctx, PROPERTY_ENABLE) != 0) - { - return 1; - } - break; - default: - return 1; - } + switch (interrupt) { + case 0: + if (lps22hh_fifo_threshold_on_int_set(&_reg_ctx, PROPERTY_ENABLE) != 0) { + return 1; + } + break; + case 1: + if (lps22hh_fifo_full_on_int_set(&_reg_ctx, PROPERTY_ENABLE) != 0) { + return 1; + } + break; + case 2: + if (lps22hh_fifo_ovr_on_int_set(&_reg_ctx, PROPERTY_ENABLE) != 0) { + return 1; + } + break; + default: + return 1; + } - return 0; + return 0; } /** @@ -592,26 +552,24 @@ */ int LPS22HHSensor::set_fifo_mode(uint8_t mode) { - /* Verify that the passed parameter contains one of the valid values */ - switch ((lps22hh_f_mode_t)mode) - { - case LPS22HH_BYPASS_MODE: - case LPS22HH_FIFO_MODE: - case LPS22HH_STREAM_MODE: - case LPS22HH_STREAM_TO_FIFO_MODE: - case LPS22HH_BYPASS_TO_STREAM_MODE: - case LPS22HH_BYPASS_TO_FIFO_MODE: - break; - default: - return 1; - } + /* Verify that the passed parameter contains one of the valid values */ + switch ((lps22hh_f_mode_t)mode) { + case LPS22HH_BYPASS_MODE: + case LPS22HH_FIFO_MODE: + case LPS22HH_STREAM_MODE: + case LPS22HH_STREAM_TO_FIFO_MODE: + case LPS22HH_BYPASS_TO_STREAM_MODE: + case LPS22HH_BYPASS_TO_FIFO_MODE: + break; + default: + return 1; + } - if (lps22hh_fifo_mode_set(&_reg_ctx, (lps22hh_f_mode_t)mode) != 0) - { - return 1; - } + if (lps22hh_fifo_mode_set(&_reg_ctx, (lps22hh_f_mode_t)mode) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -621,12 +579,11 @@ */ int LPS22HHSensor::set_fifo_watermark_level(uint8_t watermark) { - if (lps22hh_fifo_watermark_set(&_reg_ctx, watermark) != 0) - { - return 1; - } + if (lps22hh_fifo_watermark_set(&_reg_ctx, watermark) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -636,12 +593,11 @@ */ int LPS22HHSensor::stop_fifo_on_watermark(uint8_t stop) { - if (lps22hh_fifo_stop_on_wtm_set(&_reg_ctx, stop) != 0) - { - return 1; - } + if (lps22hh_fifo_stop_on_wtm_set(&_reg_ctx, stop) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -650,13 +606,12 @@ */ int LPS22HHSensor::set_one_shot() { - /* Start One Shot Measurement */ - if(lps22hh_data_rate_set(&_reg_ctx, LPS22HH_ONE_SHOOT) != 0) - { - return 1; - } + /* Start One Shot Measurement */ + if (lps22hh_data_rate_set(&_reg_ctx, LPS22HH_ONE_SHOOT) != 0) { + return 1; + } - return 0; + return 0; } /** @@ -666,39 +621,34 @@ */ int LPS22HHSensor::get_one_shot_status(uint8_t *status) { - uint8_t p_da; - uint8_t t_da; + uint8_t p_da; + uint8_t t_da; - /* Get DataReady for pressure */ - if(lps22hh_press_flag_data_ready_get(&_reg_ctx, &p_da) != 0) - { - return 1; - } + /* Get DataReady for pressure */ + if (lps22hh_press_flag_data_ready_get(&_reg_ctx, &p_da) != 0) { + return 1; + } - /* Get DataReady for temperature */ - if(lps22hh_temp_flag_data_ready_get(&_reg_ctx, &t_da) != 0) - { - return 1; - } + /* Get DataReady for temperature */ + if (lps22hh_temp_flag_data_ready_get(&_reg_ctx, &t_da) != 0) { + return 1; + } - if(p_da && t_da) - { - *status = 1; - } - else - { - *status = 0; - } + if (p_da && t_da) { + *status = 1; + } else { + *status = 0; + } - return 0; + return 0; } int32_t LPS22HH_io_write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite) { - return ((LPS22HHSensor *)handle)->io_write(pBuffer, WriteAddr, nBytesToWrite); + return ((LPS22HHSensor *)handle)->io_write(pBuffer, WriteAddr, nBytesToWrite); } int32_t LPS22HH_io_read(void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead) { - return ((LPS22HHSensor *)handle)->io_read(pBuffer, ReadAddr, nBytesToRead); + return ((LPS22HHSensor *)handle)->io_read(pBuffer, ReadAddr, nBytesToRead); }