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 BAROMETER3_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 BAROMETER3_MASTER_I2C 0
83#define BAROMETER3_MASTER_SPI 1
90#define BAROMETER3_RETVAL uint8_t
92#define BAROMETER3_OK 0x00
93#define BAROMETER3_INIT_ERROR 0xFF
100#define BAROMETER3_I2C_SLV_ADR_GND 0x76
101#define BAROMETER3_I2C_SLV_ADR_VCC 0x77
108#define BAROMETER3_READ_BIT_MASK 0x80
109#define BAROMETER3_WRITE_BIT_MASK 0x7F
116#define BAROMETER3_PSR_B2 0x00
117#define BAROMETER3_PSR_B1 0x01
118#define BAROMETER3_PSR_B0 0x02
119#define BAROMETER3_TMP_B2 0x03
120#define BAROMETER3_TMP_B1 0x04
121#define BAROMETER3_TMP_B0 0x05
122#define BAROMETER3_PRS_CFG 0x06
123#define BAROMETER3_TMP_CFG 0x07
124#define BAROMETER3_MEAS_CFG 0x08
125#define BAROMETER3_CFG_REG 0x09
126#define BAROMETER3_INT_STS 0x0A
127#define BAROMETER3_FIFO_STS 0x0B
128#define BAROMETER3_RESET 0x0C
129#define BAROMETER3_PROD_ID 0x0D
130#define BAROMETER3_COEF_C0 0x10
131#define BAROMETER3_COEF_C0_C1 0x11
132#define BAROMETER3_COEF_C1 0x12
133#define BAROMETER3_COEF_C00_MSB 0x13
134#define BAROMETER3_COEF_C00_LSB 0x14
135#define BAROMETER3_COEF_C00_C10 0x15
136#define BAROMETER3_COEF_C10_MSB 0x16
137#define BAROMETER3_COEF_C10_LSB 0x17
138#define BAROMETER3_COEF_C01_MSB 0x18
139#define BAROMETER3_COEF_C01_LSB 0x19
140#define BAROMETER3_COEF_C11_MSB 0x1A
141#define BAROMETER3_COEF_C11_LSB 0x1B
142#define BAROMETER3_COEF_C20_MSB 0x1C
143#define BAROMETER3_COEF_C20_LSB 0x1D
144#define BAROMETER3_COEF_C21_MSB 0x1E
145#define BAROMETER3_COEF_C21_LSB 0x1F
146#define BAROMETER3_COEF_C30_MSB 0x20
147#define BAROMETER3_COEF_C30_LSB 0x21
148#define BAROMETER3_COEF_SRCE 0x28
155#define BAROMETER3_PM_RATE_1 0x00
156#define BAROMETER3_PM_RATE_2 0x10
157#define BAROMETER3_PM_RATE_4 0x20
158#define BAROMETER3_PM_RATE_8 0x30
159#define BAROMETER3_PM_RATE_16 0x40
160#define BAROMETER3_PM_RATE_32 0x50
161#define BAROMETER3_PM_RATE_64 0x60
162#define BAROMETER3_PM_RATE_128 0x70
163#define BAROMETER3_PM_PRC_1 0x00
164#define BAROMETER3_PM_PRC_2 0x01
165#define BAROMETER3_PM_PRC_4 0x02
166#define BAROMETER3_PM_PRC_8 0x03
167#define BAROMETER3_PM_PRC_16 0x04
168#define BAROMETER3_PM_PRC_32 0x05
169#define BAROMETER3_PM_PRC_64 0x06
170#define BAROMETER3_PM_PRC_128 0x07
177#define BAROMETER3_TMP_INT 0x00
178#define BAROMETER3_TMP_EXT 0x80
179#define BAROMETER3_TMP_RATE_1 0x00
180#define BAROMETER3_TMP_RATE_2 0x10
181#define BAROMETER3_TMP_RATE_4 0x20
182#define BAROMETER3_TMP_RATE_8 0x30
183#define BAROMETER3_TMP_RATE_16 0x40
184#define BAROMETER3_TMP_RATE_32 0x50
185#define BAROMETER3_TMP_RATE_64 0x60
186#define BAROMETER3_TMP_RATE_128 0x70
187#define BAROMETER3_TMP_PRC_1 0x00
188#define BAROMETER3_TMP_PRC_2 0x01
189#define BAROMETER3_TMP_PRC_4 0x02
190#define BAROMETER3_TMP_PRC_8 0x03
191#define BAROMETER3_TMP_PRC_16 0x04
192#define BAROMETER3_TMP_PRC_32 0x05
193#define BAROMETER3_TMP_PRC_64 0x06
194#define BAROMETER3_TMP_PRC_128 0x07
201#define BAROMETER3_COEF_RDY 0x80
202#define BAROMETER3_SENSOR_RDY 0x40
203#define BAROMETER3_TMP_RDY 0x20
204#define BAROMETER3_PRS_RDY 0x10
205#define BAROMETER3_MEAS_CTRL_IDLE 0x00
206#define BAROMETER3_MEAS_CTRL_CMD_PM 0x01
207#define BAROMETER3_MEAS_CTRL_CMD_TM 0x02
208#define BAROMETER3_MEAS_CTRL_CONT_PM 0x05
209#define BAROMETER3_MEAS_CTRL_CONT_TM 0x06
210#define BAROMETER3_MEAS_CTRL_CONT_MEAS 0x07
217#define BAROMETER3_INT_HL_ACT_L 0x00
218#define BAROMETER3_INT_HL_ACT_H 0x80
219#define BAROMETER3_INT_FIFO 0x40
220#define BAROMETER3_INT_TMP 0x20
221#define BAROMETER3_INT_PRS 0x10
222#define BAROMETER3_T_SHIFT 0x08
223#define BAROMETER3_P_SHIFT 0x04
224#define BAROMETER3_FIFO_EN 0x02
225#define BAROMETER3_SPI_MODE_4_WIRE 0x00
226#define BAROMETER3_SPI_MODE_3_WIRE 0x01
233#define BAROMETER3_INT_FIFO_FULL 0x04
234#define BAROMETER3_INT_TMP_FLG 0x02
235#define BAROMETER3_INT_PRS_FLG 0x01
242#define BAROMETER3_FIFO_FULL 0x02
243#define BAROMETER3_FIFO_EMPTY 0x01
244#define BAROMETER3_FIFO_SIZE 32
251#define BAROMETER3_FIFO_FLUSH 0x80
252#define BAROMETER3_SOFT_RST 0x09
259#define BAROMETER3_TMP_COEF_SRCE 0x80
266#define BAROMETER3_SCALE_FCTR_OSR_1 524288
267#define BAROMETER3_SCALE_FCTR_OSR_2 1572864
268#define BAROMETER3_SCALE_FCTR_OSR_4 3670016
269#define BAROMETER3_SCALE_FCTR_OSR_8 7864320
270#define BAROMETER3_SCALE_FCTR_OSR_16 253952
271#define BAROMETER3_SCALE_FCTR_OSR_32 516096
272#define BAROMETER3_SCALE_FCTR_OSR_64 1040384
273#define BAROMETER3_SCALE_FCTR_OSR_128 2088960
280#define BAROMETER3_SUCCESS 0
281#define BAROMETER3_BUSY 1
282#define BAROMETER3_MAX_BUSYTIME 990
283#define BAROMETER3_FAIL 2
284#define BAROMETER3_UNFIN 3
291#define BAROMETER3_SPI_DUMMY 0x00
298#define SPI_COMMUNICATION 1
299#define I2C_COMMUNICATION 2
306#define BAROMETER3_PRODUCT_ID 0x10
313#define BAROMETER3_PASCAL_TO_MBAR 100
#define BAROMETER3_RETVAL
Definition barometer3.h:90
void barometer3_cfg_temp(barometer3_t *ctx, uint8_t temp_mr, uint8_t temp_osr)
Temperature Measurement Configuration function.
void barometer3_standby(barometer3_t *ctx)
Standby function.
void barometer3_generic_read(barometer3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void barometer3_set_op_mode(barometer3_t *ctx, uint8_t op_mode)
Set mode of operation function.
void barometer3_cfg_pres(barometer3_t *ctx, uint8_t prs_mr, uint8_t prs_osr)
Pressure Measurement Configuration function.
void barometer3_def_cfg(barometer3_t *ctx)
Apply Default Configuration function.
uint8_t barometer3_meas_prs_once(barometer3_t *ctx, float *result, uint8_t prs_osr)
Get Pressure Measurement Once function.
void barometer3_read_coeffs(barometer3_t *ctx)
Read Calculation Coefficients function.
void barometer3_disable_fifo(barometer3_t *ctx)
Disable FIFO function.
uint8_t barometer3_get_fifo_val(barometer3_t *ctx, int32_t *value)
Get FIFO Value function.
void barometer3_generic_write(barometer3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
BAROMETER3_RETVAL barometer3_init(barometer3_t *ctx, barometer3_cfg_t *cfg)
Initialization function.
uint8_t barometer3_check_int(barometer3_t *ctx)
Check interrupt ststus function.
uint8_t barometer3_read_byte(barometer3_t *ctx, uint8_t reg_adr)
Read byte function.
void barometer3_flush_fifo(barometer3_t *ctx)
Flush FIFO function.
uint8_t barometer3_get_single_res(barometer3_t *ctx, float *result)
Get Single measurement function.
void barometer3_cfg_setup(barometer3_cfg_t *cfg)
Config Object Initialization function.
uint8_t barometer3_st_meas_temp_once(barometer3_t *ctx, uint8_t temp_osr)
Start Measure Temperature Once function.
void barometer3_get_raw_res(barometer3_t *ctx, uint8_t reg_adr, int32_t *raw)
Get Raw Measurement results.
uint8_t barometer3_meas_temp_once(barometer3_t *ctx, float *result, uint8_t temp_osr)
Get Temperature Measurement Once function.
float barometer3_calc_temp(barometer3_t *ctx, int32_t raw)
Temperature Calculation function.
uint8_t barometer3_get_cont_res(barometer3_t *ctx, float *temp_buf, float *prs_buf)
Get Continuous results function.
uint8_t barometer3_st_meas_pres_once(barometer3_t *ctx, uint8_t prs_osr)
Start Measure Pressure Once function.
float barometer3_calc_pres(barometer3_t *ctx, int32_t raw)
Pressure Calculation function.
struct barometer3_s barometer3_t
Click ctx object definition.
uint8_t barometer3_select_t
Communication type.
Definition barometer3.h:326
void(* barometer3_master_io_t)(struct barometer3_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition barometer3.h:331
Click configuration structure definition.
Definition barometer3.h:384
uint32_t i2c_speed
Definition barometer3.h:400
spi_master_chip_select_polarity_t cs_polarity
Definition barometer3.h:405
pin_name_t sck
Definition barometer3.h:391
spi_master_mode_t spi_mode
Definition barometer3.h:404
pin_name_t mosi
Definition barometer3.h:390
uint32_t spi_speed
Definition barometer3.h:403
pin_name_t scl
Definition barometer3.h:387
pin_name_t int_pin
Definition barometer3.h:396
pin_name_t miso
Definition barometer3.h:389
pin_name_t sda
Definition barometer3.h:388
barometer3_select_t sel
Definition barometer3.h:407
pin_name_t cs
Definition barometer3.h:392
uint8_t i2c_address
Definition barometer3.h:401
Click ctx object definition.
Definition barometer3.h:337
digital_out_t cs
Definition barometer3.h:344
int32_t coef_c00
Definition barometer3.h:361
int32_t coef_c30
Definition barometer3.h:367
uint8_t cfg_temp_osr
Definition barometer3.h:370
spi_master_t spi
Definition barometer3.h:349
int32_t coef_c10
Definition barometer3.h:362
barometer3_master_io_t write_f
Definition barometer3.h:355
uint8_t cfg_temp_mr
Definition barometer3.h:369
uint8_t cfg_prs_mr
Definition barometer3.h:371
uint8_t communication_interface
Definition barometer3.h:376
int32_t coef_c21
Definition barometer3.h:366
int32_t coef_c1
Definition barometer3.h:360
float coef_temp_scal
Definition barometer3.h:368
int32_t coef_c0_half
Definition barometer3.h:359
digital_in_t int_pin
Definition barometer3.h:340
i2c_master_t i2c
Definition barometer3.h:348
int32_t coef_c20
Definition barometer3.h:365
barometer3_master_io_t read_f
Definition barometer3.h:356
uint8_t cfg_prs_osr
Definition barometer3.h:372
int32_t coef_c11
Definition barometer3.h:364
uint8_t slave_address
Definition barometer3.h:353
int32_t coef_c01
Definition barometer3.h:363
barometer3_select_t master_sel
Definition barometer3.h:357
pin_name_t chip_select
Definition barometer3.h:354
uint8_t cfg_temp_sens
Definition barometer3.h:373
uint8_t cfg_op_mode
Definition barometer3.h:374