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"
72#define PRESSURE_REG_REF_P_XLB 0x8
73#define PRESSURE_REG_REF_P_LSB 0x9
74#define PRESSURE_REG_REF_P_MSB 0xA
75#define PRESSURE_REG_DEVICE_ID 0xF
76#define PRESSURE_REG_RES_CFG 0x10
77#define PRESSURE_REG_CTRL_REG1 0x20
78#define PRESSURE_REG_CTRL_REG2 0x21
79#define PRESSURE_REG_CTRL_REG3 0x22
80#define PRESSURE_REG_INT_CFG 0x23
81#define PRESSURE_REG_INT_SOURCE 0x24
82#define PRESSURE_REG_THSH_P_LSB 0x25
83#define PRESSURE_REG_THSH_P_MSB 0x26
84#define PRESSURE_REG_STATUS 0x27
85#define PRESSURE_REG_PRESS_OUT_XLB 0x28
86#define PRESSURE_REG_PRESS_OUT_LSB 0x29
87#define PRESSURE_REG_PRESS_OUT_MSB 0x2A
88#define PRESSURE_REG_TEMP_OUT_LSB 0x2B
89#define PRESSURE_REG_TEMP_OUT_MSB 0x2C
90#define PRESSURE_REG_AMP_CTRL 0x30
97#define PRESSURE_WHO_AM_I 0xBB
109#define PRESSURE_SET_RES_AVG_1 0x0
110#define PRESSURE_SET_RES_AVG_2 0x1
111#define PRESSURE_SET_RES_AVG_4 0x2
112#define PRESSURE_SET_RES_AVG_8 0x3
113#define PRESSURE_SET_RES_AVG_16 0x4
114#define PRESSURE_SET_RES_AVG_32 0x5
115#define PRESSURE_SET_RES_AVG_64 0x6
116#define PRESSURE_SET_RES_AVG_128 0x7
117#define PRESSURE_SET_RES_AVG_256 0x8
118#define PRESSURE_SET_RES_AVG_384 0x9
119#define PRESSURE_SET_RES_AVG_512 0xA
126#define PRESSURE_SET_PWR_UP_DEV 0x80
127#define PRESSURE_SET_PWR_UP_INT 0x8
128#define PRESSURE_SET_BLOCK_DATA_UPDATE 0x4
129#define PRESSURE_SET_PWR_UP_DELTA_PRESS 0x2
130#define PRESSURE_SET_SPI_3_WIRE 0x1
137#define PRESSURE_SET_REBOOT_MEM_CONTENT 0x80
138#define PRESSURE_SET_SW_RESET 0x4
139#define PRESSURE_SET_AUTOZERO_EN 0x2
140#define PRESSURE_SET_ONESHOT_EN 0x1
141#define PRESSURE_SET_NORMAL_MODE 0x0
148#define PRESSURE_SET_INT_ACT_LOW 0x80
149#define PRESSURE_SET_INT_OPEN_DRAIN 0x40
150#define PRESSURE_SET_INT_GND 0x0
151#define PRESSURE_SET_INT_PRESS_HIGH 0x1
152#define PRESSURE_SET_INT_PRESS_LOW 0x2
153#define PRESSURE_SET_INT_P_LOW_OR_HIGH 0x3
154#define PRESSURE_SET_INT_DATA_RDY 0x4
155#define PRESSURE_SET_INT_TRI_STATE 0x7
169#define PRESSURE_FLAG_MASK_P_DATA_OR 0x20
170#define PRESSURE_FLAG_MASK_T_DATA_OR 0x10
171#define PRESSURE_FLAG_MASK_P_DATA_RDY 0x2
172#define PRESSURE_FLAG_MASK_T_DATA_RDY 0x1
179#define PRESSURE_FLAG_MASK_INT_ACT 0x4
180#define PRESSURE_FLAG_MASK_DIFF_P_LOW 0x2
181#define PRESSURE_FLAG_MASK_DIFF_P_HIGH 0x1
190#define PRESSURE_DATA_NUMBER_MIN 1
191#define PRESSURE_DATA_NUMBER_MAX 49
200#define PRESSURE_MAP_MIKROBUS( cfg, mikrobus ) \
201 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
202 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
203 cfg.sdo = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
204 cfg.sdi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
205 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT ); \
206 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
207 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
404 uint8_t *data_in, uint8_t n_data );
423 uint8_t *data_out, uint8_t n_data );
float pressure_get_pressure(pressure_t *ctx)
Pressure Get function.
void pressure_sw_reset(pressure_t *ctx)
Software Reset function.
pressure_err_t pressure_init(pressure_t *ctx, pressure_cfg_t *cfg)
Click Initialization function.
void pressure_pwr_ctrl(pressure_t *ctx, pressure_pwr_ctrl_t state)
Device Power Control function.
void pressure_cfg_setup(pressure_cfg_t *cfg)
Configuration Object Setup function.
void pressure_pwr_ctrl_delta_pressure(pressure_t *ctx, pressure_pwr_ctrl_t state)
Delta Pressure Power Control function.
pressure_err_t pressure_generic_multiple_write(pressure_t *ctx, uint8_t reg_addr, uint8_t *data_in, uint8_t n_data)
Generic Multiple Write function.
pressure_err_t pressure_generic_single_write(pressure_t *ctx, uint8_t reg_addr, uint8_t data_in)
Generic Single Write function.
void pressure_default_cfg(pressure_t *ctx)
Click Default Configuration function.
void pressure_set_odr(pressure_t *ctx, pressure_odr_t odr)
Output Data Rate Set function.
void pressure_pwr_ctrl_interrupt(pressure_t *ctx, pressure_pwr_ctrl_t state)
Interrupt Power Control function.
uint8_t pressure_get_status(pressure_t *ctx, uint8_t bit_mask)
Status Get function.
uint8_t pressure_read_id(pressure_t *ctx)
ID Read function.
float pressure_get_temperature(pressure_t *ctx)
Temperature Get function.
void pressure_reboot_memory(pressure_t *ctx)
Memory Reboot function.
uint8_t pressure_get_int_pin(pressure_t *ctx)
INT Pin Get function.
void pressure_block_data_update(pressure_t *ctx, pressure_pwr_ctrl_t state)
Data Update Block function.
pressure_err_t pressure_generic_multiple_read(pressure_t *ctx, uint8_t reg_addr, uint8_t *data_out, uint8_t n_data)
Generic Multiple Read function.
struct pressure_s pressure_t
Click context object definition.
pressure_drv_select_t
Click driver selector definition.
Definition pressure.h:238
void(* pressure_master_transfer_t)(struct pressure_s *, uint8_t, uint8_t *, uint8_t)
Click master transfer function definition.
Definition pressure.h:220
pressure_err_t
Click error code definition.
Definition pressure.h:226
pressure_pwr_ctrl_t
Click power control definition.
Definition pressure.h:264
pressure_odr_t
Click output data rate definition.
Definition pressure.h:248
@ PRESSURE_DRV_SEL_I2C
Definition pressure.h:239
@ PRESSURE_DRV_SEL_SPI
Definition pressure.h:240
@ PRESSURE_ERR_ADDR
Definition pressure.h:229
@ PRESSURE_OK
Definition pressure.h:227
@ PRESSURE_ERR_INIT_DRV
Definition pressure.h:228
@ PRESSURE_ERR_NDATA
Definition pressure.h:230
@ PRESSURE_PWR_DOWN
Definition pressure.h:265
@ PRESSURE_PWR_UP
Definition pressure.h:266
@ PRESSURE_ODR_P12HZ_T1HZ
Definition pressure.h:252
@ PRESSURE_ODR_P25HZ_T25HZ
Definition pressure.h:256
@ PRESSURE_ODR_P1HZ_T1HZ
Definition pressure.h:250
@ PRESSURE_ODR_P7HZ_T7HZ
Definition pressure.h:254
@ PRESSURE_ODR_P7HZ_T1HZ
Definition pressure.h:251
@ PRESSURE_ODR_P12HZ_T12HZ
Definition pressure.h:255
@ PRESSURE_ODR_P25HZ_T1HZ
Definition pressure.h:253
@ PRESSURE_ODR_ONE_SHOT
Definition pressure.h:249
Click configuration structure definition.
Definition pressure.h:297
bool i2c_addr
Definition pressure.h:310
pin_name_t sdi
Definition pressure.h:302
uint32_t i2c_speed
Definition pressure.h:311
spi_master_chip_select_polarity_t cs_polarity
Definition pressure.h:314
pin_name_t sck
Definition pressure.h:300
spi_master_mode_t spi_mode
Definition pressure.h:313
pressure_drv_select_t drv_sel
Definition pressure.h:316
uint32_t spi_speed
Definition pressure.h:312
pin_name_t sdo
Definition pressure.h:301
pin_name_t scl
Definition pressure.h:303
pin_name_t int_pin
Definition pressure.h:307
pin_name_t sda
Definition pressure.h:304
pin_name_t cs
Definition pressure.h:299
Click context object definition.
Definition pressure.h:274
digital_out_t cs
Definition pressure.h:276
spi_master_t spi
Definition pressure.h:283
digital_in_t int_pin
Definition pressure.h:279
i2c_master_t i2c
Definition pressure.h:282
uint8_t slave_addr
Definition pressure.h:286
pressure_master_transfer_t write
Definition pressure.h:288
pressure_master_transfer_t read
Definition pressure.h:289
pin_name_t chip_select
Definition pressure.h:287