Nordic Thingy:52
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
drv_ccs811.h
1 /*
2  Copyright (c) 2010 - 2017, Nordic Semiconductor ASA
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form, except as embedded into a Nordic
12  Semiconductor ASA integrated circuit in a product or a software update for
13  such product, must reproduce the above copyright notice, this list of
14  conditions and the following disclaimer in the documentation and/or other
15  materials provided with the distribution.
16 
17  3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  contributors may be used to endorse or promote products derived from this
19  software without specific prior written permission.
20 
21  4. This software, with or without modification, must only be used with a
22  Nordic Semiconductor ASA integrated circuit.
23 
24  5. Any software provided in binary form under this license must not be reverse
25  engineered, decompiled, modified and/or disassembled.
26 
27  THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
28  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29  OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
30  DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
31  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef DRV_CCS811_H__
40 #define DRV_CCS811_H__
41 
42 #include "nrf_drv_twi.h"
43 
44 #include <stdint.h>
45 
57 enum
58 {
63 };
64 
67 typedef struct
68 {
69  uint8_t twi_addr;
70  nrf_drv_twi_t const * p_twi_instance;
71  nrf_drv_twi_config_t const * p_twi_cfg;
73 
76 typedef enum
77 {
84 
87 typedef struct
88 {
89  uint16_t ec02_ppm;
90  uint16_t tvoc_ppb;
91  uint8_t status;
92  uint8_t err_id;
93  uint16_t raw_data;
95 
98 void drv_ccs811_init(void);
99 
107 uint32_t drv_ccs811_open(drv_ccs811_cfg_t const * const p_drv_ccs811_cfg);
108 
116 uint32_t drv_ccs811_status_get(uint8_t * p_status);
117 
125 uint32_t drv_ccs811_meas_mode_get(uint8_t * p_meas_mode);
126 
136 uint32_t drv_ccs811_meas_mode_modify(uint8_t set_mask, uint8_t clr_mask);
137 
147 uint32_t drv_ccs811_alg_result_data_get(drv_ccs811_alg_result_descr_t alg_result_descr, drv_ccs811_alg_result_t * p_alg_result_data);
148 
156 uint32_t drv_ccs811_raw_data_get(uint16_t * p_raw_data);
157 
168 uint32_t drv_ccs811_env_data_set(uint16_t rh_ppth, int32_t temp_mdeg);
169 
179 uint32_t drv_ccs811_thresholds_get(uint16_t * p_low_to_medium, uint16_t * p_medium_to_high, uint8_t * p_hysteresis);
180 
190 uint32_t drv_ccs811_thresholds_set(uint16_t low_to_medium, uint16_t medium_to_highm, uint8_t hysteresis);
191 
200 uint32_t drv_ccs811_ntc_get(uint16_t * p_r_ref_mv, uint16_t * p_r_ntc_mv);
201 
209 uint32_t drv_ccs811_baseline_get(uint16_t * p_baseline);
210 
218 uint32_t drv_ccs811_baseline_set(uint16_t baseline);
219 
227 uint32_t drv_ccs811_hw_id_get(uint8_t * p_hw_id);
228 
236 uint32_t drv_ccs811_hw_version_get(uint8_t * p_hw_version);
237 
245 uint32_t drv_ccs811_fw_boot_version_get(uint16_t * p_fw_boot_version);
246 
254 uint32_t drv_ccs811_fw_app_version_get(uint16_t * p_fw_app_version);
255 
263 uint32_t drv_ccs811_err_id_get(uint8_t * p_err_id);
264 
270 uint32_t drv_ccs811_app_start(void);
271 
277 uint32_t drv_ccs811_sw_reset(void);
278 
284 uint32_t drv_ccs811_close(void);
285 
286 #endif // DRV_CCS811_H__
287