Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
environment2_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 ENVIRONMENT2_CLICK_H
37 #define ENVIRONMENT2_CLICK_H
38 
39 #include <stdint.h>
40 
41 /* use powerdown/sleep/idle mode between measurements when (1) */
42 #define ENVIRONMENT2_USE_POWERDOWN 0
43 
44 /* timing parameters [ms] */
45 #define SGP40_T_TEST 250 /* sgp40 250 ms for measure_test self test */
46 #define SGP40_T_MEAS_RAW 30 /* sgp40 30 ms measurement time (between i2c write and read) for raw signals */
47 #define SHT40_T_MEAS 10 /* sht40 10 ms measurement time (between i2c write and read) for temperature and humidity */
48 #define SGP40_T_INIT 60000 /* sgp40 60 seconds until reliably detecting voc events */
49 #define SGP40_T_SETTLING 3600000 /* sgp40 1 hour until specification is met */
50 #define SGP40_T_POWERUP 170 /* sgp40 power-up (wait between dummy read and read to warm up heating plate */
51 /* SGP40_T_POWERUP taken from: https://github.com/Sensirion/arduino-gas-index-algorithm */
52 
53 #define SGP40_T_SLEEP 0xFFFFFFFF /* dummy time to indicate device is in sleep mode */
54 
55 /* sgp40 maximum data length */
56 #define SGP40_MAXDLEN 6
57 /* sgp40 2C slave address + memory address (command) */
58 #define SGP40_ADDLEN 3
59 /* sht40 maximum data length */
60 #define SHT40_MAXDLEN 6
61 /* sht40 2C slave address + memory address (command) */
62 #define SHT40_ADDLEN 2
63 
64 /* data acquisition status */
66 {
67  ENVIRONMENT2_ST_OK = 0, /* read values ok */
68  ENVIRONMENT2_ST_SETTLING = 1, /* settling */
69  ENVIRONMENT2_ST_INIT = 2, /* initialisating */
70  ENVIRONMENT2_ST_SLEEP = 3, /* device is in sleep mode */
71  ENVIRONMENT2_ST_FAIL = 4 /* acquisition failed */
72 };
73 
74 /* new functions */
75 uint8_t MIKROSDK_ENVIRONMENT2_get_temp_hum(int16_t *humidity, int16_t *temperature);
76 uint8_t MIKROSDK_ENVIRONMENT2_get_air_quality(uint16_t *air_quality_raw);
77 uint8_t MIKROSDK_ENVIRONMENT2_get_voc_index(int32_t *voc_index);
78 uint8_t MIKROSDK_ENVIRONMENT2_get_voc_index_with_rh_t(int32_t *voc_index,
79  uint16_t *air_quality_raw,
80  int16_t *relative_humidity,
81  int16_t *temperature);
87 uint8_t MIKROSDK_ENVIRONMENT2_Acquire(int32_t *voc_index,
88  uint16_t *air_quality,
89  int16_t *humidity,
90  int16_t *temperature);
92 uint8_t MIKROSDK_ENVIRONMENT2_Powerup(void);
93 
94 #endif // ENVIRONMENT2_CLICK_H
uint8_t MIKROSDK_ENVIRONMENT2_Acquire(int32_t *voc_index, uint16_t *air_quality, int16_t *humidity, int16_t *temperature)
Definition: environment2.c:411
uint8_t MIKROSDK_ENVIRONMENT2_get_voc_index(int32_t *voc_index)
Definition: environment2.c:253
uint8_t MIKROSDK_ENVIRONMENT2_Powerdown(void)
Definition: environment2.c:440
uint8_t MIKROSDK_ENVIRONMENT2_get_temp_hum(int16_t *humidity, int16_t *temperature)
Definition: environment2.c:219
uint8_t MIKROSDK_ENVIRONMENT2_soft_reset(void)
Definition: environment2.c:346
uint8_t MIKROSDK_ENVIRONMENT2_Powerup(void)
Definition: environment2.c:450
uint8_t MIKROSDK_ENVIRONMENT2_get_voc_index_with_rh_t(int32_t *voc_index, uint16_t *air_quality_raw, int16_t *relative_humidity, int16_t *temperature)
Definition: environment2.c:275
uint8_t MIKROSDK_ENVIRONMENT2_sgp40_measure_test(void)
Definition: environment2.c:299
uint8_t MIKROSDK_ENVIRONMENT2_sgp40_heater_off(void)
Definition: environment2.c:327
uint8_t MIKROSDK_ENVIRONMENT2_get_air_quality(uint16_t *air_quality_raw)
Definition: environment2.c:235
uint8_t MIKROSDK_ENVIRONMENT2_Reinitialise(void)
Definition: environment2.c:384
environment2_status
Definition: environment2_click.h:66
@ ENVIRONMENT2_ST_OK
Definition: environment2_click.h:67
@ ENVIRONMENT2_ST_SETTLING
Definition: environment2_click.h:68
@ ENVIRONMENT2_ST_FAIL
Definition: environment2_click.h:71
@ ENVIRONMENT2_ST_SLEEP
Definition: environment2_click.h:70
@ ENVIRONMENT2_ST_INIT
Definition: environment2_click.h:69
uint8_t MIKROSDK_ENVIRONMENT2_Initialise(void)
Definition: environment2.c:363