Nordic Thingy:52 v2.2.0
drv_gas_sensor.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 
48 #ifndef __DRV_GAS_SENSOR_H__
49 #define __DRV_GAS_SENSOR_H__
50 
51 #include "nrf_drv_twi.h"
52 #include "drv_ccs811.h"
53 #include "drv_ccs811_bitfields.h"
54 #include "sdk_errors.h"
55 
59 
62 typedef enum
63 {
64  DRV_GAS_SENSOR_MODE_250MS,
65  DRV_GAS_SENSOR_MODE_1S,
66  DRV_GAS_SENSOR_MODE_10S,
67  DRV_GAS_SENSOR_MODE_60S
69 
73 
76 typedef struct
77 {
78  nrf_drv_twi_t const * p_twi_instance;
79  nrf_drv_twi_config_t const * p_twi_cfg;
80  uint8_t twi_addr;
83 
84 
93 ret_code_t drv_gas_sensor_calibrate_humid_temp(uint16_t rh_ppth, int32_t temp_mdeg);
94 
95 
103 ret_code_t drv_gas_sensor_baseline_get(uint16_t * p_baseline);
104 
112 ret_code_t drv_gas_sensor_baseline_set(uint16_t baseline);
113 
114 
123 ret_code_t drv_gas_sensor_raw_data_get(uint8_t * p_current_selected, uint16_t * p_raw_adc_reading);
124 
133 
142 ret_code_t drv_gas_sensor_stop(void);
143 
151 ret_code_t drv_gas_sensor_init(drv_gas_init_t * p_init);
152 
153 #endif
154 
The algorithm result data of the CCS811 device.
Definition: drv_ccs811.h:87
drv_gas_sensor_mode_t
Gas sensor measurement intervals.
Definition: drv_gas_sensor.h:62
drv_gas_sensor_data_handler_t data_handler
Handler to be called when data capture has finished.
Definition: drv_gas_sensor.h:81
nrf_drv_twi_t const * p_twi_instance
The TWI instance.
Definition: drv_gas_sensor.h:78
ret_code_t drv_gas_sensor_start(drv_gas_sensor_mode_t mode)
Function for starting data acquisition from the the gas sensor.
Gas sensor init struct.
Definition: drv_gas_sensor.h:76
ret_code_t drv_gas_sensor_baseline_get(uint16_t *p_baseline)
Function for reading a baseline value from the gas sensor.
uint8_t twi_addr
TWI address on bus.
Definition: drv_gas_sensor.h:80
ret_code_t drv_gas_sensor_baseline_set(uint16_t baseline)
Function for writing a baseline value to the gas sensor.
ret_code_t drv_gas_sensor_init(drv_gas_init_t *p_init)
Function for initializing the gas sensor.
void(* drv_gas_sensor_data_handler_t)(drv_gas_sensor_data_t const *p_evt)
Gas sensor driver event handler callback type.
Definition: drv_gas_sensor.h:72
nrf_drv_twi_config_t const * p_twi_cfg
TWI configuraion.
Definition: drv_gas_sensor.h:79
ret_code_t drv_gas_sensor_raw_data_get(uint8_t *p_current_selected, uint16_t *p_raw_adc_reading)
Function for getting a baseline value from the gas sensor.
ret_code_t drv_gas_sensor_stop(void)
Function for stopping data acquisition from the the gas sensor.
ret_code_t drv_gas_sensor_calibrate_humid_temp(uint16_t rh_ppth, int32_t temp_mdeg)
Function for calibrating the gas sensor based on the ambient humidity and temperature.
drv_ccs811_alg_result_t drv_gas_sensor_data_t
Struct for holding the measurement results.
Definition: drv_gas_sensor.h:58