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 PRESSURE21_REG_CHIP_ID 0x01
76#define PRESSURE21_REG_REV_ID 0x02
77#define PRESSURE21_REG_CHIP_STATUS 0x11
78#define PRESSURE21_REG_DRIVE_CONFIG 0x13
79#define PRESSURE21_REG_INT_CONFIG 0x14
80#define PRESSURE21_REG_INT_SOURCE 0x15
81#define PRESSURE21_REG_FIFO_CONFIG 0x16
82#define PRESSURE21_REG_FIFO_COUNT 0x17
83#define PRESSURE21_REG_FIFO_SEL 0x18
84#define PRESSURE21_REG_TEMP_DATA_XLSB 0x1D
85#define PRESSURE21_REG_TEMP_DATA_LSB 0x1E
86#define PRESSURE21_REG_TEMP_DATA_MSB 0x1F
87#define PRESSURE21_REG_PRESS_DATA_XLSB 0x20
88#define PRESSURE21_REG_PRESS_DATA_LSB 0x21
89#define PRESSURE21_REG_PRESS_DATA_MSB 0x22
90#define PRESSURE21_REG_INT_STATUS 0x27
91#define PRESSURE21_REG_STATUS 0x28
92#define PRESSURE21_REG_FIFO_DATA 0x29
93#define PRESSURE21_REG_NVM_ADDR 0x2B
94#define PRESSURE21_REG_NVM_DATA_LSB 0x2C
95#define PRESSURE21_REG_NVM_DATA_MSB 0x2D
96#define PRESSURE21_REG_DSP_CONFIG 0x30
97#define PRESSURE21_REG_DSP_IIR 0x31
98#define PRESSURE21_REG_OOR_THR_P_LSB 0x32
99#define PRESSURE21_REG_OOR_THR_P_MSB 0x33
100#define PRESSURE21_REG_OOR_RANGE 0x34
101#define PRESSURE21_REG_OOR_CONFIG 0x35
102#define PRESSURE21_REG_OSR_CONFIG 0x36
103#define PRESSURE21_REG_ODR_CONFIG 0x37
104#define PRESSURE21_REG_OSR_EFF 0x38
105#define PRESSURE21_REG_CMD 0x7E
123#define PRESSURE21_CHIP_ID 0x50
129#define PRESSURE21_PAD_INT_DRV_DEFAULT 0x30
130#define PRESSURE21_INT_ENABLE 0x08
131#define PRESSURE21_INT_DISABLE 0x00
132#define PRESSURE21_INT_OPEN_DRAIN 0x04
133#define PRESSURE21_INT_PUSH_PULL 0x00
134#define PRESSURE21_INT_ACTIVE_HIGH 0x02
135#define PRESSURE21_INT_ACTIVE_LOW 0x00
136#define PRESSURE21_INT_LATCHED 0x01
137#define PRESSURE21_INT_PULSED 0x00
143#define PRESSURE21_OOR_P_EN 0x08
144#define PRESSURE21_FIFO_THS_EN 0x04
145#define PRESSURE21_FIFO_FULL_EN 0x02
146#define PRESSURE21_DRDY_DATA_REG_EN 0x01
147#define PRESSURE21_DISABLE_INT 0x00
153#define PRESSURE21_INT_STAT_POR 0x10
154#define PRESSURE21_INT_STAT_OOR_P 0x08
155#define PRESSURE21_INT_STAT_FIFO_THS 0x04
156#define PRESSURE21_INT_STAT_FIFO_FULL 0x02
157#define PRESSURE21_INT_STAT_DRDY_DATA_REG 0x01
163#define PRESSURE21_OOR_SEL_IIR_P 0x80
164#define PRESSURE21_FIFO_SEL_IIR_P 0x40
165#define PRESSURE21_SHDW_SEL_IIR_P 0x20
166#define PRESSURE21_FIFO_SEL_IIR_T 0x10
167#define PRESSURE21_SHDW_SEL_IIR_T 0x08
168#define PRESSURE21_IIR_FLUSH_FORCED_EN 0x04
169#define PRESSURE21_DSP_CFG_RESERVED_BITS 0x03
175#define PRESSURE21_SET_IIR_P_BYPASS 0x00
176#define PRESSURE21_SET_IIR_P_FLT_COEF_1 0x08
177#define PRESSURE21_SET_IIR_P_FLT_COEF_3 0x10
178#define PRESSURE21_SET_IIR_P_FLT_COEF_7 0x18
179#define PRESSURE21_SET_IIR_P_FLT_COEF_15 0x20
180#define PRESSURE21_SET_IIR_P_FLT_COEF_31 0x28
181#define PRESSURE21_SET_IIR_P_FLT_COEF_63 0x30
182#define PRESSURE21_SET_IIR_P_FLT_COEF_127 0x38
183#define PRESSURE21_SET_IIR_T_BYPASS 0x00
184#define PRESSURE21_SET_IIR_T_FLT_COEF_1 0x01
185#define PRESSURE21_SET_IIR_T_FLT_COEF_3 0x02
186#define PRESSURE21_SET_IIR_T_FLT_COEF_7 0x03
187#define PRESSURE21_SET_IIR_T_FLT_COEF_15 0x04
188#define PRESSURE21_SET_IIR_T_FLT_COEF_31 0x05
189#define PRESSURE21_SET_IIR_T_FLT_COEF_63 0x06
190#define PRESSURE21_SET_IIR_T_FLT_COEF_127 0x07
196#define PRESSURE21_PRESS_EN 0x40
197#define PRESSURE21_OSR_P_1X 0x00
198#define PRESSURE21_OSR_P_2X 0x08
199#define PRESSURE21_OSR_P_4X 0x10
200#define PRESSURE21_OSR_P_8X 0x18
201#define PRESSURE21_OSR_P_16X 0x20
202#define PRESSURE21_OSR_P_32X 0x28
203#define PRESSURE21_OSR_P_64X 0x30
204#define PRESSURE21_OSR_P_128X 0x38
205#define PRESSURE21_OSR_T_1X 0x00
206#define PRESSURE21_OSR_T_2X 0x01
207#define PRESSURE21_OSR_T_4X 0x02
208#define PRESSURE21_OSR_T_8X 0x03
209#define PRESSURE21_OSR_T_16X 0x04
210#define PRESSURE21_OSR_T_32X 0x05
211#define PRESSURE21_OSR_T_64X 0x06
212#define PRESSURE21_OSR_T_128X 0x07
218#define PRESSURE21_DEEP_DIS 0x80
219#define PRESSURE21_ODR_240_HZ 0x00
220#define PRESSURE21_ODR_218p537_HZ 0x04
221#define PRESSURE21_ODR_199p111_HZ 0x08
222#define PRESSURE21_ODR_179p2_HZ 0x0C
223#define PRESSURE21_ODR_160_HZ 0x10
224#define PRESSURE21_ODR_149p333_HZ 0x14
225#define PRESSURE21_ODR_140_HZ 0x18
226#define PRESSURE21_ODR_129p855_HZ 0x1C
227#define PRESSURE21_ODR_120_HZ 0x20
228#define PRESSURE21_ODR_110p164_HZ 0x24
229#define PRESSURE21_ODR_100p299_HZ 0x28
230#define PRESSURE21_ODR_89p6_HZ 0x2C
231#define PRESSURE21_ODR_80_HZ 0x30
232#define PRESSURE21_ODR_70_HZ 0x34
233#define PRESSURE21_ODR_60_HZ 0x38
234#define PRESSURE21_ODR_50p056_HZ 0x3C
235#define PRESSURE21_ODR_45p025_HZ 0x40
236#define PRESSURE21_ODR_40_HZ 0x44
237#define PRESSURE21_ODR_35_HZ 0x48
238#define PRESSURE21_ODR_30_HZ 0x4C
239#define PRESSURE21_ODR_25p005_HZ 0x50
240#define PRESSURE21_ODR_20_HZ 0x54
241#define PRESSURE21_ODR_15_HZ 0x58
242#define PRESSURE21_ODR_10_HZ 0x5C
243#define PRESSURE21_ODR_5_HZ 0x60
244#define PRESSURE21_ODR_4_HZ 0x64
245#define PRESSURE21_ODR_3_HZ 0x68
246#define PRESSURE21_ODR_2_HZ 0x6C
247#define PRESSURE21_ODR_1_HZ 0x70
248#define PRESSURE21_ODR_0p5_HZ 0x74
249#define PRESSURE21_ODR_0p25_HZ 0x78
250#define PRESSURE21_ODR_0p125_HZ 0x7C
251#define PRESSURE21_PWR_MODE_STANDBY 0x00
252#define PRESSURE21_PWR_MODE_NORMAL 0x01
253#define PRESSURE21_PWR_MODE_FORCE 0x02
254#define PRESSURE21_PWR_MODE_NON_STOP 0x03
260#define PRESSURE21_PRESS_RESOLUTION 64.0
261#define PRESSURE21_TEMP_RESOLUTION 65536.0
262#define PRESSURE21_PA_TO_MBAR 0.01
269#define PRESSURE21_DEVICE_ADDRESS_0 0x46
270#define PRESSURE21_DEVICE_ADDRESS_1 0x47
280#define PRESSURE21_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
281#define PRESSURE21_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
299#define PRESSURE21_MAP_MIKROBUS( cfg, mikrobus ) \
300 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
301 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
302 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
303 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
304 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
305 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
306 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t pressure21_get_sensor_data(pressure21_t *ctx, float *pressure, float *temperature)
Pressure 21 get sensor data function.
void pressure21_drv_interface_selection(pressure21_cfg_t *cfg, pressure21_drv_t drv_sel)
Pressure 21 driver interface setup function.
err_t pressure21_write_register(pressure21_t *ctx, uint8_t reg, uint8_t data_in)
Pressure 21 write register function.
err_t pressure21_init(pressure21_t *ctx, pressure21_cfg_t *cfg)
Pressure 21 initialization function.
void pressure21_cfg_setup(pressure21_cfg_t *cfg)
Pressure 21 configuration object setup function.
err_t pressure21_check_communication(pressure21_t *ctx)
Pressure 21 check communication function.
err_t pressure21_default_cfg(pressure21_t *ctx)
Pressure 21 default configuration function.
err_t pressure21_generic_read(pressure21_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Pressure 21 data reading function.
err_t pressure21_generic_write(pressure21_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Pressure 21 data writing function.
uint8_t pressure21_get_int_pin(pressure21_t *ctx)
Pressure 21 get int pin function.
err_t pressure21_read_register(pressure21_t *ctx, uint8_t reg, uint8_t *data_out)
Pressure 21 read register function.
err_t(* pressure21_master_io_t)(struct pressure21_s *, uint8_t, uint8_t *, uint8_t)
Pressure 21 Click driver interface.
Definition pressure21.h:326
pressure21_return_value_t
Pressure 21 Click return value data.
Definition pressure21.h:378
@ PRESSURE21_OK
Definition pressure21.h:379
@ PRESSURE21_ERROR
Definition pressure21.h:380
struct pressure21_s pressure21_t
Pressure 21 Click context object.
pressure21_drv_t
Pressure 21 Click driver selector.
Definition pressure21.h:316
@ PRESSURE21_DRV_SEL_SPI
Definition pressure21.h:317
@ PRESSURE21_DRV_SEL_I2C
Definition pressure21.h:318
This file contains SPI specific macros, functions, etc.
Pressure 21 Click configuration object.
Definition pressure21.h:353
uint32_t i2c_speed
Definition pressure21.h:362
pressure21_drv_t drv_sel
Definition pressure21.h:369
spi_master_chip_select_polarity_t cs_polarity
Definition pressure21.h:367
pin_name_t sck
Definition pressure21.h:358
spi_master_mode_t spi_mode
Definition pressure21.h:366
pin_name_t mosi
Definition pressure21.h:357
uint32_t spi_speed
Definition pressure21.h:365
pin_name_t scl
Definition pressure21.h:354
pin_name_t int_pin
Definition pressure21.h:360
pin_name_t miso
Definition pressure21.h:356
pin_name_t sda
Definition pressure21.h:355
pin_name_t cs
Definition pressure21.h:359
uint8_t i2c_address
Definition pressure21.h:363
Pressure 21 Click context object.
Definition pressure21.h:333
pressure21_master_io_t read_f
Definition pressure21.h:344
spi_master_t spi
Definition pressure21.h:337
pressure21_drv_t drv_sel
Definition pressure21.h:341
pressure21_master_io_t write_f
Definition pressure21.h:343
digital_in_t int_pin
Definition pressure21.h:334
i2c_master_t i2c
Definition pressure21.h:336
uint8_t slave_address
Definition pressure21.h:339
pin_name_t chip_select
Definition pressure21.h:340