Contains the BSP driver for the B-L475E-IOT01 board.

Dependents:   mbed-os-example-ble-Thermometer DISCO_L475VG_IOT01-Telegram-BOT DISCO_L475VG_IOT01-sche_cheveux DISCO_L475VG_IOT01-QSPI_FLASH_FILE_SYSTEM ... more

https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/

Committer:
bcostm
Date:
Fri Apr 14 13:09:54 2017 +0200
Revision:
4:137bb367ba50
Child:
7:bfe8272ced90
Add remaining Components files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 4:137bb367ba50 1 /**
bcostm 4:137bb367ba50 2 ******************************************************************************
bcostm 4:137bb367ba50 3 * @file lps22hb.h
bcostm 4:137bb367ba50 4 * @author MCD Application Team
bcostm 4:137bb367ba50 5 * @version V1.0.0
bcostm 4:137bb367ba50 6 * @date 14-February-2017
bcostm 4:137bb367ba50 7 * @brief LPS22HB header driver file
bcostm 4:137bb367ba50 8 ******************************************************************************
bcostm 4:137bb367ba50 9 * @attention
bcostm 4:137bb367ba50 10 *
bcostm 4:137bb367ba50 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
bcostm 4:137bb367ba50 12 *
bcostm 4:137bb367ba50 13 * Redistribution and use in source and binary forms, with or without modification,
bcostm 4:137bb367ba50 14 * are permitted provided that the following conditions are met:
bcostm 4:137bb367ba50 15 * 1. Redistributions of source code must retain the above copyright notice,
bcostm 4:137bb367ba50 16 * this list of conditions and the following disclaimer.
bcostm 4:137bb367ba50 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcostm 4:137bb367ba50 18 * this list of conditions and the following disclaimer in the documentation
bcostm 4:137bb367ba50 19 * and/or other materials provided with the distribution.
bcostm 4:137bb367ba50 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bcostm 4:137bb367ba50 21 * may be used to endorse or promote products derived from this software
bcostm 4:137bb367ba50 22 * without specific prior written permission.
bcostm 4:137bb367ba50 23 *
bcostm 4:137bb367ba50 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bcostm 4:137bb367ba50 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bcostm 4:137bb367ba50 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bcostm 4:137bb367ba50 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bcostm 4:137bb367ba50 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bcostm 4:137bb367ba50 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bcostm 4:137bb367ba50 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bcostm 4:137bb367ba50 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bcostm 4:137bb367ba50 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bcostm 4:137bb367ba50 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcostm 4:137bb367ba50 34 *
bcostm 4:137bb367ba50 35 ******************************************************************************
bcostm 4:137bb367ba50 36 */
bcostm 4:137bb367ba50 37
bcostm 4:137bb367ba50 38 /* Define to prevent recursive inclusion -------------------------------------*/
bcostm 4:137bb367ba50 39 #ifndef __LPS22HB__H
bcostm 4:137bb367ba50 40 #define __LPS22HB__H
bcostm 4:137bb367ba50 41
bcostm 4:137bb367ba50 42 #ifdef __cplusplus
bcostm 4:137bb367ba50 43 extern "C" {
bcostm 4:137bb367ba50 44 #endif
bcostm 4:137bb367ba50 45
bcostm 4:137bb367ba50 46 /* Includes ------------------------------------------------------------------*/
bcostm 4:137bb367ba50 47 #include "../Common/psensor.h"
bcostm 4:137bb367ba50 48 #include "../Common/tsensor.h"
bcostm 4:137bb367ba50 49
bcostm 4:137bb367ba50 50 /** @addtogroup BSP
bcostm 4:137bb367ba50 51 * @{
bcostm 4:137bb367ba50 52 */
bcostm 4:137bb367ba50 53
bcostm 4:137bb367ba50 54 /** @addtogroup Component
bcostm 4:137bb367ba50 55 * @{
bcostm 4:137bb367ba50 56 */
bcostm 4:137bb367ba50 57
bcostm 4:137bb367ba50 58 /** @addtogroup LPS22HB
bcostm 4:137bb367ba50 59 * @{
bcostm 4:137bb367ba50 60 */
bcostm 4:137bb367ba50 61
bcostm 4:137bb367ba50 62 /** @defgroup LPS22HB_Exported_Macros LPS22HB Exported Macros
bcostm 4:137bb367ba50 63 * @{
bcostm 4:137bb367ba50 64 */
bcostm 4:137bb367ba50 65
bcostm 4:137bb367ba50 66 /**
bcostm 4:137bb367ba50 67 * @brief Bitfield positioning.
bcostm 4:137bb367ba50 68 */
bcostm 4:137bb367ba50 69 #define LPS22HB_BIT(x) ((uint8_t)x)
bcostm 4:137bb367ba50 70 /**
bcostm 4:137bb367ba50 71 * @}
bcostm 4:137bb367ba50 72 */
bcostm 4:137bb367ba50 73
bcostm 4:137bb367ba50 74
bcostm 4:137bb367ba50 75 /** @defgroup LPS22HB_Exported_Constants LPS22HB Exported Constants
bcostm 4:137bb367ba50 76 * @{
bcostm 4:137bb367ba50 77 */
bcostm 4:137bb367ba50 78
bcostm 4:137bb367ba50 79 /**
bcostm 4:137bb367ba50 80 * @brief Device Identification register.
bcostm 4:137bb367ba50 81 * Read
bcostm 4:137bb367ba50 82 * Default value: 0xB1
bcostm 4:137bb367ba50 83 * 7:0 This read-only register contains the device identifier that, for LPS22HB, is set to B1h.
bcostm 4:137bb367ba50 84 */
bcostm 4:137bb367ba50 85
bcostm 4:137bb367ba50 86 #define LPS22HB_WHO_AM_I_REG (uint8_t)0x0F
bcostm 4:137bb367ba50 87
bcostm 4:137bb367ba50 88 /**
bcostm 4:137bb367ba50 89 * @brief Device Identification value.
bcostm 4:137bb367ba50 90 */
bcostm 4:137bb367ba50 91 #define LPS22HB_WHO_AM_I_VAL (uint8_t)0xB1
bcostm 4:137bb367ba50 92
bcostm 4:137bb367ba50 93 /**
bcostm 4:137bb367ba50 94 * @brief Reference Pressure Register(LSB data)
bcostm 4:137bb367ba50 95 * Read/write
bcostm 4:137bb367ba50 96 * Default value: 0x00
bcostm 4:137bb367ba50 97 * 7:0 REFL7-0: Lower part of the reference pressure value that
bcostm 4:137bb367ba50 98 * is sum to the sensor output pressure.
bcostm 4:137bb367ba50 99 */
bcostm 4:137bb367ba50 100 #define LPS22HB_REF_P_XL_REG (uint8_t)0x15
bcostm 4:137bb367ba50 101
bcostm 4:137bb367ba50 102 /**
bcostm 4:137bb367ba50 103 * @brief Reference Pressure Register (Middle data)
bcostm 4:137bb367ba50 104 * Read/write
bcostm 4:137bb367ba50 105 * Default value: 0x00
bcostm 4:137bb367ba50 106 * 7:0 REFL15-8: Middle part of the reference pressure value that
bcostm 4:137bb367ba50 107 * is sum to the sensor output pressure.
bcostm 4:137bb367ba50 108 */
bcostm 4:137bb367ba50 109 #define LPS22HB_REF_P_L_REG (uint8_t)0x16
bcostm 4:137bb367ba50 110
bcostm 4:137bb367ba50 111 /**
bcostm 4:137bb367ba50 112 * @brief Reference Pressure Register (MSB data)
bcostm 4:137bb367ba50 113 * Read/write
bcostm 4:137bb367ba50 114 * Default value: 0x00
bcostm 4:137bb367ba50 115 * 7:0 REFL23-16 Higest part of the reference pressure value that
bcostm 4:137bb367ba50 116 * is sum to the sensor output pressure.
bcostm 4:137bb367ba50 117 */
bcostm 4:137bb367ba50 118 #define LPS22HB_REF_P_H_REG (uint8_t)0x17
bcostm 4:137bb367ba50 119
bcostm 4:137bb367ba50 120 /**
bcostm 4:137bb367ba50 121 * @brief Pressure and temperature resolution mode Register
bcostm 4:137bb367ba50 122 * Read/write
bcostm 4:137bb367ba50 123 * Default value: 0x05
bcostm 4:137bb367ba50 124 * 7:2 These bits must be set to 0 for proper operation of the device
bcostm 4:137bb367ba50 125 * 1: Reserved
bcostm 4:137bb367ba50 126 * 0 LC_EN: Low Current Mode Enable. Default 0
bcostm 4:137bb367ba50 127 */
bcostm 4:137bb367ba50 128 #define LPS22HB_RES_CONF_REG (uint8_t)0x1A
bcostm 4:137bb367ba50 129 #define LPS22HB_LCEN_MASK (uint8_t)0x01
bcostm 4:137bb367ba50 130
bcostm 4:137bb367ba50 131 /**
bcostm 4:137bb367ba50 132 * @brief Control Register 1
bcostm 4:137bb367ba50 133 * Read/write
bcostm 4:137bb367ba50 134 * Default value: 0x00
bcostm 4:137bb367ba50 135 * 7: This bit must be set to 0 for proper operation of the device
bcostm 4:137bb367ba50 136 * 6:4 ODR2, ODR1, ODR0: output data rate selection.Default 000
bcostm 4:137bb367ba50 137 * ODR2 | ODR1 | ODR0 | Pressure output data-rate(Hz) | Pressure output data-rate(Hz)
bcostm 4:137bb367ba50 138 * ----------------------------------------------------------------------------------
bcostm 4:137bb367ba50 139 * 0 | 0 | 0 | one shot | one shot
bcostm 4:137bb367ba50 140 * 0 | 0 | 1 | 1 | 1
bcostm 4:137bb367ba50 141 * 0 | 1 | 0 | 10 | 10
bcostm 4:137bb367ba50 142 * 0 | 1 | 1 | 25 | 25
bcostm 4:137bb367ba50 143 * 1 | 0 | 0 | 50 | 50
bcostm 4:137bb367ba50 144 * 1 | 0 | 1 | 75 | 75
bcostm 4:137bb367ba50 145 * 1 | 1 | 0 | Reserved | Reserved
bcostm 4:137bb367ba50 146 * 1 | 1 | 1 | Reserved | Reserved
bcostm 4:137bb367ba50 147 *
bcostm 4:137bb367ba50 148 * 3 EN_LPFP: Enable Low Pass filter on Pressure data. Default value:0
bcostm 4:137bb367ba50 149 * 2:LPF_CFG Low-pass configuration register. (0: Filter cutoff is ODR/9; 1: filter cutoff is ODR/20)
bcostm 4:137bb367ba50 150 * 1 BDU: block data update. 0 - continuous update; 1 - output registers not updated until MSB and LSB reading.
bcostm 4:137bb367ba50 151 * 0 SIM: SPI Serial Interface Mode selection. 0 - SPI 4-wire; 1 - SPI 3-wire
bcostm 4:137bb367ba50 152 */
bcostm 4:137bb367ba50 153 #define LPS22HB_CTRL_REG1 (uint8_t)0x10
bcostm 4:137bb367ba50 154
bcostm 4:137bb367ba50 155 #define LPS22HB_ODR_MASK (uint8_t)0x70
bcostm 4:137bb367ba50 156 #define LPS22HB_LPFP_MASK (uint8_t)0x08
bcostm 4:137bb367ba50 157 #define LPS22HB_LPFP_CUTOFF_MASK (uint8_t)0x04
bcostm 4:137bb367ba50 158 #define LPS22HB_BDU_MASK (uint8_t)0x02
bcostm 4:137bb367ba50 159 #define LPS22HB_SIM_MASK (uint8_t)0x01
bcostm 4:137bb367ba50 160
bcostm 4:137bb367ba50 161 #define LPS22HB_LPFP_BIT LPS22HB_BIT(3)
bcostm 4:137bb367ba50 162
bcostm 4:137bb367ba50 163 /**
bcostm 4:137bb367ba50 164 * @brief Control Register 2
bcostm 4:137bb367ba50 165 * Read/write
bcostm 4:137bb367ba50 166 * Default value: 0x10
bcostm 4:137bb367ba50 167 * 7 BOOT: Reboot memory content. 0: normal mode; 1: reboot memory content. Self-clearing upon completation
bcostm 4:137bb367ba50 168 * 6 FIFO_EN: FIFO Enable. 0: disable; 1: enable
bcostm 4:137bb367ba50 169 * 5 STOP_ON_FTH: Stop on FIFO Threshold FIFO Watermark level use. 0: disable; 1: enable
bcostm 4:137bb367ba50 170 * 4 IF_ADD_INC: Register address automatically incrementeed during a multiple byte access with a serial interface (I2C or SPI).
bcostm 4:137bb367ba50 171 * Default value 1.( 0: disable; 1: enable)
bcostm 4:137bb367ba50 172 * 3 I2C DIS: Disable I2C interface 0: I2C Enabled; 1: I2C disabled
bcostm 4:137bb367ba50 173 * 2 SWRESET: Software reset. 0: normal mode; 1: SW reset. Self-clearing upon completation
bcostm 4:137bb367ba50 174 * 1 AUTO_ZERO: Autozero enable. 0: normal mode; 1: autozero enable.
bcostm 4:137bb367ba50 175 * 0 ONE_SHOT: One shot enable. 0: waiting for start of conversion; 1: start for a new dataset
bcostm 4:137bb367ba50 176 */
bcostm 4:137bb367ba50 177 #define LPS22HB_CTRL_REG2 (uint8_t)0x11
bcostm 4:137bb367ba50 178
bcostm 4:137bb367ba50 179 #define LPS22HB_BOOT_BIT LPS22HB_BIT(7)
bcostm 4:137bb367ba50 180 #define LPS22HB_FIFO_EN_BIT LPS22HB_BIT(6)
bcostm 4:137bb367ba50 181 #define LPS22HB_WTM_EN_BIT LPS22HB_BIT(5)
bcostm 4:137bb367ba50 182 #define LPS22HB_ADD_INC_BIT LPS22HB_BIT(4)
bcostm 4:137bb367ba50 183 #define LPS22HB_I2C_BIT LPS22HB_BIT(3)
bcostm 4:137bb367ba50 184 #define LPS22HB_SW_RESET_BIT LPS22HB_BIT(2)
bcostm 4:137bb367ba50 185
bcostm 4:137bb367ba50 186 #define LPS22HB_FIFO_EN_MASK (uint8_t)0x40
bcostm 4:137bb367ba50 187 #define LPS22HB_WTM_EN_MASK (uint8_t)0x20
bcostm 4:137bb367ba50 188 #define LPS22HB_ADD_INC_MASK (uint8_t)0x10
bcostm 4:137bb367ba50 189 #define LPS22HB_I2C_MASK (uint8_t)0x08
bcostm 4:137bb367ba50 190 #define LPS22HB_ONE_SHOT_MASK (uint8_t)0x01
bcostm 4:137bb367ba50 191
bcostm 4:137bb367ba50 192
bcostm 4:137bb367ba50 193 /**
bcostm 4:137bb367ba50 194 * @brief CTRL Reg3 Interrupt Control Register
bcostm 4:137bb367ba50 195 * Read/write
bcostm 4:137bb367ba50 196 * Default value: 0x00
bcostm 4:137bb367ba50 197 * 7 INT_H_L: Interrupt active high, low. 0:active high; 1: active low.
bcostm 4:137bb367ba50 198 * 6 PP_OD: Push-Pull/OpenDrain selection on interrupt pads. 0: Push-pull; 1: open drain.
bcostm 4:137bb367ba50 199 * 5 F_FSS5: FIFO full flag on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
bcostm 4:137bb367ba50 200 * 4 F_FTH: FIFO threshold (watermark) status on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
bcostm 4:137bb367ba50 201 * 3 F_OVR: FIFO overrun interrupt on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
bcostm 4:137bb367ba50 202 * 2 DRDY: Data-ready signal on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
bcostm 4:137bb367ba50 203 * 1:0 INT_S2, INT_S1: data signal on INT pad control bits.
bcostm 4:137bb367ba50 204 * INT_S2 | INT_S1 | INT pin
bcostm 4:137bb367ba50 205 * ------------------------------------------------------
bcostm 4:137bb367ba50 206 * 0 | 0 | Data signal( in order of priority:PTH_DRDY or F_FTH or F_OVR_or F_FSS5
bcostm 4:137bb367ba50 207 * 0 | 1 | Pressure high (P_high)
bcostm 4:137bb367ba50 208 * 1 | 0 | Pressure low (P_low)
bcostm 4:137bb367ba50 209 * 1 | 1 | P_low OR P_high
bcostm 4:137bb367ba50 210 */
bcostm 4:137bb367ba50 211 #define LPS22HB_CTRL_REG3 (uint8_t)0x12
bcostm 4:137bb367ba50 212
bcostm 4:137bb367ba50 213 #define LPS22HB_PP_OD_BIT LPS22HB_BIT(6)
bcostm 4:137bb367ba50 214 #define LPS22HB_FIFO_FULL_BIT LPS22HB_BIT(5)
bcostm 4:137bb367ba50 215 #define LPS22HB_FIFO_FTH_BIT LPS22HB_BIT(4)
bcostm 4:137bb367ba50 216 #define LPS22HB_FIFO_OVR_BIT LPS22HB_BIT(3)
bcostm 4:137bb367ba50 217 #define LPS22HB_DRDY_BIT LPS22HB_BIT(2)
bcostm 4:137bb367ba50 218
bcostm 4:137bb367ba50 219
bcostm 4:137bb367ba50 220 #define LPS22HB_INT_H_L_MASK (uint8_t)0x80
bcostm 4:137bb367ba50 221 #define LPS22HB_PP_OD_MASK (uint8_t)0x40
bcostm 4:137bb367ba50 222 #define LPS22HB_FIFO_FULL_MASK (uint8_t)0x20
bcostm 4:137bb367ba50 223 #define LPS22HB_FIFO_FTH_MASK (uint8_t)0x10
bcostm 4:137bb367ba50 224 #define LPS22HB_FIFO_OVR_MASK (uint8_t)0x08
bcostm 4:137bb367ba50 225 #define LPS22HB_DRDY_MASK (uint8_t)0x04
bcostm 4:137bb367ba50 226 #define LPS22HB_INT_S12_MASK (uint8_t)0x03
bcostm 4:137bb367ba50 227
bcostm 4:137bb367ba50 228
bcostm 4:137bb367ba50 229 /**
bcostm 4:137bb367ba50 230 * @brief Interrupt Differential configuration Register
bcostm 4:137bb367ba50 231 * Read/write
bcostm 4:137bb367ba50 232 * Default value: 0x00.
bcostm 4:137bb367ba50 233 * 7 AUTORIFP: AutoRifP Enable
bcostm 4:137bb367ba50 234 * 6 RESET_ARP: Reset AutoRifP function
bcostm 4:137bb367ba50 235 * 4 AUTOZERO: Autozero enabled
bcostm 4:137bb367ba50 236 * 5 RESET_AZ: Reset Autozero Function
bcostm 4:137bb367ba50 237 * 3 DIFF_EN: Interrupt generation enable
bcostm 4:137bb367ba50 238 * 2 LIR: Latch Interrupt request into INT_SOURCE register. 0 - interrupt request not latched
bcostm 4:137bb367ba50 239 * 1 - interrupt request latched
bcostm 4:137bb367ba50 240 * 1 PL_E: Enable interrupt generation on differential pressure low event. 0 - disable; 1 - enable
bcostm 4:137bb367ba50 241 * 0 PH_E: Enable interrupt generation on differential pressure high event. 0 - disable; 1 - enable
bcostm 4:137bb367ba50 242 */
bcostm 4:137bb367ba50 243 #define LPS22HB_INTERRUPT_CFG_REG (uint8_t)0x0B
bcostm 4:137bb367ba50 244
bcostm 4:137bb367ba50 245 #define LPS22HB_DIFF_EN_BIT LPS22HB_BIT(3)
bcostm 4:137bb367ba50 246 #define LPS22HB_LIR_BIT LPS22HB_BIT(2)
bcostm 4:137bb367ba50 247 #define LPS22HB_PLE_BIT LPS22HB_BIT(1)
bcostm 4:137bb367ba50 248 #define LPS22HB_PHE_BIT LPS22HB_BIT(0)
bcostm 4:137bb367ba50 249
bcostm 4:137bb367ba50 250 #define LPS22HB_AUTORIFP_MASK (uint8_t)0x80
bcostm 4:137bb367ba50 251 #define LPS22HB_RESET_ARP_MASK (uint8_t)0x40
bcostm 4:137bb367ba50 252 #define LPS22HB_AUTOZERO_MASK (uint8_t)0x20
bcostm 4:137bb367ba50 253 #define LPS22HB_RESET_AZ_MASK (uint8_t)0x10
bcostm 4:137bb367ba50 254 #define LPS22HB_DIFF_EN_MASK (uint8_t)0x08
bcostm 4:137bb367ba50 255 #define LPS22HB_LIR_MASK (uint8_t)0x04
bcostm 4:137bb367ba50 256 #define LPS22HB_PLE_MASK (uint8_t)0x02
bcostm 4:137bb367ba50 257 #define LPS22HB_PHE_MASK (uint8_t)0x01
bcostm 4:137bb367ba50 258
bcostm 4:137bb367ba50 259
bcostm 4:137bb367ba50 260
bcostm 4:137bb367ba50 261 /**
bcostm 4:137bb367ba50 262 * @brief Interrupt source Register (It is cleared by reading it)
bcostm 4:137bb367ba50 263 * Read
bcostm 4:137bb367ba50 264 * 7 BOOT_STATUS: If 1 indicates that the Boot (Reboot) phase is running.
bcostm 4:137bb367ba50 265 * 6:3 Reserved: Keep these bits at 0
bcostm 4:137bb367ba50 266 * 2 IA: Interrupt Active.0: no interrupt has been generated
bcostm 4:137bb367ba50 267 * 1: one or more interrupt events have been generated.
bcostm 4:137bb367ba50 268 * 1 PL: Differential pressure Low. 0: no interrupt has been generated
bcostm 4:137bb367ba50 269 * 1: Low differential pressure event has occurred.
bcostm 4:137bb367ba50 270 * 0 PH: Differential pressure High. 0: no interrupt has been generated
bcostm 4:137bb367ba50 271 * 1: High differential pressure event has occurred.
bcostm 4:137bb367ba50 272 */
bcostm 4:137bb367ba50 273 #define LPS22HB_INTERRUPT_SOURCE_REG (uint8_t)0x25
bcostm 4:137bb367ba50 274
bcostm 4:137bb367ba50 275 #define LPS22HB_BOOT_STATUS_BIT LPS22HB_BIT(7)
bcostm 4:137bb367ba50 276 #define LPS22HB_IA_BIT LPS22HB_BIT(2)
bcostm 4:137bb367ba50 277 #define LPS22HB_PL_BIT LPS22HB_BIT(1)
bcostm 4:137bb367ba50 278 #define LPS22HB_PH_BIT LPS22HB_BIT(0)
bcostm 4:137bb367ba50 279
bcostm 4:137bb367ba50 280 #define LPS22HB_BOOT_STATUS_MASK (uint8_t)0x80
bcostm 4:137bb367ba50 281 #define LPS22HB_IA_MASK (uint8_t)0x04
bcostm 4:137bb367ba50 282 #define LPS22HB_PL_MASK (uint8_t)0x02
bcostm 4:137bb367ba50 283 #define LPS22HB_PH_MASK (uint8_t)0x01
bcostm 4:137bb367ba50 284
bcostm 4:137bb367ba50 285
bcostm 4:137bb367ba50 286 /**
bcostm 4:137bb367ba50 287 * @brief Status Register
bcostm 4:137bb367ba50 288 * Read
bcostm 4:137bb367ba50 289 * 7:6 Reserved: 0
bcostm 4:137bb367ba50 290 * 5 T_OR: Temperature data overrun. 0: no overrun has occurred
bcostm 4:137bb367ba50 291 * 1: a new data for temperature has overwritten the previous one.
bcostm 4:137bb367ba50 292 * 4 P_OR: Pressure data overrun. 0: no overrun has occurred
bcostm 4:137bb367ba50 293 * 1: new data for pressure has overwritten the previous one.
bcostm 4:137bb367ba50 294 * 3:2 Reserved: 0
bcostm 4:137bb367ba50 295 * 1 T_DA: Temperature data available. 0: new data for temperature is not yet available
bcostm 4:137bb367ba50 296 * 1: new data for temperature is available.
bcostm 4:137bb367ba50 297 * 0 P_DA: Pressure data available. 0: new data for pressure is not yet available
bcostm 4:137bb367ba50 298 * 1: new data for pressure is available.
bcostm 4:137bb367ba50 299 */
bcostm 4:137bb367ba50 300 #define LPS22HB_STATUS_REG (uint8_t)0x27
bcostm 4:137bb367ba50 301
bcostm 4:137bb367ba50 302 #define LPS22HB_TOR_BIT LPS22HB_BIT(5)
bcostm 4:137bb367ba50 303 #define LPS22HB_POR_BIT LPS22HB_BIT(4)
bcostm 4:137bb367ba50 304 #define LPS22HB_TDA_BIT LPS22HB_BIT(1)
bcostm 4:137bb367ba50 305 #define LPS22HB_PDA_BIT LPS22HB_BIT(0)
bcostm 4:137bb367ba50 306
bcostm 4:137bb367ba50 307 #define LPS22HB_TOR_MASK (uint8_t)0x20
bcostm 4:137bb367ba50 308 #define LPS22HB_POR_MASK (uint8_t)0x10
bcostm 4:137bb367ba50 309 #define LPS22HB_TDA_MASK (uint8_t)0x02
bcostm 4:137bb367ba50 310 #define LPS22HB_PDA_MASK (uint8_t)0x01
bcostm 4:137bb367ba50 311
bcostm 4:137bb367ba50 312
bcostm 4:137bb367ba50 313 /**
bcostm 4:137bb367ba50 314 * @brief Pressure data (LSB) register.
bcostm 4:137bb367ba50 315 * Read
bcostm 4:137bb367ba50 316 * Default value: 0x00.(To be verified)
bcostm 4:137bb367ba50 317 * POUT7 - POUT0: Pressure data LSB (2's complement).
bcostm 4:137bb367ba50 318 * Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
bcostm 4:137bb367ba50 319 * PRESS_OUT_XL)[dec]/4096.
bcostm 4:137bb367ba50 320 */
bcostm 4:137bb367ba50 321 #define LPS22HB_PRESS_OUT_XL_REG (uint8_t)0x28
bcostm 4:137bb367ba50 322
bcostm 4:137bb367ba50 323 /**
bcostm 4:137bb367ba50 324 * @brief Pressure data (Middle part) register.
bcostm 4:137bb367ba50 325 * Read
bcostm 4:137bb367ba50 326 * Default value: 0x80.
bcostm 4:137bb367ba50 327 * POUT15 - POUT8: Pressure data middle part (2's complement).
bcostm 4:137bb367ba50 328 * Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
bcostm 4:137bb367ba50 329 * PRESS_OUT_XL)[dec]/4096.
bcostm 4:137bb367ba50 330 */
bcostm 4:137bb367ba50 331 #define LPS22HB_PRESS_OUT_L_REG (uint8_t)0x29
bcostm 4:137bb367ba50 332
bcostm 4:137bb367ba50 333 /**
bcostm 4:137bb367ba50 334 * @brief Pressure data (MSB) register.
bcostm 4:137bb367ba50 335 * Read
bcostm 4:137bb367ba50 336 * Default value: 0x2F.
bcostm 4:137bb367ba50 337 * POUT23 - POUT16: Pressure data MSB (2's complement).
bcostm 4:137bb367ba50 338 * Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
bcostm 4:137bb367ba50 339 * PRESS_OUT_XL)[dec]/4096.
bcostm 4:137bb367ba50 340 */
bcostm 4:137bb367ba50 341 #define LPS22HB_PRESS_OUT_H_REG (uint8_t)0x2A
bcostm 4:137bb367ba50 342
bcostm 4:137bb367ba50 343 /**
bcostm 4:137bb367ba50 344 * @brief Temperature data (LSB) register.
bcostm 4:137bb367ba50 345 * Read
bcostm 4:137bb367ba50 346 * Default value: 0x00.
bcostm 4:137bb367ba50 347 * TOUT7 - TOUT0: temperature data LSB.
bcostm 4:137bb367ba50 348 * Tout(degC)=TEMP_OUT/100
bcostm 4:137bb367ba50 349 */
bcostm 4:137bb367ba50 350 #define LPS22HB_TEMP_OUT_L_REG (uint8_t)0x2B
bcostm 4:137bb367ba50 351
bcostm 4:137bb367ba50 352 /**
bcostm 4:137bb367ba50 353 * @brief Temperature data (MSB) register.
bcostm 4:137bb367ba50 354 * Read
bcostm 4:137bb367ba50 355 * Default value: 0x00.
bcostm 4:137bb367ba50 356 * TOUT15 - TOUT8: temperature data MSB.
bcostm 4:137bb367ba50 357 * Tout(degC)=TEMP_OUT/100
bcostm 4:137bb367ba50 358 */
bcostm 4:137bb367ba50 359 #define LPS22HBH_TEMP_OUT_H_REG (uint8_t)0x2C
bcostm 4:137bb367ba50 360
bcostm 4:137bb367ba50 361 /**
bcostm 4:137bb367ba50 362 * @brief Threshold pressure (LSB) register.
bcostm 4:137bb367ba50 363 * Read/write
bcostm 4:137bb367ba50 364 * Default value: 0x00.
bcostm 4:137bb367ba50 365 * 7:0 THS7-THS0: LSB Threshold pressure Low part of threshold value for pressure interrupt
bcostm 4:137bb367ba50 366 * generation. The complete threshold value is given by THS_P_H & THS_P_L and is
bcostm 4:137bb367ba50 367 * expressed as unsigned number. P_ths(hPA)=(THS_P_H & THS_P_L)[dec]/16.
bcostm 4:137bb367ba50 368 */
bcostm 4:137bb367ba50 369 #define LPS22HB_THS_P_LOW_REG (uint8_t)0x0C
bcostm 4:137bb367ba50 370
bcostm 4:137bb367ba50 371 /**
bcostm 4:137bb367ba50 372 * @brief Threshold pressure (MSB)
bcostm 4:137bb367ba50 373 * Read/write
bcostm 4:137bb367ba50 374 * Default value: 0x00.
bcostm 4:137bb367ba50 375 * 7:0 THS15-THS8: MSB Threshold pressure. High part of threshold value for pressure interrupt
bcostm 4:137bb367ba50 376 * generation. The complete threshold value is given by THS_P_H & THS_P_L and is
bcostm 4:137bb367ba50 377 * expressed as unsigned number. P_ths(mbar)=(THS_P_H & THS_P_L)[dec]/16.
bcostm 4:137bb367ba50 378 */
bcostm 4:137bb367ba50 379 #define LPS22HB_THS_P_HIGH_REG (uint8_t)0x0D
bcostm 4:137bb367ba50 380
bcostm 4:137bb367ba50 381 /**
bcostm 4:137bb367ba50 382 * @brief FIFO control register
bcostm 4:137bb367ba50 383 * Read/write
bcostm 4:137bb367ba50 384 * Default value: 0x00
bcostm 4:137bb367ba50 385 * 7:5 F_MODE2, F_MODE1, F_MODE0: FIFO mode selection.
bcostm 4:137bb367ba50 386 * FM2 | FM1 | FM0 | FIFO MODE
bcostm 4:137bb367ba50 387 * ---------------------------------------------------
bcostm 4:137bb367ba50 388 * 0 | 0 | 0 | BYPASS MODE
bcostm 4:137bb367ba50 389 * 0 | 0 | 1 | FIFO MODE. Stops collecting data when full
bcostm 4:137bb367ba50 390 * 0 | 1 | 0 | STREAM MODE: Keep the newest measurements in the FIFO
bcostm 4:137bb367ba50 391 * 0 | 1 | 1 | STREAM MODE until trigger deasserted, then change to FIFO MODE
bcostm 4:137bb367ba50 392 * 1 | 0 | 0 | BYPASS MODE until trigger deasserted, then STREAM MODE
bcostm 4:137bb367ba50 393 * 1 | 0 | 1 | Reserved for future use
bcostm 4:137bb367ba50 394 * 1 | 1 | 0 | Reserved
bcostm 4:137bb367ba50 395 * 1 | 1 | 1 | BYPASS mode until trigger deasserted, then FIFO MODE
bcostm 4:137bb367ba50 396 *
bcostm 4:137bb367ba50 397 * 4:0 WTM_POINT4-0 : FIFO Watermark level selection (0-31)
bcostm 4:137bb367ba50 398 */
bcostm 4:137bb367ba50 399 #define LPS22HB_CTRL_FIFO_REG (uint8_t)0x14
bcostm 4:137bb367ba50 400
bcostm 4:137bb367ba50 401 #define LPS22HB_FIFO_MODE_MASK (uint8_t)0xE0
bcostm 4:137bb367ba50 402 #define LPS22HB_WTM_POINT_MASK (uint8_t)0x1F
bcostm 4:137bb367ba50 403
bcostm 4:137bb367ba50 404
bcostm 4:137bb367ba50 405 /**
bcostm 4:137bb367ba50 406 * @brief FIFO Status register
bcostm 4:137bb367ba50 407 * Read
bcostm 4:137bb367ba50 408 * 7 FTH_FIFO: FIFO threshold status. 0:FIFO filling is lower than FTH level
bcostm 4:137bb367ba50 409 * 1: FIFO is equal or higher than FTH level.
bcostm 4:137bb367ba50 410 * 6 OVR: Overrun bit status. 0 - FIFO not full
bcostm 4:137bb367ba50 411 * 1 - FIFO is full and at least one sample in the FIFO has been overwritten.
bcostm 4:137bb367ba50 412 * 5:0 FSS: FIFO Stored data level. 000000: FIFO empty, 100000: FIFO is full and has 32 unread samples.
bcostm 4:137bb367ba50 413 */
bcostm 4:137bb367ba50 414 #define LPS22HB_STATUS_FIFO_REG (uint8_t)0x26
bcostm 4:137bb367ba50 415
bcostm 4:137bb367ba50 416 #define LPS22HB_FTH_FIFO_BIT LPS22HB_BIT(7)
bcostm 4:137bb367ba50 417 #define LPS22HB_OVR_FIFO_BIT LPS22HB_BIT(6)
bcostm 4:137bb367ba50 418
bcostm 4:137bb367ba50 419 #define LPS22HB_FTH_FIFO_MASK (uint8_t)0x80
bcostm 4:137bb367ba50 420 #define LPS22HB_OVR_FIFO_MASK (uint8_t)0x40
bcostm 4:137bb367ba50 421 #define LPS22HB_LEVEL_FIFO_MASK (uint8_t)0x3F
bcostm 4:137bb367ba50 422 #define LPS22HB_FIFO_EMPTY (uint8_t)0x00
bcostm 4:137bb367ba50 423 #define LPS22HB_FIFO_FULL (uint8_t)0x20
bcostm 4:137bb367ba50 424
bcostm 4:137bb367ba50 425
bcostm 4:137bb367ba50 426
bcostm 4:137bb367ba50 427 /**
bcostm 4:137bb367ba50 428 * @brief Pressure offset register (LSB)
bcostm 4:137bb367ba50 429 * Read/write
bcostm 4:137bb367ba50 430 * Default value: 0x00
bcostm 4:137bb367ba50 431 * 7:0 RPDS7-0:Pressure Offset for 1 point calibration (OPC) after soldering.
bcostm 4:137bb367ba50 432 * This register contains the low part of the pressure offset value after soldering,for
bcostm 4:137bb367ba50 433 * differential pressure computing. The complete value is given by RPDS_L & RPDS_H
bcostm 4:137bb367ba50 434 * and is expressed as signed 2 complement value.
bcostm 4:137bb367ba50 435 */
bcostm 4:137bb367ba50 436 #define LPS22HB_RPDS_L_REG (uint8_t)0x18
bcostm 4:137bb367ba50 437
bcostm 4:137bb367ba50 438 /**
bcostm 4:137bb367ba50 439 * @brief Pressure offset register (MSB)
bcostm 4:137bb367ba50 440 * Read/write
bcostm 4:137bb367ba50 441 * Default value: 0x00
bcostm 4:137bb367ba50 442 * 7:0 RPDS15-8:Pressure Offset for 1 point calibration (OPC) after soldering.
bcostm 4:137bb367ba50 443 * This register contains the high part of the pressure offset value after soldering (see description RPDS_L)
bcostm 4:137bb367ba50 444 */
bcostm 4:137bb367ba50 445 #define LPS22HB_RPDS_H_REG (uint8_t)0x19
bcostm 4:137bb367ba50 446
bcostm 4:137bb367ba50 447
bcostm 4:137bb367ba50 448 /**
bcostm 4:137bb367ba50 449 * @brief Clock Tree Configuration register
bcostm 4:137bb367ba50 450 * Read/write
bcostm 4:137bb367ba50 451 * Default value: 0x00
bcostm 4:137bb367ba50 452 * 7:6 Reserved.
bcostm 4:137bb367ba50 453 * 5: CTE: Clock Tree Enhancement
bcostm 4:137bb367ba50 454 */
bcostm 4:137bb367ba50 455 #define LPS22HB_CLOCK_TREE_CONFIGURATION (uint8_t)0x43
bcostm 4:137bb367ba50 456 #define LPS22HB_CTE_MASK (uint8_t)0x20
bcostm 4:137bb367ba50 457
bcostm 4:137bb367ba50 458 /**
bcostm 4:137bb367ba50 459 * @}
bcostm 4:137bb367ba50 460 */
bcostm 4:137bb367ba50 461
bcostm 4:137bb367ba50 462
bcostm 4:137bb367ba50 463 /** @defgroup LPS22HB_Pressure_Exported_Functions LPS22HB Pressure Exported Functions
bcostm 4:137bb367ba50 464 * @{
bcostm 4:137bb367ba50 465 */
bcostm 4:137bb367ba50 466 /* PRESSURE functions */
bcostm 4:137bb367ba50 467 void LPS22HB_P_Init(uint16_t DeviceAddr);
bcostm 4:137bb367ba50 468 uint8_t LPS22HB_P_ReadID(uint16_t DeviceAddr);
bcostm 4:137bb367ba50 469 float LPS22HB_P_ReadPressure(uint16_t DeviceAddr);
bcostm 4:137bb367ba50 470 /**
bcostm 4:137bb367ba50 471 * @}
bcostm 4:137bb367ba50 472 */
bcostm 4:137bb367ba50 473
bcostm 4:137bb367ba50 474 /** @defgroup HTS221_PressImported_Globals PRESSURE Imported Globals
bcostm 4:137bb367ba50 475 * @{
bcostm 4:137bb367ba50 476 */
bcostm 4:137bb367ba50 477 /* PRESSURE driver structure */
bcostm 4:137bb367ba50 478 extern PSENSOR_DrvTypeDef LPS22HB_P_Drv;
bcostm 4:137bb367ba50 479 /**
bcostm 4:137bb367ba50 480 * @}
bcostm 4:137bb367ba50 481 */
bcostm 4:137bb367ba50 482
bcostm 4:137bb367ba50 483 /** @defgroup LPS22HB_Temperature_Exported_Functions LPS22HB Temperature Exported Functions
bcostm 4:137bb367ba50 484 * @{
bcostm 4:137bb367ba50 485 */
bcostm 4:137bb367ba50 486 /* TEMPERATURE functions */
bcostm 4:137bb367ba50 487 void LPS22HB_T_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct);
bcostm 4:137bb367ba50 488 float LPS22HB_T_ReadTemp(uint16_t DeviceAddr);
bcostm 4:137bb367ba50 489 /**
bcostm 4:137bb367ba50 490 * @}
bcostm 4:137bb367ba50 491 */
bcostm 4:137bb367ba50 492
bcostm 4:137bb367ba50 493 /** @defgroup HTS221_TempImported_Globals Temperature Imported Globals
bcostm 4:137bb367ba50 494 * @{
bcostm 4:137bb367ba50 495 */
bcostm 4:137bb367ba50 496 /* Temperature driver structure */
bcostm 4:137bb367ba50 497 extern TSENSOR_DrvTypeDef LPS22HB_T_Drv;
bcostm 4:137bb367ba50 498 /**
bcostm 4:137bb367ba50 499 * @}
bcostm 4:137bb367ba50 500 */
bcostm 4:137bb367ba50 501
bcostm 4:137bb367ba50 502 /** @defgroup LPS22HB_Imported_Functions LPS22HB Imported Functions
bcostm 4:137bb367ba50 503 * @{
bcostm 4:137bb367ba50 504 */
bcostm 4:137bb367ba50 505 /* IO functions */
bcostm 4:137bb367ba50 506 extern void SENSOR_IO_Init(void);
bcostm 4:137bb367ba50 507 extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
bcostm 4:137bb367ba50 508 extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
bcostm 4:137bb367ba50 509 extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
bcostm 4:137bb367ba50 510 extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
bcostm 4:137bb367ba50 511
bcostm 4:137bb367ba50 512 /**
bcostm 4:137bb367ba50 513 * @}
bcostm 4:137bb367ba50 514 */
bcostm 4:137bb367ba50 515
bcostm 4:137bb367ba50 516 #ifdef __cplusplus
bcostm 4:137bb367ba50 517 }
bcostm 4:137bb367ba50 518 #endif
bcostm 4:137bb367ba50 519
bcostm 4:137bb367ba50 520 #endif /* __LPS22HB__H */
bcostm 4:137bb367ba50 521
bcostm 4:137bb367ba50 522 /**
bcostm 4:137bb367ba50 523 * @}
bcostm 4:137bb367ba50 524 */
bcostm 4:137bb367ba50 525
bcostm 4:137bb367ba50 526 /**
bcostm 4:137bb367ba50 527 * @}
bcostm 4:137bb367ba50 528 */
bcostm 4:137bb367ba50 529
bcostm 4:137bb367ba50 530 /**
bcostm 4:137bb367ba50 531 * @}
bcostm 4:137bb367ba50 532 */
bcostm 4:137bb367ba50 533
bcostm 4:137bb367ba50 534 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/