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"
67#define NDIRCO2_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
71 cfg.bsy = MIKROBUS( mikrobus, MIKROBUS_RST ); \
72 cfg.cal = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
80#define NDIRCO2_RETVAL uint8_t
82#define NDIRCO2_OK 0x00
83#define NDIRCO2_INIT_ERROR 0xFF
90#define NDIRCO2_SOFTWARE_RESET_REG 0x00
91#define NDIRCO2_CONTROL_REG 0x01
92#define NDIRCO2_STATUS_REG 0x02
93#define NDIRCO2_DATA_LOW_REG 0x03
94#define NDIRCO2_DATA_HIGH_REG 0x04
95#define NDIRCO2_AVERAGING_COUNT_REG 0x07
96#define NDIRCO2_HIGH_ALARM_THRESHOLD_REG 0x0C
97#define NDIRCO2_LOW_ALARM_THRESHOLD_REG 0x0D
98#define NDIRCO2_FUNCTION_REG 0x0F
105#define NDIRCO2_NORMAL_STATE 0x00
106#define NDIRCO2_RESET 0x01
113#define NDIRCO2_MOVING_AVERAGE_SEL 0x00
114#define NDIRCO2_IIR_DIGITAL_FILTER_SEL 0x04
121#define NDIRCO2_MIN_AVG_COUNT_1_TIME 0x00
122#define NDIRCO2_MAX_AVG_COUNT_64_TIMES 0x3F
129#define NDIRCO2_PWM_PIN_DISABLE 0x00
130#define NDIRCO2_PWM_PIN_ENABLE 0x01
131#define NDIRCO2_PWM_HIGH_CONCENTRATION 0x00
132#define NDIRCO2_PWM_LOW_CONCENTRATION 0x08
139#define NDIRCO2_CHECK_EACH_MEASURE 0x00
140#define NDIRCO2_CHECK_AVG_COMPLETED 0x01
141#define NDIRCO2_POWER_DOWN_MODE 0x00
142#define NDIRCO2_CONTINUOUS_OP_MODE 0x01
#define NDIRCO2_RETVAL
Definition ndirco2.h:80
NDIRCO2_RETVAL ndirco2_init(ndirco2_t *ctx, ndirco2_cfg_t *cfg)
Initialization function.
uint8_t ndirco2_read_register(ndirco2_t *ctx, uint8_t register_address, uint16_t *data_out)
Generic Read function.
void ndirco2_read_co2(ndirco2_t *ctx, uint8_t set_check_mode, uint16_t *output_data)
CO2 Concentration Read function.
void ndirco2_set_mode(ndirco2_t *ctx, uint8_t select_mode)
Mode Set function.
void ndirco2_generic_read(ndirco2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void ndirco2_read_current_address(ndirco2_t *ctx, uint8_t *data_out, uint8_t n_bytes)
Current Address Read function.
void ndirco2_generic_write(ndirco2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void ndirco2_reset(ndirco2_t *ctx)
Software Reset function.
uint8_t ndirco2_check_average_complete(ndirco2_t *ctx)
Average Complete Check function.
uint8_t ndirco2_write_register(ndirco2_t *ctx, uint8_t register_address, uint8_t transfer_data)
Generic Write function.
void ndirco2_cfg_setup(ndirco2_cfg_t *cfg)
Config Object Initialization function.
uint8_t ndirco2_check_busy(ndirco2_t *ctx)
Data Ready Check function.
uint8_t ndirco2_check_alarm(ndirco2_t *ctx)
CO2 Concentration Limit Check function.
Click configuration structure definition.
Definition ndirco2.h:178
pin_name_t cal
Definition ndirco2.h:188
uint32_t i2c_speed
Definition ndirco2.h:193
pin_name_t bsy
Definition ndirco2.h:187
pin_name_t scl
Definition ndirco2.h:181
pin_name_t int_pin
Definition ndirco2.h:189
pin_name_t sda
Definition ndirco2.h:182
pin_name_t an
Definition ndirco2.h:186
uint8_t i2c_address
Definition ndirco2.h:194
Click ctx object definition.
Definition ndirco2.h:156
digital_in_t int_pin
Definition ndirco2.h:162
i2c_master_t i2c
Definition ndirco2.h:166
digital_in_t an
Definition ndirco2.h:159
digital_in_t bsy
Definition ndirco2.h:160
digital_in_t cal
Definition ndirco2.h:161
uint8_t slave_address
Definition ndirco2.h:170