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"
74#define CO23_REG_PROD_ID 0x00
75#define CO23_REG_SENS_STS 0x01
76#define CO23_REG_MEAS_RATE_H 0x02
77#define CO23_REG_MEAS_RATE_L 0x03
78#define CO23_REG_MEAS_CFG 0x04
79#define CO23_REG_CO2PPM_H 0x05
80#define CO23_REG_CO2PPM_L 0x06
81#define CO23_REG_MEAS_STS 0x07
82#define CO23_REG_INT_CFG 0x08
83#define CO23_REG_ALARM_TH_H 0x09
84#define CO23_REG_ALARM_TH_L 0x0A
85#define CO23_REG_PRESS_REF_H 0x0B
86#define CO23_REG_PRESS_REF_L 0x0C
87#define CO23_REG_CALIB_REF_H 0x0D
88#define CO23_REG_CALIB_REF_L 0x0E
89#define CO23_REG_SCRATCH_PAD 0x0F
90#define CO23_REG_SENS_RST 0x10
108#define CO23_OP_MODE_IDLE 0x00
109#define CO23_OP_MODE_SINGLE 0x01
110#define CO23_OP_MODE_CONTINUOUS 0x02
111#define CO23_OP_BOC_CFG_DISABLE 0x00
112#define CO23_OP_BOC_CFG_AUTOMATIC 0x01
113#define CO23_OP_BOC_CFG_FORCED 0x02
114#define CO23_PWM_MODE_SINGLE_PULSE 0x00
115#define CO23_PWM_MODE_TRAIN_PULSE 0x01
122#define CO23_TX_DRV_BUFFER_SIZE 100
123#define CO23_RX_DRV_BUFFER_SIZE 300
130#define CO23_DEVICE_ADDRESS 0x28
148#define CO23_MAP_MIKROBUS( cfg, mikrobus ) \
149 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
150 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
151 cfg.pwo = MIKROBUS( mikrobus, MIKROBUS_AN ); \
152 cfg.pws = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
153 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
154 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
155 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
co23_soft_reset_value_t
CO2 3 Click soft reset command value data.
Definition co23.h:299
@ CO23_CMD_SOFT_RESET
Definition co23.h:300
@ CO23_CMD_RESET_FCS
Definition co23.h:304
@ CO23_CMD_SAVE_FCS_CALIB_OFFSET
Definition co23.h:303
@ CO23_CMD_RESET_ABOC
Definition co23.h:301
@ CO23_CMD_STEPWISE_FILTER_DIS
Definition co23.h:302
@ CO23_CMD_STEPWISE_FILTER_EN
Definition co23.h:305
err_t(* co23_master_io_t)(struct co23_s *, uint8_t, uint8_t *, uint8_t)
CO2 3 Click driver interface.
Definition co23.h:175
co23_return_value_t
CO2 3 Click return value data.
Definition co23.h:314
@ CO23_ERROR
Definition co23.h:316
@ CO23_OK
Definition co23.h:315
struct co23_s co23_t
CO2 3 Click context object.
co23_drv_t
CO2 3 Click driver selector.
Definition co23.h:165
@ CO23_DRV_SEL_UART
Definition co23.h:167
@ CO23_DRV_SEL_I2C
Definition co23.h:166
#define CO23_RX_DRV_BUFFER_SIZE
Definition co23.h:123
#define CO23_TX_DRV_BUFFER_SIZE
CO2 3 driver buffer size.
Definition co23.h:122
uint8_t co23_get_pwo_pin(co23_t *ctx)
CO2 3 get PWM output function.
err_t co23_get_meas_status(co23_t *ctx, co23_meas_status_t *meas_status)
CO2 3 get measurement status function.
err_t co23_get_co2_ppm(co23_t *ctx, uint16_t *co2_ppm)
CO2 3 get CO2 concentration function.
err_t co23_generic_write(co23_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
CO2 3 I2C writing function.
err_t co23_get_device_id(co23_t *ctx, uint8_t *prod, uint8_t *rev)
CO2 3 get device ID function.
err_t co23_get_int_cfg(co23_t *ctx, co23_int_cfg_t *int_cfg)
CO2 3 get interrupt pin configuration function.
void co23_drv_interface_selection(co23_cfg_t *cfg, co23_drv_t drv_sel)
CO2 3 driver interface setup function.
err_t co23_soft_reset_trigger(co23_t *ctx, co23_soft_reset_value_t reset_cmd)
CO2 3 soft reset trigger function.
err_t co23_set_meas_cfg(co23_t *ctx, co23_meas_cfg_t meas_cfg)
CO2 3 set measurement configuration function.
err_t co23_set_alarm_threshold(co23_t *ctx, uint16_t alarm_th_ppm)
CO2 3 set alarm threshold function.
err_t co23_generic_read(co23_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
CO2 3 I2C reading function.
err_t co23_set_calib_ref(co23_t *ctx, uint16_t calib_ppm)
CO2 3 set calibration function.
err_t co23_default_cfg(co23_t *ctx)
CO2 3 default configuration function.
void co23_cfg_setup(co23_cfg_t *cfg)
CO2 3 configuration object setup function.
uint8_t co23_get_int_pin(co23_t *ctx)
CO2 3 get interrupt function.
err_t co23_set_pressure_ref(co23_t *ctx, uint16_t pressure_mbar)
CO2 3 set alarm threshold function.
err_t co23_set_int_cfg(co23_t *ctx, co23_int_cfg_t int_cfg)
CO2 3 set interrupt pin configuration function.
err_t co23_set_meas_rate(co23_t *ctx, uint16_t meas_rate_sec)
CO2 3 set measurement rate function.
err_t co23_init(co23_t *ctx, co23_cfg_t *cfg)
CO2 3 initialization function.
err_t co23_get_sens_status(co23_t *ctx, co23_sens_status_t *sens_status)
CO2 3 get sensor status function.
err_t co23_get_meas_cfg(co23_t *ctx, co23_meas_cfg_t *meas_cfg)
CO2 3 get measurement configuration function.
CO2 3 Click configuration object.
Definition co23.h:212
uint32_t baud_rate
Definition co23.h:225
pin_name_t pws
Definition co23.h:221
co23_drv_t drv_sel
Definition co23.h:234
uint32_t i2c_speed
Definition co23.h:231
bool uart_blocking
Definition co23.h:226
uart_data_bits_t data_bit
Definition co23.h:227
pin_name_t tx_pin
Definition co23.h:215
pin_name_t pwo
Definition co23.h:220
pin_name_t rx_pin
Definition co23.h:214
uart_stop_bits_t stop_bit
Definition co23.h:229
pin_name_t scl
Definition co23.h:217
pin_name_t int_pin
Definition co23.h:222
uart_parity_t parity_bit
Definition co23.h:228
pin_name_t sda
Definition co23.h:218
uint8_t i2c_address
Definition co23.h:232
CO2 3 Click interrupt configuration object.
Definition co23.h:287
uint8_t alarm_typ
Definition co23.h:290
uint8_t int_func
Definition co23.h:289
uint8_t int_typ
Definition co23.h:288
CO2 3 Click measurement configuration object.
Definition co23.h:260
uint8_t boc_cfg
Definition co23.h:263
uint8_t pwm_mode
Definition co23.h:262
uint8_t pwm_outen
Definition co23.h:261
uint8_t op_mode
Definition co23.h:264
CO2 3 Click measurement status object.
Definition co23.h:273
uint8_t int_sts_clr
Definition co23.h:277
uint8_t alarm
Definition co23.h:276
uint8_t drdy
Definition co23.h:274
uint8_t alarm_clr
Definition co23.h:278
uint8_t int_sts
Definition co23.h:275
CO2 3 Click context object.
Definition co23.h:182
char uart_tx_buffer[CO23_TX_DRV_BUFFER_SIZE]
Definition co23.h:199
co23_drv_t drv_sel
Definition co23.h:201
co23_master_io_t write_f
Definition co23.h:202
co23_master_io_t read_f
Definition co23.h:203
uart_t uart
Definition co23.h:192
digital_in_t int_pin
Definition co23.h:188
i2c_master_t i2c
Definition co23.h:191
char uart_rx_buffer[CO23_RX_DRV_BUFFER_SIZE]
Definition co23.h:198
digital_in_t pwo
Definition co23.h:187
uint8_t slave_address
Definition co23.h:195
digital_out_t pws
Definition co23.h:184
CO2 3 Click sens status object.
Definition co23.h:243
uint8_t pwm_dis_st
Definition co23.h:245
uint8_t ortmp_clr
Definition co23.h:249
uint8_t orvs_clr
Definition co23.h:250
uint8_t iccer_clr
Definition co23.h:251
uint8_t sen_rdy
Definition co23.h:244
uint8_t orvs
Definition co23.h:247
uint8_t iccer
Definition co23.h:248
uint8_t ortmp
Definition co23.h:246