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 APC1SENSOR_ADDRESS_CMD 0x40
75#define APC1SENSOR_ADDRESS_RESPONSE 0x47
76#define APC1SENSOR_CMD_SET_MEAS_MODE 0xE1
77#define APC1SENSOR_CMD_REQ_MEASUREMENT 0xE2
78#define APC1SENSOR_CMD_SET_MODE 0xE4
79#define APC1SENSOR_CMD_GET_INFO 0xE9
97#define APC1SENSOR_HEADER_0 0x42
98#define APC1SENSOR_HEADER_1 0x4D
104#define APC1SENSOR_MEASUREMENT_PASSIVE 0x00
105#define APC1SENSOR_MEASUREMENT_ACTIVE 0x01
111#define APC1SENSOR_MODE_IDLE 0x00
112#define APC1SENSOR_MODE_MEASUREMENT 0x01
113#define APC1SENSOR_MODE_RESET 0x0F
119#define APC1SENSOR_OPMODE_NORMAL 0
120#define APC1SENSOR_OPMODE_DEEP_SLEEP 1
121#define APC1SENSOR_OPMODE_RESET 2
128#define APC1SENSOR_TX_DRV_BUFFER_SIZE 100
129#define APC1SENSOR_RX_DRV_BUFFER_SIZE 300
136#define APC1SENSOR_DEVICE_ADDRESS 0x12
154#define APC1SENSOR_MAP_MIKROBUS( cfg, mikrobus ) \
155 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
156 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
157 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
158 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
159 cfg.set = MIKROBUS( mikrobus, MIKROBUS_CS ); \
160 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
266 uint8_t module_name[ 7 ];
267 uint8_t serial_num[ 8 ];
268 uint8_t fw_version[ 2 ];
apc1sensor_drv_t
APC1 Sensor Click driver selector.
Definition apc1sensor.h:170
@ APC1SENSOR_DRV_SEL_UART
Definition apc1sensor.h:172
@ APC1SENSOR_DRV_SEL_I2C
Definition apc1sensor.h:171
apc1sensor_return_value_t
APC1 Sensor Demo return value data.
Definition apc1sensor.h:277
@ APC1SENSOR_ERROR
Definition apc1sensor.h:279
@ APC1SENSOR_OK
Definition apc1sensor.h:278
#define APC1SENSOR_TX_DRV_BUFFER_SIZE
APC1 Sensor driver buffer size.
Definition apc1sensor.h:128
#define APC1SENSOR_RX_DRV_BUFFER_SIZE
Definition apc1sensor.h:129
void apc1sensor_cfg_setup(apc1sensor_cfg_t *cfg)
APC1 Sensor configuration object setup function.
err_t apc1sensor_init(apc1sensor_t *ctx, apc1sensor_cfg_t *cfg)
APC1 Sensor initialization function.
err_t apc1sensor_read_measurement(apc1sensor_t *ctx, apc1sensor_measurement_t *measurement)
APC1 Sensor read measurement function.
err_t apc1sensor_default_cfg(apc1sensor_t *ctx)
APC1 Sensor default configuration function.
err_t apc1sensor_set_idle_mode(apc1sensor_t *ctx)
APC1 Sensor set idle mode function.
err_t apc1sensor_sw_reset(apc1sensor_t *ctx)
APC1 Sensor sw reset function.
void apc1sensor_drv_interface_sel(apc1sensor_cfg_t *cfg, apc1sensor_drv_t drv_sel)
APC1 Sensor driver interface setup function.
err_t apc1sensor_start_measurement(apc1sensor_t *ctx)
APC1 Sensor start measurement function.
err_t apc1sensor_set_meas_mode(apc1sensor_t *ctx, uint8_t mode)
APC1 Sensor set meas mode function.
void apc1sensor_set_opmode(apc1sensor_t *ctx, uint8_t opmode)
APC1 Sensor set opmode function.
err_t apc1sensor_read_info(apc1sensor_t *ctx, apc1sensor_info_t *info)
APC1 Sensor read info function.
err_t apc1sensor_request_meas(apc1sensor_t *ctx)
APC1 Sensor request meas function.
void apc1sensor_reset_device(apc1sensor_t *ctx)
APC1 Sensor reset device function.
APC1 Sensor Demo configuration object.
Definition apc1sensor.h:204
uint32_t baud_rate
Definition apc1sensor.h:216
pin_name_t set
Definition apc1sensor.h:210
apc1sensor_drv_t drv_sel
Definition apc1sensor.h:222
uint32_t i2c_speed
Definition apc1sensor.h:213
bool uart_blocking
Definition apc1sensor.h:217
uart_data_bits_t data_bit
Definition apc1sensor.h:218
pin_name_t tx_pin
Definition apc1sensor.h:208
pin_name_t rx_pin
Definition apc1sensor.h:207
uart_stop_bits_t stop_bit
Definition apc1sensor.h:220
pin_name_t scl
Definition apc1sensor.h:205
uart_parity_t parity_bit
Definition apc1sensor.h:219
pin_name_t sda
Definition apc1sensor.h:206
pin_name_t rst
Definition apc1sensor.h:211
uint8_t i2c_address
Definition apc1sensor.h:214
APC1 Sensor Demo module type, ID and firmware version object.
Definition apc1sensor.h:265
APC1 Sensor Demo measurement data object.
Definition apc1sensor.h:231
uint16_t part_over_2_5um
Definition apc1sensor.h:241
uint16_t part_over_1_0um
Definition apc1sensor.h:240
uint16_t part_over_0_5um
Definition apc1sensor.h:239
uint16_t tvoc
Definition apc1sensor.h:244
uint8_t error_code
Definition apc1sensor.h:256
uint8_t aqi
Definition apc1sensor.h:254
uint16_t pm10
Definition apc1sensor.h:234
uint16_t eco2
Definition apc1sensor.h:245
float t_raw
Definition apc1sensor.h:248
float rh_raw
Definition apc1sensor.h:249
uint32_t rs1
Definition apc1sensor.h:251
uint16_t part_over_0_3um
Definition apc1sensor.h:238
uint32_t rs0
Definition apc1sensor.h:250
float rh_comp
Definition apc1sensor.h:247
float t_comp
Definition apc1sensor.h:246
uint16_t pm1_0_air
Definition apc1sensor.h:235
uint8_t version
Definition apc1sensor.h:255
uint16_t pm2_5_air
Definition apc1sensor.h:236
uint16_t part_over_10um
Definition apc1sensor.h:243
uint16_t pm2_5
Definition apc1sensor.h:233
uint32_t rs3
Definition apc1sensor.h:253
uint16_t pm1_0
Definition apc1sensor.h:232
uint32_t rs2
Definition apc1sensor.h:252
uint16_t pm10_air
Definition apc1sensor.h:237
uint16_t part_over_5_0um
Definition apc1sensor.h:242
APC1 Sensor Demo context object.
Definition apc1sensor.h:181
apc1sensor_drv_t drv_sel
Definition apc1sensor.h:193
uint8_t meas_mode
Definition apc1sensor.h:195
uart_t uart
Definition apc1sensor.h:186
i2c_master_t i2c
Definition apc1sensor.h:185
digital_out_t set
Definition apc1sensor.h:182
digital_out_t rst
Definition apc1sensor.h:183
uint8_t slave_address
Definition apc1sensor.h:188