LibDriver STCC4
Loading...
Searching...
No Matches
driver_stcc4.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_STCC4_H
38#define DRIVER_STCC4_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
64 STCC4_ADDRESS_0 = (0x64 << 1),
65 STCC4_ADDRESS_1 = (0x65 << 1),
67
71typedef enum
72{
76
80typedef struct stcc4_handle_s
81{
82 uint8_t iic_addr;
83 uint8_t (*iic_init)(void);
84 uint8_t (*iic_deinit)(void);
85 uint8_t (*iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
86 uint8_t (*iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
87 void (*delay_ms)(uint32_t ms);
88 void (*debug_print)(const char *const fmt, ...);
89 uint8_t inited;
90 uint8_t type;
92
108
112
119
126#define DRIVER_STCC4_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
127
134#define DRIVER_STCC4_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
135
142#define DRIVER_STCC4_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
143
150#define DRIVER_STCC4_LINK_IIC_READ_COMMAND(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
151
158#define DRIVER_STCC4_LINK_IIC_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
159
166#define DRIVER_STCC4_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
167
174#define DRIVER_STCC4_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
175
179
186
195uint8_t stcc4_info(stcc4_info_t *info);
196
207
217uint8_t stcc4_get_address_pin(stcc4_handle_t *handle, stcc4_address_t *address);
218
230uint8_t stcc4_init(stcc4_handle_t *handle);
231
243uint8_t stcc4_deinit(stcc4_handle_t *handle);
244
264uint8_t stcc4_read(stcc4_handle_t *handle, int16_t *co2_raw, int16_t *co2_ppm,
265 uint16_t *temperature_raw, float *temperature_s,
266 uint16_t *humidity_raw, float *humidity_s, uint16_t *sensor_status);
267
279
291
304uint8_t stcc4_set_rht_compensation(stcc4_handle_t *handle, uint16_t temperature_raw, uint16_t humidity_raw);
305
317uint8_t stcc4_set_pressure_compensation(stcc4_handle_t *handle, uint16_t pressure_raw);
318
330
342
353
365
376
389
402uint8_t stcc4_perform_self_test(stcc4_handle_t *handle, uint16_t *result);
403
415
427
441uint8_t stcc4_perform_forced_recalibration(stcc4_handle_t *handle, uint16_t target_co2, uint16_t *correct_co2);
442
456uint8_t stcc4_get_product_id(stcc4_handle_t *handle, uint32_t *product_id, uint8_t unique_serial_number[8]);
457
469uint8_t stcc4_frc_co2_convert_to_register(stcc4_handle_t *handle, float ppm, uint16_t *reg);
470
482uint8_t stcc4_frc_co2_convert_to_data(stcc4_handle_t *handle, uint16_t reg, float *ppm);
483
495uint8_t stcc4_humidity_convert_to_register(stcc4_handle_t *handle, float percentage, uint16_t *reg);
496
508uint8_t stcc4_humidity_convert_to_data(stcc4_handle_t *handle, uint16_t reg, float *percentage);
509
521uint8_t stcc4_temperature_convert_to_register(stcc4_handle_t *handle, float deg, uint16_t *reg);
522
534uint8_t stcc4_temperature_convert_to_data(stcc4_handle_t *handle, uint16_t reg, float *deg);
535
547uint8_t stcc4_pressure_convert_to_register(stcc4_handle_t *handle, float pa, uint16_t *reg);
548
560uint8_t stcc4_pressure_convert_to_data(stcc4_handle_t *handle, uint16_t reg, float *pa);
561
565
572
586uint8_t stcc4_set_reg(stcc4_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len);
587
602uint8_t stcc4_get_reg(stcc4_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len, uint16_t delay_ms);
603
607
611
612#ifdef __cplusplus
613}
614#endif
615
616#endif
uint8_t stcc4_humidity_convert_to_register(stcc4_handle_t *handle, float percentage, uint16_t *reg)
convert the humidity to the register raw data
uint8_t stcc4_perform_self_test(stcc4_handle_t *handle, uint16_t *result)
perform self test
stcc4_bool_t
stcc4 bool enumeration definition
uint8_t stcc4_frc_co2_convert_to_register(stcc4_handle_t *handle, float ppm, uint16_t *reg)
convert the frc co2 to the register raw data
uint8_t stcc4_stop_continuous_measurement(stcc4_handle_t *handle)
stop continuous measurement
uint8_t stcc4_pressure_convert_to_data(stcc4_handle_t *handle, uint16_t reg, float *pa)
convert the register raw data to pressure
uint8_t stcc4_set_rht_compensation(stcc4_handle_t *handle, uint16_t temperature_raw, uint16_t humidity_raw)
set rht compensation
uint8_t stcc4_exit_sleep_mode(stcc4_handle_t *handle)
exit sleep mode
uint8_t stcc4_deinit(stcc4_handle_t *handle)
close the chip
uint8_t stcc4_temperature_convert_to_register(stcc4_handle_t *handle, float deg, uint16_t *reg)
convert the temperature to the register raw data
uint8_t stcc4_perform_conditioning(stcc4_handle_t *handle)
perform conditioning
uint8_t stcc4_pressure_convert_to_register(stcc4_handle_t *handle, float pa, uint16_t *reg)
convert the pressure to the register raw data
uint8_t stcc4_frc_co2_convert_to_data(stcc4_handle_t *handle, uint16_t reg, float *ppm)
convert the register raw data to frc co2 ppm
uint8_t stcc4_set_pressure_compensation(stcc4_handle_t *handle, uint16_t pressure_raw)
set pressure compensation
uint8_t stcc4_enable_testing_mode(stcc4_handle_t *handle)
enable testing mode
uint8_t stcc4_info(stcc4_info_t *info)
get chip information
uint8_t stcc4_perform_factory_reset(stcc4_handle_t *handle)
perform factory reset
struct stcc4_handle_s stcc4_handle_t
stcc4 handle structure definition
stcc4_address_t
stcc4 address enumeration definition
uint8_t stcc4_enter_sleep_mode(stcc4_handle_t *handle)
enter sleep mode
uint8_t stcc4_measure_single_shot(stcc4_handle_t *handle)
measure single shot
uint8_t stcc4_perform_soft_reset(stcc4_handle_t *handle)
perform soft reset
uint8_t stcc4_init(stcc4_handle_t *handle)
initialize the chip
uint8_t stcc4_temperature_convert_to_data(stcc4_handle_t *handle, uint16_t reg, float *deg)
convert the register raw data to temperature
uint8_t stcc4_get_address_pin(stcc4_handle_t *handle, stcc4_address_t *address)
get address pin
uint8_t stcc4_set_address_pin(stcc4_handle_t *handle, stcc4_address_t address)
set address pin
uint8_t stcc4_humidity_convert_to_data(stcc4_handle_t *handle, uint16_t reg, float *percentage)
convert the register raw data to humidity
uint8_t stcc4_read(stcc4_handle_t *handle, int16_t *co2_raw, int16_t *co2_ppm, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s, uint16_t *sensor_status)
read data
uint8_t stcc4_get_product_id(stcc4_handle_t *handle, uint32_t *product_id, uint8_t unique_serial_number[8])
get product id
uint8_t stcc4_disable_testing_mode(stcc4_handle_t *handle)
disable testing mode
uint8_t stcc4_start_continuous_measurement(stcc4_handle_t *handle)
start continuous measurement
uint8_t stcc4_perform_forced_recalibration(stcc4_handle_t *handle, uint16_t target_co2, uint16_t *correct_co2)
perform forced recalibration
struct stcc4_info_s stcc4_info_t
stcc4 information structure definition
@ STCC4_BOOL_FALSE
@ STCC4_BOOL_TRUE
@ STCC4_ADDRESS_1
@ STCC4_ADDRESS_0
uint8_t stcc4_get_reg(stcc4_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len, uint16_t delay_ms)
get the chip register
uint8_t stcc4_set_reg(stcc4_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
set the chip register
stcc4 handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
stcc4 information structure definition
float temperature_max
float supply_voltage_max_v
uint32_t driver_version
float temperature_min
float max_current_ma
char manufacturer_name[32]
float supply_voltage_min_v
char interface[8]
char chip_name[32]