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 AIRQUALITY3_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
70 cfg.wke = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
78#define AIRQUALITY3_RETVAL uint8_t
80#define AIRQUALITY3_OK 0x00
81#define AIRQUALITY3_INIT_ERROR 0xFF
88#define AIRQUALITY3_REG_ID 0x20
89#define AIRQUALITY3_REG_ERROR_ID 0xE0
90#define AIRQUALITY3_REG_STATUS 0x00
91#define AIRQUALITY3_REG_HW_VERSION 0x21
92#define AIRQUALITY3_REG_FW_BOOT_VERSION 0x23
93#define AIRQUALITY3_REG_FW_APP_VERSION 0x24
94#define AIRQUALITY3_REG_SW_RESET 0xFF
95#define AIRQUALITY3_REG_ALG_DATA 0x02
96#define AIRQUALITY3_REG_RAW_DATA 0x03
97#define AIRQUALITY3_REG_ENV_DATA 0x05
98#define AIRQUALITY3_REG_NTC 0x06
99#define AIRQUALITY3_REG_MEAS_MODE 0x01
100#define AIRQUALITY3_REG_BASELINE 0x11
107#define AIRQUALITY3_DRIVE_MODE_0 ( 0x00 << 4 )
108#define AIRQUALITY3_DRIVE_MODE_1 ( 0x01 << 4 )
109#define AIRQUALITY3_DRIVE_MODE_2 ( 0x02 << 4 )
110#define AIRQUALITY3_DRIVE_MODE_3 ( 0x03 << 4 )
111#define AIRQUALITY3_DRIVE_MODE_4 ( 0x04 << 4 )
112#define AIRQUALITY3_INT_DATARDY_0 ( 0x00 << 3 )
113#define AIRQUALITY3_INT_DATARDY_1 ( 0x01 << 3 )
114#define AIRQUALITY3_INT_THRESH_0 ( 0x00 << 2 )
115#define AIRQUALITY3_INT_THRESH_1 ( 0x01 << 2 )
122#define AIRQUALITY3_APP_START 0xF4
123#define AIRQUALITY3_APP_VERIFY 0xF3
124#define AIRQUALITY3_APP_DATA 0xF2
125#define AIRQUALITY3_APP_ERASE 0xF1
132#define AIRQUALITY3_DEVICE_SLAVE_ADDRESS 0x5A
139#define AIRQUALITY3_POWER_STATE_ON 0
140#define AIRQUALITY3_POWER_STATE_OFF 1
#define AIRQUALITY3_RETVAL
Definition airquality3.h:78
void airquality3_get_device_info(airquality3_t *ctx, airguality3_info_t *info)
Get device info.
uint8_t airquality3_get_starus(airquality3_t *ctx)
Reads status.
uint8_t airquality3_get_co2_and_tvoc(airquality3_t *ctx, airquality3_air_data_t *air_data)
Get CO2 and TVOC data.
void airquality3_app_function(airquality3_t *ctx, uint8_t app_task)
function to start APP task
void airquality3_set_environment_data(airquality3_t *ctx, uint32_t env_data)
Temperature and humidity data settings.
void airquality3_software_reset(airquality3_t *ctx, uint32_t reset)
Software reset.
void airquality3_hardware_reset(airquality3_t *ctx)
Hardware reset.
void airquality3_default_cfg(airquality3_t *ctx)
Click Default Configuration function.
uint8_t airquality3_get_interrupt_state(airquality3_t *ctx)
Get interrupt state.
void airquality3_get_ntc_data(airquality3_t *ctx, uint8_t *data_buf)
Get NTC value.
void airquality3_set_measurement_mode(airquality3_t *ctx, uint8_t mode)
Function for settings sensor drive mode and interrupts.
AIRQUALITY3_RETVAL airquality3_init(airquality3_t *ctx, airquality3_cfg_t *cfg)
Initialization function.
void airquality3_get_raw_data(airquality3_t *ctx, uint16_t *raw_data)
Function reads raw ADC data values for resistance and current source used.
void airquality3_set_baseline(airquality3_t *ctx, uint16_t baseline)
Function for settings baseline value.
void airquality3_generic_write(airquality3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void airquality3_generic_read(airquality3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void airquality3_cfg_setup(airquality3_cfg_t *cfg)
Config Object Initialization function.
void airquality3_set_power(airquality3_t *ctx, uint16_t pwr_state)
Function for power ON/OFF chip.
Info structure definition.
Definition airquality3.h:201
uint8_t fw_app_ver
Definition airquality3.h:205
uint8_t hw_ver
Definition airquality3.h:203
uint8_t fw_boot_ver
Definition airquality3.h:204
uint8_t device_id
Definition airquality3.h:202
Air data structure definition.
Definition airquality3.h:213
uint16_t tvoc
Definition airquality3.h:215
uint8_t m_status
Definition airquality3.h:217
uint16_t raw_data
Definition airquality3.h:216
uint16_t co2
Definition airquality3.h:214
Click configuration structure definition.
Definition airquality3.h:178
uint32_t i2c_speed
Definition airquality3.h:192
pin_name_t wke
Definition airquality3.h:187
pin_name_t scl
Definition airquality3.h:181
pin_name_t int_pin
Definition airquality3.h:188
pin_name_t sda
Definition airquality3.h:182
pin_name_t rst
Definition airquality3.h:186
uint8_t i2c_address
Definition airquality3.h:193
Click ctx object definition.
Definition airquality3.h:154
digital_in_t int_pin
Definition airquality3.h:162
i2c_master_t i2c
Definition airquality3.h:166
digital_out_t wke
Definition airquality3.h:158
digital_out_t rst
Definition airquality3.h:157
uint8_t slave_address
Definition airquality3.h:170