51 #include "nrf_drv_twi.h" 55 #define INTERRUPT_CFG_REG 0x0B 56 #define INTERRUPT_CFG_REG_DEFAULT 0x00 59 #define INTERRUPT_CFG_REG_AUTORIFP_Pos 7 60 #define INTERRUPT_CFG_REG_AUTORIFP_Msk (1 << INTERRUPT_CFG_REG_AUTORIFP_Pos) 61 #define INTERRUPT_CFG_REG_AUTORIFP_Disable 0 62 #define INTERRUPT_CFG_REG_AUTORIFP_Enable 1 65 #define INTERRUPT_CFG_REG_RESET_ARP_Pos 6 66 #define INTERRUPT_CFG_REG_RESET_ARP_Msk (1 << INTERRUPT_CFG_REG_RESET_ARP_Pos) 67 #define INTERRUPT_CFG_REG_RESET_ARP_Disable 0 68 #define INTERRUPT_CFG_REG_RESET_ARP_Enable 1 71 #define INTERRUPT_CFG_REG_AUTOZERO_Pos 5 72 #define INTERRUPT_CFG_REG_AUTOZERO_Msk (1 << INTERRUPT_CFG_REG_AUTOZERO_Pos) 73 #define INTERRUPT_CFG_REG_AUTOZERO_Disable 0 74 #define INTERRUPT_CFG_REG_AUTOZERO_Enable 1 77 #define INTERRUPT_CFG_REG_RESET_AZ_Pos 4 78 #define INTERRUPT_CFG_REG_RESET_AZ_Msk (1 << INTERRUPT_CFG_REG_RESET_AZ_Pos) 79 #define INTERRUPT_CFG_REG_RESET_AZ_Disable 0 80 #define INTERRUPT_CFG_REG_RESET_AZ_Enable 1 83 #define INTERRUPT_CFG_REG_DIFF_EN_Pos 3 84 #define INTERRUPT_CFG_REG_DIFF_EN_Msk (1 << INTERRUPT_CFG_REG_DIFF_EN_Pos) 85 #define INTERRUPT_CFG_REG_DIFF_EN_Disable 0 86 #define INTERRUPT_CFG_REG_DIFF_EN_Enable 1 89 #define INTERRUPT_CFG_REG_LIR_Pos 2 90 #define INTERRUPT_CFG_REG_LIR_Msk (1 << INTERRUPT_CFG_REG_LIR_Pos) 91 #define INTERRUPT_CFG_REG_LIR_Disable 0 92 #define INTERRUPT_CFG_REG_LIR_Enable 1 95 #define INTERRUPT_CFG_REG_PLE_Pos 1 96 #define INTERRUPT_CFG_REG_PLE_Msk (1 << INTERRUPT_CFG_REG_PLE_Pos) 97 #define INTERRUPT_CFG_REG_PLE_Disable 0 98 #define INTERRUPT_CFG_REG_PLE_Enable 1 101 #define INTERRUPT_CFG_REG_PHE_Pos 0 102 #define INTERRUPT_CFG_REG_PHE_Msk (1 << INTERRUPT_CFG_REG_PHE_Pos) 103 #define INTERRUPT_CFG_REG_PHE_Disable 0 104 #define INTERRUPT_CFG_REG_PHE_Enable 1 107 #define THS_P_L_REG 0x0C 110 #define THS_P_H_REG 0x0D 113 #define WHO_AM_I_REG 0x0F 114 #define WHO_AM_I_REG_VALUE 0xB1 117 #define CTRL_REG1 0x10 118 #define CTRL_REG1_DEFAULT 0x00 121 #define CTRL_REG1_ODR_Pos 4 122 #define CTRL_REG1_ODR_Msk (7 << CTRL_REG1_ODR_Pos) 123 #define CTRL_REG1_ODR_OneShot 0 124 #define CTRL_REG1_ODR_PowerDown 0 125 #define CTRL_REG1_ODR_1Hz 1 126 #define CTRL_REG1_ODR_10Hz 2 127 #define CTRL_REG1_ODR_25Hz 3 128 #define CTRL_REG1_ODR_50Hz 4 129 #define CTRL_REG1_ODR_75Hz 5 132 #define CTRL_REG1_EN_LPFP_Pos 3 133 #define CTRL_REG1_EN_LPFP_Msk (1 << CTRL_REG1_EN_LPFP_Pos) 134 #define CTRL_REG1_EN_LPFP_Disable 0 135 #define CTRL_REG1_EN_LPFP_Enable 1 138 #define CTRL_REG1_LPFP_CFG_Pos 2 139 #define CTRL_REG1_LPFP_CFG_Msk (1 << CTRL_REG1_LPFP_CFG_Pos) 140 #define CTRL_REG1_LPFP_CFG_ODR_9 0 141 #define CTRL_REG1_LPFP_CFG_ODR_20 1 144 #define CTRL_REG1_BDU_Pos 1 145 #define CTRL_REG1_BDU_Msk (1 << CTRL_REG1_BDU_Pos) 146 #define CTRL_REG1_BDU_Disable 0 147 #define CTRL_REG1_BDU_Enable 1 150 #define CTRL_REG1_SIM_Pos 0 151 #define CTRL_REG1_SIM_Msk (1 << CTRL_REG1_SIM_Pos) 152 #define CTRL_REG1_SIM_4Wire 0 153 #define CTRL_REG1_SIM_3Wire 1 156 #define CTRL_REG2 0x11 157 #define CTRL_REG2_DEFAULT 0x10 160 #define CTRL_REG2_BOOT_Pos 7 161 #define CTRL_REG2_BOOT_Msk (1 << CTRL_REG2_BOOT_Pos) 162 #define CTRL_REG2_BOOT_Normal 0 163 #define CTRL_REG2_BOOT_Reboot 1 166 #define CTRL_REG2_FIFO_EN_Pos 6 167 #define CTRL_REG2_FIFO_EN_Msk (1 << CTRL_REG2_FIFO_EN_Pos) 168 #define CTRL_REG2_FIFO_EN_Disable 0 169 #define CTRL_REG2_FIFO_EN_Enable 1 172 #define CTRL_REG2_STOP_ON_FTH_Pos 5 173 #define CTRL_REG2_STOP_ON_FTH_Msk (1 << CTRL_REG2_STOP_ON_FTH_Pos) 174 #define CTRL_REG2_STOP_ON_FTH_Disable 0 175 #define CTRL_REG2_STOP_ON_FTH_Enable 1 178 #define CTRL_REG2_IF_ADD_INC_Pos 4 179 #define CTRL_REG2_IF_ADD_INC_Msk (1 << CTRL_REG2_IF_ADD_INC_Pos) 180 #define CTRL_REG2_IF_ADD_INC_Disable 0 181 #define CTRL_REG2_IF_ADD_INC_Enable 1 184 #define CTRL_REG2_I2C_DIS_Pos 3 185 #define CTRL_REG2_I2C_DIS_Msk (1 << CTRL_REG2_I2C_DIS_Pos) 186 #define CTRL_REG2_I2C_DIS_Disable 1 187 #define CTRL_REG2_I2C_DIS_Enable 0 190 #define CTRL_REG2_SWRESET_Pos 2 191 #define CTRL_REG2_SWRESET_Msk (1 << CTRL_REG2_SWRESET_Pos) 192 #define CTRL_REG2_SWRESET_Reset 1 195 #define CTRL_REG2_ONE_SHOT_Pos 0 196 #define CTRL_REG2_ONE_SHOT_Msk (1 << CTRL_REG2_ONE_SHOT_Pos) 197 #define CTRL_REG2_ONE_SHOT_Idle 0 198 #define CTRL_REG2_ONE_SHOT_Enable 1 201 #define CTRL_REG3 0x12 202 #define CTRL_REG3_DEFAULT 0x00 205 #define CTRL_REG3_INT_H_L_Pos 7 206 #define CTRL_REG3_INT_H_L_Msk (1 << CTRL_REG3_INT_H_L_Pos) 207 #define CTRL_REG3_INT_H_L_ActiveHigh 0 208 #define CTRL_REG3_INT_H_L_ActiveLow 1 211 #define CTRL_REG3_PP_OD_Pos 6 212 #define CTRL_REG3_PP_OD_Msk (1 << CTRL_REG3_PP_OD_Pos) 213 #define CTRL_REG3_PP_OD_PushPull 0 214 #define CTRL_REG3_PP_OD_OpenDrain 1 217 #define CTRL_REG3_F_FSS5_Pos 5 218 #define CTRL_REG3_F_FSS5_Msk (1 << CTRL_REG3_F_FSS5_Pos) 219 #define CTRL_REG3_F_FSS5_Disable 0 220 #define CTRL_REG3_F_FSS5_Enable 1 223 #define CTRL_REG3_F_FTH_Pos 4 224 #define CTRL_REG3_F_FTH_Msk (1 << CTRL_REG3_F_FTH_Pos) 225 #define CTRL_REG3_F_FTH_Disable 0 226 #define CTRL_REG3_F_FTH_Enable 1 229 #define CTRL_REG3_F_OVR_Pos 3 230 #define CTRL_REG3_F_OVR_Msk (1 << CTRL_REG3_F_OVR_Pos) 231 #define CTRL_REG3_F_OVR_Disable 0 232 #define CTRL_REG3_F_OVR_Enable 1 235 #define CTRL_REG3_DRDY_Pos 2 236 #define CTRL_REG3_DRDY_Msk (1 << CTRL_REG3_DRDY_Pos) 237 #define CTRL_REG3_DRDY_Disable 0 238 #define CTRL_REG3_DRDY_Enable 1 241 #define CTRL_REG3_INT_S_Pos 0 242 #define CTRL_REG3_INT_S_Msk (3 << CTRL_REG3_INT_S_Pos) 243 #define CTRL_REG3_INT_S_Pri 0 244 #define CTRL_REG3_INT_S_High 1 245 #define CTRL_REG3_INT_S_Low 2 246 #define CTRL_REG3_INT_S_HighOrLow 3 249 #define FIFO_CTRL_REG 0x14 250 #define FIFO_CTRL_REG_DEFAULT 0x00 253 #define FIFO_CTRL_REG_F_MODE_Pos 5 254 #define FIFO_CTRL_REG_F_MODE_Msk (7 << FIFO_CTRL_REG_F_MODE_Pos) 255 #define FIFO_CTRL_REG_F_MODE_Bypass 0 256 #define FIFO_CTRL_REG_F_MODE_Fifo 1 257 #define FIFO_CTRL_REG_F_MODE_Stream 2 258 #define FIFO_CTRL_REG_F_MODE_StreamToFifo 3 259 #define FIFO_CTRL_REG_F_MODE_BypassToStream 4 260 #define FIFO_CTRL_REG_F_MODE_DynamicStream 6 261 #define FIFO_CTRL_REG_F_MODE_BypassToFifo 7 264 #define REF_P_XL_REG 0x15 267 #define REF_P_L_REG 0x16 270 #define REF_P_H_REG 0x17 273 #define RPDS_L_REG 0x18 276 #define RPDS_H_REG 0x19 279 #define RES_CONF_REG 0x1A 280 #define RES_CONF_REG_DEFAULT 0x00 283 #define RES_CONF_REG_LC_EN_Pos 0 284 #define RES_CONF_REG_LC_EN_Msk (1 << RES_CONF_REG_LC_EN_Pos) 285 #define RES_CONF_REG_LC_EN_Disable 0 286 #define RES_CONF_REG_LC_EN_Enable 1 289 #define INT_SOURCE_REG 0x25 292 #define FIFO_STATUS_REG 0x26 295 #define STATUS_REG 0x27 298 #define STATUS_REG_T_OR_Pos 5 299 #define STATUS_REG_T_OR_Msk (1 << STATUS_REG_T_OR_Pos) 300 #define STATUS_REG_T_OR_Overrun 1 303 #define STATUS_REG_P_OR_Pos 4 304 #define STATUS_REG_P_OR_Msk (1 << STATUS_REG_P_OR_Pos) 305 #define STATUS_REG_P_OR_Overrun 1 308 #define STATUS_REG_T_DA_Pos 1 309 #define STATUS_REG_T_DA_Msk (1 << STATUS_REG_T_DA_Pos) 310 #define STATUS_REG_T_DA_Available 1 313 #define STATUS_REG_P_DA_Pos 0 314 #define STATUS_REG_P_DA_Msk (1 << STATUS_REG_P_DA_Pos) 315 #define STATUS_REG_P_DA_Available 1 318 #define PRESS_OUT_XL_REG 0x28 321 #define PRESS_OUT_L_REG 0x29 324 #define PRESS_OUT_H_REG 0x2A 327 #define TEMP_OUT_L_REG 0x2B 330 #define TEMP_OUT_H_REG 0x2C 333 #define LPFP_RES_REG 0x33 340 uint16_t int_threshold;
362 DRV_LPS22HB_ODR_PowerDown,
364 DRV_LPS22HB_ODR_10Hz,
365 DRV_LPS22HB_ODR_25Hz,
366 DRV_LPS22HB_ODR_50Hz,
uint32_t drv_lps22hb_temperature_get(uint16_t *p_temperature)
Function for getting the temperature data.
uint32_t drv_lps22hb_init(void)
Function for initializing the LPS22HB driver.
uint32_t drv_lps22hb_close(void)
Function for closing the LPS22HB driver.
uint32_t drv_lps22hb_pressure_offset_get(uint16_t *p_offset)
Function for getting pressure offset.
uint32_t drv_lps22hb_fifo_status_get(uint8_t *p_status)
Function for getting the FIFO status.
uint32_t drv_lps22hb_status_get(uint8_t *p_status)
Function for getting the status.
nrf_drv_twi_t const * p_twi_instance
The instance of TWI master to be used for transactions.
Definition: drv_lps22hb.h:354
Configuration struct for the LPS22HB pressure sensor.
Definition: drv_lps22hb.h:337
uint32_t drv_lps22hb_pressure_offset_set(uint16_t offset)
Function for setting pressure offset.
uint32_t drv_lps22hb_ref_pressure_get(uint32_t *p_ref_press)
Function for getting reference pressure.
uint32_t drv_lps22hb_odr_set(drv_lps22hb_odr_t odr)
Function for outputting data rate of the LPS22HB.
uint32_t drv_lps22hb_verify(uint8_t *who_am_i)
Function for reading and checking the WHO_AM_I register of the LPS22HB sensor.
uint32_t pin_int
Interrupt pin number.
Definition: drv_lps22hb.h:353
uint32_t drv_lps22hb_open(drv_lps22hb_twi_cfg_t const *const p_twi_cfg)
Function for opening the LPS22HB driver according to the specified configuration. ...
uint32_t drv_lps22hb_one_shot(void)
Function for starting a one-shot conversion of the LPS22HB sensor data.
nrf_drv_twi_config_t const * p_twi_cfg
The TWI configuration to use while the driver is enabled.
Definition: drv_lps22hb.h:355
drv_lps22hb_odr_t
Available data rates.
Definition: drv_lps22hb.h:360
uint32_t drv_lps22hb_reboot(void)
Function for rebooting the LPS22HB memory content.
uint8_t twi_addr
TWI address.
Definition: drv_lps22hb.h:352
uint32_t drv_lps22hb_sw_reset(void)
Function for performing a software reset of the LPS22HB.
uint32_t drv_lps22hb_int_source_get(uint8_t *p_source)
Function for getting the interrupt source register.
uint32_t drv_lps22hb_ref_pressure_set(uint32_t ref_press)
Function for setting reference pressure.
uint32_t drv_lps22hb_cfg_set(drv_lps22hb_cfg_t const *const p_cfg)
Function for configuring the LPS22HB sensor according to the specified configuration.
uint32_t drv_lps22hb_pressure_get(uint32_t *p_pressure)
Function for getting the pressure data. To calculate p(hPa) = *p_pressure(LSB) / 4096(LSB/hPa).
Initialization struct for the LPS22HB pressure sensor driver.
Definition: drv_lps22hb.h:350
uint32_t drv_lps22hb_low_pass_reset(void)
Function for resetting low-pass filter of the LPS22HB.
uint32_t drv_lps22hb_cfg_get(drv_lps22hb_cfg_t *p_cfg)
Function for reading the configuration of the LPS22HB sensor.