LibDriver SGP30
Loading...
Searching...
No Matches
driver_sgp30.h
Go to the documentation of this file.
1
37
38#ifndef DRIVER_SGP30_H
39#define DRIVER_SGP30_H
40
41#include <math.h>
42#include <stdio.h>
43#include <stdint.h>
44#include <string.h>
45
46#ifdef __cplusplus
47extern "C"{
48#endif
49
55
60
64typedef struct sgp30_handle_s
65{
66 uint8_t (*iic_init)(void);
67 uint8_t (*iic_deinit)(void);
68 uint8_t (*iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
69 uint8_t (*iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
70 void (*delay_ms)(uint32_t ms);
71 void (*debug_print)(const char *const fmt, ...);
72 uint8_t inited;
74
90
94
101
108#define DRIVER_SGP30_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
109
116#define DRIVER_SGP30_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
117
124#define DRIVER_SGP30_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
125
132#define DRIVER_SGP30_LINK_IIC_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
133
140#define DRIVER_SGP30_LINK_IIC_READ_COMMAND(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
141
148#define DRIVER_SGP30_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
149
156#define DRIVER_SGP30_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
157
161
168
177uint8_t sgp30_info(sgp30_info_t *info);
178
189uint8_t sgp30_init(sgp30_handle_t *handle);
190
202uint8_t sgp30_deinit(sgp30_handle_t *handle);
203
214uint8_t sgp30_iaq_init(sgp30_handle_t *handle);
215
228uint8_t sgp30_read(sgp30_handle_t *handle, uint16_t *co2_eq_ppm, uint16_t *tvoc_ppb);
229
242uint8_t sgp30_measure_iaq(sgp30_handle_t *handle, uint16_t *co2_eq_ppm, uint16_t *tvoc_ppb);
243
256uint8_t sgp30_get_measure_raw(sgp30_handle_t *handle, uint16_t *tvoc, uint16_t *co2_eq);
257
269uint8_t sgp30_set_tvoc_baseline(sgp30_handle_t *handle, uint16_t tvoc_baseline);
270
282uint8_t sgp30_get_tvoc_inceptive_baseline(sgp30_handle_t *handle, uint16_t *tvoc_baseline);
283
294uint8_t sgp30_soft_reset(sgp30_handle_t *handle);
295
307uint8_t sgp30_get_serial_id(sgp30_handle_t *handle, uint16_t id[3]);
308
321uint8_t sgp30_set_iaq_baseline(sgp30_handle_t *handle, uint16_t tvoc, uint16_t co2_eq);
322
335uint8_t sgp30_get_iaq_baseline(sgp30_handle_t *handle, uint16_t *tvoc, uint16_t *co2_eq);
336
348uint8_t sgp30_set_absolute_humidity(sgp30_handle_t *handle, uint16_t humidity);
349
363uint8_t sgp30_absolute_humidity_convert_to_register(sgp30_handle_t *handle, float temp, float rh, uint16_t *reg);
364
376uint8_t sgp30_measure_test(sgp30_handle_t *handle, uint16_t *result);
377
390uint8_t sgp30_get_feature_set(sgp30_handle_t *handle, uint8_t *product_type, uint8_t *product_version);
391
404uint8_t sgp30_get_measure_raw(sgp30_handle_t *handle, uint16_t *tvoc, uint16_t *co2_eq);
405
409
416
430uint8_t sgp30_set_reg(sgp30_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len);
431
445uint8_t sgp30_get_reg(sgp30_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len);
446
450
454
455#ifdef __cplusplus
456}
457#endif
458
459#endif
uint8_t sgp30_get_iaq_baseline(sgp30_handle_t *handle, uint16_t *tvoc, uint16_t *co2_eq)
get the chip iaq baseline
uint8_t sgp30_set_tvoc_baseline(sgp30_handle_t *handle, uint16_t tvoc_baseline)
set the chip tvoc baseline
struct sgp30_handle_s sgp30_handle_t
sgp30 handle structure definition
uint8_t sgp30_init(sgp30_handle_t *handle)
initialize the chip
uint8_t sgp30_absolute_humidity_convert_to_register(sgp30_handle_t *handle, float temp, float rh, uint16_t *reg)
convert the absolute humidity to the register data
uint8_t sgp30_deinit(sgp30_handle_t *handle)
close the chip
struct sgp30_info_s sgp30_info_t
sgp30 information structure definition
uint8_t sgp30_get_serial_id(sgp30_handle_t *handle, uint16_t id[3])
get the chip serial id
uint8_t sgp30_set_iaq_baseline(sgp30_handle_t *handle, uint16_t tvoc, uint16_t co2_eq)
set the chip iaq baseline
uint8_t sgp30_set_absolute_humidity(sgp30_handle_t *handle, uint16_t humidity)
set the chip absolute_humidity
uint8_t sgp30_get_measure_raw(sgp30_handle_t *handle, uint16_t *tvoc, uint16_t *co2_eq)
get the iaq measure raw result
uint8_t sgp30_read(sgp30_handle_t *handle, uint16_t *co2_eq_ppm, uint16_t *tvoc_ppb)
read the iaq measure result
uint8_t sgp30_get_feature_set(sgp30_handle_t *handle, uint8_t *product_type, uint8_t *product_version)
get the chip feature
uint8_t sgp30_info(sgp30_info_t *info)
get chip information
uint8_t sgp30_soft_reset(sgp30_handle_t *handle)
soft reset the chip
uint8_t sgp30_measure_test(sgp30_handle_t *handle, uint16_t *result)
run the chip measure test
uint8_t sgp30_measure_iaq(sgp30_handle_t *handle, uint16_t *co2_eq_ppm, uint16_t *tvoc_ppb)
get the iaq measure result
uint8_t sgp30_iaq_init(sgp30_handle_t *handle)
initialize the chip iaq
uint8_t sgp30_get_tvoc_inceptive_baseline(sgp30_handle_t *handle, uint16_t *tvoc_baseline)
get the chip tvoc inceptive baseline
uint8_t sgp30_set_reg(sgp30_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t sgp30_get_reg(sgp30_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
get the chip register
sgp30 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)
sgp30 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]