42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
66#define AIRQUALITY2_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
75#define AIRQUALITY2_RETVAL uint8_t
77#define AIRQUALITY2_OK 0x00
78#define AIRQUALITY2_INIT_ERROR 0xFF
85#define AIRQUALITY2_I2C_ADDRESS 0x5A
86#define AIRQUALITY2_START_READING 0xB5
93#define AIRQUALITY2_TYPE_C 0x00
94#define AIRQUALITY2_TYPE_P 0x01
95#define AIRQUALITY2_MEASUREMENT_INTERVAL_TYPE_C 1000
96#define AIRQUALITY2_MEASUREMENT_INTERVAL_TYPE_P 11000
103#define AIRQUALITY2_READ_CO2_AND_STATUS 3
104#define AIRQUALITY2_READ_ALL 9
111#define AIRQUALITY2_STATUS_OK 0x00
112#define AIRQUALITY2_STATUS_RUNIN 0x10
113#define AIRQUALITY2_STATUS_BUSY 0x01
114#define AIRQUALITY2_STATUS_ERROR 0x80
121#define AIRQUALITY2_STATUS_NOT_UPDATED_AT_ALL 0xf0
122#define AIRQUALITY2_STATUS_UPDATING 0xf1
123#define AIRQUALITY2_STATUS_I2C_REQ_FAILED 0xf2
130#define AIRQUALITY2_CO2_PREDICTION_MSB_OFFSET 0x00
131#define AIRQUALITY2_CO2_PREDICTION_LSB_OFFSET 0x01
132#define AIRQUALITY2_STATUS_OFFSET 0x02
133#define AIRQUALITY2_RESISTANCE_NULL_BYTE 0x03
134#define AIRQUALITY2_RESISTANCE_MSB_OFFSET 0x04
135#define AIRQUALITY2_RESISTANCE_MID_OFFSET 0x05
136#define AIRQUALITY2_RESISTANCE_LSB_OFFSET 0x06
137#define AIRQUALITY2_TVOC_PREDICTION_MSB_OFFSET 0x07
138#define AIRQUALITY2_TVOC_PREDICTION_LSB_OFFSET 0x08
#define AIRQUALITY2_RETVAL
Definition airquality2.h:75
void airquality2_generic_read(airquality2_t *ctx, uint8_t *data_buf, uint8_t len)
Generic read function.
void airquality2_cfg_setup(airquality2_cfg_t *cfg)
Config Object Initialization function.
uint8_t airquality2_get_all_data(airquality2_t *ctx, uint16_t *value_co2, uint16_t *value_tvoc, int32_t *resistance)
Read all data info function.
AIRQUALITY2_RETVAL airquality2_init(airquality2_t *ctx, airquality2_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition airquality2.h:167
uint32_t i2c_speed
Definition airquality2.h:175
pin_name_t scl
Definition airquality2.h:170
pin_name_t sda
Definition airquality2.h:171
uint8_t i2c_address
Definition airquality2.h:176
Click ctx object definition.
Definition airquality2.h:152
i2c_master_t i2c
Definition airquality2.h:155
uint8_t slave_address
Definition airquality2.h:159