Added SPI3w support through DevSPI

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON_3W

Fork of LPS22HB by ST

Committer:
nikapov
Date:
Mon Sep 04 16:06:45 2017 +0000
Revision:
0:3de9cb936fd1
First version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nikapov 0:3de9cb936fd1 1 /**
nikapov 0:3de9cb936fd1 2 *******************************************************************************
nikapov 0:3de9cb936fd1 3 * @file LPS22HB_driver.c
nikapov 0:3de9cb936fd1 4 * @author HESA Application Team
nikapov 0:3de9cb936fd1 5 * @version V1.1
nikapov 0:3de9cb936fd1 6 * @date 10-August-2016
nikapov 0:3de9cb936fd1 7 * @brief LPS22HB driver file
nikapov 0:3de9cb936fd1 8 *******************************************************************************
nikapov 0:3de9cb936fd1 9 * @attention
nikapov 0:3de9cb936fd1 10 *
nikapov 0:3de9cb936fd1 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
nikapov 0:3de9cb936fd1 12 *
nikapov 0:3de9cb936fd1 13 * Redistribution and use in source and binary forms, with or without modification,
nikapov 0:3de9cb936fd1 14 * are permitted provided that the following conditions are met:
nikapov 0:3de9cb936fd1 15 * 1. Redistributions of source code must retain the above copyright notice,
nikapov 0:3de9cb936fd1 16 * this list of conditions and the following disclaimer.
nikapov 0:3de9cb936fd1 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
nikapov 0:3de9cb936fd1 18 * this list of conditions and the following disclaimer in the documentation
nikapov 0:3de9cb936fd1 19 * and/or other materials provided with the distribution.
nikapov 0:3de9cb936fd1 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
nikapov 0:3de9cb936fd1 21 * may be used to endorse or promote products derived from this software
nikapov 0:3de9cb936fd1 22 * without specific prior written permission.
nikapov 0:3de9cb936fd1 23 *
nikapov 0:3de9cb936fd1 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
nikapov 0:3de9cb936fd1 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
nikapov 0:3de9cb936fd1 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
nikapov 0:3de9cb936fd1 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
nikapov 0:3de9cb936fd1 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
nikapov 0:3de9cb936fd1 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
nikapov 0:3de9cb936fd1 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
nikapov 0:3de9cb936fd1 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
nikapov 0:3de9cb936fd1 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nikapov 0:3de9cb936fd1 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nikapov 0:3de9cb936fd1 34 *
nikapov 0:3de9cb936fd1 35 ******************************************************************************
nikapov 0:3de9cb936fd1 36 */
nikapov 0:3de9cb936fd1 37
nikapov 0:3de9cb936fd1 38 /* Includes ------------------------------------------------------------------*/
nikapov 0:3de9cb936fd1 39 #include "LPS22HB_driver.h"
nikapov 0:3de9cb936fd1 40 #ifdef USE_FULL_ASSERT_LPS22HB
nikapov 0:3de9cb936fd1 41 #include <stdio.h>
nikapov 0:3de9cb936fd1 42 #endif
nikapov 0:3de9cb936fd1 43
nikapov 0:3de9cb936fd1 44 /** @addtogroup Environmental_Sensor
nikapov 0:3de9cb936fd1 45 * @{
nikapov 0:3de9cb936fd1 46 */
nikapov 0:3de9cb936fd1 47
nikapov 0:3de9cb936fd1 48 /** @defgroup LPS22HB_DRIVER
nikapov 0:3de9cb936fd1 49 * @brief LPS22HB DRIVER
nikapov 0:3de9cb936fd1 50 * @{
nikapov 0:3de9cb936fd1 51 */
nikapov 0:3de9cb936fd1 52
nikapov 0:3de9cb936fd1 53 /** @defgroup LPS22HB_Imported_Function_Prototypes
nikapov 0:3de9cb936fd1 54 * @{
nikapov 0:3de9cb936fd1 55 */
nikapov 0:3de9cb936fd1 56
nikapov 0:3de9cb936fd1 57 extern uint8_t LPS22HB_io_write( void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite );
nikapov 0:3de9cb936fd1 58 extern uint8_t LPS22HB_io_read( void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead );
nikapov 0:3de9cb936fd1 59
nikapov 0:3de9cb936fd1 60 /**
nikapov 0:3de9cb936fd1 61 * @}
nikapov 0:3de9cb936fd1 62 */
nikapov 0:3de9cb936fd1 63
nikapov 0:3de9cb936fd1 64 /** @defgroup LPS22HB_Private_Function_Prototypes
nikapov 0:3de9cb936fd1 65 * @{
nikapov 0:3de9cb936fd1 66 */
nikapov 0:3de9cb936fd1 67
nikapov 0:3de9cb936fd1 68 /**
nikapov 0:3de9cb936fd1 69 * @}
nikapov 0:3de9cb936fd1 70 */
nikapov 0:3de9cb936fd1 71
nikapov 0:3de9cb936fd1 72 /** @defgroup LPS22HB_Private_Functions
nikapov 0:3de9cb936fd1 73 * @{
nikapov 0:3de9cb936fd1 74 */
nikapov 0:3de9cb936fd1 75
nikapov 0:3de9cb936fd1 76 /**
nikapov 0:3de9cb936fd1 77 * @}
nikapov 0:3de9cb936fd1 78 */
nikapov 0:3de9cb936fd1 79
nikapov 0:3de9cb936fd1 80 /** @defgroup LPS22HB_Public_Functions
nikapov 0:3de9cb936fd1 81 * @{
nikapov 0:3de9cb936fd1 82 */
nikapov 0:3de9cb936fd1 83
nikapov 0:3de9cb936fd1 84 /*******************************************************************************
nikapov 0:3de9cb936fd1 85 * Function Name : LPS22HB_read_reg
nikapov 0:3de9cb936fd1 86 * Description : Generic Reading function. It must be fullfilled with either
nikapov 0:3de9cb936fd1 87 * : I2C or SPI reading functions
nikapov 0:3de9cb936fd1 88 * Input : Register Address
nikapov 0:3de9cb936fd1 89 * Output : Data Read
nikapov 0:3de9cb936fd1 90 * Return : None
nikapov 0:3de9cb936fd1 91 *******************************************************************************/
nikapov 0:3de9cb936fd1 92 LPS22HB_Error_et LPS22HB_read_reg( void *handle, uint8_t RegAddr, uint16_t NumByteToRead, uint8_t *Data )
nikapov 0:3de9cb936fd1 93 {
nikapov 0:3de9cb936fd1 94
nikapov 0:3de9cb936fd1 95 if ( LPS22HB_io_read( handle, RegAddr, Data, NumByteToRead ) )
nikapov 0:3de9cb936fd1 96 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 97 else
nikapov 0:3de9cb936fd1 98 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 99 }
nikapov 0:3de9cb936fd1 100
nikapov 0:3de9cb936fd1 101 /*******************************************************************************
nikapov 0:3de9cb936fd1 102 * Function Name : LPS22HB_write_reg
nikapov 0:3de9cb936fd1 103 * Description : Generic Writing function. It must be fullfilled with either
nikapov 0:3de9cb936fd1 104 * : I2C or SPI writing function
nikapov 0:3de9cb936fd1 105 * Input : Register Address, Data to be written
nikapov 0:3de9cb936fd1 106 * Output : None
nikapov 0:3de9cb936fd1 107 * Return : None
nikapov 0:3de9cb936fd1 108 *******************************************************************************/
nikapov 0:3de9cb936fd1 109 LPS22HB_Error_et LPS22HB_write_reg( void *handle, uint8_t RegAddr, uint16_t NumByteToWrite, uint8_t *Data )
nikapov 0:3de9cb936fd1 110 {
nikapov 0:3de9cb936fd1 111
nikapov 0:3de9cb936fd1 112 if ( LPS22HB_io_write( handle, RegAddr, Data, NumByteToWrite ) )
nikapov 0:3de9cb936fd1 113 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 114 else
nikapov 0:3de9cb936fd1 115 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 116 }
nikapov 0:3de9cb936fd1 117
nikapov 0:3de9cb936fd1 118 /**
nikapov 0:3de9cb936fd1 119 * @brief Read identification code by WHO_AM_I register
nikapov 0:3de9cb936fd1 120 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 121 * @param Buffer to empty by Device identification Value.
nikapov 0:3de9cb936fd1 122 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 123 */
nikapov 0:3de9cb936fd1 124 LPS22HB_Error_et LPS22HB_Get_DeviceID(void *handle, uint8_t* deviceid)
nikapov 0:3de9cb936fd1 125 {
nikapov 0:3de9cb936fd1 126 if(LPS22HB_read_reg(handle, LPS22HB_WHO_AM_I_REG, 1, deviceid))
nikapov 0:3de9cb936fd1 127 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 128
nikapov 0:3de9cb936fd1 129 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 130 }
nikapov 0:3de9cb936fd1 131
nikapov 0:3de9cb936fd1 132
nikapov 0:3de9cb936fd1 133 /**
nikapov 0:3de9cb936fd1 134 * @brief Get the LPS22HB driver version.
nikapov 0:3de9cb936fd1 135 * @param None
nikapov 0:3de9cb936fd1 136 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 137 */
nikapov 0:3de9cb936fd1 138 LPS22HB_Error_et LPS22HB_Get_DriverVersion(LPS22HB_driverVersion_st *Version)
nikapov 0:3de9cb936fd1 139 {
nikapov 0:3de9cb936fd1 140 Version->Major = LPS22HB_driverVersion_Major;
nikapov 0:3de9cb936fd1 141 Version->Minor = LPS22HB_driverVersion_Minor;
nikapov 0:3de9cb936fd1 142 Version->Point = LPS22HB_driverVersion_Point;
nikapov 0:3de9cb936fd1 143
nikapov 0:3de9cb936fd1 144 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 145 }
nikapov 0:3de9cb936fd1 146
nikapov 0:3de9cb936fd1 147
nikapov 0:3de9cb936fd1 148 /**
nikapov 0:3de9cb936fd1 149 * @brief Set LPS22HB Low Power or Low Noise Mode Configuration
nikapov 0:3de9cb936fd1 150 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 151 * @param LPS22HB_LowNoise or LPS22HB_LowPower mode
nikapov 0:3de9cb936fd1 152 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 153 */
nikapov 0:3de9cb936fd1 154 LPS22HB_Error_et LPS22HB_Set_PowerMode(void *handle, LPS22HB_PowerMode_et mode)
nikapov 0:3de9cb936fd1 155 {
nikapov 0:3de9cb936fd1 156 uint8_t tmp;
nikapov 0:3de9cb936fd1 157
nikapov 0:3de9cb936fd1 158 LPS22HB_assert_param(IS_LPS22HB_PowerMode(mode));
nikapov 0:3de9cb936fd1 159
nikapov 0:3de9cb936fd1 160 if(LPS22HB_read_reg(handle, LPS22HB_RES_CONF_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 161 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 162
nikapov 0:3de9cb936fd1 163 tmp &= ~LPS22HB_LCEN_MASK;
nikapov 0:3de9cb936fd1 164 tmp |= (uint8_t)mode;
nikapov 0:3de9cb936fd1 165
nikapov 0:3de9cb936fd1 166 if(LPS22HB_write_reg(handle, LPS22HB_RES_CONF_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 167 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 168
nikapov 0:3de9cb936fd1 169 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 170 }
nikapov 0:3de9cb936fd1 171
nikapov 0:3de9cb936fd1 172 /**
nikapov 0:3de9cb936fd1 173 * @brief Get LPS22HB Power Mode
nikapov 0:3de9cb936fd1 174 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 175 * @param Buffer to empty with Mode: Low Noise or Low Current
nikapov 0:3de9cb936fd1 176 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 177 */
nikapov 0:3de9cb936fd1 178 LPS22HB_Error_et LPS22HB_Get_PowerMode(void *handle, LPS22HB_PowerMode_et* mode)
nikapov 0:3de9cb936fd1 179 {
nikapov 0:3de9cb936fd1 180 uint8_t tmp;
nikapov 0:3de9cb936fd1 181
nikapov 0:3de9cb936fd1 182 if(LPS22HB_read_reg(handle, LPS22HB_RES_CONF_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 183 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 184
nikapov 0:3de9cb936fd1 185 *mode = (LPS22HB_PowerMode_et)(tmp & LPS22HB_LCEN_MASK);
nikapov 0:3de9cb936fd1 186
nikapov 0:3de9cb936fd1 187 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 188 }
nikapov 0:3de9cb936fd1 189
nikapov 0:3de9cb936fd1 190
nikapov 0:3de9cb936fd1 191 /**
nikapov 0:3de9cb936fd1 192 * @brief Set LPS22HB Output Data Rate
nikapov 0:3de9cb936fd1 193 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 194 * @param Output Data Rate
nikapov 0:3de9cb936fd1 195 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 196 */
nikapov 0:3de9cb936fd1 197 LPS22HB_Error_et LPS22HB_Set_Odr(void *handle, LPS22HB_Odr_et odr)
nikapov 0:3de9cb936fd1 198 {
nikapov 0:3de9cb936fd1 199 uint8_t tmp;
nikapov 0:3de9cb936fd1 200
nikapov 0:3de9cb936fd1 201
nikapov 0:3de9cb936fd1 202 LPS22HB_assert_param(IS_LPS22HB_ODR(odr));
nikapov 0:3de9cb936fd1 203
nikapov 0:3de9cb936fd1 204 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 205 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 206
nikapov 0:3de9cb936fd1 207 tmp &= ~LPS22HB_ODR_MASK;
nikapov 0:3de9cb936fd1 208 tmp |= (uint8_t)odr;
nikapov 0:3de9cb936fd1 209
nikapov 0:3de9cb936fd1 210 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 211 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 212
nikapov 0:3de9cb936fd1 213 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 214 }
nikapov 0:3de9cb936fd1 215
nikapov 0:3de9cb936fd1 216 /**
nikapov 0:3de9cb936fd1 217 * @brief Get LPS22HB Output Data Rate
nikapov 0:3de9cb936fd1 218 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 219 * @param Buffer to empty with Output Data Rate
nikapov 0:3de9cb936fd1 220 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 221 */
nikapov 0:3de9cb936fd1 222 LPS22HB_Error_et LPS22HB_Get_Odr(void *handle, LPS22HB_Odr_et* odr)
nikapov 0:3de9cb936fd1 223 {
nikapov 0:3de9cb936fd1 224 uint8_t tmp;
nikapov 0:3de9cb936fd1 225
nikapov 0:3de9cb936fd1 226 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 227 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 228
nikapov 0:3de9cb936fd1 229 *odr = (LPS22HB_Odr_et)(tmp & LPS22HB_ODR_MASK);
nikapov 0:3de9cb936fd1 230
nikapov 0:3de9cb936fd1 231 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 232 }
nikapov 0:3de9cb936fd1 233
nikapov 0:3de9cb936fd1 234 /**
nikapov 0:3de9cb936fd1 235 * @brief Enable/Disale low-pass filter on LPS22HB pressure data
nikapov 0:3de9cb936fd1 236 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 237 * @param state: enable or disable
nikapov 0:3de9cb936fd1 238 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 239 */
nikapov 0:3de9cb936fd1 240 LPS22HB_Error_et LPS22HB_Set_LowPassFilter(void *handle, LPS22HB_State_et state)
nikapov 0:3de9cb936fd1 241 {
nikapov 0:3de9cb936fd1 242 uint8_t tmp;
nikapov 0:3de9cb936fd1 243
nikapov 0:3de9cb936fd1 244 LPS22HB_assert_param(IS_LPS22HB_State(state));
nikapov 0:3de9cb936fd1 245
nikapov 0:3de9cb936fd1 246 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 247 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 248
nikapov 0:3de9cb936fd1 249 tmp &= ~LPS22HB_LPFP_MASK;
nikapov 0:3de9cb936fd1 250 tmp |= ((uint8_t)state)<<LPS22HB_LPFP_BIT;
nikapov 0:3de9cb936fd1 251
nikapov 0:3de9cb936fd1 252
nikapov 0:3de9cb936fd1 253 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 254 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 255
nikapov 0:3de9cb936fd1 256
nikapov 0:3de9cb936fd1 257 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 258 }
nikapov 0:3de9cb936fd1 259
nikapov 0:3de9cb936fd1 260
nikapov 0:3de9cb936fd1 261 /**
nikapov 0:3de9cb936fd1 262 * @brief Set low-pass filter cutoff configuration on LPS22HB pressure data
nikapov 0:3de9cb936fd1 263 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 264 * @param Filter Cutoff ODR/9 or ODR/20
nikapov 0:3de9cb936fd1 265 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 266 */
nikapov 0:3de9cb936fd1 267 LPS22HB_Error_et LPS22HB_Set_LowPassFilterCutoff(void *handle, LPS22HB_LPF_Cutoff_et cutoff){
nikapov 0:3de9cb936fd1 268
nikapov 0:3de9cb936fd1 269 uint8_t tmp;
nikapov 0:3de9cb936fd1 270
nikapov 0:3de9cb936fd1 271 LPS22HB_assert_param(IS_LPS22HB_LPF_Cutoff(cutoff));
nikapov 0:3de9cb936fd1 272
nikapov 0:3de9cb936fd1 273 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 274 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 275
nikapov 0:3de9cb936fd1 276 tmp &= ~LPS22HB_LPFP_CUTOFF_MASK;
nikapov 0:3de9cb936fd1 277 tmp |= (uint8_t)cutoff;
nikapov 0:3de9cb936fd1 278
nikapov 0:3de9cb936fd1 279
nikapov 0:3de9cb936fd1 280
nikapov 0:3de9cb936fd1 281 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 282 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 283
nikapov 0:3de9cb936fd1 284
nikapov 0:3de9cb936fd1 285 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 286
nikapov 0:3de9cb936fd1 287 }
nikapov 0:3de9cb936fd1 288
nikapov 0:3de9cb936fd1 289 /**
nikapov 0:3de9cb936fd1 290 * @brief Set Block Data Mode
nikapov 0:3de9cb936fd1 291 * @detail It is recommended to set BDU bit to ‘1’.
nikapov 0:3de9cb936fd1 292 * @detail This feature avoids reading LSB and MSB related to different samples.
nikapov 0:3de9cb936fd1 293 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 294 * @param LPS22HB_BDU_CONTINUOUS_UPDATE, LPS22HB_BDU_NO_UPDATE
nikapov 0:3de9cb936fd1 295 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 296 */
nikapov 0:3de9cb936fd1 297
nikapov 0:3de9cb936fd1 298 LPS22HB_Error_et LPS22HB_Set_Bdu(void *handle, LPS22HB_Bdu_et bdu)
nikapov 0:3de9cb936fd1 299 {
nikapov 0:3de9cb936fd1 300 uint8_t tmp;
nikapov 0:3de9cb936fd1 301
nikapov 0:3de9cb936fd1 302
nikapov 0:3de9cb936fd1 303 LPS22HB_assert_param(IS_LPS22HB_BDUMode(bdu));
nikapov 0:3de9cb936fd1 304
nikapov 0:3de9cb936fd1 305 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 306 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 307
nikapov 0:3de9cb936fd1 308 tmp &= ~LPS22HB_BDU_MASK;
nikapov 0:3de9cb936fd1 309 tmp |= ((uint8_t)bdu);
nikapov 0:3de9cb936fd1 310
nikapov 0:3de9cb936fd1 311
nikapov 0:3de9cb936fd1 312 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 313 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 314
nikapov 0:3de9cb936fd1 315 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 316 }
nikapov 0:3de9cb936fd1 317
nikapov 0:3de9cb936fd1 318 /**
nikapov 0:3de9cb936fd1 319 * @brief Get Block Data Mode
nikapov 0:3de9cb936fd1 320 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 321 * @param Buffer to empty whit the bdu mode read from sensor
nikapov 0:3de9cb936fd1 322 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 323 */
nikapov 0:3de9cb936fd1 324 LPS22HB_Error_et LPS22HB_Get_Bdu(void *handle, LPS22HB_Bdu_et* bdu)
nikapov 0:3de9cb936fd1 325 {
nikapov 0:3de9cb936fd1 326 uint8_t tmp;
nikapov 0:3de9cb936fd1 327
nikapov 0:3de9cb936fd1 328 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 329 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 330
nikapov 0:3de9cb936fd1 331 *bdu = (LPS22HB_Bdu_et)(tmp & LPS22HB_BDU_MASK);
nikapov 0:3de9cb936fd1 332
nikapov 0:3de9cb936fd1 333 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 334 }
nikapov 0:3de9cb936fd1 335
nikapov 0:3de9cb936fd1 336 /**
nikapov 0:3de9cb936fd1 337 * @brief Set SPI mode: 3 Wire Interface or 4 Wire Interface
nikapov 0:3de9cb936fd1 338 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 339 * @param LPS22HB_SPI_3_WIRE, LPS22HB_SPI_4_WIRE
nikapov 0:3de9cb936fd1 340 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 341 */
nikapov 0:3de9cb936fd1 342 LPS22HB_Error_et LPS22HB_Set_SpiInterface(void *handle, LPS22HB_SPIMode_et spimode)
nikapov 0:3de9cb936fd1 343 {
nikapov 0:3de9cb936fd1 344 uint8_t tmp;
nikapov 0:3de9cb936fd1 345
nikapov 0:3de9cb936fd1 346
nikapov 0:3de9cb936fd1 347 LPS22HB_assert_param(IS_LPS22HB_SPIMode(spimode));
nikapov 0:3de9cb936fd1 348
nikapov 0:3de9cb936fd1 349 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 350 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 351
nikapov 0:3de9cb936fd1 352 tmp &= ~LPS22HB_SIM_MASK;
nikapov 0:3de9cb936fd1 353 tmp |= (uint8_t)spimode;
nikapov 0:3de9cb936fd1 354
nikapov 0:3de9cb936fd1 355 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 356 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 357
nikapov 0:3de9cb936fd1 358 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 359 }
nikapov 0:3de9cb936fd1 360
nikapov 0:3de9cb936fd1 361 /**
nikapov 0:3de9cb936fd1 362 * @brief Clock Tree Configuration
nikapov 0:3de9cb936fd1 363 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 364 * @param LPS22HB_CTE_NotBalanced, LPS22HB_CTE_ABalanced
nikapov 0:3de9cb936fd1 365 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 366 */
nikapov 0:3de9cb936fd1 367 LPS22HB_Error_et LPS22HB_Set_ClockTreeConfifuration(void *handle, LPS22HB_CTE_et mode)
nikapov 0:3de9cb936fd1 368 {
nikapov 0:3de9cb936fd1 369 uint8_t tmp;
nikapov 0:3de9cb936fd1 370
nikapov 0:3de9cb936fd1 371
nikapov 0:3de9cb936fd1 372 LPS22HB_assert_param(IS_LPS22HB_CTE(mode));
nikapov 0:3de9cb936fd1 373
nikapov 0:3de9cb936fd1 374 if(LPS22HB_read_reg(handle, LPS22HB_CLOCK_TREE_CONFIGURATION, 1, &tmp))
nikapov 0:3de9cb936fd1 375 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 376
nikapov 0:3de9cb936fd1 377 tmp &= ~LPS22HB_CTE_MASK;
nikapov 0:3de9cb936fd1 378 tmp |= (uint8_t)mode;
nikapov 0:3de9cb936fd1 379
nikapov 0:3de9cb936fd1 380
nikapov 0:3de9cb936fd1 381 if(LPS22HB_write_reg(handle, LPS22HB_CLOCK_TREE_CONFIGURATION, 1, &tmp))
nikapov 0:3de9cb936fd1 382 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 383
nikapov 0:3de9cb936fd1 384 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 385 }
nikapov 0:3de9cb936fd1 386
nikapov 0:3de9cb936fd1 387
nikapov 0:3de9cb936fd1 388 /**
nikapov 0:3de9cb936fd1 389 * @brief Get SPI mode: 3 Wire Interface or 4 Wire Interface
nikapov 0:3de9cb936fd1 390 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 391 * @param Buffet to empty with spi mode read from Sensor
nikapov 0:3de9cb936fd1 392 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 393 */
nikapov 0:3de9cb936fd1 394 LPS22HB_Error_et LPS22HB_Get_SpiInterface(void *handle, LPS22HB_SPIMode_et* spimode)
nikapov 0:3de9cb936fd1 395 {
nikapov 0:3de9cb936fd1 396 uint8_t tmp;
nikapov 0:3de9cb936fd1 397
nikapov 0:3de9cb936fd1 398 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 399 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 400
nikapov 0:3de9cb936fd1 401 *spimode = (LPS22HB_SPIMode_et)(tmp & LPS22HB_SIM_MASK);
nikapov 0:3de9cb936fd1 402
nikapov 0:3de9cb936fd1 403 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 404 }
nikapov 0:3de9cb936fd1 405
nikapov 0:3de9cb936fd1 406 /**
nikapov 0:3de9cb936fd1 407 * @brief Software Reset. Self-clearing upon completion
nikapov 0:3de9cb936fd1 408 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 409 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 410 */
nikapov 0:3de9cb936fd1 411 LPS22HB_Error_et LPS22HB_SwReset(void *handle)
nikapov 0:3de9cb936fd1 412 {
nikapov 0:3de9cb936fd1 413 uint8_t tmp;
nikapov 0:3de9cb936fd1 414
nikapov 0:3de9cb936fd1 415 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 416 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 417
nikapov 0:3de9cb936fd1 418 tmp |= (0x01<<LPS22HB_SW_RESET_BIT);
nikapov 0:3de9cb936fd1 419
nikapov 0:3de9cb936fd1 420 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 421 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 422
nikapov 0:3de9cb936fd1 423 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 424 }
nikapov 0:3de9cb936fd1 425
nikapov 0:3de9cb936fd1 426 /**
nikapov 0:3de9cb936fd1 427 * @brief Reboot Memory Content
nikapov 0:3de9cb936fd1 428 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 429 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 430 */
nikapov 0:3de9cb936fd1 431
nikapov 0:3de9cb936fd1 432 LPS22HB_Error_et LPS22HB_MemoryBoot(void *handle)
nikapov 0:3de9cb936fd1 433 {
nikapov 0:3de9cb936fd1 434 uint8_t tmp;
nikapov 0:3de9cb936fd1 435
nikapov 0:3de9cb936fd1 436 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 437 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 438
nikapov 0:3de9cb936fd1 439 tmp |= (0x01<<LPS22HB_BOOT_BIT);
nikapov 0:3de9cb936fd1 440
nikapov 0:3de9cb936fd1 441 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 442 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 443
nikapov 0:3de9cb936fd1 444 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 445 }
nikapov 0:3de9cb936fd1 446
nikapov 0:3de9cb936fd1 447 /**
nikapov 0:3de9cb936fd1 448 * @brief Software Reset ann Reboot Memory Content.
nikapov 0:3de9cb936fd1 449 * @detail The device is reset to the power on configuration if the SWRESET bit is set to ‘1’
nikapov 0:3de9cb936fd1 450 + and BOOT is set to ‘1’; Self-clearing upon completion.
nikapov 0:3de9cb936fd1 451 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 452 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 453 */
nikapov 0:3de9cb936fd1 454 LPS22HB_Error_et LPS22HB_SwResetAndMemoryBoot(void *handle)
nikapov 0:3de9cb936fd1 455 {
nikapov 0:3de9cb936fd1 456 uint8_t tmp;
nikapov 0:3de9cb936fd1 457
nikapov 0:3de9cb936fd1 458 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 459 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 460
nikapov 0:3de9cb936fd1 461 tmp |= ((0x01<<LPS22HB_SW_RESET_BIT) | (0x01<<LPS22HB_BOOT_BIT));
nikapov 0:3de9cb936fd1 462
nikapov 0:3de9cb936fd1 463 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 464 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 465
nikapov 0:3de9cb936fd1 466 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 467 }
nikapov 0:3de9cb936fd1 468
nikapov 0:3de9cb936fd1 469
nikapov 0:3de9cb936fd1 470 /**
nikapov 0:3de9cb936fd1 471 * @brief Enable/Disable FIFO Mode
nikapov 0:3de9cb936fd1 472 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 473 * @param LPS22HB_ENABLE/LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 474 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 475 */
nikapov 0:3de9cb936fd1 476 LPS22HB_Error_et LPS22HB_Set_FifoModeUse(void *handle, LPS22HB_State_et status)
nikapov 0:3de9cb936fd1 477 {
nikapov 0:3de9cb936fd1 478 uint8_t tmp;
nikapov 0:3de9cb936fd1 479
nikapov 0:3de9cb936fd1 480 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 481
nikapov 0:3de9cb936fd1 482 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 483 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 484
nikapov 0:3de9cb936fd1 485 tmp &= ~LPS22HB_FIFO_EN_MASK;
nikapov 0:3de9cb936fd1 486 tmp |= ((uint8_t)status)<<LPS22HB_FIFO_EN_BIT;
nikapov 0:3de9cb936fd1 487
nikapov 0:3de9cb936fd1 488 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 489 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 490
nikapov 0:3de9cb936fd1 491 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 492 }
nikapov 0:3de9cb936fd1 493 /**
nikapov 0:3de9cb936fd1 494 * @brief Enable/Disable FIFO Watermark Level Use
nikapov 0:3de9cb936fd1 495 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 496 * @param LPS22HB_ENABLE/LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 497 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 498 */
nikapov 0:3de9cb936fd1 499 LPS22HB_Error_et LPS22HB_Set_FifoWatermarkLevelUse(void *handle, LPS22HB_State_et status)
nikapov 0:3de9cb936fd1 500 {
nikapov 0:3de9cb936fd1 501 uint8_t tmp;
nikapov 0:3de9cb936fd1 502
nikapov 0:3de9cb936fd1 503 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 504
nikapov 0:3de9cb936fd1 505 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 506 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 507
nikapov 0:3de9cb936fd1 508 tmp &= ~LPS22HB_WTM_EN_MASK;
nikapov 0:3de9cb936fd1 509 tmp |= ((uint8_t)status)<<LPS22HB_WTM_EN_BIT;
nikapov 0:3de9cb936fd1 510
nikapov 0:3de9cb936fd1 511 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 512 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 513
nikapov 0:3de9cb936fd1 514 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 515 }
nikapov 0:3de9cb936fd1 516
nikapov 0:3de9cb936fd1 517 /**
nikapov 0:3de9cb936fd1 518 * @brief Enable or Disable the Automatic increment register address during a multiple byte access with a serial interface (I2C or SPI)
nikapov 0:3de9cb936fd1 519 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 520 * @param LPS22HB_ENABLE/LPS22HB_DISABLE. Default is LPS22HB_ENABLE
nikapov 0:3de9cb936fd1 521 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 522 */
nikapov 0:3de9cb936fd1 523 LPS22HB_Error_et LPS22HB_Set_AutomaticIncrementRegAddress(void *handle, LPS22HB_State_et status){
nikapov 0:3de9cb936fd1 524
nikapov 0:3de9cb936fd1 525 uint8_t tmp;
nikapov 0:3de9cb936fd1 526
nikapov 0:3de9cb936fd1 527 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 528
nikapov 0:3de9cb936fd1 529 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 530 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 531
nikapov 0:3de9cb936fd1 532 tmp &= ~LPS22HB_ADD_INC_MASK;
nikapov 0:3de9cb936fd1 533 tmp |= (((uint8_t)status)<<LPS22HB_ADD_INC_BIT);
nikapov 0:3de9cb936fd1 534
nikapov 0:3de9cb936fd1 535 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 536 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 537
nikapov 0:3de9cb936fd1 538 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 539
nikapov 0:3de9cb936fd1 540 }
nikapov 0:3de9cb936fd1 541
nikapov 0:3de9cb936fd1 542 /**
nikapov 0:3de9cb936fd1 543 * @brief Enable/Disable I2C Interface
nikapov 0:3de9cb936fd1 544 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 545 * @param State: LPS22HB_ENABLE (reset bit)/ LPS22HB_DISABLE (set bit)
nikapov 0:3de9cb936fd1 546 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 547 */
nikapov 0:3de9cb936fd1 548 LPS22HB_Error_et LPS22HB_Set_I2C(void *handle, LPS22HB_State_et statei2c)
nikapov 0:3de9cb936fd1 549 {
nikapov 0:3de9cb936fd1 550 uint8_t tmp;
nikapov 0:3de9cb936fd1 551
nikapov 0:3de9cb936fd1 552 LPS22HB_assert_param(IS_LPS22HB_State(statei2c));
nikapov 0:3de9cb936fd1 553
nikapov 0:3de9cb936fd1 554 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 555 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 556
nikapov 0:3de9cb936fd1 557 /*Reset Bit->I2C Enabled*/
nikapov 0:3de9cb936fd1 558 tmp &= ~LPS22HB_I2C_MASK;
nikapov 0:3de9cb936fd1 559 tmp|=((uint8_t)~statei2c)<<LPS22HB_I2C_BIT;
nikapov 0:3de9cb936fd1 560
nikapov 0:3de9cb936fd1 561 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 562 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 563
nikapov 0:3de9cb936fd1 564 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 565 }
nikapov 0:3de9cb936fd1 566
nikapov 0:3de9cb936fd1 567
nikapov 0:3de9cb936fd1 568 /**
nikapov 0:3de9cb936fd1 569 * @brief Set the one-shot bit in order to start acquisition when the ONE SHOT mode
nikapov 0:3de9cb936fd1 570 * has been selected by the ODR configuration.
nikapov 0:3de9cb936fd1 571 * @detail Once the measurement is done, ONE_SHOT bit will self-clear.
nikapov 0:3de9cb936fd1 572 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 573 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 574 */
nikapov 0:3de9cb936fd1 575 LPS22HB_Error_et LPS22HB_StartOneShotMeasurement(void *handle)
nikapov 0:3de9cb936fd1 576 {
nikapov 0:3de9cb936fd1 577 uint8_t tmp;
nikapov 0:3de9cb936fd1 578
nikapov 0:3de9cb936fd1 579 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 580 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 581
nikapov 0:3de9cb936fd1 582 /* Set the one shot bit */
nikapov 0:3de9cb936fd1 583 /* Once the measurement is done, one shot bit will self-clear*/
nikapov 0:3de9cb936fd1 584 tmp |= LPS22HB_ONE_SHOT_MASK;
nikapov 0:3de9cb936fd1 585
nikapov 0:3de9cb936fd1 586 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 587 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 588
nikapov 0:3de9cb936fd1 589 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 590
nikapov 0:3de9cb936fd1 591 }
nikapov 0:3de9cb936fd1 592
nikapov 0:3de9cb936fd1 593 /**
nikapov 0:3de9cb936fd1 594 * @brief Set Interrupt Active on High or Low Level
nikapov 0:3de9cb936fd1 595 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 596 * @param LPS22HB_ActiveHigh/LPS22HB_ActiveLow
nikapov 0:3de9cb936fd1 597 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 598 */
nikapov 0:3de9cb936fd1 599 LPS22HB_Error_et LPS22HB_Set_InterruptActiveLevel(void *handle, LPS22HB_InterruptActiveLevel_et mode)
nikapov 0:3de9cb936fd1 600 {
nikapov 0:3de9cb936fd1 601 uint8_t tmp;
nikapov 0:3de9cb936fd1 602
nikapov 0:3de9cb936fd1 603 LPS22HB_assert_param(IS_LPS22HB_InterruptActiveLevel(mode));
nikapov 0:3de9cb936fd1 604
nikapov 0:3de9cb936fd1 605 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 606 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 607
nikapov 0:3de9cb936fd1 608 tmp &= ~LPS22HB_INT_H_L_MASK;
nikapov 0:3de9cb936fd1 609 tmp |= ((uint8_t)mode);
nikapov 0:3de9cb936fd1 610
nikapov 0:3de9cb936fd1 611 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 612 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 613
nikapov 0:3de9cb936fd1 614 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 615 }
nikapov 0:3de9cb936fd1 616
nikapov 0:3de9cb936fd1 617
nikapov 0:3de9cb936fd1 618 /**
nikapov 0:3de9cb936fd1 619 * @brief Push-pull/open drain selection on interrupt pads. Default tmp: 0
nikapov 0:3de9cb936fd1 620 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 621 * @param LPS22HB_PushPull/LPS22HB_OpenDrain
nikapov 0:3de9cb936fd1 622 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 623 */
nikapov 0:3de9cb936fd1 624 LPS22HB_Error_et LPS22HB_Set_InterruptOutputType(void *handle, LPS22HB_OutputType_et output)
nikapov 0:3de9cb936fd1 625 {
nikapov 0:3de9cb936fd1 626 uint8_t tmp;
nikapov 0:3de9cb936fd1 627
nikapov 0:3de9cb936fd1 628 LPS22HB_assert_param(IS_LPS22HB_OutputType(output));
nikapov 0:3de9cb936fd1 629
nikapov 0:3de9cb936fd1 630 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 631 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 632
nikapov 0:3de9cb936fd1 633 tmp &= ~LPS22HB_PP_OD_MASK;
nikapov 0:3de9cb936fd1 634 tmp |= (uint8_t)output;
nikapov 0:3de9cb936fd1 635
nikapov 0:3de9cb936fd1 636 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 637 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 638
nikapov 0:3de9cb936fd1 639 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 640 }
nikapov 0:3de9cb936fd1 641
nikapov 0:3de9cb936fd1 642 /**
nikapov 0:3de9cb936fd1 643 * @brief Set Data signal on INT pad control bits.
nikapov 0:3de9cb936fd1 644 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 645 * @param LPS22HB_DATA,LPS22HB_P_HIGH_LPS22HB_P_LOW,LPS22HB_P_LOW_HIGH
nikapov 0:3de9cb936fd1 646 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 647 */
nikapov 0:3de9cb936fd1 648 LPS22HB_Error_et LPS22HB_Set_InterruptControlConfig(void *handle, LPS22HB_OutputSignalConfig_et config)
nikapov 0:3de9cb936fd1 649 {
nikapov 0:3de9cb936fd1 650 uint8_t tmp;
nikapov 0:3de9cb936fd1 651
nikapov 0:3de9cb936fd1 652 LPS22HB_assert_param(IS_LPS22HB_OutputSignal(config));
nikapov 0:3de9cb936fd1 653
nikapov 0:3de9cb936fd1 654 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 655 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 656
nikapov 0:3de9cb936fd1 657 tmp &= ~(LPS22HB_INT_S12_MASK);
nikapov 0:3de9cb936fd1 658 tmp |= (uint8_t)config;
nikapov 0:3de9cb936fd1 659
nikapov 0:3de9cb936fd1 660 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 661 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 662
nikapov 0:3de9cb936fd1 663 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 664 }
nikapov 0:3de9cb936fd1 665
nikapov 0:3de9cb936fd1 666
nikapov 0:3de9cb936fd1 667 /**
nikapov 0:3de9cb936fd1 668 * @brief Enable/Disable Data-ready signal on INT_DRDY pin.
nikapov 0:3de9cb936fd1 669 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 670 * @param LPS22HB_ENABLE/LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 671 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 672 */
nikapov 0:3de9cb936fd1 673 LPS22HB_Error_et LPS22HB_Set_DRDYInterrupt(void *handle, LPS22HB_State_et status)
nikapov 0:3de9cb936fd1 674 {
nikapov 0:3de9cb936fd1 675 uint8_t tmp;
nikapov 0:3de9cb936fd1 676
nikapov 0:3de9cb936fd1 677
nikapov 0:3de9cb936fd1 678 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 679
nikapov 0:3de9cb936fd1 680 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 681 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 682
nikapov 0:3de9cb936fd1 683 tmp &= ~LPS22HB_DRDY_MASK;
nikapov 0:3de9cb936fd1 684 tmp |= ((uint8_t)status)<<LPS22HB_DRDY_BIT;
nikapov 0:3de9cb936fd1 685
nikapov 0:3de9cb936fd1 686 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 687 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 688
nikapov 0:3de9cb936fd1 689 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 690 }
nikapov 0:3de9cb936fd1 691
nikapov 0:3de9cb936fd1 692 /**
nikapov 0:3de9cb936fd1 693 * @brief Enable/Disable FIFO overrun interrupt on INT_DRDY pin.
nikapov 0:3de9cb936fd1 694 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 695 * @param LPS22HB_ENABLE/LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 696 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 697 */
nikapov 0:3de9cb936fd1 698 LPS22HB_Error_et LPS22HB_Set_FIFO_OVR_Interrupt(void *handle, LPS22HB_State_et status)
nikapov 0:3de9cb936fd1 699 {
nikapov 0:3de9cb936fd1 700 uint8_t tmp;
nikapov 0:3de9cb936fd1 701
nikapov 0:3de9cb936fd1 702
nikapov 0:3de9cb936fd1 703 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 704
nikapov 0:3de9cb936fd1 705 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 706 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 707
nikapov 0:3de9cb936fd1 708 tmp &= ~LPS22HB_FIFO_OVR_MASK;
nikapov 0:3de9cb936fd1 709 tmp |= ((uint8_t)status)<<LPS22HB_FIFO_OVR_BIT;
nikapov 0:3de9cb936fd1 710
nikapov 0:3de9cb936fd1 711 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 712 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 713
nikapov 0:3de9cb936fd1 714 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 715 }
nikapov 0:3de9cb936fd1 716
nikapov 0:3de9cb936fd1 717 /**
nikapov 0:3de9cb936fd1 718 * @brief Enable/Disable FIFO threshold (Watermark) interrupt on INT_DRDY pin.
nikapov 0:3de9cb936fd1 719 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 720 * @param LPS22HB_ENABLE/LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 721 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 722 */
nikapov 0:3de9cb936fd1 723 LPS22HB_Error_et LPS22HB_Set_FIFO_FTH_Interrupt(void *handle, LPS22HB_State_et status)
nikapov 0:3de9cb936fd1 724 {
nikapov 0:3de9cb936fd1 725 uint8_t tmp;
nikapov 0:3de9cb936fd1 726
nikapov 0:3de9cb936fd1 727 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 728
nikapov 0:3de9cb936fd1 729 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 730 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 731
nikapov 0:3de9cb936fd1 732 tmp &= ~LPS22HB_FIFO_FTH_MASK;
nikapov 0:3de9cb936fd1 733 tmp |= ((uint8_t)status)<<LPS22HB_FIFO_FTH_BIT;
nikapov 0:3de9cb936fd1 734
nikapov 0:3de9cb936fd1 735 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 736 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 737
nikapov 0:3de9cb936fd1 738 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 739 }
nikapov 0:3de9cb936fd1 740
nikapov 0:3de9cb936fd1 741 /**
nikapov 0:3de9cb936fd1 742 * @brief Enable/Disable FIFO FULL interrupt on INT_DRDY pin.
nikapov 0:3de9cb936fd1 743 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 744 * @param LPS22HB_ENABLE/LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 745 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 746 */
nikapov 0:3de9cb936fd1 747 LPS22HB_Error_et LPS22HB_Set_FIFO_FULL_Interrupt(void *handle, LPS22HB_State_et status)
nikapov 0:3de9cb936fd1 748 {
nikapov 0:3de9cb936fd1 749 uint8_t tmp;
nikapov 0:3de9cb936fd1 750
nikapov 0:3de9cb936fd1 751 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 752
nikapov 0:3de9cb936fd1 753 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 754 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 755
nikapov 0:3de9cb936fd1 756 tmp &= ~LPS22HB_FIFO_FULL_MASK;
nikapov 0:3de9cb936fd1 757 tmp |= ((uint8_t)status)<<LPS22HB_FIFO_FULL_BIT;
nikapov 0:3de9cb936fd1 758
nikapov 0:3de9cb936fd1 759 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 760 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 761
nikapov 0:3de9cb936fd1 762 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 763 }
nikapov 0:3de9cb936fd1 764
nikapov 0:3de9cb936fd1 765
nikapov 0:3de9cb936fd1 766
nikapov 0:3de9cb936fd1 767 /**
nikapov 0:3de9cb936fd1 768 * @brief Enable AutoRifP function
nikapov 0:3de9cb936fd1 769 * @detail When this function is enabled, an internal register is set with the current pressure values
nikapov 0:3de9cb936fd1 770 * and the content is subtracted from the pressure output value and result is used for the interrupt generation.
nikapov 0:3de9cb936fd1 771 * the AutoRifP is slf creared.
nikapov 0:3de9cb936fd1 772 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 773 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 774 */
nikapov 0:3de9cb936fd1 775 LPS22HB_Error_et LPS22HB_Set_AutoRifP(void *handle)
nikapov 0:3de9cb936fd1 776 {
nikapov 0:3de9cb936fd1 777 uint8_t tmp;
nikapov 0:3de9cb936fd1 778
nikapov 0:3de9cb936fd1 779 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 780 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 781
nikapov 0:3de9cb936fd1 782 tmp |= ((uint8_t)LPS22HB_AUTORIFP_MASK);
nikapov 0:3de9cb936fd1 783
nikapov 0:3de9cb936fd1 784 if(LPS22HB_write_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 785 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 786
nikapov 0:3de9cb936fd1 787 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 788 }
nikapov 0:3de9cb936fd1 789
nikapov 0:3de9cb936fd1 790 /**
nikapov 0:3de9cb936fd1 791 * @brief Disable AutoRifP function
nikapov 0:3de9cb936fd1 792 * @detail the RESET_ARP bit is used to disable the AUTORIFP function. This bis i is selfdleared
nikapov 0:3de9cb936fd1 793 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 794 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 795 */
nikapov 0:3de9cb936fd1 796 LPS22HB_Error_et LPS22HB_ResetAutoRifP(void *handle)
nikapov 0:3de9cb936fd1 797 {
nikapov 0:3de9cb936fd1 798 uint8_t tmp;
nikapov 0:3de9cb936fd1 799
nikapov 0:3de9cb936fd1 800 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 801 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 802
nikapov 0:3de9cb936fd1 803
nikapov 0:3de9cb936fd1 804 tmp |= ((uint8_t)LPS22HB_RESET_ARP_MASK);
nikapov 0:3de9cb936fd1 805
nikapov 0:3de9cb936fd1 806 if(LPS22HB_write_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 807 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 808
nikapov 0:3de9cb936fd1 809 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 810 }
nikapov 0:3de9cb936fd1 811
nikapov 0:3de9cb936fd1 812
nikapov 0:3de9cb936fd1 813 /*
nikapov 0:3de9cb936fd1 814 * @brief Set AutoZero Function bit
nikapov 0:3de9cb936fd1 815 * @detail When set to ‘1’, the actual pressure output is copied in the REF_P reg (@0x15..0x17)
nikapov 0:3de9cb936fd1 816 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 817 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 818 */
nikapov 0:3de9cb936fd1 819 LPS22HB_Error_et LPS22HB_Set_AutoZeroFunction(void *handle)
nikapov 0:3de9cb936fd1 820 {
nikapov 0:3de9cb936fd1 821 uint8_t tmp;
nikapov 0:3de9cb936fd1 822
nikapov 0:3de9cb936fd1 823 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 824 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 825
nikapov 0:3de9cb936fd1 826 tmp |= LPS22HB_AUTOZERO_MASK;
nikapov 0:3de9cb936fd1 827
nikapov 0:3de9cb936fd1 828 if(LPS22HB_write_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 829 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 830
nikapov 0:3de9cb936fd1 831 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 832 }
nikapov 0:3de9cb936fd1 833
nikapov 0:3de9cb936fd1 834
nikapov 0:3de9cb936fd1 835 /*
nikapov 0:3de9cb936fd1 836 * @brief Set ResetAutoZero Function bit
nikapov 0:3de9cb936fd1 837 * @details REF_P reg (@0x015..17) set pressure reference to default value RPDS reg (0x18/19).
nikapov 0:3de9cb936fd1 838 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 839 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 840 */
nikapov 0:3de9cb936fd1 841 LPS22HB_Error_et LPS22HB_ResetAutoZeroFunction(void *handle)
nikapov 0:3de9cb936fd1 842 {
nikapov 0:3de9cb936fd1 843 uint8_t tmp;
nikapov 0:3de9cb936fd1 844
nikapov 0:3de9cb936fd1 845 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 846 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 847
nikapov 0:3de9cb936fd1 848 /* Set the RESET_AZ bit*/
nikapov 0:3de9cb936fd1 849 /* RESET_AZ is self cleared*/
nikapov 0:3de9cb936fd1 850 tmp |= LPS22HB_RESET_AZ_MASK;
nikapov 0:3de9cb936fd1 851
nikapov 0:3de9cb936fd1 852 if(LPS22HB_write_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 853 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 854
nikapov 0:3de9cb936fd1 855
nikapov 0:3de9cb936fd1 856 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 857 }
nikapov 0:3de9cb936fd1 858
nikapov 0:3de9cb936fd1 859
nikapov 0:3de9cb936fd1 860 /**
nikapov 0:3de9cb936fd1 861 * @brief Enable/ Disable the computing of differential pressure output (Interrupt Generation)
nikapov 0:3de9cb936fd1 862 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 863 * @param LPS22HB_ENABLE,LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 864 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 865 */
nikapov 0:3de9cb936fd1 866 LPS22HB_Error_et LPS22HB_Set_InterruptDifferentialGeneration(void *handle, LPS22HB_State_et diff_en)
nikapov 0:3de9cb936fd1 867 {
nikapov 0:3de9cb936fd1 868 uint8_t tmp;
nikapov 0:3de9cb936fd1 869
nikapov 0:3de9cb936fd1 870 LPS22HB_assert_param(IS_LPS22HB_State(diff_en));
nikapov 0:3de9cb936fd1 871
nikapov 0:3de9cb936fd1 872 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 873 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 874
nikapov 0:3de9cb936fd1 875 tmp &= ~LPS22HB_DIFF_EN_MASK;
nikapov 0:3de9cb936fd1 876 tmp |= ((uint8_t)diff_en)<<LPS22HB_DIFF_EN_BIT;
nikapov 0:3de9cb936fd1 877
nikapov 0:3de9cb936fd1 878 if(LPS22HB_write_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 879 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 880
nikapov 0:3de9cb936fd1 881 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 882 }
nikapov 0:3de9cb936fd1 883
nikapov 0:3de9cb936fd1 884
nikapov 0:3de9cb936fd1 885 /**
nikapov 0:3de9cb936fd1 886 * @brief Get the DIFF_EN bit value
nikapov 0:3de9cb936fd1 887 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 888 * @param buffer to empty with the read value of DIFF_EN bit
nikapov 0:3de9cb936fd1 889 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 890 */
nikapov 0:3de9cb936fd1 891 LPS22HB_Error_et LPS22HB_Get_InterruptDifferentialGeneration(void *handle, LPS22HB_State_et* diff_en)
nikapov 0:3de9cb936fd1 892 {
nikapov 0:3de9cb936fd1 893 uint8_t tmp;
nikapov 0:3de9cb936fd1 894
nikapov 0:3de9cb936fd1 895 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 896 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 897
nikapov 0:3de9cb936fd1 898 *diff_en= (LPS22HB_State_et)((tmp & LPS22HB_DIFF_EN_MASK)>>LPS22HB_DIFF_EN_BIT);
nikapov 0:3de9cb936fd1 899
nikapov 0:3de9cb936fd1 900 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 901 }
nikapov 0:3de9cb936fd1 902
nikapov 0:3de9cb936fd1 903 /**
nikapov 0:3de9cb936fd1 904 * @brief Latch Interrupt request to the INT_SOURCE register.
nikapov 0:3de9cb936fd1 905 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 906 * @param LPS22HB_ENABLE/LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 907 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 908 */
nikapov 0:3de9cb936fd1 909 LPS22HB_Error_et LPS22HB_LatchInterruptRequest(void *handle, LPS22HB_State_et status)
nikapov 0:3de9cb936fd1 910 {
nikapov 0:3de9cb936fd1 911 uint8_t tmp;
nikapov 0:3de9cb936fd1 912
nikapov 0:3de9cb936fd1 913 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 914
nikapov 0:3de9cb936fd1 915 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 916 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 917
nikapov 0:3de9cb936fd1 918 tmp &= ~LPS22HB_LIR_MASK;
nikapov 0:3de9cb936fd1 919 tmp |= (((uint8_t)status)<<LPS22HB_LIR_BIT);
nikapov 0:3de9cb936fd1 920
nikapov 0:3de9cb936fd1 921 if(LPS22HB_write_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 922 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 923
nikapov 0:3de9cb936fd1 924 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 925 }
nikapov 0:3de9cb936fd1 926
nikapov 0:3de9cb936fd1 927
nikapov 0:3de9cb936fd1 928
nikapov 0:3de9cb936fd1 929 /**
nikapov 0:3de9cb936fd1 930 * @brief Enable\Disable Interrupt Generation on differential pressure Low event
nikapov 0:3de9cb936fd1 931 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 932 * @param LPS22HB_ENABLE/LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 933 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 934 */
nikapov 0:3de9cb936fd1 935 LPS22HB_Error_et LPS22HB_Set_PLE(void *handle, LPS22HB_State_et status)
nikapov 0:3de9cb936fd1 936 {
nikapov 0:3de9cb936fd1 937 uint8_t tmp;
nikapov 0:3de9cb936fd1 938
nikapov 0:3de9cb936fd1 939 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 940
nikapov 0:3de9cb936fd1 941 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 942 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 943
nikapov 0:3de9cb936fd1 944 tmp &= ~LPS22HB_PLE_MASK;
nikapov 0:3de9cb936fd1 945 tmp |= (((uint8_t)status)<<LPS22HB_PLE_BIT);
nikapov 0:3de9cb936fd1 946
nikapov 0:3de9cb936fd1 947 if(LPS22HB_write_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 948 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 949
nikapov 0:3de9cb936fd1 950 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 951 }
nikapov 0:3de9cb936fd1 952
nikapov 0:3de9cb936fd1 953 /**
nikapov 0:3de9cb936fd1 954 * @brief Enable\Disable Interrupt Generation on differential pressure High event
nikapov 0:3de9cb936fd1 955 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 956 * @param LPS22HB_ENABLE/LPS22HB_DISABLE
nikapov 0:3de9cb936fd1 957 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 958 */
nikapov 0:3de9cb936fd1 959 LPS22HB_Error_et LPS22HB_Set_PHE(void *handle, LPS22HB_State_et status)
nikapov 0:3de9cb936fd1 960 {
nikapov 0:3de9cb936fd1 961 uint8_t tmp;
nikapov 0:3de9cb936fd1 962
nikapov 0:3de9cb936fd1 963 LPS22HB_assert_param(IS_LPS22HB_State(status));
nikapov 0:3de9cb936fd1 964
nikapov 0:3de9cb936fd1 965 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 966 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 967
nikapov 0:3de9cb936fd1 968 tmp &= ~LPS22HB_PHE_MASK;
nikapov 0:3de9cb936fd1 969 tmp |= (((uint8_t)status)<<LPS22HB_PHE_BIT);
nikapov 0:3de9cb936fd1 970
nikapov 0:3de9cb936fd1 971 if(LPS22HB_write_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 972 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 973
nikapov 0:3de9cb936fd1 974 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 975 }
nikapov 0:3de9cb936fd1 976
nikapov 0:3de9cb936fd1 977 /**
nikapov 0:3de9cb936fd1 978 * @brief Get the Interrupt Generation on differential pressure status event and the Boot Status.
nikapov 0:3de9cb936fd1 979 * @detail The INT_SOURCE register is cleared by reading it.
nikapov 0:3de9cb936fd1 980 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 981 * @param Status Event Flag: BOOT, PH,PL,IA
nikapov 0:3de9cb936fd1 982 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 983 */
nikapov 0:3de9cb936fd1 984 LPS22HB_Error_et LPS22HB_Get_InterruptDifferentialEventStatus(void *handle, LPS22HB_InterruptDiffStatus_st* interruptsource)
nikapov 0:3de9cb936fd1 985 {
nikapov 0:3de9cb936fd1 986 uint8_t tmp;
nikapov 0:3de9cb936fd1 987
nikapov 0:3de9cb936fd1 988 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_SOURCE_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 989 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 990
nikapov 0:3de9cb936fd1 991 interruptsource->PH = (uint8_t)(tmp & LPS22HB_PH_MASK);
nikapov 0:3de9cb936fd1 992 interruptsource->PL = (uint8_t)((tmp & LPS22HB_PL_MASK)>>LPS22HB_PL_BIT);
nikapov 0:3de9cb936fd1 993 interruptsource->IA = (uint8_t)((tmp & LPS22HB_IA_MASK)>>LPS22HB_IA_BIT);
nikapov 0:3de9cb936fd1 994 interruptsource->BOOT= (uint8_t)((tmp & LPS22HB_BOOT_STATUS_MASK)>>LPS22HB_BOOT_STATUS_BIT);
nikapov 0:3de9cb936fd1 995
nikapov 0:3de9cb936fd1 996 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 997 }
nikapov 0:3de9cb936fd1 998
nikapov 0:3de9cb936fd1 999 /**
nikapov 0:3de9cb936fd1 1000 * @brief Get the status of Pressure and Temperature data
nikapov 0:3de9cb936fd1 1001 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1002 * @param Data Status Flag: TempDataAvailable, TempDataOverrun, PressDataAvailable, PressDataOverrun
nikapov 0:3de9cb936fd1 1003 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1004 */
nikapov 0:3de9cb936fd1 1005 LPS22HB_Error_et LPS22HB_Get_DataStatus(void *handle, LPS22HB_DataStatus_st* datastatus)
nikapov 0:3de9cb936fd1 1006 {
nikapov 0:3de9cb936fd1 1007 uint8_t tmp;
nikapov 0:3de9cb936fd1 1008
nikapov 0:3de9cb936fd1 1009 if(LPS22HB_read_reg(handle, LPS22HB_STATUS_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1010 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1011
nikapov 0:3de9cb936fd1 1012 datastatus->PressDataAvailable = (uint8_t)(tmp & LPS22HB_PDA_MASK);
nikapov 0:3de9cb936fd1 1013 datastatus->TempDataAvailable = (uint8_t)((tmp & LPS22HB_TDA_MASK)>>LPS22HB_PDA_BIT);
nikapov 0:3de9cb936fd1 1014 datastatus->TempDataOverrun = (uint8_t)((tmp & LPS22HB_TOR_MASK)>>LPS22HB_TOR_BIT);
nikapov 0:3de9cb936fd1 1015 datastatus->PressDataOverrun = (uint8_t)((tmp & LPS22HB_POR_MASK)>>LPS22HB_POR_BIT);
nikapov 0:3de9cb936fd1 1016
nikapov 0:3de9cb936fd1 1017 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1018 }
nikapov 0:3de9cb936fd1 1019
nikapov 0:3de9cb936fd1 1020
nikapov 0:3de9cb936fd1 1021
nikapov 0:3de9cb936fd1 1022 /**
nikapov 0:3de9cb936fd1 1023 * @brief Get the LPS22HB raw presure value
nikapov 0:3de9cb936fd1 1024 * @detail The data are expressed as PRESS_OUT_H/_L/_XL in 2’s complement.
nikapov 0:3de9cb936fd1 1025 Pout(hPA)=PRESS_OUT / 4096
nikapov 0:3de9cb936fd1 1026 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1027 * @param The buffer to empty with the pressure raw value
nikapov 0:3de9cb936fd1 1028 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1029 */
nikapov 0:3de9cb936fd1 1030 LPS22HB_Error_et LPS22HB_Get_RawPressure(void *handle, int32_t *raw_press)
nikapov 0:3de9cb936fd1 1031 {
nikapov 0:3de9cb936fd1 1032 uint8_t buffer[3];
nikapov 0:3de9cb936fd1 1033 uint32_t tmp = 0;
nikapov 0:3de9cb936fd1 1034 uint8_t i;
nikapov 0:3de9cb936fd1 1035
nikapov 0:3de9cb936fd1 1036 if(LPS22HB_read_reg(handle, LPS22HB_PRESS_OUT_XL_REG, 3, buffer))
nikapov 0:3de9cb936fd1 1037 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1038
nikapov 0:3de9cb936fd1 1039 /* Build the raw data */
nikapov 0:3de9cb936fd1 1040 for(i=0; i<3; i++)
nikapov 0:3de9cb936fd1 1041 tmp |= (((uint32_t)buffer[i]) << (8*i));
nikapov 0:3de9cb936fd1 1042
nikapov 0:3de9cb936fd1 1043 /* convert the 2's complement 24 bit to 2's complement 32 bit */
nikapov 0:3de9cb936fd1 1044 if(tmp & 0x00800000)
nikapov 0:3de9cb936fd1 1045 tmp |= 0xFF000000;
nikapov 0:3de9cb936fd1 1046
nikapov 0:3de9cb936fd1 1047 *raw_press = ((int32_t)tmp);
nikapov 0:3de9cb936fd1 1048
nikapov 0:3de9cb936fd1 1049 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1050 }
nikapov 0:3de9cb936fd1 1051
nikapov 0:3de9cb936fd1 1052 /**
nikapov 0:3de9cb936fd1 1053 * @brief Get the LPS22HB Pressure value in hPA.
nikapov 0:3de9cb936fd1 1054 * @detail The data are expressed as PRESS_OUT_H/_L/_XL in 2’s complement.
nikapov 0:3de9cb936fd1 1055 Pout(hPA)=PRESS_OUT / 4096
nikapov 0:3de9cb936fd1 1056 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1057 * @param The buffer to empty with the pressure value that must be divided by 100 to get the value in hPA
nikapov 0:3de9cb936fd1 1058 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1059 */
nikapov 0:3de9cb936fd1 1060 LPS22HB_Error_et LPS22HB_Get_Pressure(void *handle, int32_t* Pout)
nikapov 0:3de9cb936fd1 1061 {
nikapov 0:3de9cb936fd1 1062 int32_t raw_press;
nikapov 0:3de9cb936fd1 1063
nikapov 0:3de9cb936fd1 1064 if(LPS22HB_Get_RawPressure(handle, &raw_press))
nikapov 0:3de9cb936fd1 1065 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1066
nikapov 0:3de9cb936fd1 1067 *Pout = (raw_press*100)/4096;
nikapov 0:3de9cb936fd1 1068
nikapov 0:3de9cb936fd1 1069 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1070 }
nikapov 0:3de9cb936fd1 1071
nikapov 0:3de9cb936fd1 1072 /**
nikapov 0:3de9cb936fd1 1073 * @brief Get the Raw Temperature value.
nikapov 0:3de9cb936fd1 1074 * @detail Temperature data are expressed as TEMP_OUT_H&TEMP_OUT_L as 2’s complement number.
nikapov 0:3de9cb936fd1 1075 * Tout(degC)=TEMP_OUT/100
nikapov 0:3de9cb936fd1 1076 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1077 * @param Buffer to empty with the temperature raw tmp.
nikapov 0:3de9cb936fd1 1078 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1079 */
nikapov 0:3de9cb936fd1 1080 LPS22HB_Error_et LPS22HB_Get_RawTemperature(void *handle, int16_t* raw_data)
nikapov 0:3de9cb936fd1 1081 {
nikapov 0:3de9cb936fd1 1082 uint8_t buffer[2];
nikapov 0:3de9cb936fd1 1083 uint16_t tmp;
nikapov 0:3de9cb936fd1 1084
nikapov 0:3de9cb936fd1 1085 if(LPS22HB_read_reg(handle, LPS22HB_TEMP_OUT_L_REG, 2, buffer))
nikapov 0:3de9cb936fd1 1086 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1087
nikapov 0:3de9cb936fd1 1088 /* Build the raw tmp */
nikapov 0:3de9cb936fd1 1089 tmp = (((uint16_t)buffer[1]) << 8) + (uint16_t)buffer[0];
nikapov 0:3de9cb936fd1 1090
nikapov 0:3de9cb936fd1 1091 *raw_data = ((int16_t)tmp);
nikapov 0:3de9cb936fd1 1092
nikapov 0:3de9cb936fd1 1093 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1094 }
nikapov 0:3de9cb936fd1 1095
nikapov 0:3de9cb936fd1 1096
nikapov 0:3de9cb936fd1 1097 /**
nikapov 0:3de9cb936fd1 1098 * @brief Get the Temperature value in °C.
nikapov 0:3de9cb936fd1 1099 * @detail Temperature data are expressed as TEMP_OUT_H&TEMP_OUT_L as 2’s complement number.
nikapov 0:3de9cb936fd1 1100 * Tout(degC)=TEMP_OUT/100
nikapov 0:3de9cb936fd1 1101 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1102 * @param Buffer to empty with the temperature value that must be divided by 10 to get the value in °C
nikapov 0:3de9cb936fd1 1103 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1104 */
nikapov 0:3de9cb936fd1 1105 LPS22HB_Error_et LPS22HB_Get_Temperature(void *handle, int16_t* Tout)
nikapov 0:3de9cb936fd1 1106 {
nikapov 0:3de9cb936fd1 1107 int16_t raw_data;
nikapov 0:3de9cb936fd1 1108
nikapov 0:3de9cb936fd1 1109 if(LPS22HB_Get_RawTemperature(handle, &raw_data))
nikapov 0:3de9cb936fd1 1110 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1111
nikapov 0:3de9cb936fd1 1112 *Tout = (raw_data*10)/100;
nikapov 0:3de9cb936fd1 1113
nikapov 0:3de9cb936fd1 1114 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1115 }
nikapov 0:3de9cb936fd1 1116
nikapov 0:3de9cb936fd1 1117 /**
nikapov 0:3de9cb936fd1 1118 * @brief Get the threshold value used for pressure interrupt generation (hPA).
nikapov 0:3de9cb936fd1 1119 * @detail THS_P=THS_P_H&THS_P_L and is expressed as unsigned number. P_ths(hPA)=(THS_P)/16.
nikapov 0:3de9cb936fd1 1120 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1121 * @param Buffer to empty with the pressure threshold in hPA
nikapov 0:3de9cb936fd1 1122 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1123 */
nikapov 0:3de9cb936fd1 1124 LPS22HB_Error_et LPS22HB_Get_PressureThreshold(void *handle, int16_t* P_ths)
nikapov 0:3de9cb936fd1 1125 {
nikapov 0:3de9cb936fd1 1126 uint8_t tempReg[2];
nikapov 0:3de9cb936fd1 1127
nikapov 0:3de9cb936fd1 1128 if(LPS22HB_read_reg(handle, LPS22HB_THS_P_LOW_REG, 2, tempReg))
nikapov 0:3de9cb936fd1 1129 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1130
nikapov 0:3de9cb936fd1 1131 *P_ths= (((((uint16_t)tempReg[1])<<8) + tempReg[0])/16);
nikapov 0:3de9cb936fd1 1132
nikapov 0:3de9cb936fd1 1133 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1134 }
nikapov 0:3de9cb936fd1 1135
nikapov 0:3de9cb936fd1 1136 /**
nikapov 0:3de9cb936fd1 1137 * @brief Set the threshold value used for pressure interrupt generation (hPA).
nikapov 0:3de9cb936fd1 1138 * @detail THS_P=THS_P_H&THS_P_L and is expressed as unsigned number. P_ths(hPA)=(THS_P)/16.
nikapov 0:3de9cb936fd1 1139 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1140 * @param Pressure threshold in hPA
nikapov 0:3de9cb936fd1 1141 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1142 */
nikapov 0:3de9cb936fd1 1143 LPS22HB_Error_et LPS22HB_Set_PressureThreshold(void *handle, int16_t P_ths)
nikapov 0:3de9cb936fd1 1144 {
nikapov 0:3de9cb936fd1 1145 uint8_t buffer[2];
nikapov 0:3de9cb936fd1 1146
nikapov 0:3de9cb936fd1 1147 buffer[0] = (uint8_t)(16 * P_ths);
nikapov 0:3de9cb936fd1 1148 buffer[1] = (uint8_t)(((uint16_t)(16 * P_ths))>>8);
nikapov 0:3de9cb936fd1 1149
nikapov 0:3de9cb936fd1 1150 if(LPS22HB_write_reg(handle, LPS22HB_THS_P_LOW_REG, 2, buffer))
nikapov 0:3de9cb936fd1 1151 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1152
nikapov 0:3de9cb936fd1 1153 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1154 }
nikapov 0:3de9cb936fd1 1155
nikapov 0:3de9cb936fd1 1156 /**
nikapov 0:3de9cb936fd1 1157 * @brief Set Fifo Mode.
nikapov 0:3de9cb936fd1 1158 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1159 * @param Fifo Mode struct
nikapov 0:3de9cb936fd1 1160 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1161 */
nikapov 0:3de9cb936fd1 1162 LPS22HB_Error_et LPS22HB_Set_FifoMode(void *handle, LPS22HB_FifoMode_et fifomode)
nikapov 0:3de9cb936fd1 1163 {
nikapov 0:3de9cb936fd1 1164 uint8_t tmp;
nikapov 0:3de9cb936fd1 1165
nikapov 0:3de9cb936fd1 1166 LPS22HB_assert_param(IS_LPS22HB_FifoMode(fifomode));
nikapov 0:3de9cb936fd1 1167
nikapov 0:3de9cb936fd1 1168 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_FIFO_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1169 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1170
nikapov 0:3de9cb936fd1 1171 tmp &= ~LPS22HB_FIFO_MODE_MASK;
nikapov 0:3de9cb936fd1 1172 tmp |= (uint8_t)fifomode;
nikapov 0:3de9cb936fd1 1173
nikapov 0:3de9cb936fd1 1174 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_FIFO_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1175 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1176
nikapov 0:3de9cb936fd1 1177 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1178 }
nikapov 0:3de9cb936fd1 1179
nikapov 0:3de9cb936fd1 1180 /**
nikapov 0:3de9cb936fd1 1181 * @brief Get Fifo Mode
nikapov 0:3de9cb936fd1 1182 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1183 * @param buffer to empty with fifo mode tmp
nikapov 0:3de9cb936fd1 1184 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1185 */
nikapov 0:3de9cb936fd1 1186 LPS22HB_Error_et LPS22HB_Get_FifoMode(void *handle, LPS22HB_FifoMode_et* fifomode)
nikapov 0:3de9cb936fd1 1187 {
nikapov 0:3de9cb936fd1 1188 uint8_t tmp;
nikapov 0:3de9cb936fd1 1189
nikapov 0:3de9cb936fd1 1190 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_FIFO_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1191 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1192
nikapov 0:3de9cb936fd1 1193 tmp &= LPS22HB_FIFO_MODE_MASK;
nikapov 0:3de9cb936fd1 1194 *fifomode = (LPS22HB_FifoMode_et)tmp;
nikapov 0:3de9cb936fd1 1195
nikapov 0:3de9cb936fd1 1196 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1197 }
nikapov 0:3de9cb936fd1 1198
nikapov 0:3de9cb936fd1 1199 /**
nikapov 0:3de9cb936fd1 1200 * @brief Set Fifo Watermark Level.
nikapov 0:3de9cb936fd1 1201 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1202 * @param Watermark level value [0 31]
nikapov 0:3de9cb936fd1 1203 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1204 */
nikapov 0:3de9cb936fd1 1205 LPS22HB_Error_et LPS22HB_Set_FifoWatermarkLevel(void *handle, uint8_t wtmlevel)
nikapov 0:3de9cb936fd1 1206 {
nikapov 0:3de9cb936fd1 1207 uint8_t tmp;
nikapov 0:3de9cb936fd1 1208
nikapov 0:3de9cb936fd1 1209 LPS22HB_assert_param(IS_LPS22HB_WtmLevel(wtmlevel));
nikapov 0:3de9cb936fd1 1210
nikapov 0:3de9cb936fd1 1211 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_FIFO_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1212 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1213
nikapov 0:3de9cb936fd1 1214 tmp &= ~LPS22HB_WTM_POINT_MASK;
nikapov 0:3de9cb936fd1 1215 tmp |= wtmlevel;
nikapov 0:3de9cb936fd1 1216
nikapov 0:3de9cb936fd1 1217 if(LPS22HB_write_reg(handle, LPS22HB_CTRL_FIFO_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1218 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1219
nikapov 0:3de9cb936fd1 1220 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1221 }
nikapov 0:3de9cb936fd1 1222
nikapov 0:3de9cb936fd1 1223 /**
nikapov 0:3de9cb936fd1 1224 * @brief Get FIFO Watermark Level
nikapov 0:3de9cb936fd1 1225 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1226 * @param buffer to empty with watermak level[0,31] value read from sensor
nikapov 0:3de9cb936fd1 1227 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1228 */
nikapov 0:3de9cb936fd1 1229 LPS22HB_Error_et LPS22HB_Get_FifoWatermarkLevel(void *handle, uint8_t *wtmlevel)
nikapov 0:3de9cb936fd1 1230 {
nikapov 0:3de9cb936fd1 1231 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_FIFO_REG, 1, wtmlevel))
nikapov 0:3de9cb936fd1 1232 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1233
nikapov 0:3de9cb936fd1 1234 *wtmlevel &= LPS22HB_WTM_POINT_MASK;
nikapov 0:3de9cb936fd1 1235
nikapov 0:3de9cb936fd1 1236 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1237 }
nikapov 0:3de9cb936fd1 1238
nikapov 0:3de9cb936fd1 1239 /**
nikapov 0:3de9cb936fd1 1240 * @brief Get the Fifo Status
nikapov 0:3de9cb936fd1 1241 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1242 * @param Status Flag: FIFO_FTH,FIFO_EMPTY,FIFO_FULL,FIFO_OVR and level of the FIFO->FIFO_LEVEL
nikapov 0:3de9cb936fd1 1243 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1244 */
nikapov 0:3de9cb936fd1 1245 LPS22HB_Error_et LPS22HB_Get_FifoStatus(void *handle, LPS22HB_FifoStatus_st* status)
nikapov 0:3de9cb936fd1 1246 {
nikapov 0:3de9cb936fd1 1247 uint8_t tmp;
nikapov 0:3de9cb936fd1 1248
nikapov 0:3de9cb936fd1 1249 if(LPS22HB_read_reg(handle, LPS22HB_STATUS_FIFO_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1250 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1251
nikapov 0:3de9cb936fd1 1252 status->FIFO_FTH = (uint8_t)((tmp & LPS22HB_FTH_FIFO_MASK)>>LPS22HB_FTH_FIFO_BIT);
nikapov 0:3de9cb936fd1 1253 status->FIFO_OVR=(uint8_t)((tmp & LPS22HB_OVR_FIFO_MASK)>>LPS22HB_OVR_FIFO_BIT);
nikapov 0:3de9cb936fd1 1254 status->FIFO_LEVEL = (uint8_t)(tmp & LPS22HB_LEVEL_FIFO_MASK);
nikapov 0:3de9cb936fd1 1255
nikapov 0:3de9cb936fd1 1256 if(status->FIFO_LEVEL ==LPS22HB_FIFO_EMPTY)
nikapov 0:3de9cb936fd1 1257 status->FIFO_EMPTY=0x01;
nikapov 0:3de9cb936fd1 1258 else
nikapov 0:3de9cb936fd1 1259 status->FIFO_EMPTY=0x00;
nikapov 0:3de9cb936fd1 1260
nikapov 0:3de9cb936fd1 1261 if (status->FIFO_LEVEL ==LPS22HB_FIFO_FULL)
nikapov 0:3de9cb936fd1 1262 status->FIFO_FULL=0x01;
nikapov 0:3de9cb936fd1 1263 else
nikapov 0:3de9cb936fd1 1264 status->FIFO_FULL=0x00;
nikapov 0:3de9cb936fd1 1265
nikapov 0:3de9cb936fd1 1266
nikapov 0:3de9cb936fd1 1267 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1268 }
nikapov 0:3de9cb936fd1 1269
nikapov 0:3de9cb936fd1 1270 /**
nikapov 0:3de9cb936fd1 1271 * @brief Get the reference pressure after soldering for computing differential pressure (hPA)
nikapov 0:3de9cb936fd1 1272 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1273 * @param buffer to empty with the he pressure value (hPA)
nikapov 0:3de9cb936fd1 1274 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1275 */
nikapov 0:3de9cb936fd1 1276 LPS22HB_Error_et LPS22HB_Get_PressureOffsetValue(void *handle, int16_t *pressoffset)
nikapov 0:3de9cb936fd1 1277 {
nikapov 0:3de9cb936fd1 1278 uint8_t buffer[2];
nikapov 0:3de9cb936fd1 1279 int16_t raw_press;
nikapov 0:3de9cb936fd1 1280
nikapov 0:3de9cb936fd1 1281 if(LPS22HB_read_reg(handle, LPS22HB_RPDS_L_REG, 2, buffer))
nikapov 0:3de9cb936fd1 1282 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1283
nikapov 0:3de9cb936fd1 1284 raw_press = (int16_t)((((uint16_t)buffer[1]) << 8) + (uint16_t)buffer[0]);
nikapov 0:3de9cb936fd1 1285
nikapov 0:3de9cb936fd1 1286 *pressoffset = (raw_press*100)/4096;
nikapov 0:3de9cb936fd1 1287
nikapov 0:3de9cb936fd1 1288 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1289 }
nikapov 0:3de9cb936fd1 1290
nikapov 0:3de9cb936fd1 1291
nikapov 0:3de9cb936fd1 1292 /**
nikapov 0:3de9cb936fd1 1293 * @brief Get the Reference Pressure value
nikapov 0:3de9cb936fd1 1294 * @detail It is a 24-bit data added to the sensor output measurement to detect a measured pressure beyond programmed limits.
nikapov 0:3de9cb936fd1 1295 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1296 * @param Buffer to empty with reference pressure value
nikapov 0:3de9cb936fd1 1297 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1298 */
nikapov 0:3de9cb936fd1 1299 LPS22HB_Error_et LPS22HB_Get_ReferencePressure(void *handle, int32_t* RefP)
nikapov 0:3de9cb936fd1 1300 {
nikapov 0:3de9cb936fd1 1301 uint8_t buffer[3];
nikapov 0:3de9cb936fd1 1302 uint32_t tempVal=0;
nikapov 0:3de9cb936fd1 1303 int32_t raw_press;
nikapov 0:3de9cb936fd1 1304 uint8_t i;
nikapov 0:3de9cb936fd1 1305
nikapov 0:3de9cb936fd1 1306 if(LPS22HB_read_reg(handle, LPS22HB_REF_P_XL_REG, 3, buffer))
nikapov 0:3de9cb936fd1 1307 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1308
nikapov 0:3de9cb936fd1 1309 /* Build the raw data */
nikapov 0:3de9cb936fd1 1310 for(i=0; i<3; i++)
nikapov 0:3de9cb936fd1 1311 tempVal |= (((uint32_t)buffer[i]) << (8*i));
nikapov 0:3de9cb936fd1 1312
nikapov 0:3de9cb936fd1 1313 /* convert the 2's complement 24 bit to 2's complement 32 bit */
nikapov 0:3de9cb936fd1 1314 if(tempVal & 0x00800000)
nikapov 0:3de9cb936fd1 1315 tempVal |= 0xFF000000;
nikapov 0:3de9cb936fd1 1316
nikapov 0:3de9cb936fd1 1317 raw_press =((int32_t)tempVal);
nikapov 0:3de9cb936fd1 1318 *RefP = (raw_press*100)/4096;
nikapov 0:3de9cb936fd1 1319
nikapov 0:3de9cb936fd1 1320
nikapov 0:3de9cb936fd1 1321 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1322 }
nikapov 0:3de9cb936fd1 1323
nikapov 0:3de9cb936fd1 1324
nikapov 0:3de9cb936fd1 1325 /**
nikapov 0:3de9cb936fd1 1326 * @brief Check if the single measurement has completed.
nikapov 0:3de9cb936fd1 1327 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1328 * @param the returned value is set to 1, when the measurement is completed
nikapov 0:3de9cb936fd1 1329 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1330 */
nikapov 0:3de9cb936fd1 1331 LPS22HB_Error_et LPS22HB_IsMeasurementCompleted(void *handle, uint8_t* Is_Measurement_Completed)
nikapov 0:3de9cb936fd1 1332 {
nikapov 0:3de9cb936fd1 1333 uint8_t tmp;
nikapov 0:3de9cb936fd1 1334 LPS22HB_DataStatus_st datastatus;
nikapov 0:3de9cb936fd1 1335
nikapov 0:3de9cb936fd1 1336 if(LPS22HB_read_reg(handle, LPS22HB_STATUS_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1337 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1338
nikapov 0:3de9cb936fd1 1339 datastatus.TempDataAvailable=(uint8_t)((tmp&LPS22HB_TDA_MASK)>>LPS22HB_TDA_BIT);
nikapov 0:3de9cb936fd1 1340 datastatus.PressDataAvailable= (uint8_t)(tmp&LPS22HB_PDA_MASK);
nikapov 0:3de9cb936fd1 1341
nikapov 0:3de9cb936fd1 1342 *Is_Measurement_Completed=(uint8_t)((datastatus.PressDataAvailable) & (datastatus.TempDataAvailable));
nikapov 0:3de9cb936fd1 1343
nikapov 0:3de9cb936fd1 1344 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1345 }
nikapov 0:3de9cb936fd1 1346
nikapov 0:3de9cb936fd1 1347 /**
nikapov 0:3de9cb936fd1 1348 * @brief Get the values of the last single measurement.
nikapov 0:3de9cb936fd1 1349 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1350 * @param Pressure and temperature tmp
nikapov 0:3de9cb936fd1 1351 * @retval Error Code [LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1352 */
nikapov 0:3de9cb936fd1 1353 LPS22HB_Error_et LPS22HB_Get_Measurement(void *handle, LPS22HB_MeasureTypeDef_st *Measurement_Value)
nikapov 0:3de9cb936fd1 1354 {
nikapov 0:3de9cb936fd1 1355 int16_t Tout;
nikapov 0:3de9cb936fd1 1356 int32_t Pout;
nikapov 0:3de9cb936fd1 1357
nikapov 0:3de9cb936fd1 1358 if(LPS22HB_Get_Temperature(handle, &Tout))
nikapov 0:3de9cb936fd1 1359 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1360
nikapov 0:3de9cb936fd1 1361 Measurement_Value->Tout=Tout;
nikapov 0:3de9cb936fd1 1362
nikapov 0:3de9cb936fd1 1363 if(LPS22HB_Get_Pressure(handle, &Pout))
nikapov 0:3de9cb936fd1 1364 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1365
nikapov 0:3de9cb936fd1 1366 Measurement_Value->Pout=Pout;
nikapov 0:3de9cb936fd1 1367
nikapov 0:3de9cb936fd1 1368 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1369
nikapov 0:3de9cb936fd1 1370 }
nikapov 0:3de9cb936fd1 1371
nikapov 0:3de9cb936fd1 1372 /**
nikapov 0:3de9cb936fd1 1373 * @brief Initialization function for LPS22HB.
nikapov 0:3de9cb936fd1 1374 * This function make a memory boot.
nikapov 0:3de9cb936fd1 1375 * Init the sensor with a standard basic confifuration.
nikapov 0:3de9cb936fd1 1376 * Low Power, ODR 25 Hz, Low Pass Filter disabled; BDU enabled; I2C enabled;
nikapov 0:3de9cb936fd1 1377 * NO FIFO; NO Interrupt Enabled.
nikapov 0:3de9cb936fd1 1378 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1379 * @retval Error code[LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1380 */
nikapov 0:3de9cb936fd1 1381 LPS22HB_Error_et LPS22HB_Init(void *handle)
nikapov 0:3de9cb936fd1 1382 {
nikapov 0:3de9cb936fd1 1383 LPS22HB_ConfigTypeDef_st pLPS22HBInit;
nikapov 0:3de9cb936fd1 1384
nikapov 0:3de9cb936fd1 1385 /* Make LPS22HB Reset and Reboot */
nikapov 0:3de9cb936fd1 1386 if(LPS22HB_SwResetAndMemoryBoot(handle))
nikapov 0:3de9cb936fd1 1387 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1388
nikapov 0:3de9cb936fd1 1389 pLPS22HBInit.PowerMode=LPS22HB_LowPower;
nikapov 0:3de9cb936fd1 1390 pLPS22HBInit.OutputDataRate=LPS22HB_ODR_25HZ;
nikapov 0:3de9cb936fd1 1391 pLPS22HBInit.LowPassFilter=LPS22HB_DISABLE;
nikapov 0:3de9cb936fd1 1392 pLPS22HBInit.LPF_Cutoff=LPS22HB_ODR_9;
nikapov 0:3de9cb936fd1 1393 pLPS22HBInit.BDU=LPS22HB_BDU_NO_UPDATE;
nikapov 0:3de9cb936fd1 1394 pLPS22HBInit.IfAddInc=LPS22HB_ENABLE; //default
nikapov 0:3de9cb936fd1 1395 pLPS22HBInit.Sim= LPS22HB_SPI_4_WIRE;
nikapov 0:3de9cb936fd1 1396
nikapov 0:3de9cb936fd1 1397 /* Set Generic Configuration*/
nikapov 0:3de9cb936fd1 1398 if(LPS22HB_Set_GenericConfig(handle, &pLPS22HBInit))
nikapov 0:3de9cb936fd1 1399 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1400
nikapov 0:3de9cb936fd1 1401 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1402 }
nikapov 0:3de9cb936fd1 1403
nikapov 0:3de9cb936fd1 1404 /**
nikapov 0:3de9cb936fd1 1405 * @brief De initialization function for LPS22HB.
nikapov 0:3de9cb936fd1 1406 * This function make a memory boot and clear the data output flags.
nikapov 0:3de9cb936fd1 1407 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1408 * @retval Error code[LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1409 */
nikapov 0:3de9cb936fd1 1410 LPS22HB_Error_et LPS22HB_DeInit(void *handle)
nikapov 0:3de9cb936fd1 1411 {
nikapov 0:3de9cb936fd1 1412 LPS22HB_MeasureTypeDef_st Measurement_Value;
nikapov 0:3de9cb936fd1 1413
nikapov 0:3de9cb936fd1 1414 /* Make LPS22HB Reset and Reboot */
nikapov 0:3de9cb936fd1 1415 if(LPS22HB_SwResetAndMemoryBoot(handle))
nikapov 0:3de9cb936fd1 1416 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1417
nikapov 0:3de9cb936fd1 1418 /* Dump of data output */
nikapov 0:3de9cb936fd1 1419 if(LPS22HB_Get_Measurement(handle, &Measurement_Value))
nikapov 0:3de9cb936fd1 1420 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1421
nikapov 0:3de9cb936fd1 1422 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1423 }
nikapov 0:3de9cb936fd1 1424
nikapov 0:3de9cb936fd1 1425
nikapov 0:3de9cb936fd1 1426 /**
nikapov 0:3de9cb936fd1 1427 * @brief Set Generic Configuration
nikapov 0:3de9cb936fd1 1428 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1429 * @param Struct to empty with the chosen values
nikapov 0:3de9cb936fd1 1430 * @retval Error code[LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1431 */
nikapov 0:3de9cb936fd1 1432 LPS22HB_Error_et LPS22HB_Set_GenericConfig(void *handle, LPS22HB_ConfigTypeDef_st* pxLPS22HBInit)
nikapov 0:3de9cb936fd1 1433 {
nikapov 0:3de9cb936fd1 1434
nikapov 0:3de9cb936fd1 1435 /* Enable Low Current Mode (low Power) or Low Noise Mode*/
nikapov 0:3de9cb936fd1 1436 if(LPS22HB_Set_PowerMode(handle, pxLPS22HBInit->PowerMode))
nikapov 0:3de9cb936fd1 1437 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1438
nikapov 0:3de9cb936fd1 1439 /* Init the Output Data Rate*/
nikapov 0:3de9cb936fd1 1440 if(LPS22HB_Set_Odr(handle, pxLPS22HBInit->OutputDataRate))
nikapov 0:3de9cb936fd1 1441 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1442
nikapov 0:3de9cb936fd1 1443 /* BDU bit is used to inhibit the output registers update between the reading of upper and
nikapov 0:3de9cb936fd1 1444 lower register parts. In default mode (BDU = ‘0’), the lower and upper register parts are
nikapov 0:3de9cb936fd1 1445 updated continuously. If it is not sure to read faster than output data rate, it is recommended
nikapov 0:3de9cb936fd1 1446 to set BDU bit to ‘1’. In this way, after the reading of the lower (upper) register part, the
nikapov 0:3de9cb936fd1 1447 content of that output registers is not updated until the upper (lower) part is read too.
nikapov 0:3de9cb936fd1 1448 This feature avoids reading LSB and MSB related to different samples.*/
nikapov 0:3de9cb936fd1 1449
nikapov 0:3de9cb936fd1 1450 if(LPS22HB_Set_Bdu(handle, pxLPS22HBInit->BDU))
nikapov 0:3de9cb936fd1 1451 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1452
nikapov 0:3de9cb936fd1 1453 /*Enable/Disale low-pass filter on LPS22HB pressure data*/
nikapov 0:3de9cb936fd1 1454 if(LPS22HB_Set_LowPassFilter(handle, pxLPS22HBInit->LowPassFilter))
nikapov 0:3de9cb936fd1 1455 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1456
nikapov 0:3de9cb936fd1 1457 /* Set low-pass filter cutoff configuration*/
nikapov 0:3de9cb936fd1 1458 if(LPS22HB_Set_LowPassFilterCutoff(handle, pxLPS22HBInit->LPF_Cutoff))
nikapov 0:3de9cb936fd1 1459 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1460
nikapov 0:3de9cb936fd1 1461 /* SIM bit selects the SPI serial interface mode.*/
nikapov 0:3de9cb936fd1 1462 /* This feature has effect only if SPI interface is used*/
nikapov 0:3de9cb936fd1 1463
nikapov 0:3de9cb936fd1 1464 if(LPS22HB_Set_SpiInterface(handle, pxLPS22HBInit->Sim))
nikapov 0:3de9cb936fd1 1465 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1466
nikapov 0:3de9cb936fd1 1467 /*Enable or Disable the Automatic increment register address during a multiple byte access with a serial interface (I2C or SPI)*/
nikapov 0:3de9cb936fd1 1468 if(LPS22HB_Set_AutomaticIncrementRegAddress(handle, pxLPS22HBInit->IfAddInc))
nikapov 0:3de9cb936fd1 1469 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1470
nikapov 0:3de9cb936fd1 1471
nikapov 0:3de9cb936fd1 1472 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1473 }
nikapov 0:3de9cb936fd1 1474
nikapov 0:3de9cb936fd1 1475 /**
nikapov 0:3de9cb936fd1 1476 * @brief Get Generic configuration
nikapov 0:3de9cb936fd1 1477 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1478 * @param Struct to empty with configuration values
nikapov 0:3de9cb936fd1 1479 * @retval Error code[LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1480 */
nikapov 0:3de9cb936fd1 1481 LPS22HB_Error_et LPS22HB_Get_GenericConfig(void *handle, LPS22HB_ConfigTypeDef_st* pxLPS22HBInit)
nikapov 0:3de9cb936fd1 1482 {
nikapov 0:3de9cb936fd1 1483
nikapov 0:3de9cb936fd1 1484 uint8_t tmp;
nikapov 0:3de9cb936fd1 1485
nikapov 0:3de9cb936fd1 1486 /*Read LPS22HB_RES_CONF_REG*/
nikapov 0:3de9cb936fd1 1487 if(LPS22HB_Get_PowerMode(handle, &pxLPS22HBInit->PowerMode))
nikapov 0:3de9cb936fd1 1488 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1489
nikapov 0:3de9cb936fd1 1490 /*Read LPS22HB_CTRL_REG1*/
nikapov 0:3de9cb936fd1 1491 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG1, 1, &tmp))
nikapov 0:3de9cb936fd1 1492 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1493
nikapov 0:3de9cb936fd1 1494 pxLPS22HBInit->OutputDataRate= (LPS22HB_Odr_et)(tmp & LPS22HB_ODR_MASK);
nikapov 0:3de9cb936fd1 1495 pxLPS22HBInit->BDU=(LPS22HB_Bdu_et)(tmp & LPS22HB_BDU_MASK);
nikapov 0:3de9cb936fd1 1496 pxLPS22HBInit->Sim=(LPS22HB_SPIMode_et)(tmp& LPS22HB_SIM_MASK);
nikapov 0:3de9cb936fd1 1497 pxLPS22HBInit->LowPassFilter=(LPS22HB_State_et)((tmp& LPS22HB_LPFP_MASK)>>LPS22HB_LPFP_BIT);
nikapov 0:3de9cb936fd1 1498 pxLPS22HBInit->LPF_Cutoff=(LPS22HB_LPF_Cutoff_et)(tmp& LPS22HB_LPFP_CUTOFF_MASK);
nikapov 0:3de9cb936fd1 1499
nikapov 0:3de9cb936fd1 1500 /*Read LPS22HB_CTRL_REG2*/
nikapov 0:3de9cb936fd1 1501 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 1502 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1503
nikapov 0:3de9cb936fd1 1504 pxLPS22HBInit->IfAddInc=(LPS22HB_State_et)((tmp& LPS22HB_ADD_INC_MASK)>>LPS22HB_ADD_INC_BIT);
nikapov 0:3de9cb936fd1 1505
nikapov 0:3de9cb936fd1 1506 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1507 }
nikapov 0:3de9cb936fd1 1508
nikapov 0:3de9cb936fd1 1509
nikapov 0:3de9cb936fd1 1510 /**
nikapov 0:3de9cb936fd1 1511 * @brief Set Interrupt configuration
nikapov 0:3de9cb936fd1 1512 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1513 * @param Struct holding the configuration values
nikapov 0:3de9cb936fd1 1514 * @retval Error code[LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1515 */
nikapov 0:3de9cb936fd1 1516 LPS22HB_Error_et LPS22HB_Set_InterruptConfig(void *handle, LPS22HB_InterruptTypeDef_st* pLPS22HBInt)
nikapov 0:3de9cb936fd1 1517 {
nikapov 0:3de9cb936fd1 1518 /* Enable Low Current Mode (low Power) or Low Noise Mode*/
nikapov 0:3de9cb936fd1 1519 if(LPS22HB_Set_InterruptActiveLevel(handle, pLPS22HBInt->INT_H_L))
nikapov 0:3de9cb936fd1 1520 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1521
nikapov 0:3de9cb936fd1 1522 /* Push-pull/open drain selection on interrupt pads.*/
nikapov 0:3de9cb936fd1 1523 if(LPS22HB_Set_InterruptOutputType(handle, pLPS22HBInt->PP_OD))
nikapov 0:3de9cb936fd1 1524 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1525
nikapov 0:3de9cb936fd1 1526 /* Set Data signal on INT pad control bits.*/
nikapov 0:3de9cb936fd1 1527 if(LPS22HB_Set_InterruptControlConfig(handle, pLPS22HBInt->OutputSignal_INT))
nikapov 0:3de9cb936fd1 1528 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1529
nikapov 0:3de9cb936fd1 1530 /* Enable/Disable Data-ready signal on INT_DRDY pin. */
nikapov 0:3de9cb936fd1 1531 if(LPS22HB_Set_DRDYInterrupt(handle, pLPS22HBInt->DRDY))
nikapov 0:3de9cb936fd1 1532 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1533
nikapov 0:3de9cb936fd1 1534 /* Enable/Disable FIFO overrun interrupt on INT_DRDY pin. */
nikapov 0:3de9cb936fd1 1535 if(LPS22HB_Set_FIFO_OVR_Interrupt(handle, pLPS22HBInt->FIFO_OVR))
nikapov 0:3de9cb936fd1 1536 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1537
nikapov 0:3de9cb936fd1 1538 /* Enable/Disable FIFO Treshold interrupt on INT_DRDY pin. */
nikapov 0:3de9cb936fd1 1539 if(LPS22HB_Set_FIFO_FTH_Interrupt(handle, pLPS22HBInt->FIFO_FTH))
nikapov 0:3de9cb936fd1 1540 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1541
nikapov 0:3de9cb936fd1 1542 /* Enable/Disable FIFO FULL interrupt on INT_DRDY pin. */
nikapov 0:3de9cb936fd1 1543 if(LPS22HB_Set_FIFO_FULL_Interrupt(handle, pLPS22HBInt->FIFO_FULL))
nikapov 0:3de9cb936fd1 1544 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1545
nikapov 0:3de9cb936fd1 1546 /* Latch Interrupt request to the INT_SOURCE register. */
nikapov 0:3de9cb936fd1 1547 if(LPS22HB_LatchInterruptRequest(handle, pLPS22HBInt->LatchIRQ))
nikapov 0:3de9cb936fd1 1548 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1549
nikapov 0:3de9cb936fd1 1550 /* Set the threshold value used for pressure interrupt generation (hPA). */
nikapov 0:3de9cb936fd1 1551 if(LPS22HB_Set_PressureThreshold(handle, pLPS22HBInt->THS_threshold))
nikapov 0:3de9cb936fd1 1552 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1553
nikapov 0:3de9cb936fd1 1554 /*Enable/Disable AutoRifP function */
nikapov 0:3de9cb936fd1 1555 if(pLPS22HBInt->AutoRifP==LPS22HB_ENABLE){
nikapov 0:3de9cb936fd1 1556 if(LPS22HB_Set_AutoRifP(handle))
nikapov 0:3de9cb936fd1 1557 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1558 }
nikapov 0:3de9cb936fd1 1559 else{
nikapov 0:3de9cb936fd1 1560 if(LPS22HB_ResetAutoRifP(handle))
nikapov 0:3de9cb936fd1 1561 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1562 }
nikapov 0:3de9cb936fd1 1563
nikapov 0:3de9cb936fd1 1564 /*Enable/Disable AutoZero function*/
nikapov 0:3de9cb936fd1 1565 if(pLPS22HBInt->AutoZero==LPS22HB_ENABLE){
nikapov 0:3de9cb936fd1 1566 if(LPS22HB_Set_AutoZeroFunction(handle))
nikapov 0:3de9cb936fd1 1567 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1568 }
nikapov 0:3de9cb936fd1 1569 else{
nikapov 0:3de9cb936fd1 1570 if(LPS22HB_ResetAutoZeroFunction(handle))
nikapov 0:3de9cb936fd1 1571 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1572 }
nikapov 0:3de9cb936fd1 1573
nikapov 0:3de9cb936fd1 1574
nikapov 0:3de9cb936fd1 1575 if(pLPS22HBInt->OutputSignal_INT==LPS22HB_P_HIGH)
nikapov 0:3de9cb936fd1 1576 {
nikapov 0:3de9cb936fd1 1577 /* Enable\Disable Interrupt Generation on differential pressure high event*/
nikapov 0:3de9cb936fd1 1578 if(LPS22HB_Set_PHE(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1579 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1580 if(LPS22HB_Set_InterruptDifferentialGeneration(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1581 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1582 }
nikapov 0:3de9cb936fd1 1583 else if(pLPS22HBInt->OutputSignal_INT==LPS22HB_P_LOW)
nikapov 0:3de9cb936fd1 1584 {
nikapov 0:3de9cb936fd1 1585 /* Enable Interrupt Generation on differential pressure Loe event*/
nikapov 0:3de9cb936fd1 1586 if(LPS22HB_Set_PLE(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1587 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1588 if(LPS22HB_Set_InterruptDifferentialGeneration(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1589 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1590 }
nikapov 0:3de9cb936fd1 1591 else if(pLPS22HBInt->OutputSignal_INT==LPS22HB_P_LOW_HIGH)
nikapov 0:3de9cb936fd1 1592 {
nikapov 0:3de9cb936fd1 1593 /* Enable Interrupt Generation on differential pressure high event*/
nikapov 0:3de9cb936fd1 1594 if(LPS22HB_Set_PHE(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1595 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1596 /* Enable\Disable Interrupt Generation on differential pressure Loe event*/
nikapov 0:3de9cb936fd1 1597 if(LPS22HB_Set_PLE(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1598 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1599 if(LPS22HB_Set_InterruptDifferentialGeneration(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1600 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1601 }
nikapov 0:3de9cb936fd1 1602 else
nikapov 0:3de9cb936fd1 1603 {
nikapov 0:3de9cb936fd1 1604 if(LPS22HB_Set_InterruptDifferentialGeneration(handle, LPS22HB_DISABLE))
nikapov 0:3de9cb936fd1 1605 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1606 /* Disable Interrupt Generation on differential pressure High event*/
nikapov 0:3de9cb936fd1 1607 if(LPS22HB_Set_PHE(handle, LPS22HB_DISABLE))
nikapov 0:3de9cb936fd1 1608 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1609 /* Disable Interrupt Generation on differential pressure Low event*/
nikapov 0:3de9cb936fd1 1610 if(LPS22HB_Set_PLE(handle, LPS22HB_DISABLE))
nikapov 0:3de9cb936fd1 1611 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1612 }
nikapov 0:3de9cb936fd1 1613
nikapov 0:3de9cb936fd1 1614 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1615 }
nikapov 0:3de9cb936fd1 1616
nikapov 0:3de9cb936fd1 1617 /**
nikapov 0:3de9cb936fd1 1618 * @brief LPS22HBGet_InterruptConfig
nikapov 0:3de9cb936fd1 1619 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1620 * @param Struct to empty with configuration values
nikapov 0:3de9cb936fd1 1621 * @retval S Error code[LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1622 */
nikapov 0:3de9cb936fd1 1623 LPS22HB_Error_et LPS22HB_Get_InterruptConfig(void *handle, LPS22HB_InterruptTypeDef_st* pLPS22HBInt)
nikapov 0:3de9cb936fd1 1624 {
nikapov 0:3de9cb936fd1 1625 uint8_t tmp;
nikapov 0:3de9cb936fd1 1626
nikapov 0:3de9cb936fd1 1627 /*Read LPS22HB_CTRL_REG3*/
nikapov 0:3de9cb936fd1 1628 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG3, 1, &tmp))
nikapov 0:3de9cb936fd1 1629 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1630
nikapov 0:3de9cb936fd1 1631 pLPS22HBInt->INT_H_L= (LPS22HB_InterruptActiveLevel_et)(tmp & LPS22HB_INT_H_L_MASK);
nikapov 0:3de9cb936fd1 1632 pLPS22HBInt->PP_OD=(LPS22HB_OutputType_et)(tmp & LPS22HB_PP_OD_MASK);
nikapov 0:3de9cb936fd1 1633 pLPS22HBInt->OutputSignal_INT=(LPS22HB_OutputSignalConfig_et)(tmp& LPS22HB_INT_S12_MASK);
nikapov 0:3de9cb936fd1 1634 pLPS22HBInt->DRDY=(LPS22HB_State_et)((tmp& LPS22HB_DRDY_MASK)>>LPS22HB_DRDY_BIT);
nikapov 0:3de9cb936fd1 1635 pLPS22HBInt->FIFO_OVR=(LPS22HB_State_et)((tmp& LPS22HB_FIFO_OVR_MASK)>>LPS22HB_FIFO_OVR_BIT);
nikapov 0:3de9cb936fd1 1636 pLPS22HBInt->FIFO_FTH=(LPS22HB_State_et)((tmp& LPS22HB_FIFO_FTH_MASK)>>LPS22HB_FIFO_FTH_BIT);
nikapov 0:3de9cb936fd1 1637 pLPS22HBInt->FIFO_FULL=(LPS22HB_State_et)((tmp& LPS22HB_FIFO_FULL_MASK)>>LPS22HB_FIFO_FULL_BIT);
nikapov 0:3de9cb936fd1 1638
nikapov 0:3de9cb936fd1 1639 /*Read LPS22HB_INTERRUPT_CFG_REG*/
nikapov 0:3de9cb936fd1 1640 if(LPS22HB_read_reg(handle, LPS22HB_INTERRUPT_CFG_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1641 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1642
nikapov 0:3de9cb936fd1 1643 pLPS22HBInt->LatchIRQ= (LPS22HB_State_et)((tmp& LPS22HB_LIR_MASK)>>LPS22HB_LIR_BIT);
nikapov 0:3de9cb936fd1 1644
nikapov 0:3de9cb936fd1 1645 if(LPS22HB_Get_PressureThreshold(handle, &pLPS22HBInt->THS_threshold))
nikapov 0:3de9cb936fd1 1646 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1647
nikapov 0:3de9cb936fd1 1648 //AutoRifP and Autozero are self clear //
nikapov 0:3de9cb936fd1 1649 pLPS22HBInt->AutoRifP=LPS22HB_DISABLE;
nikapov 0:3de9cb936fd1 1650 pLPS22HBInt->AutoZero=LPS22HB_DISABLE;
nikapov 0:3de9cb936fd1 1651
nikapov 0:3de9cb936fd1 1652 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1653 }
nikapov 0:3de9cb936fd1 1654
nikapov 0:3de9cb936fd1 1655 /**
nikapov 0:3de9cb936fd1 1656 * @brief Set Fifo configuration
nikapov 0:3de9cb936fd1 1657 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1658 * @param Struct holding the configuration values
nikapov 0:3de9cb936fd1 1659 * @retval Error code[LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1660 */
nikapov 0:3de9cb936fd1 1661 LPS22HB_Error_et LPS22HB_Set_FifoConfig(void *handle, LPS22HB_FIFOTypeDef_st* pLPS22HBFIFO)
nikapov 0:3de9cb936fd1 1662 {
nikapov 0:3de9cb936fd1 1663
nikapov 0:3de9cb936fd1 1664 if(pLPS22HBFIFO->FIFO_MODE == LPS22HB_FIFO_BYPASS_MODE) {
nikapov 0:3de9cb936fd1 1665 /* FIFO Disable-> FIFO_EN bit=0 in CTRL_REG2*/
nikapov 0:3de9cb936fd1 1666 if(LPS22HB_Set_FifoModeUse(handle, LPS22HB_DISABLE))
nikapov 0:3de9cb936fd1 1667 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1668 /* Force->Disable FIFO Watermark Level Use*/
nikapov 0:3de9cb936fd1 1669 if(LPS22HB_Set_FifoWatermarkLevelUse(handle, LPS22HB_DISABLE))
nikapov 0:3de9cb936fd1 1670 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1671
nikapov 0:3de9cb936fd1 1672 /* Force->Disable FIFO Treshold interrupt on INT_DRDY pin. */
nikapov 0:3de9cb936fd1 1673 if(LPS22HB_Set_FIFO_FTH_Interrupt(handle, LPS22HB_DISABLE))
nikapov 0:3de9cb936fd1 1674 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1675 }
nikapov 0:3de9cb936fd1 1676 else {
nikapov 0:3de9cb936fd1 1677 /* FIFO Enable-> FIFO_EN bit=1 in CTRL_REG2*/
nikapov 0:3de9cb936fd1 1678 if(LPS22HB_Set_FifoModeUse(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1679 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1680
nikapov 0:3de9cb936fd1 1681 if (pLPS22HBFIFO->WTM_INT){
nikapov 0:3de9cb936fd1 1682 /* Enable FIFO Watermark Level Use*/
nikapov 0:3de9cb936fd1 1683 if(LPS22HB_Set_FifoWatermarkLevelUse(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1684 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1685 /*Set Fifo Watermark Level*/
nikapov 0:3de9cb936fd1 1686 if(LPS22HB_Set_FifoWatermarkLevel(handle, pLPS22HBFIFO->WTM_LEVEL))
nikapov 0:3de9cb936fd1 1687 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1688 /* Force->enable FIFO Treshold interrupt on INT_DRDY pin. */
nikapov 0:3de9cb936fd1 1689 if(LPS22HB_Set_FIFO_FTH_Interrupt(handle, LPS22HB_ENABLE))
nikapov 0:3de9cb936fd1 1690 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1691 }
nikapov 0:3de9cb936fd1 1692 }
nikapov 0:3de9cb936fd1 1693
nikapov 0:3de9cb936fd1 1694 if(LPS22HB_Set_FifoMode(handle, pLPS22HBFIFO->FIFO_MODE))
nikapov 0:3de9cb936fd1 1695 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1696
nikapov 0:3de9cb936fd1 1697 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1698 }
nikapov 0:3de9cb936fd1 1699
nikapov 0:3de9cb936fd1 1700 /**
nikapov 0:3de9cb936fd1 1701 * @brief Get Fifo configuration
nikapov 0:3de9cb936fd1 1702 * @param *handle Device handle.
nikapov 0:3de9cb936fd1 1703 * @param Struct to empty with the configuration values
nikapov 0:3de9cb936fd1 1704 * @retval Error code[LPS22HB_ERROR, LPS22HB_OK]
nikapov 0:3de9cb936fd1 1705 */
nikapov 0:3de9cb936fd1 1706 LPS22HB_Error_et LPS22HB_Get_FifoConfig(void *handle, LPS22HB_FIFOTypeDef_st* pLPS22HBFIFO)
nikapov 0:3de9cb936fd1 1707 {
nikapov 0:3de9cb936fd1 1708 uint8_t tmp;
nikapov 0:3de9cb936fd1 1709
nikapov 0:3de9cb936fd1 1710 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_FIFO_REG, 1, &tmp))
nikapov 0:3de9cb936fd1 1711 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1712
nikapov 0:3de9cb936fd1 1713 /*!< Fifo Mode Selection */
nikapov 0:3de9cb936fd1 1714 pLPS22HBFIFO->FIFO_MODE= (LPS22HB_FifoMode_et)(tmp& LPS22HB_FIFO_MODE_MASK);
nikapov 0:3de9cb936fd1 1715
nikapov 0:3de9cb936fd1 1716 /*!< FIFO threshold/Watermark level selection*/
nikapov 0:3de9cb936fd1 1717 pLPS22HBFIFO->WTM_LEVEL= (uint8_t)(tmp& LPS22HB_WTM_POINT_MASK);
nikapov 0:3de9cb936fd1 1718
nikapov 0:3de9cb936fd1 1719 if(LPS22HB_read_reg(handle, LPS22HB_CTRL_REG2, 1, &tmp))
nikapov 0:3de9cb936fd1 1720 return LPS22HB_ERROR;
nikapov 0:3de9cb936fd1 1721
nikapov 0:3de9cb936fd1 1722 /*!< Enable/Disable the watermark interrupt*/
nikapov 0:3de9cb936fd1 1723 pLPS22HBFIFO->WTM_INT= (LPS22HB_State_et)((tmp& LPS22HB_WTM_EN_MASK)>>LPS22HB_WTM_EN_BIT);
nikapov 0:3de9cb936fd1 1724
nikapov 0:3de9cb936fd1 1725
nikapov 0:3de9cb936fd1 1726 return LPS22HB_OK;
nikapov 0:3de9cb936fd1 1727 }
nikapov 0:3de9cb936fd1 1728
nikapov 0:3de9cb936fd1 1729 #ifdef USE_FULL_ASSERT_LPS22HB
nikapov 0:3de9cb936fd1 1730 /**
nikapov 0:3de9cb936fd1 1731 * @brief Reports the name of the source file and the source line number
nikapov 0:3de9cb936fd1 1732 * where the assert_param error has occurred.
nikapov 0:3de9cb936fd1 1733 * @param file: pointer to the source file name
nikapov 0:3de9cb936fd1 1734 * @param line: assert_param error line source number
nikapov 0:3de9cb936fd1 1735 * @retval : None
nikapov 0:3de9cb936fd1 1736 */
nikapov 0:3de9cb936fd1 1737 void LPS22HB_assert_failed(uint8_t* file, uint32_t line)
nikapov 0:3de9cb936fd1 1738 {
nikapov 0:3de9cb936fd1 1739 /* User can add his own implementation to report the file name and line number */
nikapov 0:3de9cb936fd1 1740 printf("Wrong parameters tmp: file %s on line %d\r\n", file, (int)line);
nikapov 0:3de9cb936fd1 1741
nikapov 0:3de9cb936fd1 1742 /* Infinite loop */
nikapov 0:3de9cb936fd1 1743 while (1)
nikapov 0:3de9cb936fd1 1744 {
nikapov 0:3de9cb936fd1 1745 }
nikapov 0:3de9cb936fd1 1746 }
nikapov 0:3de9cb936fd1 1747 #endif
nikapov 0:3de9cb936fd1 1748
nikapov 0:3de9cb936fd1 1749 /**
nikapov 0:3de9cb936fd1 1750 * @}
nikapov 0:3de9cb936fd1 1751 */
nikapov 0:3de9cb936fd1 1752
nikapov 0:3de9cb936fd1 1753 /**
nikapov 0:3de9cb936fd1 1754 * @}
nikapov 0:3de9cb936fd1 1755 */
nikapov 0:3de9cb936fd1 1756
nikapov 0:3de9cb936fd1 1757 /**
nikapov 0:3de9cb936fd1 1758 * @}
nikapov 0:3de9cb936fd1 1759 */
nikapov 0:3de9cb936fd1 1760
nikapov 0:3de9cb936fd1 1761 /******************* (C) COPYRIGHT 2013 STMicroelectronics *****END OF FILE****/