Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
airquality4_click.h
Go to the documentation of this file.
1 
5 /*
6  * Copyright (c) 2022, Cascoda Ltd.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the copyright holder nor the
17  * names of its contributors may be used to endorse or promote products
18  * derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  * Example click interface driver
34 */
35 
36 #ifndef AIRQUALITY4_CLICK_H
37 #define AIRQUALITY4_CLICK_H
38 
39 #include <stdint.h>
40 
41 /* measure raw signals (H2 and Ethanol) when 1 instead of air quality values (when 0) */
42 #define AIRQUALITY4_MEASURE_RAW_SIGNALS 0
43 
44 /* I2C slave address */
45 #define SGP30_I2C_ADDR 0x58
46 
47 /* all sgp30 maximum data length */
48 #define SGP30_MAXDLEN 6
49 /* I2C slave address + memory address (command) */
50 #define SGP30_ADDLEN 3
51 
52 /* timing parameters [ms] */
53 #define SGP30_T_INIT 17000 /* 17 seconds initialisation time after issuing init_air_quality command */
54 #define SGP30_T_CAL 43200000 /* 12 hours initial baseline calibration duration */
55 #define SGP30_T_TEST 250 /* 250 ms for measure_test self test */
56 #define SGP30_T_MEAS_RAW 25 /* 25 ms measurement time (between i2c write and read) for raw signals */
57 #define SGP30_T_MEAS_QUAL 12 /* 12 ms measurement time (between i2c write and read) for air quality signals */
58 #define SGP30_T_MEAS_POWERUP 10 /* 10 ms power-up time */
59 
60 #define SGP30_T_SLEEP 0xFFFFFFFF /* dummy time to indicate device is in sleep mode */
61 
62 /* memory address / command definitions */
63 #define SGP30_CMD_INIT_AIR_QUALITY 0x2003
64 #define SGP30_CMD_MEASURE_AIR_QUALITY 0x2008
65 #define SGP30_CMD_GET_BASELINE 0x2015
66 #define SGP30_CMD_SET_BASELINE 0x201E
67 #define SGP30_CMD_SET_HUMIDITY 0x2061
68 #define SGP30_CMD_MEASURE_TEST 0x2032
69 #define SGP30_CMD_GET_FEATURE_SET_VERSION 0x202F
70 #define SGP30_CMD_MEASURE_RAW_SIGNALS 0x2050
71 #define SGP30_CMD_GET_SERIAL_ID 0x3682
72 
73 /* data acquisition status */
75 {
76  AIRQUALITY4_ST_OK = 0, /* read values ok */
77  AIRQUALITY4_ST_NCAL = 1, /* baseline not yet calibrated */
78  AIRQUALITY4_ST_INIT = 2, /* initialisating */
79  AIRQUALITY4_ST_SLEEP = 3, /* device is in sleep mode */
80  AIRQUALITY4_ST_FAIL = 4 /* acquisition failed */
81 };
82 
83 /* new functions */
84 uint8_t MIKROSDK_AIRQUALITY4_dev_init(void);
88 uint8_t MIKROSDK_AIRQUALITY4_get_version(uint16_t *version);
90 uint8_t MIKROSDK_AIRQUALITY4_measure_raw_signals(uint16_t *value);
91 uint8_t MIKROSDK_AIRQUALITY4_measure_air_quality(uint16_t *value);
94 uint8_t MIKROSDK_AIRQUALITY4_Acquire(uint16_t *co2_h2, uint16_t *tvoc_eth);
95 uint8_t MIKROSDK_AIRQUALITY4_Powerdown(void);
96 uint8_t MIKROSDK_AIRQUALITY4_Powerup(void);
97 
98 #endif // AIRQUALITY4_CLICK_H
uint8_t MIKROSDK_AIRQUALITY4_soft_reset(void)
Definition: airquality4.c:129
uint8_t MIKROSDK_AIRQUALITY4_get_baseline(void)
Definition: airquality4.c:107
uint8_t MIKROSDK_AIRQUALITY4_Powerdown(void)
Definition: airquality4.c:308
airquality4_status
Definition: airquality4_click.h:75
@ AIRQUALITY4_ST_SLEEP
Definition: airquality4_click.h:79
@ AIRQUALITY4_ST_FAIL
Definition: airquality4_click.h:80
@ AIRQUALITY4_ST_INIT
Definition: airquality4_click.h:78
@ AIRQUALITY4_ST_NCAL
Definition: airquality4_click.h:77
@ AIRQUALITY4_ST_OK
Definition: airquality4_click.h:76
uint8_t MIKROSDK_AIRQUALITY4_measure_test(void)
Definition: airquality4.c:162
uint8_t MIKROSDK_AIRQUALITY4_Reinitialise(void)
Definition: airquality4.c:260
uint8_t MIKROSDK_AIRQUALITY4_Initialise(void)
Definition: airquality4.c:236
uint8_t MIKROSDK_AIRQUALITY4_Acquire(uint16_t *co2_h2, uint16_t *tvoc_eth)
Definition: airquality4.c:286
uint8_t MIKROSDK_AIRQUALITY4_measure_air_quality(uint16_t *value)
Definition: airquality4.c:204
uint8_t MIKROSDK_AIRQUALITY4_measure_raw_signals(uint16_t *value)
Definition: airquality4.c:184
uint8_t MIKROSDK_AIRQUALITY4_Powerup(void)
Definition: airquality4.c:324
uint8_t MIKROSDK_AIRQUALITY4_dev_init(void)
Definition: airquality4.c:95
uint8_t MIKROSDK_AIRQUALITY4_set_baseline(void)
Definition: airquality4.c:120
uint8_t MIKROSDK_AIRQUALITY4_get_version(uint16_t *version)
Definition: airquality4.c:146