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"
74#define AIRFLOW_I2C_CMD_RESET 0x11
75#define AIRFLOW_I2C_CMD_GET_SIG 0x23
76#define AIRFLOW_I2C_CMD_GET_DATA 0x26
77#define AIRFLOW_I2C_CMD_CONV 0x27
78#define AIRFLOW_I2C_CMD_GET_NON_BAR 0x50
79#define AIRFLOW_I2C_CMD_GET_NON_BLOCK_BAR 0x51
84#define AIRFLOW_SPI_CMD_NONE 0x00
85#define AIRFLOW_SPI_CMD_RESET 0x01
86#define AIRFLOW_SPI_CMD_CONV 0x04
87#define AIRFLOW_SPI_CMD_STOP 0x05
88#define AIRFLOW_SPI_CMD_GET_DATA 0x06
89#define AIRFLOW_SPI_CMD_GET_BAR 0x07
90#define AIRFLOW_SPI_CMD_GET_SIG 0x0C
108#define AIRFLOW_NO_BAROMETRIC_CORRECTION 0x01
109#define AIRFLOW_BAROMETRIC_CORRECTION 0x03
116#define AIRFLOW_SET_DEV_ADDR 0x5B
134#define AIRFLOW_MAP_MIKROBUS( cfg, mikrobus ) \
135 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
136 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
137 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
138 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
139 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
140 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
141 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
airflow_drv_t
Air Flow Click driver selector.
Definition airflow.h:151
@ AIRFLOW_DRV_SEL_I2C
Definition airflow.h:153
@ AIRFLOW_DRV_SEL_SPI
Definition airflow.h:152
err_t(* airflow_master_io_t)(struct airflow_s *, uint8_t, uint8_t *, uint8_t)
Air Flow Click driver interface.
Definition airflow.h:161
airflow_return_value_t
Air Flow Click return value data.
Definition airflow.h:225
@ AIRFLOW_OK
Definition airflow.h:226
@ AIRFLOW_ERROR
Definition airflow.h:227
struct airflow_s airflow_t
Air Flow Click context object.
void airflow_reset_device(airflow_t *ctx)
Reset device.
err_t airflow_get_status(airflow_t *ctx, uint8_t *status)
Reads status data.
err_t airflow_generic_write(airflow_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Air Flow data writing function.
err_t airflow_get_differential_pressure(airflow_t *ctx, float *pressure)
Reads differential pressure.
err_t airflow_default_cfg(airflow_t *ctx)
Air Flow default configuration function.
void airflow_drv_interface_selection(airflow_cfg_t *cfg, airflow_drv_t drv_sel)
Air Flow driver interface setup function.
err_t airflow_init(airflow_t *ctx, airflow_cfg_t *cfg)
Air Flow initialization function.
err_t airflow_get_atmospheric_pressure(airflow_t *ctx, float *pressure, float *temperature)
Reads atmospheric pressure and temperature.
uint8_t airflow_check_ready(airflow_t *ctx)
Reads ready pin state.
void airflow_cfg_setup(airflow_cfg_t *cfg)
Air Flow configuration object setup function.
err_t airflow_generic_read(airflow_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Air Flow data reading function.
Air Flow Click configuration object.
Definition airflow.h:200
uint32_t i2c_speed
Definition airflow.h:209
airflow_drv_t drv_sel
Definition airflow.h:216
spi_master_chip_select_polarity_t cs_polarity
Definition airflow.h:214
pin_name_t sck
Definition airflow.h:205
spi_master_mode_t spi_mode
Definition airflow.h:213
pin_name_t mosi
Definition airflow.h:204
uint32_t spi_speed
Definition airflow.h:212
pin_name_t scl
Definition airflow.h:201
pin_name_t rdy
Definition airflow.h:207
pin_name_t miso
Definition airflow.h:203
pin_name_t sda
Definition airflow.h:202
pin_name_t cs
Definition airflow.h:206
uint8_t i2c_address
Definition airflow.h:210
Air Flow Click context object.
Definition airflow.h:168
spi_master_t spi
Definition airflow.h:172
uint8_t major_fw_ver
Definition airflow.h:181
char output_type
Definition airflow.h:186
uint16_t pressure_range
Definition airflow.h:185
uint8_t minor_fw_ver
Definition airflow.h:182
uint8_t week
Definition airflow.h:189
airflow_drv_t drv_sel
Definition airflow.h:176
char lot_number[8]
Definition airflow.h:184
uint8_t year
Definition airflow.h:190
char calibration_id[3]
Definition airflow.h:188
char part_number[12]
Definition airflow.h:183
i2c_master_t i2c
Definition airflow.h:171
airflow_master_io_t write_f
Definition airflow.h:178
uint16_t scale_factor
Definition airflow.h:187
airflow_master_io_t read_f
Definition airflow.h:179
uint8_t slave_address
Definition airflow.h:174
uint16_t sequence_number
Definition airflow.h:191
pin_name_t chip_select
Definition airflow.h:175
digital_in_t rdy
Definition airflow.h:169