LibDriver SGP30
Loading...
Searching...
No Matches
driver_sgp30_basic.c
Go to the documentation of this file.
1
37
38#include "driver_sgp30_basic.h"
39
40static sgp30_handle_t gs_handle;
41
49uint8_t sgp30_basic_init(void)
50{
51 uint8_t res;
52
53 /* link functions */
61
62 /* sgp30 init */
63 res = sgp30_init(&gs_handle);
64 if (res != 0)
65 {
66 sgp30_interface_debug_print("sgp30: init failed.\n");
67
68 return 1;
69 }
70
71 /* soft reset */
72 res = sgp30_soft_reset(&gs_handle);
73 if (res != 0)
74 {
75 sgp30_interface_debug_print("sgp30: soft reset failed.\n");
76
77 return 1;
78 }
79
80 /* 100 ms */
82
83 /* iaq init */
84 res = sgp30_iaq_init(&gs_handle);
85 if (res != 0)
86 {
87 sgp30_interface_debug_print("sgp30: iaq init failed.\n");
88 (void)sgp30_deinit(&gs_handle);
89
90 return 1;
91 }
92
93 return 0;
94}
95
104{
105 /* close sgp30 */
106 if (sgp30_deinit(&gs_handle) != 0)
107 {
108 return 1;
109 }
110 else
111 {
112 return 0;
113 }
114}
115
125uint8_t sgp30_basic_read(uint16_t *co2_eq_ppm, uint16_t *tvoc_ppb)
126{
127 /* read data */
128 if (sgp30_read(&gs_handle, co2_eq_ppm, tvoc_ppb) != 0)
129 {
130 return 1;
131 }
132 else
133 {
134 return 0;
135 }
136}
driver sgp30 basic header file
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_deinit(sgp30_handle_t *handle)
close the chip
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_soft_reset(sgp30_handle_t *handle)
soft reset the chip
uint8_t sgp30_iaq_init(sgp30_handle_t *handle)
initialize the chip iaq
uint8_t sgp30_basic_init(void)
basic example init
uint8_t sgp30_basic_deinit(void)
basic example deinit
uint8_t sgp30_basic_read(uint16_t *co2_eq_ppm, uint16_t *tvoc_ppb)
basic example read
uint8_t sgp30_interface_iic_write_cmd(uint8_t addr, uint8_t *buf, uint16_t len)
interface iic bus write command
uint8_t sgp30_interface_iic_init(void)
interface iic bus init
uint8_t sgp30_interface_iic_read_cmd(uint8_t addr, uint8_t *buf, uint16_t len)
interface iic bus read command
void sgp30_interface_delay_ms(uint32_t ms)
interface delay ms
void sgp30_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t sgp30_interface_iic_deinit(void)
interface iic bus deinit