39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
75#define PRESSURE20_REG_TRIM1_MSB 0x05
76#define PRESSURE20_REG_TRIM2_LSB 0x06
77#define PRESSURE20_REG_TRIM2_MSB 0x07
78#define PRESSURE20_REG_DEVICE_ID 0x0C
79#define PRESSURE20_REG_IO_DRIVE_STRENGTH 0x0D
80#define PRESSURE20_REG_OTP_CONFIG1 0xAC
81#define PRESSURE20_REG_OTP_MR_LSB 0xAD
82#define PRESSURE20_REG_OTP_MR_MSB 0xAE
83#define PRESSURE20_REG_OTP_MRA_LSB 0xAF
84#define PRESSURE20_REG_OTP_MRA_MSB 0xB0
85#define PRESSURE20_REG_OTP_MRB_LSB 0xB1
86#define PRESSURE20_REG_OTP_MRB_MSB 0xB2
87#define PRESSURE20_REG_OTP_ADDRESS_REG 0xB5
88#define PRESSURE20_REG_OTP_COMMAND_REG 0xB6
89#define PRESSURE20_REG_OTP_RDATA 0xB8
90#define PRESSURE20_REG_OTP_STATUS 0xB9
91#define PRESSURE20_REG_OTP_DBG2 0xBC
92#define PRESSURE20_REG_MASTER_LOCK 0xBE
93#define PRESSURE20_REG_OTP_STATUS2 0xBF
94#define PRESSURE20_REG_MODE_SELECT 0xC0
95#define PRESSURE20_REG_INTERRUPT_STATUS 0xC1
96#define PRESSURE20_REG_INTERRUPT_MASK 0xC2
97#define PRESSURE20_REG_FIFO_CONFIG 0xC3
98#define PRESSURE20_REG_FIFO_FILL 0xC4
99#define PRESSURE20_REG_SPI_MODE 0xC5
100#define PRESSURE20_REG_PRESS_ABS_LSB 0xC7
101#define PRESSURE20_REG_PRESS_ABS_MSB 0xC8
102#define PRESSURE20_REG_PRESS_DELTA_LSB 0xC9
103#define PRESSURE20_REG_PRESS_DELTA_MSB 0xCA
104#define PRESSURE20_REG_DEVICE_STATUS 0xCD
105#define PRESSURE20_REG_I3C_INFO 0xCE
106#define PRESSURE20_REG_VERSION 0xD3
107#define PRESSURE20_REG_DUMMY 0xEE
108#define PRESSURE20_REG_PRESS_DATA_0 0xFA
109#define PRESSURE20_REG_PRESS_DATA_1 0xFB
110#define PRESSURE20_REG_PRESS_DATA_2 0xFC
111#define PRESSURE20_REG_TEMP_DATA_0 0xFD
112#define PRESSURE20_REG_TEMP_DATA_1 0xFE
113#define PRESSURE20_REG_TEMP_DATA_2 0xFF
131#define PRESSURE20_TRIM1_MSB_PEFE_OFFSET_MASK 0x3F
132#define PRESSURE20_TRIM2_LSB_HFOSC_MASK 0x7F
133#define PRESSURE20_TRIM2_MSB_PEFE_GAIN_MASK 0x70
134#define PRESSURE20_TRIM2_MSB_BG_PTAT_MASK 0x0F
140#define PRESSURE20_OTP_ADDRESS_OFFSET 0xF8
141#define PRESSURE20_OTP_ADDRESS_GAIN 0xF9
142#define PRESSURE20_OTP_ADDRESS_HFOSC 0xFA
143#define PRESSURE20_OTP_COMMAND_READ_ACTION 0x10
149#define PRESSURE20_OTP_MRA_LSB 0x04
150#define PRESSURE20_OTP_MRA_MSB 0x04
151#define PRESSURE20_OTP_MRB_LSB 0x21
152#define PRESSURE20_OTP_MRB_MSB 0x20
153#define PRESSURE20_OTP_MR_LSB 0x10
154#define PRESSURE20_OTP_MR_MSB 0x80
160#define PRESSURE20_OTP_WRITE_SWITCH 0x02
161#define PRESSURE20_OTP_ENABLE 0x01
162#define PRESSURE20_OTP_DISABLE 0x00
168#define PRESSURE20_OTP_RESET_SET 0x80
169#define PRESSURE20_OTP_RESET_CLEAR 0x00
175#define PRESSURE20_BUSY 0x01
181#define PRESSURE20_BOOT_UP_STATUS 0x01
187#define PRESSURE20_MASTER_LOCK 0x00
188#define PRESSURE20_MASTER_UNLOCK 0x1F
194#define PRESSURE20_MEAS_CONFIG_MODE0_ODR_25HZ 0x00
195#define PRESSURE20_MEAS_CONFIG_MODE1_ODR_120HZ 0x20
196#define PRESSURE20_MEAS_CONFIG_MODE2_ODR_40HZ 0x40
197#define PRESSURE20_MEAS_CONFIG_MODE3_ODR_2HZ 0x60
198#define PRESSURE20_MEAS_CONFIG_MODE4 0x80
199#define PRESSURE20_FORCED_MEAS_TRIGGER 0x10
200#define PRESSURE20_MEAS_MODE_TRIGGER 0x00
201#define PRESSURE20_MEAS_MODE_CONTINUOUS 0x08
202#define PRESSURE20_POWER_MODE_NORMAL 0x00
203#define PRESSURE20_POWER_MODE_ACTIVE 0x04
204#define PRESSURE20_FIFO_READOUT_MODE_PRESS_1ST 0x00
205#define PRESSURE20_FIFO_READOUT_MODE_TEMP_ONLY 0x01
206#define PRESSURE20_FIFO_READOUT_MODE_TEMP_1ST 0x02
207#define PRESSURE20_FIFO_READOUT_MODE_PRESS_ONLY 0x03
213#define PRESSURE20_MODE_SYNC_STATUS 0x01
219#define PRESSURE20_FIFO_FLUSH 0x80
220#define PRESSURE20_FIFO_EMPTY 0x40
221#define PRESSURE20_FIFO_FULL 0x20
222#define PRESSURE20_FIFO_LEVEL_EMPTY 0x00
223#define PRESSURE20_FIFO_LEVEL_1 0x01
224#define PRESSURE20_FIFO_LEVEL_2 0x02
225#define PRESSURE20_FIFO_LEVEL_3 0x03
226#define PRESSURE20_FIFO_LEVEL_4 0x04
227#define PRESSURE20_FIFO_LEVEL_5 0x05
228#define PRESSURE20_FIFO_LEVEL_6 0x06
229#define PRESSURE20_FIFO_LEVEL_7 0x07
230#define PRESSURE20_FIFO_LEVEL_8 0x08
231#define PRESSURE20_FIFO_LEVEL_9 0x09
232#define PRESSURE20_FIFO_LEVEL_10 0x0A
233#define PRESSURE20_FIFO_LEVEL_11 0x0B
234#define PRESSURE20_FIFO_LEVEL_12 0x0C
235#define PRESSURE20_FIFO_LEVEL_13 0x0D
236#define PRESSURE20_FIFO_LEVEL_14 0x0E
237#define PRESSURE20_FIFO_LEVEL_15 0x0F
238#define PRESSURE20_FIFO_LEVEL_FULL 0x10
244#define PRESSURE20_INT_STAT_PRESS_DELTA 0x40
245#define PRESSURE20_INT_STAT_PRESS_ABS 0x20
246#define PRESSURE20_INT_STAT_FIFO_WMK_LOW 0x08
247#define PRESSURE20_INT_STAT_FIFO_WMK_HIGH 0x04
248#define PRESSURE20_INT_STAT_FIFO_UNDERFLOW 0x02
249#define PRESSURE20_INT_STAT_FIFO_OVERFLOW 0x01
255#define PRESSURE20_INT_MASK_RESERVED 0x80
256#define PRESSURE20_INT_MASK_PRESS_DELTA 0x40
257#define PRESSURE20_INT_MASK_PRESS_ABS 0x20
258#define PRESSURE20_INT_MASK_FIFO_WMK_LOW 0x08
259#define PRESSURE20_INT_MASK_FIFO_WMK_HIGH 0x04
260#define PRESSURE20_INT_MASK_FIFO_UNDERFLOW 0x02
261#define PRESSURE20_INT_MASK_FIFO_OVERFLOW 0x01
262#define PRESSURE20_INT_MASK_ALL 0xFF
268#define PRESSURE20_DEVICE_ID 0x63
274#define PRESSURE20_PRESSURE_RES_RAW 0x020000ul
275#define PRESSURE20_PRESSURE_RES_MBAR 400
276#define PRESSURE20_PRESSURE_OFFSET_MBAR 700
277#define PRESSURE20_TEMPERATURE_RES_RAW 0x040000ul
278#define PRESSURE20_TEMPERATURE_RES_C 65
279#define PRESSURE20_TEMPERATURE_OFFSET_C 25
285#define PRESSURE20_SPI_READ_REG 0x3C
286#define PRESSURE20_SPI_WRITE_REG 0x33
293#define PRESSURE20_DEVICE_ADDRESS_0 0x63
294#define PRESSURE20_DEVICE_ADDRESS_1 0x64
304#define PRESSURE20_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
305#define PRESSURE20_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
323#define PRESSURE20_MAP_MIKROBUS( cfg, mikrobus ) \
324 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
325 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
326 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
327 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
328 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
329 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
330 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t pressure20_generic_read(pressure20_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Pressure 20 data reading function.
err_t pressure20_init(pressure20_t *ctx, pressure20_cfg_t *cfg)
Pressure 20 initialization function.
err_t pressure20_generic_write(pressure20_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Pressure 20 data writing function.
err_t pressure20_read_otp_data(pressure20_t *ctx, uint8_t otp_address, uint8_t *data_out)
Pressure 20 read otp data function.
err_t pressure20_clear_interrupts(pressure20_t *ctx)
Pressure 20 clear interrupts function.
void pressure20_cfg_setup(pressure20_cfg_t *cfg)
Pressure 20 configuration object setup function.
uint8_t pressure20_get_int_pin(pressure20_t *ctx)
Pressure 20 get int pin function.
void pressure20_drv_interface_selection(pressure20_cfg_t *cfg, pressure20_drv_t drv_sel)
Pressure 20 driver interface setup function.
err_t pressure20_write_mode_select(pressure20_t *ctx, uint8_t mode_select)
Pressure 20 write mode select function.
err_t pressure20_default_cfg(pressure20_t *ctx)
Pressure 20 default configuration function.
err_t pressure20_read_register(pressure20_t *ctx, uint8_t reg, uint8_t *data_out)
Pressure 20 read register function.
err_t pressure20_check_communication(pressure20_t *ctx)
Pressure 20 check communication function.
err_t pressure20_write_register(pressure20_t *ctx, uint8_t reg, uint8_t data_in)
Pressure 20 write register function.
err_t pressure20_read_data(pressure20_t *ctx, float *pressure, float *temperature)
Pressure 20 read data function.
pressure20_return_value_t
Pressure 20 Click return value data.
Definition pressure20.h:402
@ PRESSURE20_OK
Definition pressure20.h:403
@ PRESSURE20_ERROR
Definition pressure20.h:404
err_t(* pressure20_master_io_t)(struct pressure20_s *, uint8_t, uint8_t *, uint8_t)
Pressure 20 Click driver interface.
Definition pressure20.h:350
struct pressure20_s pressure20_t
Pressure 20 Click context object.
pressure20_drv_t
Pressure 20 Click driver selector.
Definition pressure20.h:340
@ PRESSURE20_DRV_SEL_I2C
Definition pressure20.h:342
@ PRESSURE20_DRV_SEL_SPI
Definition pressure20.h:341
This file contains SPI specific macros, functions, etc.
Pressure 20 Click configuration object.
Definition pressure20.h:377
pressure20_drv_t drv_sel
Definition pressure20.h:393
uint32_t i2c_speed
Definition pressure20.h:386
spi_master_chip_select_polarity_t cs_polarity
Definition pressure20.h:391
pin_name_t sck
Definition pressure20.h:382
spi_master_mode_t spi_mode
Definition pressure20.h:390
pin_name_t mosi
Definition pressure20.h:381
uint32_t spi_speed
Definition pressure20.h:389
pin_name_t scl
Definition pressure20.h:378
pin_name_t int_pin
Definition pressure20.h:384
pin_name_t miso
Definition pressure20.h:380
pin_name_t sda
Definition pressure20.h:379
pin_name_t cs
Definition pressure20.h:383
uint8_t i2c_address
Definition pressure20.h:387
Pressure 20 Click context object.
Definition pressure20.h:357
pressure20_drv_t drv_sel
Definition pressure20.h:365
spi_master_t spi
Definition pressure20.h:361
pressure20_master_io_t read_f
Definition pressure20.h:368
digital_in_t int_pin
Definition pressure20.h:358
i2c_master_t i2c
Definition pressure20.h:360
uint8_t slave_address
Definition pressure20.h:363
pressure20_master_io_t write_f
Definition pressure20.h:367
pin_name_t chip_select
Definition pressure20.h:364