Data Logger BLE Cellular Board
Loading...
Searching...
No Matches
bme68x.h
Go to the documentation of this file.
1/** \file bme68x.h
2 * \brief BME68X Sensor API header file
3 *
4 * \copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
5 * \date 2023-02-07
6 * \version v4.4.8
7 *
8 * \note BSD-3-Clause
9 *
10 * \note Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met: \n
12 *
13 * \note 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. \n
15 *
16 * \note 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution. \n
19 *
20 * \note 3. Neither the name of the copyright holder nor the names of its
21 * contributors may be used to endorse or promote products derived from
22 * this software without specific prior written permission. \n
23 *
24 * \note THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
34 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 *
38 */
39
40/*!
41 * @defgroup bme68x BME68X
42 * @brief <a href="https://www.bosch-sensortec.com/bst/products/all_products/bme680">Product Overview</a>
43 * and <a href="https://github.com/BoschSensortec/BME68x-Sensor-API">Sensor API Source Code</a>
44 */
45
46#ifndef BME68X_H_
47#define BME68X_H_
48
49#include "bme68x_defs.h"
50
51/* CPP guard */
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56/**
57 * \ingroup bme68x
58 * \defgroup bme68xApiInit Initialization
59 * @brief Initialize the sensor and device structure
60 */
61
62/*!
63 * \ingroup bme68xApiInit
64 * \page bme68x_api_bme68x_init bme68x_init
65 * \code
66 * int8_t bme68x_init(struct bme68x_dev *dev);
67 * \endcode
68 * @details This API reads the chip-id of the sensor which is the first step to
69 * verify the sensor and also calibrates the sensor
70 * As this API is the entry point, call this API before using other APIs.
71 *
72 * @param[in,out] dev : Structure instance of bme68x_dev
73 *
74 * @return Result of API execution status
75 * @retval 0 -> Success
76 * @retval < 0 -> Fail
77 */
78int8_t bme68x_init(struct bme68x_dev *dev);
79
80/**
81 * \ingroup bme68x
82 * \defgroup bme68xApiRegister Registers
83 * @brief Generic API for accessing sensor registers
84 */
85
86/*!
87 * \ingroup bme68xApiRegister
88 * \page bme68x_api_bme68x_set_regs bme68x_set_regs
89 * \code
90 * int8_t bme68x_set_regs(const uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, struct bme68x_dev *dev)
91 * \endcode
92 * @details This API writes the given data to the register address of the sensor
93 *
94 * @param[in] reg_addr : Register addresses to where the data is to be written
95 * @param[in] reg_data : Pointer to data buffer which is to be written
96 * in the reg_addr of sensor.
97 * @param[in] len : No of bytes of data to write
98 * @param[in,out] dev : Structure instance of bme68x_dev
99 *
100 * @return Result of API execution status
101 * @retval 0 -> Success
102 * @retval < 0 -> Fail
103 */
104int8_t bme68x_set_regs(const uint8_t *reg_addr, const uint8_t *reg_data, uint32_t len, struct bme68x_dev *dev);
105
106/*!
107 * \ingroup bme68xApiRegister
108 * \page bme68x_api_bme68x_get_regs bme68x_get_regs
109 * \code
110 * int8_t bme68x_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct bme68x_dev *dev)
111 * \endcode
112 * @details This API reads the data from the given register address of sensor.
113 *
114 * @param[in] reg_addr : Register address from where the data to be read
115 * @param[out] reg_data : Pointer to data buffer to store the read data.
116 * @param[in] len : No of bytes of data to be read.
117 * @param[in,out] dev : Structure instance of bme68x_dev.
118 *
119 * @return Result of API execution status
120 * @retval 0 -> Success
121 * @retval < 0 -> Fail
122 */
123int8_t bme68x_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct bme68x_dev *dev);
124
125/**
126 * \ingroup bme68x
127 * \defgroup bme68xApiSystem System
128 * @brief API that performs system-level operations
129 */
130
131/*!
132 * \ingroup bme68xApiSystem
133 * \page bme68x_api_bme68x_soft_reset bme68x_soft_reset
134 * \code
135 * int8_t bme68x_soft_reset(struct bme68x_dev *dev);
136 * \endcode
137 * @details This API soft-resets the sensor.
138 *
139 * @param[in,out] dev : Structure instance of bme68x_dev.
140 *
141 * @return Result of API execution status
142 * @retval 0 -> Success
143 * @retval < 0 -> Fail
144 */
145int8_t bme68x_soft_reset(struct bme68x_dev *dev);
146
147/**
148 * \ingroup bme68x
149 * \defgroup bme68xApiOm Operation mode
150 * @brief API to configure operation mode
151 */
152
153/*!
154 * \ingroup bme68xApiOm
155 * \page bme68x_api_bme68x_set_op_mode bme68x_set_op_mode
156 * \code
157 * int8_t bme68x_set_op_mode(const uint8_t op_mode, struct bme68x_dev *dev);
158 * \endcode
159 * @details This API is used to set the operation mode of the sensor
160 * @param[in] op_mode : Desired operation mode.
161 * @param[in] dev : Structure instance of bme68x_dev
162 *
163 * @return Result of API execution status
164 * @retval 0 -> Success
165 * @retval < 0 -> Fail
166 */
167int8_t bme68x_set_op_mode(const uint8_t op_mode, struct bme68x_dev *dev);
168
169/*!
170 * \ingroup bme68xApiOm
171 * \page bme68x_api_bme68x_get_op_mode bme68x_get_op_mode
172 * \code
173 * int8_t bme68x_get_op_mode(uint8_t *op_mode, struct bme68x_dev *dev);
174 * \endcode
175 * @details This API is used to get the operation mode of the sensor.
176 *
177 * @param[out] op_mode : Desired operation mode.
178 * @param[in,out] dev : Structure instance of bme68x_dev
179 *
180 * @return Result of API execution status
181 * @retval 0 -> Success
182 * @retval < 0 -> Fail
183 */
184int8_t bme68x_get_op_mode(uint8_t *op_mode, struct bme68x_dev *dev);
185
186/*!
187 * \ingroup bme68xApiConfig
188 * \page bme68x_api_bme68x_get_meas_dur bme68x_get_meas_dur
189 * \code
190 * uint32_t bme68x_get_meas_dur(const uint8_t op_mode, struct bme68x_conf *conf, struct bme68x_dev *dev);
191 * \endcode
192 * @details This API is used to get the remaining duration that can be used for heating.
193 *
194 * @param[in] op_mode : Desired operation mode.
195 * @param[in] conf : Desired sensor configuration.
196 * @param[in] dev : Structure instance of bme68x_dev
197 *
198 * @return Measurement duration calculated in microseconds
199 */
200uint32_t bme68x_get_meas_dur(const uint8_t op_mode, struct bme68x_conf *conf, struct bme68x_dev *dev);
201
202/**
203 * \ingroup bme68x
204 * \defgroup bme68xApiData Data Read out
205 * @brief Read our data from the sensor
206 */
207
208/*!
209 * \ingroup bme68xApiData
210 * \page bme68x_api_bme68x_get_data bme68x_get_data
211 * \code
212 * int8_t bme68x_get_data(uint8_t op_mode, struct bme68x_data *data, uint8_t *n_data, struct bme68x_dev *dev);
213 * \endcode
214 * @details This API reads the pressure, temperature and humidity and gas data
215 * from the sensor, compensates the data and store it in the bme68x_data
216 * structure instance passed by the user.
217 *
218 * @param[in] op_mode : Expected operation mode.
219 * @param[out] data : Structure instance to hold the data.
220 * @param[out] n_data : Number of data instances available.
221 * @param[in,out] dev : Structure instance of bme68x_dev
222 *
223 * @return Result of API execution status
224 * @retval 0 -> Success
225 * @retval < 0 -> Fail
226 */
227int8_t bme68x_get_data(uint8_t op_mode, struct bme68x_data *data, uint8_t *n_data, struct bme68x_dev *dev);
228
229/**
230 * \ingroup bme68x
231 * \defgroup bme68xApiConfig Configuration
232 * @brief Configuration API of sensor
233 */
234
235/*!
236 * \ingroup bme68xApiConfig
237 * \page bme68x_api_bme68x_set_conf bme68x_set_conf
238 * \code
239 * int8_t bme68x_set_conf(struct bme68x_conf *conf, struct bme68x_dev *dev);
240 * \endcode
241 * @details This API is used to set the oversampling, filter and odr configuration
242 *
243 * @param[in] conf : Desired sensor configuration.
244 * @param[in,out] dev : Structure instance of bme68x_dev.
245 *
246 * @return Result of API execution status
247 * @retval 0 -> Success
248 * @retval < 0 -> Fail
249 */
250int8_t bme68x_set_conf(struct bme68x_conf *conf, struct bme68x_dev *dev);
251
252/*!
253 * \ingroup bme68xApiConfig
254 * \page bme68x_api_bme68x_get_conf bme68x_get_conf
255 * \code
256 * int8_t bme68x_get_conf(struct bme68x_conf *conf, struct bme68x_dev *dev);
257 * \endcode
258 * @details This API is used to get the oversampling, filter and odr
259 * configuration
260 *
261 * @param[out] conf : Present sensor configuration.
262 * @param[in,out] dev : Structure instance of bme68x_dev.
263 *
264 * @return Result of API execution status
265 * @retval 0 -> Success
266 * @retval < 0 -> Fail
267 */
268int8_t bme68x_get_conf(struct bme68x_conf *conf, struct bme68x_dev *dev);
269
270/*!
271 * \ingroup bme68xApiConfig
272 * \page bme68x_api_bme68x_set_heatr_conf bme68x_set_heatr_conf
273 * \code
274 * int8_t bme68x_set_heatr_conf(uint8_t op_mode, const struct bme68x_heatr_conf *conf, struct bme68x_dev *dev);
275 * \endcode
276 * @details This API is used to set the gas configuration of the sensor.
277 *
278 * @param[in] op_mode : Expected operation mode of the sensor.
279 * @param[in] conf : Desired heating configuration.
280 * @param[in,out] dev : Structure instance of bme68x_dev.
281 *
282 * @return Result of API execution status
283 * @retval 0 -> Success
284 * @retval < 0 -> Fail
285 */
286int8_t bme68x_set_heatr_conf(uint8_t op_mode, const struct bme68x_heatr_conf *conf, struct bme68x_dev *dev);
287
288/*!
289 * \ingroup bme68xApiConfig
290 * \page bme68x_api_bme68x_get_heatr_conf bme68x_get_heatr_conf
291 * \code
292 * int8_t bme68x_get_heatr_conf(const struct bme68x_heatr_conf *conf, struct bme68x_dev *dev);
293 * \endcode
294 * @details This API is used to get the gas configuration of the sensor.
295 *
296 * @param[out] conf : Current configurations of the gas sensor.
297 * @param[in,out] dev : Structure instance of bme68x_dev.
298 *
299 * @return Result of API execution status
300 * @retval 0 -> Success
301 * @retval < 0 -> Fail
302 */
303int8_t bme68x_get_heatr_conf(const struct bme68x_heatr_conf *conf, struct bme68x_dev *dev);
304
305/*!
306 * \ingroup bme68xApiSystem
307 * \page bme68x_api_bme68x_selftest_check bme68x_selftest_check
308 * \code
309 * int8_t bme68x_selftest_check(const struct bme68x_dev *dev);
310 * \endcode
311 * @details This API performs Self-test of low gas variant of BME68X
312 *
313 * @param[in, out] dev : Structure instance of bme68x_dev
314 *
315 * @return Result of API execution status
316 * @retval 0 -> Success
317 * @retval < 0 -> Fail
318 */
319int8_t bme68x_selftest_check(const struct bme68x_dev *dev);
320
321#ifdef __cplusplus
322}
323#endif /* End of CPP guard */
324#endif /* BME68X_H_ */
int8_t bme68x_set_regs(const uint8_t *reg_addr, const uint8_t *reg_data, uint32_t len, struct bme68x_dev *dev)
This API writes the given data to the register address of the sensor.
Definition bme68x.c:253
int8_t bme68x_set_heatr_conf(uint8_t op_mode, const struct bme68x_heatr_conf *conf, struct bme68x_dev *dev)
Definition bme68x.c:659
uint32_t bme68x_get_meas_dur(const uint8_t op_mode, struct bme68x_conf *conf, struct bme68x_dev *dev)
Definition bme68x.c:547
int8_t bme68x_set_op_mode(const uint8_t op_mode, struct bme68x_dev *dev)
Definition bme68x.c:496
int8_t bme68x_get_op_mode(uint8_t *op_mode, struct bme68x_dev *dev)
Definition bme68x.c:528
int8_t bme68x_get_heatr_conf(const struct bme68x_heatr_conf *conf, struct bme68x_dev *dev)
This API is used to get the gas configuration of the sensor.
Definition bme68x.c:703
int8_t bme68x_init(struct bme68x_dev *dev)
Initializes the BME68X sensor.
Definition bme68x.c:215
int8_t bme68x_get_conf(struct bme68x_conf *conf, struct bme68x_dev *dev)
Definition bme68x.c:468
int8_t bme68x_soft_reset(struct bme68x_dev *dev)
Triggers a software reset on the BME68X sensor.
Definition bme68x.c:353
int8_t bme68x_get_data(uint8_t op_mode, struct bme68x_data *data, uint8_t *n_data, struct bme68x_dev *dev)
Definition bme68x.c:591
int8_t bme68x_selftest_check(const struct bme68x_dev *dev)
Definition bme68x.c:735
int8_t bme68x_set_conf(struct bme68x_conf *conf, struct bme68x_dev *dev)
Sets the oversampling, filter and ODR configurations of the sensor.
Definition bme68x.c:398
int8_t bme68x_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct bme68x_dev *dev)
This API reads the data from the given register address of sensor.
Definition bme68x.c:318