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 AIRQUALITY9_REG_PART_ID 0x00
76#define AIRQUALITY9_REG_OPMODE 0x10
77#define AIRQUALITY9_REG_CONFIG 0x11
78#define AIRQUALITY9_REG_COMMAND 0x12
79#define AIRQUALITY9_REG_TEMP_IN 0x13
80#define AIRQUALITY9_REG_RH_IN 0x15
81#define AIRQUALITY9_REG_DATA_STATUS 0x20
82#define AIRQUALITY9_REG_DATA_AQI 0x21
83#define AIRQUALITY9_REG_DATA_TVOC 0x22
84#define AIRQUALITY9_REG_DATA_ECO2 0x24
85#define AIRQUALITY9_REG_DATA_T 0x30
86#define AIRQUALITY9_REG_DATA_RH 0x32
87#define AIRQUALITY9_REG_DATA_MISR 0x38
88#define AIRQUALITY9_REG_GPR_WRITE 0x40
89#define AIRQUALITY9_REG_GPR_READ 0x48
107#define AIRQUALITY9_OPMODE_DEEP_SLEEP 0x00
108#define AIRQUALITY9_OPMODE_IDLE 0x01
109#define AIRQUALITY9_OPMODE_STANDARD 0x02
110#define AIRQUALITY9_OPMODE_RESET 0xF0
116#define AIRQUALITY_CONFIG_INTPOL_LOW 0x00
117#define AIRQUALITY_CONFIG_INTPOL_HIGH 0x40
118#define AIRQUALITY_CONFIG_INTCFG_OPEN_DRAIN 0x00
119#define AIRQUALITY_CONFIG_INTCFG_PUSH_PULL 0x20
120#define AIRQUALITY_CONFIG_INTGPR_BIT 0x08
121#define AIRQUALITY_CONFIG_INTDAT_BIT 0x02
122#define AIRQUALITY_CONFIG_INTEN_BIT 0x01
128#define AIRQUALITY_STATUS_OPMODE_RUNNING 0x80
129#define AIRQUALITY_STATUS_ERROR_DETECTED 0x40
130#define AIRQUALITY_STATUS_VALID_NORMAL_OP 0x00
131#define AIRQUALITY_STATUS_VALID_WARM_UP 0x04
132#define AIRQUALITY_STATUS_VALID_INIT_START_UP 0x08
133#define AIRQUALITY_STATUS_VALID_INVALID 0x0C
134#define AIRQUALITY_STATUS_VALID_FLAG_BITS 0x0C
135#define AIRQUALITY_STATUS_NEW_DATA 0x02
136#define AIRQUALITY_STATUS_NEW_GPR 0x01
142#define AIRQUALITY9_PART_ID_LSB 0x60
143#define AIRQUALITY9_PART_ID_MSB 0x01
149#define AIRQUALITY9_AQI_UBA_EXELLENT 1
150#define AIRQUALITY9_AQI_UBA_GOOD 2
151#define AIRQUALITY9_AQI_UBA_MODERATE 3
152#define AIRQUALITY9_AQI_UBA_POOR 4
153#define AIRQUALITY9_AQI_UBA_UNHEALTHY 5
160#define AIRQUALITY9_DEVICE_ADDRESS_0 0x52
161#define AIRQUALITY9_DEVICE_ADDRESS_1 0x53
171#define AIRQUALITY9_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
172#define AIRQUALITY9_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
190#define AIRQUALITY9_MAP_MIKROBUS( cfg, mikrobus ) \
191 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
192 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
193 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
194 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
195 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
196 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
197 cfg.en = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
198 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
struct airquality9_s airquality9_t
Air Quality 9 Click context object.
airquality9_return_value_t
Air Quality 9 Click return value data.
Definition airquality9.h:273
@ AIRQUALITY9_ERROR
Definition airquality9.h:275
@ AIRQUALITY9_OK
Definition airquality9.h:274
err_t(* airquality9_master_io_t)(struct airquality9_s *, uint8_t, uint8_t *, uint8_t)
Air Quality 9 Click driver interface.
Definition airquality9.h:218
airquality9_drv_t
Air Quality 9 Click driver selector.
Definition airquality9.h:208
@ AIRQUALITY9_DRV_SEL_SPI
Definition airquality9.h:209
@ AIRQUALITY9_DRV_SEL_I2C
Definition airquality9.h:210
err_t airquality9_init(airquality9_t *ctx, airquality9_cfg_t *cfg)
Air Quality 9 initialization function.
err_t airquality9_generic_write(airquality9_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Air Quality 9 data writing function.
err_t airquality9_read_tvoc(airquality9_t *ctx, uint16_t *tvoc)
Air Quality 9 read tvoc function.
err_t airquality9_set_operating_mode(airquality9_t *ctx, uint8_t opmode)
Air Quality 9 set operating mode function.
void airquality9_enable_device(airquality9_t *ctx)
Air Quality 9 enable device function.
err_t airquality9_read_status(airquality9_t *ctx, uint8_t *status)
Air Quality 9 read status function.
err_t airquality9_read_eco2(airquality9_t *ctx, uint16_t *eco2)
Air Quality 9 read eco2 function.
void airquality9_cfg_setup(airquality9_cfg_t *cfg)
Air Quality 9 configuration object setup function.
err_t airquality9_read_aqi_uba(airquality9_t *ctx, uint8_t *aqi_uba)
Air Quality 9 read aqi uba function.
err_t airquality9_set_interrupt_config(airquality9_t *ctx, uint8_t int_cfg)
Air Quality 9 set interrupt config function.
void airquality9_disable_device(airquality9_t *ctx)
Air Quality 9 disable device function.
err_t airquality9_default_cfg(airquality9_t *ctx)
Air Quality 9 default configuration function.
err_t airquality9_check_communication(airquality9_t *ctx)
Air Quality 9 check communication function.
err_t airquality9_generic_read(airquality9_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Air Quality 9 data reading function.
void airquality9_drv_interface_selection(airquality9_cfg_t *cfg, airquality9_drv_t drv_sel)
Air Quality 9 driver interface setup function.
uint8_t airquality9_get_int_pin(airquality9_t *ctx)
Air Quality 9 get int pin function.
This file contains SPI specific macros, functions, etc.
Air Quality 9 Click configuration object.
Definition airquality9.h:247
uint32_t i2c_speed
Definition airquality9.h:257
spi_master_chip_select_polarity_t cs_polarity
Definition airquality9.h:262
pin_name_t sck
Definition airquality9.h:252
airquality9_drv_t drv_sel
Definition airquality9.h:264
spi_master_mode_t spi_mode
Definition airquality9.h:261
pin_name_t mosi
Definition airquality9.h:251
uint32_t spi_speed
Definition airquality9.h:260
pin_name_t scl
Definition airquality9.h:248
pin_name_t en
Definition airquality9.h:254
pin_name_t int_pin
Definition airquality9.h:255
pin_name_t miso
Definition airquality9.h:250
pin_name_t sda
Definition airquality9.h:249
pin_name_t cs
Definition airquality9.h:253
uint8_t i2c_address
Definition airquality9.h:258
Air Quality 9 Click context object.
Definition airquality9.h:225
spi_master_t spi
Definition airquality9.h:231
airquality9_master_io_t write_f
Definition airquality9.h:237
airquality9_master_io_t read_f
Definition airquality9.h:238
airquality9_drv_t drv_sel
Definition airquality9.h:235
digital_in_t int_pin
Definition airquality9.h:228
i2c_master_t i2c
Definition airquality9.h:230
digital_out_t en
Definition airquality9.h:226
uint8_t slave_address
Definition airquality9.h:233
pin_name_t chip_select
Definition airquality9.h:234