| Nordic Thingy:52 v2.0.0

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 {
59 DRV_CCS811_STATUS_CODE_SUCCESS,
60 DRV_CCS811_STATUS_CODE_DISALLOWED,
61 DRV_CCS811_STATUS_CODE_INVALID_PARAM,
62 DRV_CCS811_STATUS_CODE_NOT_SUPPORTED
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;
72 } drv_ccs811_cfg_t;
73
76 typedef enum
77 {
78 DRV_CCS811_ALG_RESULT_DESCR_ECO2_ONLY = 0,
79 DRV_CCS811_ALG_RESULT_DESCR_TVOC_ONLY,
80 DRV_CCS811_ALG_RESULT_DESCR_ECO2_TVOC,
81 DRV_CCS811_ALG_RESULT_DESCR_ECO2_TVOC_STAT,
82 DRV_CCS811_ALG_RESULT_DESCR_ALL,
83 } drv_ccs811_alg_result_descr_t;
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;
94 } drv_ccs811_alg_result_t;
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
drv_ccs811_meas_mode_modify
uint32_t drv_ccs811_meas_mode_modify(uint8_t set_mask, uint8_t clr_mask)
Function for modifying the measurement mode register of the CCS811 device.
drv_ccs811_meas_mode_get
uint32_t drv_ccs811_meas_mode_get(uint8_t *p_meas_mode)
Function for getting the measurement mode of the CCS811 device.
drv_ccs811_hw_version_get
uint32_t drv_ccs811_hw_version_get(uint8_t *p_hw_version)
Function for getting the hardware version of the CCS811 device.
drv_ccs811_alg_result_t::tvoc_ppb
uint16_t tvoc_ppb
The Total Volatile Organic Compound (TVOC) value in parts per billion (ppb).
Definition: drv_ccs811.h:90
drv_ccs811_init
void drv_ccs811_init(void)
Function for initializing the CCS811 driver.
drv_ccs811_ntc_get
uint32_t drv_ccs811_ntc_get(uint16_t *p_r_ref_mv, uint16_t *p_r_ntc_mv)
Function for getting the NTC data of the CCS811 device.
drv_ccs811_alg_result_t
The algorithm result data of the CCS811 device.
Definition: drv_ccs811.h:87
drv_ccs811_thresholds_get
uint32_t drv_ccs811_thresholds_get(uint16_t *p_low_to_medium, uint16_t *p_medium_to_high, uint8_t *p_hysteresis)
Function for the thresholds of the CCS811 device.
drv_ccs811_alg_result_t::ec02_ppm
uint16_t ec02_ppm
The equivalent CO2 (eCO2) value in parts per million (ppm).
Definition: drv_ccs811.h:89
DRV_CCS811_ALG_RESULT_DESCR_ECO2_TVOC
Both eCO2 and TVOC values, but no additional information.
Definition: drv_ccs811.h:80
drv_ccs811_hw_id_get
uint32_t drv_ccs811_hw_id_get(uint8_t *p_hw_id)
Function for getting the hardware identity of the CCS811 device.
drv_ccs811_cfg_t::p_twi_cfg
nrf_drv_twi_config_t const * p_twi_cfg
The TWI configuration to use while the driver is enabled.
Definition: drv_ccs811.h:71
drv_ccs811_cfg_t::twi_addr
uint8_t twi_addr
TWI address of the CCS811.
Definition: drv_ccs811.h:69
drv_ccs811_app_start
uint32_t drv_ccs811_app_start(void)
Function for starting the application of the CCS811 device.
drv_ccs811_open
uint32_t drv_ccs811_open(drv_ccs811_cfg_t const *const p_drv_ccs811_cfg)
Function for opening the CCS811 driver according to the specified configuration.
drv_ccs811_baseline_set
uint32_t drv_ccs811_baseline_set(uint16_t baseline)
Function for writing the baseline value to the CCS811 device.
DRV_CCS811_ALG_RESULT_DESCR_ECO2_ONLY
Only the equivalent CO2 (eCO2) value.
Definition: drv_ccs811.h:78
DRV_CCS811_STATUS_CODE_NOT_SUPPORTED
Not supported.
Definition: drv_ccs811.h:62
drv_ccs811_sw_reset
uint32_t drv_ccs811_sw_reset(void)
Function for starting the application of the CCS811 device.
drv_ccs811_baseline_get
uint32_t drv_ccs811_baseline_get(uint16_t *p_baseline)
Function for getting the baseline value from the CCS811 device.
drv_ccs811_alg_result_t::status
uint8_t status
The status according to the CCS811 status format (drv_ccs811_status_get).
Definition: drv_ccs811.h:91
drv_ccs811_alg_result_descr_t
drv_ccs811_alg_result_descr_t
Descriptor of the CCS811 result data format.
Definition: drv_ccs811.h:76
drv_ccs811_fw_boot_version_get
uint32_t drv_ccs811_fw_boot_version_get(uint16_t *p_fw_boot_version)
Function for getting the version of the firmware bootloader of the CCS811 device. ...
drv_ccs811_cfg_t
CCS811 configuration.
Definition: drv_ccs811.h:67
DRV_CCS811_ALG_RESULT_DESCR_ECO2_TVOC_STAT
Both eCO2 and TVOC values + status.
Definition: drv_ccs811.h:81
drv_ccs811_raw_data_get
uint32_t drv_ccs811_raw_data_get(uint16_t *p_raw_data)
Function for getting the raw data of the CCS811 device.
drv_ccs811_fw_app_version_get
uint32_t drv_ccs811_fw_app_version_get(uint16_t *p_fw_app_version)
Function for getting the version of the firmware application of the CCS811 device.
DRV_CCS811_STATUS_CODE_INVALID_PARAM
Invalid parameters.
Definition: drv_ccs811.h:61
drv_ccs811_err_id_get
uint32_t drv_ccs811_err_id_get(uint8_t *p_err_id)
Function for getting the error identifier of the CCS811 device.
DRV_CCS811_STATUS_CODE_DISALLOWED
Disallowed.
Definition: drv_ccs811.h:60
drv_ccs811_env_data_set
uint32_t drv_ccs811_env_data_set(uint16_t rh_ppth, int32_t temp_mdeg)
Function for setting the environmental data of the CCS811 device.
drv_ccs811_alg_result_t::err_id
uint8_t err_id
The err_id according to the CCS811 err_id format (drv_ccs811_err_id_get).
Definition: drv_ccs811.h:92
drv_ccs811_thresholds_set
uint32_t drv_ccs811_thresholds_set(uint16_t low_to_medium, uint16_t medium_to_highm, uint8_t hysteresis)
Function for setting the thresholds of the CCS811 device.
DRV_CCS811_ALG_RESULT_DESCR_ALL
All available result data (eCO2 and TVOC, status, error ID, and raw data).
Definition: drv_ccs811.h:82
DRV_CCS811_ALG_RESULT_DESCR_TVOC_ONLY
Only the Total Volatile Organic Compound (TVOC) value.
Definition: drv_ccs811.h:79
drv_ccs811_alg_result_t::raw_data
uint16_t raw_data
The raw_data according to the CCS811 raw_data format (drv_ccs811_raw_data_get)
Definition: drv_ccs811.h:93
drv_ccs811_cfg_t::p_twi_instance
nrf_drv_twi_t const * p_twi_instance
The instance of TWI master to be used for transactions.
Definition: drv_ccs811.h:70
drv_ccs811_close
uint32_t drv_ccs811_close(void)
Function for closing the CCS811 driver.
drv_ccs811_status_get
uint32_t drv_ccs811_status_get(uint8_t *p_status)
Function for getting the status of the CCS811 device.
drv_ccs811_alg_result_data_get
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)
Function for getting the calculation result data of the CCS811 device.
DRV_CCS811_STATUS_CODE_SUCCESS
Successful.
Definition: drv_ccs811.h:59