MEMS nano pressure sensor: 260-1260 hPa absolute digital output barometer.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: X_NUCLEO_IKS01A3 X_NUCLEO_IKS01A3
Revision 0:c761bc6186e8, committed 2019-03-06
- Comitter:
- cparata
- Date:
- Wed Mar 06 09:18:20 2019 +0000
- Child:
- 1:978cae936ddb
- Commit message:
- First version of LPS22HH library
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LPS22HHSensor.cpp Wed Mar 06 09:18:20 2019 +0000
@@ -0,0 +1,704 @@
+/**
+ ******************************************************************************
+ * @file LPS22HHSensor.cpp
+ * @author SRA
+ * @version V1.0.0
+ * @date February 2019
+ * @brief Implementation of a LPS22HH pressure sensor.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "LPS22HHSensor.h"
+
+
+/* Class Implementation ------------------------------------------------------*/
+
+/** Constructor
+ * @param spi object of an helper class which handles the SPI peripheral
+ * @param cs_pin the chip select pin
+ * @param int_pin the interrupt pin
+ * @param spi_type the SPI type
+ */
+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;
+ }
+
+ _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
+ * @param i2c object of an helper class which handles the I2C peripheral
+ * @param address the address of the component's instance
+ * @param int_pin the interrupt pin
+ */
+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;
+}
+
+
+/**
+ * @brief Initializing the component
+ * @param init pointer to device specific initalization structure
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::init(void *init)
+{
+ /* Disable MIPI I3C(SM) interface */
+ 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;
+ }
+
+ /* 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 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;
+
+ return 0;
+}
+
+/**
+ * @brief Get WHO_AM_I value
+ * @param id the WHO_AM_I value
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::read_id(uint8_t *id)
+{
+ if (lps22hh_device_id_get(&_reg_ctx, id) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Enable the LPS22HH pressure sensor
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::enable()
+{
+ /* 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;
+ }
+
+ _is_enabled = 1;
+
+ return 0;
+}
+
+/**
+ * @brief Disable the LPS22HH pressure sensor
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::disable()
+{
+ /* 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;
+ }
+
+
+ _is_enabled = 0;
+
+ return 0;
+}
+
+
+/**
+ * @brief Get output data rate
+ * @param odr the output data rate value
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_odr(float *odr)
+{
+ int ret = 0;
+ lps22hh_odr_t odr_low_level;
+
+ 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;
+
+ case LPS22HH_1_Hz:
+ *odr = 1.0f;
+ break;
+
+ case LPS22HH_10_Hz:
+ *odr = 10.0f;
+ break;
+
+ case LPS22HH_25_Hz:
+ *odr = 25.0f;
+ break;
+
+ case LPS22HH_50_Hz:
+ *odr = 50.0f;
+ break;
+
+ case LPS22HH_75_Hz:
+ *odr = 75.0f;
+ break;
+
+ case LPS22HH_100_Hz:
+ *odr = 100.0f;
+ break;
+
+ case LPS22HH_200_Hz:
+ *odr = 200.0f;
+ break;
+
+ default:
+ ret = 1;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Set the LPS22HH pressure sensor output data rate
+ * @param odr the output data rate value to be set
+ * @retval 0 in case of success, an error code otherwise
+ */
+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);
+ }
+}
+
+
+/**
+ * @brief Set output data rate
+ * @param odr the output data rate value to be set
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::set_odr_when_enabled(float 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;
+
+ if (lps22hh_data_rate_set(&_reg_ctx, new_odr) != 0)
+ {
+ return 1;
+ }
+
+ if (lps22hh_data_rate_get(&_reg_ctx, &_last_odr) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Set output data rate when disabled
+ * @param odr the output data rate value to be set
+ * @retval 0 in case of success, an error code otherwise
+ */
+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;
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH pressure value
+ * @param value pointer where the pressure value is written
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_pressure(float *value)
+{
+ 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;
+ }
+
+ *value = LPS22HH_FROM_LSB_TO_hPa((float)(data_raw_pressure.i32bit));
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH pressure data ready bit value
+ * @param status the status of data ready bit
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_press_drdy_status(uint8_t *status)
+{
+ if (lps22hh_press_flag_data_ready_get(&_reg_ctx, status) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH temperature value
+ * @param value pointer where the temperature value is written
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_temperature(float *value)
+{
+ 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;
+ }
+
+ *value = LPS22HH_FROM_LSB_TO_degC((float)(data_raw_temperature.i16bit));
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH temperature data ready bit value
+ * @param status the status of data ready bit
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_temp_drdy_status(uint8_t *status)
+{
+ if (lps22hh_temp_flag_data_ready_get(&_reg_ctx, status) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH register value
+ * @param reg address to be written
+ * @param data value to be written
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::read_reg(uint8_t reg, uint8_t *data)
+{
+ if (lps22hh_read_reg(&_reg_ctx, reg, data, 1) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Set the LPS22HH register value
+ * @param reg address to be written
+ * @param data value to be written
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::write_reg(uint8_t reg, uint8_t data)
+{
+ if (lps22hh_write_reg(&_reg_ctx, reg, &data, 1) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH FIFO data
+ * @param press the pointer where FIFO pressure value is stored
+ * @param temp the pointer where FIFO temperature value is stored
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_fifo_data(float *press, float *temp)
+{
+ 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;
+ }
+
+ *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;
+ }
+
+ *temp = LPS22HH_FROM_LSB_TO_degC((float)(data_raw_temperature.i16bit));
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH FIFO threshold
+ * @param status the status of FIFO threshold
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_fifo_fth_status(uint8_t *status)
+{
+ if (lps22hh_fifo_wtm_flag_get(&_reg_ctx, status) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH FIFO full status
+ * @param status the status of FIFO full status
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_fifo_full_status(uint8_t *status)
+{
+ if (lps22hh_fifo_full_flag_get(&_reg_ctx, status) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH FIFO OVR status
+ * @param status the status of FIFO OVR status
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_fifo_ovr_status(uint8_t *status)
+{
+ if (lps22hh_fifo_ovr_flag_get(&_reg_ctx, status) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH FIFO data level
+ * @param status the status of FIFO data level
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_fifo_level(uint8_t *status)
+{
+ if (lps22hh_fifo_data_level_get(&_reg_ctx, status) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Reset the FIFO interrupt
+ * @param interrupt The FIFO interrupt to be reset; values: 0 = FTH; 1 = FULL; 2 = OVR
+ * @retval 0 in case of success, an error code otherwise
+ */
+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;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Set the FIFO interrupt
+ * @param interrupt The FIFO interrupt to be set; values: 0 = FTH; 1 = FULL; 2 = OVR
+ * @retval 0 in case of success, an error code otherwise
+ */
+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;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Set the FIFO mode
+ * @param Mode the FIFO mode to be set
+ * @retval 0 in case of success, an error code otherwise
+ */
+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;
+ }
+
+ if (lps22hh_fifo_mode_set(&_reg_ctx, (lps22hh_f_mode_t)mode) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Set the LPS22HH FIFO watermark level
+ * @param watermark the FIFO watermark level to be set
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::set_fifo_watermark_level(uint8_t watermark)
+{
+ if (lps22hh_fifo_watermark_set(&_reg_ctx, watermark) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Set the LPS22HH stop on watermark function
+ * @param stop the state of stop on watermark function
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::stop_fifo_on_watermark(uint8_t stop)
+{
+ if (lps22hh_fifo_stop_on_wtm_set(&_reg_ctx, stop) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Set the LPS22HH One Shot Mode
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::set_one_shot()
+{
+ /* Start One Shot Measurement */
+ if(lps22hh_data_rate_set(&_reg_ctx, LPS22HH_ONE_SHOOT) != 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Get the LPS22HH One Shot Status
+ * @param status pointer to the one shot status (1 means measurements available, 0 means measurements not available yet)
+ * @retval 0 in case of success, an error code otherwise
+ */
+int LPS22HHSensor::get_one_shot_status(uint8_t *status)
+{
+ 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 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;
+ }
+
+ 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);
+}
+
+int32_t LPS22HH_io_read(void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead)
+{
+ return ((LPS22HHSensor *)handle)->io_read(pBuffer, ReadAddr, nBytesToRead);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LPS22HHSensor.h Wed Mar 06 09:18:20 2019 +0000
@@ -0,0 +1,205 @@
+/**
+ ******************************************************************************
+ * @file LPS22HHSensor.h
+ * @author SRA
+ * @version V1.0.0
+ * @date February 2019
+ * @brief Abstract Class of a LPS22HH pressure sensor.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+
+/* Prevent recursive inclusion -----------------------------------------------*/
+
+#ifndef __LPS22HHSensor_H__
+#define __LPS22HHSensor_H__
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "DevI2C.h"
+#include "lps22hh_reg.h"
+#include "PressureSensor.h"
+#include "TempSensor.h"
+#include <assert.h>
+
+/* Defines -------------------------------------------------------------------*/
+/* Typedefs ------------------------------------------------------------------*/
+/* Class Declaration ---------------------------------------------------------*/
+
+/**
+ * Abstract class of a LPS22HH pressure sensor.
+ */
+class LPS22HHSensor : public PressureSensor, public TempSensor
+{
+ public:
+ enum SPI_type_t {SPI3W, SPI4W};
+ LPS22HHSensor(SPI *spi, PinName cs_pin, PinName int_pin=NC, SPI_type_t spi_type=SPI4W);
+ LPS22HHSensor(DevI2C *i2c, uint8_t address=LPS22HH_I2C_ADD_H, PinName int_pin=NC);
+ virtual int init(void *init);
+ virtual int read_id(uint8_t *id);
+ virtual int get_pressure(float *value);
+ virtual int get_temperature(float *value);
+ int enable(void);
+ int disable(void);
+ int get_odr(float *odr);
+ int set_odr(float odr);
+ int read_reg(uint8_t reg, uint8_t *data);
+ int write_reg(uint8_t reg, uint8_t data);
+ int get_press_drdy_status(uint8_t *status);
+ int get_temp_drdy_status(uint8_t *status);
+ int get_fifo_data(float *press, float *temp);
+ int get_fifo_fth_status(uint8_t *status);
+ int get_fifo_full_status(uint8_t *status);
+ int get_fifo_ovr_status(uint8_t *status);
+ int get_fifo_level(uint8_t *status);
+ int reset_fifo_interrupt(uint8_t interrupt);
+ int set_fifo_interrupt(uint8_t interrupt);
+ int set_fifo_mode(uint8_t mode);
+ int set_fifo_watermark_level(uint8_t watermark);
+ int stop_fifo_on_watermark(uint8_t stop);
+ int set_one_shot();
+ int get_one_shot_status(uint8_t *status);
+
+ /**
+ * @brief Attaching an interrupt handler to the INT interrupt.
+ * @param fptr an interrupt handler.
+ * @retval None.
+ */
+ void attach_int_irq(void (*fptr)(void))
+ {
+ _int_irq.rise(fptr);
+ }
+
+ /**
+ * @brief Enabling the INT interrupt handling.
+ * @param None.
+ * @retval None.
+ */
+ void enable_int_irq(void)
+ {
+ _int_irq.enable_irq();
+ }
+
+ /**
+ * @brief Disabling the INT interrupt handling.
+ * @param None.
+ * @retval None.
+ */
+ void disable_int_irq(void)
+ {
+ _int_irq.disable_irq();
+ }
+
+
+ /**
+ * @brief Utility function to read data.
+ * @param pBuffer: pointer to data to be read.
+ * @param RegisterAddr: specifies internal address register to be read.
+ * @param NumByteToRead: number of bytes to be read.
+ * @retval 0 if ok, an error code otherwise.
+ */
+ uint8_t io_read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead)
+ {
+ if (_dev_spi) {
+ /* Write Reg Address */
+ _dev_spi->lock();
+ _cs_pin = 0;
+ if (_spi_type == SPI4W) {
+ _dev_spi->write(RegisterAddr | 0x80);
+ for (int i=0; i<NumByteToRead; i++) {
+ *(pBuffer+i) = _dev_spi->write(0x00);
+ }
+ } else if (_spi_type == SPI3W){
+ /* Write RD Reg Address with RD bit*/
+ uint8_t TxByte = RegisterAddr | 0x80;
+ _dev_spi->write((char *)&TxByte, 1, (char *)pBuffer, (int) NumByteToRead);
+ }
+ _cs_pin = 1;
+ _dev_spi->unlock();
+ return 0;
+ }
+ if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead);
+ return 1;
+ }
+
+ /**
+ * @brief Utility function to write data.
+ * @param pBuffer: pointer to data to be written.
+ * @param RegisterAddr: specifies internal address register to be written.
+ * @param NumByteToWrite: number of bytes to write.
+ * @retval 0 if ok, an error code otherwise.
+ */
+ uint8_t io_write(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite)
+ {
+ if (_dev_spi) {
+ _dev_spi->lock();
+ _cs_pin = 0;
+ _dev_spi->write(RegisterAddr);
+ _dev_spi->write((char *)pBuffer, (int) NumByteToWrite, NULL, 0);
+ _cs_pin = 1;
+ _dev_spi->unlock();
+ return 0;
+ }
+ if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite);
+ return 1;
+ }
+
+ private:
+ int set_odr_when_enabled(float odr);
+ int set_odr_when_disabled(float odr);
+
+ /* Helper classes. */
+ DevI2C *_dev_i2c;
+ SPI *_dev_spi;
+
+ /* Configuration */
+ uint8_t _address;
+ DigitalOut _cs_pin;
+ InterruptIn _int_irq;
+ SPI_type_t _spi_type;
+
+ uint8_t _is_enabled;
+ lps22hh_odr_t _last_odr;
+
+ lps22hh_ctx_t _reg_ctx;
+
+};
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+int32_t LPS22HH_io_write( void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite );
+int32_t LPS22HH_io_read( void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead );
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ST_INTERFACES.lib Wed Mar 06 09:18:20 2019 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/ST_INTERFACES/#d3c9b33b992c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_COMMON.lib Wed Mar 06 09:18:20 2019 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/X_NUCLEO_COMMON/#21096473f63e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lps22hh_reg.c Wed Mar 06 09:18:20 2019 +0000
@@ -0,0 +1,1829 @@
+/*
+ ******************************************************************************
+ * @file lps22hh_reg.c
+ * @author Sensors Software Solution Team
+ * @brief LPS22HH driver file
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+
+#include "lps22hh_reg.h"
+
+/**
+ * @defgroup LPS22HH
+ * @brief This file provides a set of functions needed to drive the
+ * lps22hh enhanced inertial module.
+ * @{
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Interfaces_Functions
+ * @brief This section provide a set of functions used to read and
+ * write a generic register of the device.
+ * MANDATORY: return 0 -> no Error.
+ * @{
+ *
+ */
+
+/**
+ * @brief Read generic device register
+ *
+ * @param ctx read / write interface definitions(ptr)
+ * @param reg register to read
+ * @param data pointer to buffer that store the data read(ptr)
+ * @param len number of consecutive register to read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_read_reg(lps22hh_ctx_t* ctx, uint8_t reg, uint8_t* data,
+ uint16_t len)
+{
+ int32_t ret;
+ ret = ctx->read_reg(ctx->handle, reg, data, len);
+ return ret;
+}
+
+/**
+ * @brief Write generic device register
+ *
+ * @param ctx read / write interface definitions(ptr)
+ * @param reg register to write
+ * @param data pointer to data to write in register reg(ptr)
+ * @param len number of consecutive register to write
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_write_reg(lps22hh_ctx_t* ctx, uint8_t reg, uint8_t* data,
+ uint16_t len)
+{
+ int32_t ret;
+ ret = ctx->write_reg(ctx->handle, reg, data, len);
+ return ret;
+}
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Sensitivity
+ * @brief These functions convert raw-data into engineering units.
+ * @{
+ *
+ */
+float lps22hh_from_lsb_to_hpa(int16_t lsb)
+{
+ return ( (float) lsb / 4096.0f );
+}
+
+float lps22hh_from_lsb_to_celsius(int16_t lsb)
+{
+ return ( (float) lsb / 100.0f );
+}
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Data_Generation
+ * @brief This section groups all the functions concerning
+ * data generation.
+ * @{
+ *
+ */
+
+/**
+ * @brief Reset Autozero function.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of reset_az in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_autozero_rst_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.reset_az = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Reset Autozero function.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of reset_az in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_autozero_rst_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ *val = reg.reset_az;
+
+ return ret;
+}
+
+/**
+ * @brief Enable Autozero function.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of autozero in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_autozero_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.autozero = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Enable Autozero function.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of autozero in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_autozero_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ *val = reg.autozero;
+
+ return ret;
+}
+
+/**
+ * @brief Reset AutoRifP function.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of reset_arp in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pressure_snap_rst_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.reset_arp = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Reset AutoRifP function.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of reset_arp in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pressure_snap_rst_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ *val = reg.reset_arp;
+
+ return ret;
+}
+
+/**
+ * @brief Enable AutoRefP function.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of autorefp in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pressure_snap_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.autorefp = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Enable AutoRefP function.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of autorefp in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pressure_snap_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ *val = reg.autorefp;
+
+ return ret;
+}
+
+/**
+ * @brief Block Data Update.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of bdu in reg CTRL_REG1
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_block_data_update_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_ctrl_reg1_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.bdu = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Block Data Update.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of bdu in reg CTRL_REG1
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_block_data_update_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_ctrl_reg1_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*) ®, 1);
+ *val = reg.bdu;
+
+ return ret;
+}
+
+/**
+ * @brief Output data rate selection.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of odr in reg CTRL_REG1
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_data_rate_set(lps22hh_ctx_t *ctx, lps22hh_odr_t val)
+{
+ lps22hh_ctrl_reg1_t ctrl_reg1;
+ lps22hh_ctrl_reg2_t ctrl_reg2;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*)&ctrl_reg1, 1);
+ if (ret == 0) {
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*)&ctrl_reg2, 1);
+ }
+ if (ret == 0) {
+ ctrl_reg1.odr = (uint8_t)val & 0x07U;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*)&ctrl_reg1, 1);
+ }
+ if (ret == 0) {
+ ctrl_reg2.low_noise_en = ((uint8_t)val & 0x10U) >> 4;
+ ctrl_reg2.one_shot = ((uint8_t)val & 0x08U) >> 3;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*)&ctrl_reg2, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Output data rate selection.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of odr in reg CTRL_REG1
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_data_rate_get(lps22hh_ctx_t *ctx, lps22hh_odr_t *val)
+{
+ lps22hh_ctrl_reg1_t ctrl_reg1;
+ lps22hh_ctrl_reg2_t ctrl_reg2;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*)&ctrl_reg1, 1);
+ if (ret == 0) {
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*)&ctrl_reg2, 1);
+ }
+ if (ret == 0) {
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*)&ctrl_reg2, 1);
+ switch (((ctrl_reg2.low_noise_en << 4) + (ctrl_reg2.one_shot << 3) +
+ ctrl_reg1.odr )) {
+ case LPS22HH_POWER_DOWN:
+ *val = LPS22HH_POWER_DOWN;
+ break;
+ case LPS22HH_ONE_SHOOT:
+ *val = LPS22HH_ONE_SHOOT;
+ break;
+ case LPS22HH_1_Hz:
+ *val = LPS22HH_1_Hz;
+ break;
+ case LPS22HH_10_Hz:
+ *val = LPS22HH_10_Hz;
+ break;
+ case LPS22HH_25_Hz:
+ *val = LPS22HH_25_Hz;
+ break;
+ case LPS22HH_50_Hz:
+ *val = LPS22HH_50_Hz;
+ break;
+ case LPS22HH_75_Hz:
+ *val = LPS22HH_75_Hz;
+ break;
+ case LPS22HH_1_Hz_LOW_NOISE:
+ *val = LPS22HH_1_Hz_LOW_NOISE;
+ break;
+ case LPS22HH_10_Hz_LOW_NOISE:
+ *val = LPS22HH_10_Hz_LOW_NOISE;
+ break;
+ case LPS22HH_25_Hz_LOW_NOISE:
+ *val = LPS22HH_25_Hz_LOW_NOISE;
+ break;
+ case LPS22HH_50_Hz_LOW_NOISE:
+ *val = LPS22HH_50_Hz_LOW_NOISE;
+ break;
+ case LPS22HH_75_Hz_LOW_NOISE:
+ *val = LPS22HH_75_Hz_LOW_NOISE;
+ break;
+ case LPS22HH_100_Hz:
+ *val = LPS22HH_100_Hz;
+ break;
+ case LPS22HH_200_Hz:
+ *val = LPS22HH_200_Hz;
+ break;
+ default:
+ *val = LPS22HH_POWER_DOWN;
+ break;
+ }
+ }
+ return ret;
+}
+
+/**
+ * @brief The Reference pressure value is a 16-bit data
+ * expressed as 2’s complement. The value is used
+ * when AUTOZERO or AUTORIFP function is enabled.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that contains data to write
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pressure_ref_set(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_write_reg(ctx, LPS22HH_REF_P_XL, buff, 2);
+ return ret;
+}
+
+/**
+ * @brief The Reference pressure value is a 16-bit
+ * data expressed as 2’s complement.
+ * The value is used when AUTOZERO or AUTORIFP
+ * function is enabled.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that stores data read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pressure_ref_get(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_REF_P_XL, buff, 2);
+ return ret;
+}
+
+/**
+ * @brief The pressure offset value is 16-bit data
+ * that can be used to implement one-point
+ * calibration (OPC) after soldering.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that contains data to write
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pressure_offset_set(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_write_reg(ctx, LPS22HH_RPDS_L, buff, 2);
+ return ret;
+}
+
+/**
+ * @brief The pressure offset value is 16-bit
+ * data that can be used to implement
+ * one-point calibration (OPC) after
+ * soldering.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that stores data read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pressure_offset_get(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_RPDS_L, buff, 2);
+ return ret;
+}
+
+/**
+ * @brief Read all the interrupt/status flag of the device.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val registers STATUS,FIFO_STATUS2,INT_SOURCE
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_all_sources_get(lps22hh_ctx_t *ctx, lps22hh_all_sources_t *val)
+{
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INT_SOURCE,
+ (uint8_t*) &(val->int_source), 1);
+ if (ret == 0) {
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2,
+ (uint8_t*) &(val->fifo_status2), 1);
+ }
+ if (ret == 0) {
+ ret = lps22hh_read_reg(ctx, LPS22HH_STATUS,
+ (uint8_t*) &(val->status), 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief The STATUS_REG register is read by the primary interface.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val structure of registers from STATUS to STATUS_REG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_status_reg_get(lps22hh_ctx_t *ctx, lps22hh_status_t *val)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_STATUS, (uint8_t*) val, 1);
+ return ret;
+}
+
+/**
+ * @brief Pressure new data available.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of p_da in reg STATUS
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_press_flag_data_ready_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_status_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_STATUS, (uint8_t*) ®, 1);
+ *val = reg.p_da;
+
+ return ret;
+}
+
+/**
+ * @brief Temperature data available.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of t_da in reg STATUS
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_temp_flag_data_ready_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_status_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_STATUS, (uint8_t*) ®, 1);
+ *val = reg.t_da;
+
+ return ret;
+}
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Data_Output
+ * @brief This section groups all the data output functions.
+ * @{
+ *
+ */
+
+/**
+ * @brief Pressure output value.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that stores data read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pressure_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_PRESSURE_OUT_XL, buff, 3);
+ return ret;
+}
+
+/**
+ * @brief Temperature output value.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that stores data read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_temperature_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_TEMP_OUT_L, buff, 2);
+ return ret;
+}
+
+/**
+ * @brief Pressure output from FIFO value.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that stores data read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_pressure_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_DATA_OUT_PRESS_XL, buff, 3);
+ return ret;
+}
+
+/**
+ * @brief Temperature output from FIFO value.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that stores data read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_temperature_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_DATA_OUT_TEMP_L, buff, 2);
+ return ret;
+}
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Common
+ * @brief This section groups common useful functions.
+ * @{
+ *
+ */
+
+/**
+ * @brief DeviceWhoamI[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that stores data read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_device_id_get(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_WHO_AM_I, buff, 1);
+ return ret;
+}
+
+/**
+ * @brief Software reset. Restore the default values
+ * in user registers.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of swreset in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_reset_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.swreset = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Software reset. Restore the default values
+ * in user registers.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of swreset in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_reset_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ *val = reg.swreset;
+
+ return ret;
+}
+
+/**
+ * @brief Register address automatically
+ * incremented during a multiple byte access
+ * with a serial interface.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of if_add_inc in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_auto_increment_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.if_add_inc = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Register address automatically
+ * incremented during a multiple byte
+ * access with a serial interface.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of if_add_inc in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_auto_increment_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ *val = reg.if_add_inc;
+
+ return ret;
+}
+
+/**
+ * @brief Reboot memory content. Reload the calibration
+ * parameters.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of boot in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_boot_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.boot = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Reboot memory content. Reload the calibration
+ * parameters.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of boot in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_boot_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ *val = reg.boot;
+
+ return ret;
+}
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Filters
+ * @brief This section group all the functions concerning the
+ * filters configuration.
+ * @{
+ *
+ */
+
+/**
+ * @brief Low-pass bandwidth selection.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of lpfp_cfg in reg CTRL_REG1
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_lp_bandwidth_set(lps22hh_ctx_t *ctx, lps22hh_lpfp_cfg_t val)
+{
+ lps22hh_ctrl_reg1_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.lpfp_cfg = (uint8_t)val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Low-pass bandwidth selection.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of lpfp_cfg in reg CTRL_REG1
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_lp_bandwidth_get(lps22hh_ctx_t *ctx, lps22hh_lpfp_cfg_t *val)
+{
+ lps22hh_ctrl_reg1_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*) ®, 1);
+ switch (reg.lpfp_cfg) {
+ case LPS22HH_LPF_ODR_DIV_2:
+ *val = LPS22HH_LPF_ODR_DIV_2;
+ break;
+ case LPS22HH_LPF_ODR_DIV_9:
+ *val = LPS22HH_LPF_ODR_DIV_9;
+ break;
+ case LPS22HH_LPF_ODR_DIV_20:
+ *val = LPS22HH_LPF_ODR_DIV_20;
+ break;
+ default:
+ *val = LPS22HH_LPF_ODR_DIV_2;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Serial_Interface
+ * @brief This section groups all the functions concerning serial
+ * interface management
+ * @{
+ *
+ */
+
+/**
+ * @brief Enable/Disable I2C interface.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of i2c_disable in reg IF_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_i2c_interface_set(lps22hh_ctx_t *ctx,
+ lps22hh_i2c_disable_t val)
+{
+ lps22hh_if_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.i2c_disable = (uint8_t)val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Enable/Disable I2C interface.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of i2c_disable in reg IF_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_i2c_interface_get(lps22hh_ctx_t *ctx,
+ lps22hh_i2c_disable_t *val)
+{
+ lps22hh_if_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ switch (reg.i2c_disable) {
+ case LPS22HH_I2C_ENABLE:
+ *val = LPS22HH_I2C_ENABLE;
+ break;
+ case LPS22HH_I2C_DISABLE:
+ *val = LPS22HH_I2C_DISABLE;
+ break;
+ default:
+ *val = LPS22HH_I2C_ENABLE;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief I3C Enable/Disable communication protocol.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of int_en_i3c in reg IF_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_i3c_interface_set(lps22hh_ctx_t *ctx,
+ lps22hh_i3c_disable_t val)
+{
+ lps22hh_if_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.i3c_disable = ((uint8_t)val & 0x01u);
+ reg.int_en_i3c = ((uint8_t)val & 0x10U) >> 4;
+ ret = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief I3C Enable/Disable communication protocol.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of int_en_i3c in reg IF_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_i3c_interface_get(lps22hh_ctx_t *ctx,
+ lps22hh_i3c_disable_t *val)
+{
+ lps22hh_if_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+
+ switch ((reg.int_en_i3c << 4) + reg.int_en_i3c) {
+ case LPS22HH_I3C_ENABLE:
+ *val = LPS22HH_I3C_ENABLE;
+ break;
+ case LPS22HH_I3C_ENABLE_INT_PIN_ENABLE:
+ *val = LPS22HH_I3C_ENABLE_INT_PIN_ENABLE;
+ break;
+ case LPS22HH_I3C_DISABLE:
+ *val = LPS22HH_I3C_DISABLE;
+ break;
+ default:
+ *val = LPS22HH_I3C_ENABLE;
+ break;
+ }
+ return ret;
+}
+
+/**
+ * @brief Enable/Disable pull-up on SDO pin.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of sdo_pu_en in reg IF_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_sdo_sa0_mode_set(lps22hh_ctx_t *ctx, lps22hh_pu_en_t val)
+{
+ lps22hh_if_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.sdo_pu_en = (uint8_t)val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Enable/Disable pull-up on SDO pin.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of sdo_pu_en in reg IF_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_sdo_sa0_mode_get(lps22hh_ctx_t *ctx, lps22hh_pu_en_t *val)
+{
+ lps22hh_if_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ switch (reg.sdo_pu_en) {
+ case LPS22HH_PULL_UP_DISCONNECT:
+ *val = LPS22HH_PULL_UP_DISCONNECT;
+ break;
+ case LPS22HH_PULL_UP_CONNECT:
+ *val = LPS22HH_PULL_UP_CONNECT;
+ break;
+ default:
+ *val = LPS22HH_PULL_UP_DISCONNECT;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Connect/Disconnect SDO/SA0 internal pull-up.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of sda_pu_en in reg IF_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_sda_mode_set(lps22hh_ctx_t *ctx, lps22hh_pu_en_t val)
+{
+ lps22hh_if_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.sda_pu_en = (uint8_t)val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Connect/Disconnect SDO/SA0 internal pull-up.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of sda_pu_en in reg IF_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_sda_mode_get(lps22hh_ctx_t *ctx, lps22hh_pu_en_t *val)
+{
+ lps22hh_if_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t*) ®, 1);
+ switch (reg.sda_pu_en) {
+ case LPS22HH_PULL_UP_DISCONNECT:
+ *val = LPS22HH_PULL_UP_DISCONNECT;
+ break;
+ case LPS22HH_PULL_UP_CONNECT:
+ *val = LPS22HH_PULL_UP_CONNECT;
+ break;
+ default:
+ *val = LPS22HH_PULL_UP_DISCONNECT;
+ break;
+ }
+ return ret;
+}
+
+/**
+ * @brief SPI Serial Interface Mode selection.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of sim in reg CTRL_REG1
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_spi_mode_set(lps22hh_ctx_t *ctx, lps22hh_sim_t val)
+{
+ lps22hh_ctrl_reg1_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.sim = (uint8_t)val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief SPI Serial Interface Mode selection.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of sim in reg CTRL_REG1
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_spi_mode_get(lps22hh_ctx_t *ctx, lps22hh_sim_t *val)
+{
+ lps22hh_ctrl_reg1_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t*) ®, 1);
+ switch (reg.sim) {
+ case LPS22HH_SPI_4_WIRE:
+ *val = LPS22HH_SPI_4_WIRE;
+ break;
+ case LPS22HH_SPI_3_WIRE:
+ *val = LPS22HH_SPI_3_WIRE;
+ break;
+ default:
+ *val = LPS22HH_SPI_4_WIRE;
+ break;
+ }
+ return ret;
+}
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Interrupt_Pins
+ * @brief This section groups all the functions that manage
+ * interrupt pins.
+ * @{
+ *
+ */
+
+/**
+ * @brief Latch interrupt request to the INT_SOURCE (24h) register.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of lir in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_int_notification_set(lps22hh_ctx_t *ctx, lps22hh_lir_t val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.lir = (uint8_t)val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Latch interrupt request to the INT_SOURCE (24h) register.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of lir in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_int_notification_get(lps22hh_ctx_t *ctx, lps22hh_lir_t *val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+
+ switch (reg.lir) {
+ case LPS22HH_INT_PULSED:
+ *val = LPS22HH_INT_PULSED;
+ break;
+ case LPS22HH_INT_LATCHED:
+ *val = LPS22HH_INT_LATCHED;
+ break;
+ default:
+ *val = LPS22HH_INT_PULSED;
+ break;
+ }
+ return ret;
+}
+
+/**
+ * @brief Push-pull/open drain selection on interrupt pads.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of pp_od in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pin_mode_set(lps22hh_ctx_t *ctx, lps22hh_pp_od_t val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.pp_od = (uint8_t)val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Push-pull/open drain selection on interrupt pads.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of pp_od in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pin_mode_get(lps22hh_ctx_t *ctx, lps22hh_pp_od_t *val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+
+
+ switch (reg.pp_od) {
+ case LPS22HH_PUSH_PULL:
+ *val = LPS22HH_PUSH_PULL;
+ break;
+ case LPS22HH_OPEN_DRAIN:
+ *val = LPS22HH_OPEN_DRAIN;
+ break;
+ default:
+ *val = LPS22HH_PUSH_PULL;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Interrupt active-high/low.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of int_h_l in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pin_polarity_set(lps22hh_ctx_t *ctx, lps22hh_int_h_l_t val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.int_h_l = (uint8_t)val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Interrupt active-high/low.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of int_h_l in reg CTRL_REG2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pin_polarity_get(lps22hh_ctx_t *ctx, lps22hh_int_h_l_t *val)
+{
+ lps22hh_ctrl_reg2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t*) ®, 1);
+
+ switch (reg.int_h_l) {
+ case LPS22HH_ACTIVE_HIGH:
+ *val = LPS22HH_ACTIVE_HIGH;
+ break;
+ case LPS22HH_ACTIVE_LOW:
+ *val = LPS22HH_ACTIVE_LOW;
+ break;
+ default:
+ *val = LPS22HH_ACTIVE_HIGH;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Select the signal that need to route on int pad.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val registers CTRL_REG3
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pin_int_route_set(lps22hh_ctx_t *ctx,
+ lps22hh_ctrl_reg3_t *val)
+{
+ int32_t ret;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t*) val, 1);
+ return ret;
+}
+
+/**
+ * @brief Select the signal that need to route on int pad.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val registers CTRL_REG3
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_pin_int_route_get(lps22hh_ctx_t *ctx,
+ lps22hh_ctrl_reg3_t *val)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t*) val, 1);
+ return ret;
+}
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Interrupt_on_Threshold
+ * @brief This section groups all the functions that manage the
+ * interrupt on threshold event generation.
+ * @{
+ *
+ */
+
+/**
+ * @brief Enable interrupt generation on pressure low/high event.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of pe in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_int_on_threshold_set(lps22hh_ctx_t *ctx, lps22hh_pe_t val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.pe = (uint8_t)val;
+
+ if (val == LPS22HH_NO_THRESHOLD){
+ reg.diff_en = PROPERTY_DISABLE;
+ }
+ else{
+ reg.diff_en = PROPERTY_ENABLE;
+ }
+ ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Enable interrupt generation on pressure low/high event.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of pe in reg INTERRUPT_CFG
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_int_on_threshold_get(lps22hh_ctx_t *ctx, lps22hh_pe_t *val)
+{
+ lps22hh_interrupt_cfg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t*) ®, 1);
+
+ switch (reg.pe) {
+ case LPS22HH_NO_THRESHOLD:
+ *val = LPS22HH_NO_THRESHOLD;
+ break;
+ case LPS22HH_POSITIVE:
+ *val = LPS22HH_POSITIVE;
+ break;
+ case LPS22HH_NEGATIVE:
+ *val = LPS22HH_NEGATIVE;
+ break;
+ case LPS22HH_BOTH:
+ *val = LPS22HH_BOTH;
+ break;
+ default:
+ *val = LPS22HH_NO_THRESHOLD;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief User-defined threshold value for pressure interrupt event.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that contains data to write
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_int_treshold_set(lps22hh_ctx_t *ctx, uint16_t buff)
+{
+ int32_t ret;
+ lps22hh_ths_p_l_t ths_p_l;
+ lps22hh_ths_p_h_t ths_p_h;
+
+ ths_p_l.ths = (uint8_t)(buff & 0x00FFU);
+ ths_p_h.ths = (uint8_t)((buff & 0x7F00U) >> 8);
+
+ ret = lps22hh_write_reg(ctx, LPS22HH_THS_P_L,
+ (uint8_t*)&ths_p_l, 1);
+ if (ret == 0) {
+ ret = lps22hh_write_reg(ctx, LPS22HH_THS_P_H,
+ (uint8_t*)&ths_p_h, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief User-defined threshold value for pressure interrupt event.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that stores data read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_int_treshold_get(lps22hh_ctx_t *ctx, uint16_t *buff)
+{
+ int32_t ret;
+ lps22hh_ths_p_l_t ths_p_l;
+ lps22hh_ths_p_h_t ths_p_h;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_THS_P_L,
+ (uint8_t*)&ths_p_l, 1);
+ if (ret == 0) {
+ ret = lps22hh_read_reg(ctx, LPS22HH_THS_P_H,
+ (uint8_t*)&ths_p_h, 1);
+ *buff = (uint16_t)ths_p_h.ths << 8;
+ *buff |= (uint16_t)ths_p_l.ths;
+ }
+ return ret;
+}
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @defgroup LPS22HH_Fifo
+ * @brief This section group all the functions concerning the fifo usage.
+ * @{
+ *
+ */
+
+/**
+ * @brief Fifo Mode selection.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of f_mode in reg FIFO_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_mode_set(lps22hh_ctx_t *ctx, lps22hh_f_mode_t val)
+{
+ lps22hh_fifo_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.f_mode = (uint8_t)val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Fifo Mode selection.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val Get the values of f_mode in reg FIFO_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_mode_get(lps22hh_ctx_t *ctx, lps22hh_f_mode_t *val)
+{
+ lps22hh_fifo_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t*) ®, 1);
+
+ switch (reg.f_mode) {
+ case LPS22HH_BYPASS_MODE:
+ *val = LPS22HH_BYPASS_MODE;
+ break;
+ case LPS22HH_FIFO_MODE:
+ *val = LPS22HH_FIFO_MODE;
+ break;
+ case LPS22HH_STREAM_MODE:
+ *val = LPS22HH_STREAM_MODE;
+ break;
+ case LPS22HH_DYNAMIC_STREAM_MODE:
+ *val = LPS22HH_DYNAMIC_STREAM_MODE;
+ break;
+ case LPS22HH_BYPASS_TO_FIFO_MODE:
+ *val = LPS22HH_BYPASS_TO_FIFO_MODE;
+ break;
+ case LPS22HH_BYPASS_TO_STREAM_MODE:
+ *val = LPS22HH_BYPASS_TO_STREAM_MODE;
+ break;
+ case LPS22HH_STREAM_TO_FIFO_MODE:
+ *val = LPS22HH_STREAM_TO_FIFO_MODE;
+ break;
+ default:
+ *val = LPS22HH_BYPASS_MODE;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Sensing chain FIFO stop values memorization at
+ * threshold level.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of stop_on_wtm in reg FIFO_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_stop_on_wtm_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_fifo_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.stop_on_wtm = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief Sensing chain FIFO stop values memorization at threshold
+ * level.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of stop_on_wtm in reg FIFO_CTRL
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_stop_on_wtm_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_fifo_ctrl_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t*) ®, 1);
+ *val = reg.stop_on_wtm;
+
+ return ret;
+}
+
+/**
+ * @brief FIFO watermark level selection.[set]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of wtm in reg FIFO_WTM
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_watermark_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_fifo_wtm_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_WTM, (uint8_t*) ®, 1);
+ if (ret == 0) {
+ reg.wtm = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_FIFO_WTM, (uint8_t*) ®, 1);
+ }
+ return ret;
+}
+
+/**
+ * @brief FIFO watermark level selection.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of wtm in reg FIFO_WTM
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_watermark_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_fifo_wtm_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_WTM, (uint8_t*) ®, 1);
+ *val = reg.wtm;
+
+ return ret;
+}
+
+/**
+ * @brief FIFO stored data level.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param buff buffer that stores data read
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_data_level_get(lps22hh_ctx_t *ctx, uint8_t *buff)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS1, buff, 1);
+ return ret;
+}
+
+/**
+ * @brief Read all the FIFO status flag of the device.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val registers FIFO_STATUS2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_src_get(lps22hh_ctx_t *ctx, lps22hh_fifo_status2_t *val)
+{
+ int32_t ret;
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t*) val, 1);
+ return ret;
+}
+
+/**
+ * @brief Smart FIFO full status.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of fifo_full_ia in reg FIFO_STATUS2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_full_flag_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_fifo_status2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t*) ®, 1);
+ *val = reg.fifo_full_ia;
+
+ return ret;
+}
+
+/**
+ * @brief FIFO overrun status.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of fifo_ovr_ia in reg FIFO_STATUS2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_ovr_flag_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_fifo_status2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t*) ®, 1);
+ *val = reg.fifo_ovr_ia;
+
+ return ret;
+}
+
+/**
+ * @brief FIFO watermark status.[get]
+ *
+ * @param ctx read / write interface definitions
+ * @param val change the values of fifo_wtm_ia in reg FIFO_STATUS2
+ * @retval interface status (MANDATORY: return 0 -> no Error)
+ *
+ */
+int32_t lps22hh_fifo_wtm_flag_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_fifo_status2_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t*) ®, 1);
+ *val = reg.fifo_wtm_ia;
+
+ return ret;
+}
+
+/**
+ * @brief FIFO overrun interrupt on INT_DRDY pin.[set]
+ *
+ * @param lps22hh_ctx_t *ctx: read / write interface definitions
+ * @param uint8_t val: change the values of f_ovr in reg CTRL_REG3
+ *
+ */
+int32_t lps22hh_fifo_ovr_on_int_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_reg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, &(reg.byte), 1);
+ reg.ctrl_reg3.int_f_ovr = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG3, &(reg.byte), 1);
+
+ return ret;
+}
+
+/**
+ * @brief FIFO overrun interrupt on INT_DRDY pin.[get]
+ *
+ * @param lps22hh_ctx_t *ctx: read / write interface definitions
+ * @param uint8_t: change the values of f_ovr in reg CTRL_REG3
+ *
+ */
+int32_t lps22hh_fifo_ovr_on_int_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_reg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, &(reg.byte), 1);
+ *val = reg.ctrl_reg3.int_f_ovr;
+
+ return ret;
+}
+
+/**
+ * @brief FIFO watermark status on INT_DRDY pin.[set]
+ *
+ * @param lps22hh_ctx_t *ctx: read / write interface definitions
+ * @param uint8_t val: change the values of f_fth in reg CTRL_REG3
+ *
+ */
+int32_t lps22hh_fifo_threshold_on_int_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_reg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, &(reg.byte), 1);
+ reg.ctrl_reg3.int_f_wtm = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG3, &(reg.byte), 1);
+
+ return ret;
+}
+
+/**
+ * @brief FIFO watermark status on INT_DRDY pin.[get]
+ *
+ * @param lps22hb_ctx_t *ctx: read / write interface definitions
+ * @param uint8_t: change the values of f_fth in reg CTRL_REG3
+ *
+ */
+int32_t lps22hh_fifo_threshold_on_int_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_reg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, &(reg.byte), 1);
+ *val = reg.ctrl_reg3.int_f_wtm;
+
+ return ret;
+}
+
+/**
+ * @brief FIFO full flag on INT_DRDY pin.[set]
+ *
+ * @param lps22hh_ctx_t *ctx: read / write interface definitions
+ * @param uint8_t val: change the values of f_fss5 in reg CTRL_REG3
+ *
+ */
+int32_t lps22hh_fifo_full_on_int_set(lps22hh_ctx_t *ctx, uint8_t val)
+{
+ lps22hh_reg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, &(reg.byte), 1);
+ reg.ctrl_reg3.int_f_full = val;
+ ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG3, &(reg.byte), 1);
+
+ return ret;
+}
+
+/**
+ * @brief FIFO full flag on INT_DRDY pin.[get]
+ *
+ * @param lps22hh_ctx_t *ctx: read / write interface definitions
+ * @param uint8_t: change the values of f_fss5 in reg CTRL_REG3
+ *
+ */
+int32_t lps22hh_fifo_full_on_int_get(lps22hh_ctx_t *ctx, uint8_t *val)
+{
+ lps22hh_reg_t reg;
+ int32_t ret;
+
+ ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, &(reg.byte), 1);
+ *val = reg.ctrl_reg3.int_f_full;
+
+ return ret;
+}
+
+/**
+ * @}
+ *
+ */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lps22hh_reg.h Wed Mar 06 09:18:20 2019 +0000
@@ -0,0 +1,546 @@
+/*
+ ******************************************************************************
+ * @file lps22hh_reg.h
+ * @author Sensors Software Solution Team
+ * @brief This file contains all the functions prototypes for the
+ * lps22hh_reg.c driver.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef LPS22HH_DRIVER_H
+#define LPS22HH_DRIVER_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include <stdint.h>
+#include <math.h>
+
+/** @addtogroup LPS22HH
+ * @{
+ *
+ */
+
+/** @defgroup LPS22HH_sensors_common_types
+ * @{
+ *
+ */
+
+#ifndef MEMS_SHARED_TYPES
+#define MEMS_SHARED_TYPES
+
+/**
+ * @defgroup axisXbitXX_t
+ * @brief These unions are useful to represent different sensors data type.
+ * These unions are not need by the driver.
+ *
+ * REMOVING the unions you are compliant with:
+ * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed "
+ *
+ * @{
+ *
+ */
+
+typedef union{
+ int16_t i16bit[3];
+ uint8_t u8bit[6];
+} axis3bit16_t;
+
+typedef union{
+ int16_t i16bit;
+ uint8_t u8bit[2];
+} axis1bit16_t;
+
+typedef union{
+ int32_t i32bit[3];
+ uint8_t u8bit[12];
+} axis3bit32_t;
+
+typedef union{
+ int32_t i32bit;
+ uint8_t u8bit[4];
+} axis1bit32_t;
+
+/**
+ * @}
+ *
+ */
+
+typedef struct{
+ uint8_t bit0 : 1;
+ uint8_t bit1 : 1;
+ uint8_t bit2 : 1;
+ uint8_t bit3 : 1;
+ uint8_t bit4 : 1;
+ uint8_t bit5 : 1;
+ uint8_t bit6 : 1;
+ uint8_t bit7 : 1;
+} bitwise_t;
+
+#define PROPERTY_DISABLE (0U)
+#define PROPERTY_ENABLE (1U)
+
+#endif /* MEMS_SHARED_TYPES */
+
+/**
+ * @}
+ *
+ */
+
+/** @addtogroup LPS22HH_Interfaces_Functions
+ * @brief This section provide a set of functions used to read and
+ * write a generic register of the device.
+ * MANDATORY: return 0 -> no Error.
+ * @{
+ *
+ */
+
+typedef int32_t (*lps22hh_write_ptr)(void *, uint8_t, uint8_t*, uint16_t);
+typedef int32_t (*lps22hh_read_ptr) (void *, uint8_t, uint8_t*, uint16_t);
+
+typedef struct {
+ /** Component mandatory fields **/
+ lps22hh_write_ptr write_reg;
+ lps22hh_read_ptr read_reg;
+ /** Customizable optional pointer **/
+ void *handle;
+} lps22hh_ctx_t;
+
+/**
+ * @}
+ *
+ */
+
+/** @defgroup LPS22HH_Infos
+ * @{
+ *
+ */
+
+/** I2C Device Address 8 bit format if SA0=0 -> B9 if SA0=1 -> BB **/
+#define LPS22HH_I2C_ADD_H 0xBBU
+#define LPS22HH_I2C_ADD_L 0xB9U
+
+/** Device Identification (Who am I) **/
+#define LPS22HH_ID 0xB3U
+
+/**
+ * @}
+ *
+ */
+
+/**
+ * @addtogroup LPS22HH_Sensitivity
+ * @brief These macro are maintained for back compatibility.
+ * in order to convert data into engineering units please
+ * use functions:
+ * -> _from_lsb_to_hpa(int16_t lsb)
+ * -> _from_lsb_to_celsius(int16_t lsb);
+ *
+ * REMOVING the MACRO you are compliant with:
+ * MISRA-C 2012 [Dir 4.9] -> " avoid function-like macros "
+ * @{
+ *
+ */
+
+#define LPS22HH_FROM_LSB_TO_hPa(lsb) (float)( lsb / 4096.0f )
+#define LPS22HH_FROM_LSB_TO_degC(lsb) (float)( lsb / 100.0f )
+
+/**
+ * @}
+ *
+ */
+
+#define LPS22HH_INTERRUPT_CFG 0x0BU
+typedef struct {
+ uint8_t pe : 2; /* ple + phe */
+ uint8_t lir : 1;
+ uint8_t diff_en : 1;
+ uint8_t reset_az : 1;
+ uint8_t autozero : 1;
+ uint8_t reset_arp : 1;
+ uint8_t autorefp : 1;
+} lps22hh_interrupt_cfg_t;
+
+#define LPS22HH_THS_P_L 0x0CU
+typedef struct {
+ uint8_t ths : 8;
+} lps22hh_ths_p_l_t;
+
+#define LPS22HH_THS_P_H 0x0DU
+typedef struct {
+ uint8_t ths : 7;
+ uint8_t not_used_01 : 1;
+} lps22hh_ths_p_h_t;
+
+#define LPS22HH_IF_CTRL 0x0EU
+typedef struct {
+ uint8_t i2c_disable : 1;
+ uint8_t i3c_disable : 1;
+ uint8_t pd_dis_int1 : 1;
+ uint8_t sdo_pu_en : 1;
+ uint8_t sda_pu_en : 1;
+ uint8_t not_used_01 : 2;
+ uint8_t int_en_i3c : 1;
+} lps22hh_if_ctrl_t;
+
+#define LPS22HH_WHO_AM_I 0x0FU
+#define LPS22HH_CTRL_REG1 0x10U
+typedef struct {
+ uint8_t sim : 1;
+ uint8_t bdu : 1;
+ uint8_t lpfp_cfg : 2; /* en_lpfp + lpfp_cfg */
+ uint8_t odr : 3;
+ uint8_t not_used_01 : 1;
+} lps22hh_ctrl_reg1_t;
+
+#define LPS22HH_CTRL_REG2 0x11U
+typedef struct {
+ uint8_t one_shot : 1;
+ uint8_t low_noise_en : 1;
+ uint8_t swreset : 1;
+ uint8_t not_used_01 : 1;
+ uint8_t if_add_inc : 1;
+ uint8_t pp_od : 1;
+ uint8_t int_h_l : 1;
+ uint8_t boot : 1;
+} lps22hh_ctrl_reg2_t;
+
+#define LPS22HH_CTRL_REG3 0x12U
+typedef struct {
+ uint8_t int_s : 2;
+ uint8_t drdy : 1;
+ uint8_t int_f_ovr : 1;
+ uint8_t int_f_wtm : 1;
+ uint8_t int_f_full : 1;
+ uint8_t not_used_01 : 2;
+} lps22hh_ctrl_reg3_t;
+
+#define LPS22HH_FIFO_CTRL 0x13U
+typedef struct {
+ uint8_t f_mode : 3; /* f_mode + trig_modes */
+ uint8_t stop_on_wtm : 1;
+ uint8_t not_used_01 : 4;
+} lps22hh_fifo_ctrl_t;
+
+#define LPS22HH_FIFO_WTM 0x14U
+typedef struct {
+ uint8_t wtm : 7;
+ uint8_t not_used_01 : 1;
+} lps22hh_fifo_wtm_t;
+
+#define LPS22HH_REF_P_XL 0x15U
+#define LPS22HH_REF_P_L 0x16U
+#define LPS22HH_RPDS_L 0x18U
+#define LPS22HH_RPDS_H 0x19U
+#define LPS22HH_INT_SOURCE 0x24U
+typedef struct {
+ uint8_t ph : 1;
+ uint8_t pl : 1;
+ uint8_t ia : 1;
+ uint8_t not_used_01 : 5;
+} lps22hh_int_source_t;
+
+#define LPS22HH_FIFO_STATUS1 0x25U
+#define LPS22HH_FIFO_STATUS2 0x26U
+typedef struct {
+ uint8_t not_used_01 : 5;
+ uint8_t fifo_full_ia : 1;
+ uint8_t fifo_ovr_ia : 1;
+ uint8_t fifo_wtm_ia : 1;
+} lps22hh_fifo_status2_t;
+
+#define LPS22HH_STATUS 0x27U
+typedef struct {
+ uint8_t p_da : 1;
+ uint8_t t_da : 1;
+ uint8_t not_used_01 : 2;
+ uint8_t p_or : 1;
+ uint8_t t_or : 1;
+ uint8_t not_used_02 : 2;
+} lps22hh_status_t;
+
+#define LPS22HH_PRESSURE_OUT_XL 0x28U
+#define LPS22HH_PRESSURE_OUT_L 0x29U
+#define LPS22HH_PRESSURE_OUT_H 0x2AU
+#define LPS22HH_TEMP_OUT_L 0x2BU
+#define LPS22HH_TEMP_OUT_H 0x2CU
+#define LPS22HH_FIFO_DATA_OUT_PRESS_XL 0x78U
+#define LPS22HH_FIFO_DATA_OUT_PRESS_L 0x79U
+#define LPS22HH_FIFO_DATA_OUT_PRESS_H 0x7AU
+#define LPS22HH_FIFO_DATA_OUT_TEMP_L 0x7BU
+#define LPS22HH_FIFO_DATA_OUT_TEMP_H 0x7CU
+
+/**
+ * @defgroup LPS22HH_Register_Union
+ * @brief This union group all the registers that has a bitfield
+ * description.
+ * This union is useful but not need by the driver.
+ *
+ * REMOVING this union you are compliant with:
+ * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed "
+ *
+ * @{
+ *
+ */
+typedef union{
+ lps22hh_interrupt_cfg_t interrupt_cfg;
+ lps22hh_if_ctrl_t if_ctrl;
+ lps22hh_ctrl_reg1_t ctrl_reg1;
+ lps22hh_ctrl_reg2_t ctrl_reg2;
+ lps22hh_ctrl_reg3_t ctrl_reg3;
+ lps22hh_fifo_ctrl_t fifo_ctrl;
+ lps22hh_fifo_wtm_t fifo_wtm;
+ lps22hh_int_source_t int_source;
+ lps22hh_fifo_status2_t fifo_status2;
+ lps22hh_status_t status;
+ bitwise_t bitwise;
+ uint8_t byte;
+} lps22hh_reg_t;
+
+/**
+ * @}
+ *
+ */
+
+int32_t lps22hh_read_reg(lps22hh_ctx_t *ctx, uint8_t reg, uint8_t* data,
+ uint16_t len);
+int32_t lps22hh_write_reg(lps22hh_ctx_t *ctx, uint8_t reg, uint8_t* data,
+ uint16_t len);
+
+extern float lps22hh_from_lsb_to_hpa(int16_t lsb);
+extern float lps22hh_from_lsb_to_celsius(int16_t lsb);
+
+int32_t lps22hh_autozero_rst_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_autozero_rst_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_autozero_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_autozero_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_pressure_snap_rst_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_pressure_snap_rst_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_pressure_snap_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_pressure_snap_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_block_data_update_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_block_data_update_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+typedef enum {
+ LPS22HH_POWER_DOWN = 0x00,
+ LPS22HH_ONE_SHOOT = 0x08,
+ LPS22HH_1_Hz = 0x01,
+ LPS22HH_10_Hz = 0x02,
+ LPS22HH_25_Hz = 0x03,
+ LPS22HH_50_Hz = 0x04,
+ LPS22HH_75_Hz = 0x05,
+ LPS22HH_1_Hz_LOW_NOISE = 0x11,
+ LPS22HH_10_Hz_LOW_NOISE = 0x12,
+ LPS22HH_25_Hz_LOW_NOISE = 0x13,
+ LPS22HH_50_Hz_LOW_NOISE = 0x14,
+ LPS22HH_75_Hz_LOW_NOISE = 0x15,
+ LPS22HH_100_Hz = 0x06,
+ LPS22HH_200_Hz = 0x07,
+} lps22hh_odr_t;
+int32_t lps22hh_data_rate_set(lps22hh_ctx_t *ctx, lps22hh_odr_t val);
+int32_t lps22hh_data_rate_get(lps22hh_ctx_t *ctx, lps22hh_odr_t *val);
+
+int32_t lps22hh_pressure_ref_set(lps22hh_ctx_t *ctx, uint8_t *buff);
+int32_t lps22hh_pressure_ref_get(lps22hh_ctx_t *ctx, uint8_t *buff);
+
+int32_t lps22hh_pressure_offset_set(lps22hh_ctx_t *ctx, uint8_t *buff);
+int32_t lps22hh_pressure_offset_get(lps22hh_ctx_t *ctx, uint8_t *buff);
+
+typedef struct{
+ lps22hh_int_source_t int_source;
+ lps22hh_fifo_status2_t fifo_status2;
+ lps22hh_status_t status;
+} lps22hh_all_sources_t;
+int32_t lps22hh_all_sources_get(lps22hh_ctx_t *ctx,
+ lps22hh_all_sources_t *val);
+
+int32_t lps22hh_status_reg_get(lps22hh_ctx_t *ctx, lps22hh_status_t *val);
+
+int32_t lps22hh_press_flag_data_ready_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_temp_flag_data_ready_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_pressure_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff);
+
+int32_t lps22hh_temperature_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff);
+
+int32_t lps22hh_fifo_pressure_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff);
+
+int32_t lps22hh_fifo_temperature_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff);
+
+int32_t lps22hh_device_id_get(lps22hh_ctx_t *ctx, uint8_t *buff);
+
+int32_t lps22hh_reset_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_reset_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_auto_increment_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_auto_increment_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_boot_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_boot_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+typedef enum {
+ LPS22HH_LPF_ODR_DIV_2 = 0,
+ LPS22HH_LPF_ODR_DIV_9 = 2,
+ LPS22HH_LPF_ODR_DIV_20 = 3,
+} lps22hh_lpfp_cfg_t;
+int32_t lps22hh_lp_bandwidth_set(lps22hh_ctx_t *ctx, lps22hh_lpfp_cfg_t val);
+int32_t lps22hh_lp_bandwidth_get(lps22hh_ctx_t *ctx, lps22hh_lpfp_cfg_t *val);
+
+typedef enum {
+ LPS22HH_I2C_ENABLE = 0,
+ LPS22HH_I2C_DISABLE = 1,
+} lps22hh_i2c_disable_t;
+int32_t lps22hh_i2c_interface_set(lps22hh_ctx_t *ctx,
+ lps22hh_i2c_disable_t val);
+int32_t lps22hh_i2c_interface_get(lps22hh_ctx_t *ctx,
+ lps22hh_i2c_disable_t *val);
+
+typedef enum {
+ LPS22HH_I3C_ENABLE = 0x00,
+ LPS22HH_I3C_ENABLE_INT_PIN_ENABLE = 0x10,
+ LPS22HH_I3C_DISABLE = 0x11,
+} lps22hh_i3c_disable_t;
+int32_t lps22hh_i3c_interface_set(lps22hh_ctx_t *ctx,
+ lps22hh_i3c_disable_t val);
+int32_t lps22hh_i3c_interface_get(lps22hh_ctx_t *ctx,
+ lps22hh_i3c_disable_t *val);
+
+typedef enum {
+ LPS22HH_PULL_UP_DISCONNECT = 0,
+ LPS22HH_PULL_UP_CONNECT = 1,
+} lps22hh_pu_en_t;
+int32_t lps22hh_sdo_sa0_mode_set(lps22hh_ctx_t *ctx, lps22hh_pu_en_t val);
+int32_t lps22hh_sdo_sa0_mode_get(lps22hh_ctx_t *ctx, lps22hh_pu_en_t *val);
+int32_t lps22hh_sda_mode_set(lps22hh_ctx_t *ctx, lps22hh_pu_en_t val);
+int32_t lps22hh_sda_mode_get(lps22hh_ctx_t *ctx, lps22hh_pu_en_t *val);
+
+typedef enum {
+ LPS22HH_SPI_4_WIRE = 0,
+ LPS22HH_SPI_3_WIRE = 1,
+} lps22hh_sim_t;
+int32_t lps22hh_spi_mode_set(lps22hh_ctx_t *ctx, lps22hh_sim_t val);
+int32_t lps22hh_spi_mode_get(lps22hh_ctx_t *ctx, lps22hh_sim_t *val);
+
+typedef enum {
+ LPS22HH_INT_PULSED = 0,
+ LPS22HH_INT_LATCHED = 1,
+} lps22hh_lir_t;
+int32_t lps22hh_int_notification_set(lps22hh_ctx_t *ctx, lps22hh_lir_t val);
+int32_t lps22hh_int_notification_get(lps22hh_ctx_t *ctx, lps22hh_lir_t *val);
+
+typedef enum {
+ LPS22HH_PUSH_PULL = 0,
+ LPS22HH_OPEN_DRAIN = 1,
+} lps22hh_pp_od_t;
+int32_t lps22hh_pin_mode_set(lps22hh_ctx_t *ctx, lps22hh_pp_od_t val);
+int32_t lps22hh_pin_mode_get(lps22hh_ctx_t *ctx, lps22hh_pp_od_t *val);
+
+typedef enum {
+ LPS22HH_ACTIVE_HIGH = 0,
+ LPS22HH_ACTIVE_LOW = 1,
+} lps22hh_int_h_l_t;
+int32_t lps22hh_pin_polarity_set(lps22hh_ctx_t *ctx, lps22hh_int_h_l_t val);
+int32_t lps22hh_pin_polarity_get(lps22hh_ctx_t *ctx, lps22hh_int_h_l_t *val);
+
+int32_t lps22hh_pin_int_route_set(lps22hh_ctx_t *ctx,
+ lps22hh_ctrl_reg3_t *val);
+int32_t lps22hh_pin_int_route_get(lps22hh_ctx_t *ctx,
+ lps22hh_ctrl_reg3_t *val);
+
+typedef enum {
+ LPS22HH_NO_THRESHOLD = 0,
+ LPS22HH_POSITIVE = 1,
+ LPS22HH_NEGATIVE = 2,
+ LPS22HH_BOTH = 3,
+} lps22hh_pe_t;
+int32_t lps22hh_int_on_threshold_set(lps22hh_ctx_t *ctx, lps22hh_pe_t val);
+int32_t lps22hh_int_on_threshold_get(lps22hh_ctx_t *ctx, lps22hh_pe_t *val);
+
+int32_t lps22hh_int_treshold_set(lps22hh_ctx_t *ctx, uint16_t buff);
+int32_t lps22hh_int_treshold_get(lps22hh_ctx_t *ctx, uint16_t *buff);
+
+typedef enum {
+ LPS22HH_BYPASS_MODE = 0,
+ LPS22HH_FIFO_MODE = 1,
+ LPS22HH_STREAM_MODE = 2,
+ LPS22HH_DYNAMIC_STREAM_MODE = 3,
+ LPS22HH_BYPASS_TO_FIFO_MODE = 5,
+ LPS22HH_BYPASS_TO_STREAM_MODE = 6,
+ LPS22HH_STREAM_TO_FIFO_MODE = 7,
+} lps22hh_f_mode_t;
+int32_t lps22hh_fifo_mode_set(lps22hh_ctx_t *ctx, lps22hh_f_mode_t val);
+int32_t lps22hh_fifo_mode_get(lps22hh_ctx_t *ctx, lps22hh_f_mode_t *val);
+
+int32_t lps22hh_fifo_stop_on_wtm_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_fifo_stop_on_wtm_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_fifo_watermark_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_fifo_watermark_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_fifo_data_level_get(lps22hh_ctx_t *ctx, uint8_t *buff);
+
+int32_t lps22hh_fifo_src_get(lps22hh_ctx_t *ctx, lps22hh_fifo_status2_t *val);
+
+int32_t lps22hh_fifo_full_flag_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_fifo_ovr_flag_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_fifo_wtm_flag_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_fifo_ovr_on_int_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_fifo_ovr_on_int_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_fifo_threshold_on_int_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_fifo_threshold_on_int_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+int32_t lps22hh_fifo_full_on_int_set(lps22hh_ctx_t *ctx, uint8_t val);
+int32_t lps22hh_fifo_full_on_int_get(lps22hh_ctx_t *ctx, uint8_t *val);
+
+/**
+ * @}
+ *
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*LPS22HH_REGS_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/