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"
73#define PRESSURE22_CMD_ADC_READ 0x00
74#define PRESSURE22_CMD_RESET 0x1E
75#define PRESSURE22_CMD_PROM_VERSION 0xA0
76#define PRESSURE22_CMD_PROM_READ_C1 0xA2
77#define PRESSURE22_CMD_PROM_READ_C2 0xA4
78#define PRESSURE22_CMD_PROM_READ_C3 0xA6
79#define PRESSURE22_CMD_PROM_READ_C4 0xA8
80#define PRESSURE22_CMD_PROM_READ_C5 0xAA
81#define PRESSURE22_CMD_PROM_READ_C6 0xAC
82#define PRESSURE22_CMD_PROM_END 0xAE
100#define PRESSURE22_CRC4_BIT_MASK 0x000Fu
101#define PRESSURE22_VER_DEF_BIT_MASK 0x007Fu
102#define PRESSURE22_FCT_DEF_BIT_MASK 0x001Fu
108#define PRESSURE22_TEMPERATURE_20_C 40.0f
109#define PRESSURE22_TEMPERATURE_10_C 10.0f
110#define PRESSURE22_TEMP_TYPICAL 2000.0f
111#define PRESSURE22_TEMP_DIV 100.0f
112#define PRESSURE22_OFF_ACT_TEMP_MULTP 131072.0f
113#define PRESSURE22_OFF_ACT_TEMP_DIV 64.0f
114#define PRESSURE22_SENS_ACT_TEMP_MULTP 65536.0f
115#define PRESSURE22_SENS_ACT_TEMP_DIV 128.0f
116#define PRESSURE22_TEMP_COMP_PRESS_DIV 2097152.0f
117#define PRESSURE22_COMP_PRESS_DIV 32768.0f
118#define PRESSURE22_PRESS_CONVERT_PA_MBAR 100.0f
119#define PRESSURE22_SEC_COMP_TI_DIV 34359738368.0f
120#define PRESSURE22_SEC_COMP_TI_1_MULTP 14.0f
121#define PRESSURE22_SEC_COMP_OFFI_1_MULTP 35.0f
122#define PRESSURE22_SEC_COMP_SENS_MULTP 63.0f
123#define PRESSURE22_SEC_COMP_OFFI_1_DIV 8.0f
124#define PRESSURE22_SEC_COMP_TI_2_MULTP 12.0f
125#define PRESSURE22_SEC_COMP_OFFI_2_MULTP 30.0f
126#define PRESSURE22_SEC_COMP_OFFI_2_DIV 256.0f
127#define PRESSURE22_SEC_COMP_SENSI_DIV 32.0f
134#define PRESSURE22_DEVICE_ADDRESS 0x76
152#define PRESSURE22_MAP_MIKROBUS( cfg, mikrobus ) \
153 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
154 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
err_t pressure22_generic_write(pressure22_t *ctx, uint8_t cmd, uint8_t *data_in, uint8_t len)
Pressure 22 I2C writing function.
void pressure22_cfg_setup(pressure22_cfg_t *cfg)
Pressure 22 configuration object setup function.
err_t pressure22_generic_read(pressure22_t *ctx, uint8_t cmd, uint8_t *data_out, uint8_t len)
Pressure 22 I2C reading function.
err_t pressure22_get_adc_data(pressure22_t *ctx, uint32_t *adc)
Pressure 22 gets the ADC data function.
err_t pressure22_init(pressure22_t *ctx, pressure22_cfg_t *cfg)
Pressure 22 initialization function.
err_t pressure22_default_cfg(pressure22_t *ctx)
Pressure 22 default configuration function.
void pressure22_set_conversion(pressure22_t *ctx, pressure22_press_conv_t press_conv, pressure22_temp_conv_t temp_conv)
Pressure 22 set conversion function.
err_t pressure22_sw_reset(pressure22_t *ctx)
Pressure 22 sw reset function.
err_t pressure22_check_data_validity(pressure22_t *ctx)
Pressure 22 checks data validity function.
err_t pressure22_get_prom_data(pressure22_t *ctx, uint8_t cmd_prom, uint16_t *prom)
Pressure 22 gets the PROM data function.
err_t pressure22_get_measurement_data(pressure22_t *ctx, float *temperature, float *pressure)
Pressure 22 get the measurement data function.
err_t pressure22_get_calibration_data(pressure22_t *ctx)
Pressure 22 gets the calibration data function.
err_t pressure22_set_command(pressure22_t *ctx, uint8_t cmd)
Pressure 22 set the command function.
pressure22_press_conv_t
Pressure 22 Click pressure conversion value data.
Definition pressure22.h:164
@ PRESSURE22_CMD_PRESS_OSR_256
Definition pressure22.h:165
@ PRESSURE22_CMD_PRESS_OSR_1024
Definition pressure22.h:167
@ PRESSURE22_CMD_PRESS_OSR_512
Definition pressure22.h:166
@ PRESSURE22_CMD_PRESS_OSR_2048
Definition pressure22.h:168
@ PRESSURE22_CMD_PRESS_OSR_4096
Definition pressure22.h:169
@ PRESSURE22_CMD_PRESS_OSR_8192
Definition pressure22.h:170
pressure22_return_value_t
Pressure 22 Click return value data.
Definition pressure22.h:238
@ PRESSURE22_OK
Definition pressure22.h:239
@ PRESSURE22_ERROR
Definition pressure22.h:240
pressure22_temp_conv_t
Pressure 22 Click temperature conversion value data.
Definition pressure22.h:179
@ PRESSURE22_CMD_TEMP_OSR_4096
Definition pressure22.h:184
@ PRESSURE22_CMD_TEMP_OSR_512
Definition pressure22.h:181
@ PRESSURE22_CMD_TEMP_OSR_1024
Definition pressure22.h:182
@ PRESSURE22_CMD_TEMP_OSR_2048
Definition pressure22.h:183
@ PRESSURE22_CMD_TEMP_OSR_8192
Definition pressure22.h:185
@ PRESSURE22_CMD_TEMP_OSR_256
Definition pressure22.h:180
Pressure 22 Click configuration object.
Definition pressure22.h:224
uint32_t i2c_speed
Definition pressure22.h:228
pin_name_t scl
Definition pressure22.h:225
pin_name_t sda
Definition pressure22.h:226
uint8_t i2c_address
Definition pressure22.h:229
Pressure 22 Click context object.
Definition pressure22.h:194
uint16_t prom_c1
Definition pressure22.h:206
uint16_t prom_pt
Definition pressure22.h:202
uint16_t prom_c6
Definition pressure22.h:211
uint16_t prom_c3
Definition pressure22.h:208
uint16_t prom_c4
Definition pressure22.h:209
pressure22_temp_conv_t temp_conv
Definition pressure22.h:215
uint8_t prom_fct
Definition pressure22.h:205
i2c_master_t i2c
Definition pressure22.h:196
uint16_t prom_c2
Definition pressure22.h:207
uint16_t prom_c5
Definition pressure22.h:210
uint8_t slave_address
Definition pressure22.h:199
uint8_t prom_crc
Definition pressure22.h:203
uint8_t prom_ver
Definition pressure22.h:204
pressure22_press_conv_t press_conv
Definition pressure22.h:214