42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55#include "drv_spi_master.h"
68#define LPS22HB_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
70 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
71 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
72 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
73 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
74 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
75 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
82#define LPS22HB_MASTER_I2C 0
83#define LPS22HB_MASTER_SPI 1
90#define LPS22HB_RETVAL uint8_t
92#define LPS22HB_OK 0x00
93#define LPS22HB_INIT_ERROR 0xFF
100#define LPS22HB_DEV_RES_PRES 4096.0
101#define LPS22HB_DEV_RES_TEMP 100.0
108#define LPS22HB_I2C_ADDRESS_0 0x5C
109#define LPS22HB_I2C_ADDRESS_1 0x5D
116#define LPS22HB_REG_INTERRUPT_CFG 0x0B
117#define LPS22HB_REG_THS_P_L 0x0C
118#define LPS22HB_REG_THS_P_H 0x0D
119#define LPS22HB_REG_WHO_AM_I 0x0F
121#define LPS22HB_REG_REF_P_XL 0x15
122#define LPS22HB_REG_REF_P_L 0x16
123#define LPS22HB_REG_REF_P_H 0x17
124#define LPS22HB_REG_RPDS_L 0x18
125#define LPS22HB_REG_RPDS_H 0x19
126#define LPS22HB_REG_RES_CONF 0x1A
127#define LPS22HB_REG_INT_SOURCE 0x25
128#define LPS22HB_REG_FIFO_STATUS 0x26
129#define LPS22HB_REG_STATUS 0x27
130#define LPS22HB_REG_PRESS_OUT_XL 0x28
131#define LPS22HB_REG_PRESS_OUT_L 0x29
132#define LPS22HB_REG_PRESS_OUT_H 0x2A
133#define LPS22HB_REG_TEMP_OUT_L 0x2B
134#define LPS22HB_REG_TEMP_OUT_H 0x2C
135#define LPS22HB_REG_CLOCK_TREE_CONFIGURATION 0x43
142#define LPS22HB_RES_CONF_NORMAL_MODE 0x00
143#define LPS22HB_RES_CONF_LOW_CURRENT_MODE 0x01
150#define LPS22HB_CTRL_REG_R1 0x10
151#define LPS22HB_CTRL_REG_R2 0x11
152#define LPS22HB_CTRL_REG_R3 0x12
153#define LPS22HB_CTRL_REG_FIFO 0x14
155#define LPS22HB_CTRL_I2C 0x10
156#define LPS22HB_CTRL_SPI 0x18
163#define LPS22HB_MASK_DATA 0x80
164#define LPS22HB_MASK_DATA_RESET 0x02
165#define LPS22HB_MASK_DATA_ODR 0x30
167#define LPS22HB_MASK_REG1_ODR 0x70
168#define LPS22HB_MASK_REG1_LPFP 0x08
169#define LPS22HB_MASK_REG1_LPFP_CUTOFF 0x04
170#define LPS22HB_MASK_REG1_BDU 0x02
171#define LPS22HB_MASK_REG1_SIM 0x01
173#define LPS22HB_MASK_REG2_FIFO_EN 0x40
174#define LPS22HB_MASK_REG2_WTM_EN 0x20
175#define LPS22HB_MASK_REG2_ADD_INC 0x10
176#define LPS22HB_MASK_REG2_I2C 0x08
177#define LPS22HB_MASK_REG2_ONE_SHOT 0x01
179#define LPS22HB_MASK_REG3_INT_H_L 0x80
180#define LPS22HB_MASK_REG3_PP_OD 0x40
181#define LPS22HB_MASK_REG3_FIFO_FULL 0x20
182#define LPS22HB_MASK_REG3_FIFO_FTH 0x10
183#define LPS22HB_MASK_REG3_FIFO_OVR 0x08
184#define LPS22HB_MASK_REG3_DRDY 0x04
185#define LPS22HB_MASK_REG3_INT_S12 0x03
192#define LPS22HB_INT_MASK_CFG_AUTORIFP 0x80
193#define LPS22HB_INT_MASK_CFG_RESET_ARP 0x40
194#define LPS22HB_INT_MASK_CFG_AUTOZERO 0x20
195#define LPS22HB_INT_MASK_CFG_RESET_AZ 0x10
196#define LPS22HB_INT_MASK_CFG_DIFF_EN 0x08
197#define LPS22HB_INT_MASK_CFG_LIR 0x04
198#define LPS22HB_INT_MASK_CFG_PLE 0x02
199#define LPS22HB_INT_MASK_CFG_PHE 0x01
201#define LPS22HB_INT_MASK_SOURCE_BOOT_STATUS 0x80
202#define LPS22HB_INT_MASK_SOURCE_IA 0x04
203#define LPS22HB_INT_MASK_SOURCE_PL 0x02
204#define LPS22HB_INT_MASK_SOURCE_PH 0x01
206#define LPS22HB_INT_MASK_SOURCE_TOR 0x20
207#define LPS22HB_INT_MASK_SOURCE_POR 0x10
208#define LPS22HB_INT_MASK_SOURCE_TDA 0x02
209#define LPS22HB_INT_MASK_SOURCE_PDA 0x01
216#define LPS22HB_FIFO_MASK_CTRL_MODE 0xE0
217#define LPS22HB_FIFO_MASK_CTRL_WTM_POINT 0x1F
219#define LPS22HB_FIFO_MASK_STATUS_FTH 0x80
220#define LPS22HB_FIFO_MASK_STATUS_OVR 0x40
221#define LPS22HB_FIFO_MASK_STATUS_LEVEL 0x3F
222#define LPS22HB_FIFO_STATUS_EMPTY 0x00
223#define LPS22HB_FIFO_STATUS_FULL 0x20
#define LPS22HB_RETVAL
Definition lps22hb.h:90
void lps22hb_update_reg(lps22hb_t *ctx, uint8_t reg_adr, uint8_t reg_val)
Update register function.
uint8_t lps22hb_check_int(lps22hb_t *ctx)
Check Interrupt state function.
float lps22hb_get_temp(lps22hb_t *ctx)
Get temperature value function.
void lps22hb_start_configuration(lps22hb_t *ctx)
Set start configuration function.
void lps22hb_default_cfg(lps22hb_t *ctx, lps22hb_cfg_t *cfg)
Click Default Configuration function.
float lps22hb_get_pressure(lps22hb_t *ctx)
Get pressure value function.
void lps22hb_generic_read(lps22hb_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void lps22hb_set_fifo_mode(lps22hb_t *ctx, uint8_t mode_sel, uint8_t wm_lvl)
Set FIFO control mode function.
void lps22hb_cfg_setup(lps22hb_cfg_t *cfg)
Config Object Initialization function.
void lps22hb_soft_reset(lps22hb_t *ctx)
Soft reset function.
LPS22HB_RETVAL lps22hb_init(lps22hb_t *ctx, lps22hb_cfg_t *cfg)
Initialization function.
void lps22hb_generic_write(lps22hb_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void(* lps22hb_master_io_t)(struct lps22hb_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition lps22hb.h:242
struct lps22hb_s lps22hb_t
Click ctx object definition.
uint8_t lps22hb_select_t
Communication type.
Definition lps22hb.h:237
Click configuration structure definition.
Definition lps22hb.h:276
lps22hb_select_t sel
Definition lps22hb.h:299
uint32_t i2c_speed
Definition lps22hb.h:292
spi_master_chip_select_polarity_t cs_polarity
Definition lps22hb.h:297
pin_name_t sck
Definition lps22hb.h:283
spi_master_mode_t spi_mode
Definition lps22hb.h:296
pin_name_t mosi
Definition lps22hb.h:282
uint32_t spi_speed
Definition lps22hb.h:295
pin_name_t scl
Definition lps22hb.h:279
pin_name_t int_pin
Definition lps22hb.h:288
pin_name_t miso
Definition lps22hb.h:281
pin_name_t sda
Definition lps22hb.h:280
pin_name_t cs
Definition lps22hb.h:284
uint8_t i2c_address
Definition lps22hb.h:293
Click ctx object definition.
Definition lps22hb.h:248
lps22hb_master_io_t read_f
Definition lps22hb.h:267
digital_out_t cs
Definition lps22hb.h:251
spi_master_t spi
Definition lps22hb.h:260
lps22hb_master_io_t write_f
Definition lps22hb.h:266
lps22hb_select_t master_sel
Definition lps22hb.h:268
digital_in_t int_pin
Definition lps22hb.h:255
i2c_master_t i2c
Definition lps22hb.h:259
uint8_t slave_address
Definition lps22hb.h:264
pin_name_t chip_select
Definition lps22hb.h:265