Data Logger BLE Cellular Board
Loading...
Searching...
No Matches
bme68x_defs.h
Go to the documentation of this file.
1/**
2* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
3*
4* BSD-3-Clause
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8*
9* 1. Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11*
12* 2. Redistributions in binary form must reproduce the above copyright
13* notice, this list of conditions and the following disclaimer in the
14* documentation and/or other materials provided with the distribution.
15*
16* 3. Neither the name of the copyright holder nor the names of its
17* contributors may be used to endorse or promote products derived from
18* this software without specific prior written permission.
19*
20* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31* POSSIBILITY OF SUCH DAMAGE.
32*
33* @file bme68x_defs.h
34* @date 2023-02-07
35* @version v4.4.8
36*
37*/
38
39/*! @cond DOXYGEN_SUPRESS */
40
41#ifndef BME68X_DEFS_H_
42#define BME68X_DEFS_H_
43
44/********************************************************* */
45/*! Header includes */
46/********************************************************* */
47#ifdef __KERNEL__
48#include <linux/types.h>
49#include <linux/kernel.h>
50#else
51#include <stdint.h>
52#include <stddef.h>
53#endif
54
55/********************************************************* */
56/*! Common Macros */
57/********************************************************* */
58#ifdef __KERNEL__
59#if !defined(UINT8_C) && !defined(INT8_C)
60#define INT8_C(x) S8_C(x)
61#define UINT8_C(x) U8_C(x)
62#endif
63
64#if !defined(UINT16_C) && !defined(INT16_C)
65#define INT16_C(x) S16_C(x)
66#define UINT16_C(x) U16_C(x)
67#endif
68
69#if !defined(INT32_C) && !defined(UINT32_C)
70#define INT32_C(x) S32_C(x)
71#define UINT32_C(x) U32_C(x)
72#endif
73
74#if !defined(INT64_C) && !defined(UINT64_C)
75#define INT64_C(x) S64_C(x)
76#define UINT64_C(x) U64_C(x)
77#endif
78#endif
79
80/*! C standard macros */
81#ifndef NULL
82#ifdef __cplusplus
83#define NULL 0
84#else
85#define NULL ((void *) 0)
86#endif
87#endif
88
89#ifndef BME68X_DO_NOT_USE_FPU
90
91/* Comment or un-comment the macro to provide floating point data output */
92#define BME68X_USE_FPU
93#endif
94
95/* Period between two polls (value can be given by user) */
96#ifndef BME68X_PERIOD_POLL
97#define BME68X_PERIOD_POLL UINT32_C(10000)
98#endif
99
100/* BME68X unique chip identifier */
101#define BME68X_CHIP_ID UINT8_C(0x61)
102
103/* Period for a soft reset */
104#define BME68X_PERIOD_RESET UINT32_C(10000)
105
106/* BME68X lower I2C address */
107#define BME68X_I2C_ADDR_LOW UINT8_C(0x76)
108
109/* BME68X higher I2C address */
110#define BME68X_I2C_ADDR_HIGH UINT8_C(0x77)
111
112/* Soft reset command */
113#define BME68X_SOFT_RESET_CMD UINT8_C(0xb6)
114
115/* Return code definitions */
116/* Success */
117#define BME68X_OK INT8_C(0)
118
119/* Errors */
120/* Null pointer passed */
121#define BME68X_E_NULL_PTR INT8_C(-1)
122
123/* Communication failure */
124#define BME68X_E_COM_FAIL INT8_C(-2)
125
126/* Sensor not found */
127#define BME68X_E_DEV_NOT_FOUND INT8_C(-3)
128
129/* Incorrect length parameter */
130#define BME68X_E_INVALID_LENGTH INT8_C(-4)
131
132/* Self test fail error */
133#define BME68X_E_SELF_TEST INT8_C(-5)
134
135/* Warnings */
136/* Define a valid operation mode */
137#define BME68X_W_DEFINE_OP_MODE INT8_C(1)
138
139/* No new data was found */
140#define BME68X_W_NO_NEW_DATA INT8_C(2)
141
142/* Define the shared heating duration */
143#define BME68X_W_DEFINE_SHD_HEATR_DUR INT8_C(3)
144
145/* Information - only available via bme68x_dev.info_msg */
146#define BME68X_I_PARAM_CORR UINT8_C(1)
147
148/* Register map addresses in I2C */
149/* Register for 3rd group of coefficients */
150#define BME68X_REG_COEFF3 UINT8_C(0x00)
151
152/* 0th Field address*/
153#define BME68X_REG_FIELD0 UINT8_C(0x1d)
154
155/* 0th Current DAC address*/
156#define BME68X_REG_IDAC_HEAT0 UINT8_C(0x50)
157
158/* 0th Res heat address */
159#define BME68X_REG_RES_HEAT0 UINT8_C(0x5a)
160
161/* 0th Gas wait address */
162#define BME68X_REG_GAS_WAIT0 UINT8_C(0x64)
163
164/* Shared heating duration address */
165#define BME68X_REG_SHD_HEATR_DUR UINT8_C(0x6E)
166
167/* CTRL_GAS_0 address */
168#define BME68X_REG_CTRL_GAS_0 UINT8_C(0x70)
169
170/* CTRL_GAS_1 address */
171#define BME68X_REG_CTRL_GAS_1 UINT8_C(0x71)
172
173/* CTRL_HUM address */
174#define BME68X_REG_CTRL_HUM UINT8_C(0x72)
175
176/* CTRL_MEAS address */
177#define BME68X_REG_CTRL_MEAS UINT8_C(0x74)
178
179/* CONFIG address */
180#define BME68X_REG_CONFIG UINT8_C(0x75)
181
182/* MEM_PAGE address */
183#define BME68X_REG_MEM_PAGE UINT8_C(0xf3)
184
185/* Unique ID address */
186#define BME68X_REG_UNIQUE_ID UINT8_C(0x83)
187
188/* Register for 1st group of coefficients */
189#define BME68X_REG_COEFF1 UINT8_C(0x8a)
190
191/* Chip ID address */
192#define BME68X_REG_CHIP_ID UINT8_C(0xd0)
193
194/* Soft reset address */
195#define BME68X_REG_SOFT_RESET UINT8_C(0xe0)
196
197/* Register for 2nd group of coefficients */
198#define BME68X_REG_COEFF2 UINT8_C(0xe1)
199
200/* Variant ID Register */
201#define BME68X_REG_VARIANT_ID UINT8_C(0xF0)
202
203/* Enable/Disable macros */
204
205/* Enable */
206#define BME68X_ENABLE UINT8_C(0x01)
207
208/* Disable */
209#define BME68X_DISABLE UINT8_C(0x00)
210
211/* Variant ID macros */
212
213/* Low Gas variant */
214#define BME68X_VARIANT_GAS_LOW UINT8_C(0x00)
215
216/* High Gas variant */
217#define BME68X_VARIANT_GAS_HIGH UINT8_C(0x01)
218
219/* Oversampling setting macros */
220
221/* Switch off measurement */
222#define BME68X_OS_NONE UINT8_C(0)
223
224/* Perform 1 measurement */
225#define BME68X_OS_1X UINT8_C(1)
226
227/* Perform 2 measurements */
228#define BME68X_OS_2X UINT8_C(2)
229
230/* Perform 4 measurements */
231#define BME68X_OS_4X UINT8_C(3)
232
233/* Perform 8 measurements */
234#define BME68X_OS_8X UINT8_C(4)
235
236/* Perform 16 measurements */
237#define BME68X_OS_16X UINT8_C(5)
238
239/* IIR Filter settings */
240
241/* Switch off the filter */
242#define BME68X_FILTER_OFF UINT8_C(0)
243
244/* Filter coefficient of 2 */
245#define BME68X_FILTER_SIZE_1 UINT8_C(1)
246
247/* Filter coefficient of 4 */
248#define BME68X_FILTER_SIZE_3 UINT8_C(2)
249
250/* Filter coefficient of 8 */
251#define BME68X_FILTER_SIZE_7 UINT8_C(3)
252
253/* Filter coefficient of 16 */
254#define BME68X_FILTER_SIZE_15 UINT8_C(4)
255
256/* Filter coefficient of 32 */
257#define BME68X_FILTER_SIZE_31 UINT8_C(5)
258
259/* Filter coefficient of 64 */
260#define BME68X_FILTER_SIZE_63 UINT8_C(6)
261
262/* Filter coefficient of 128 */
263#define BME68X_FILTER_SIZE_127 UINT8_C(7)
264
265/* ODR/Standby time macros */
266
267/* Standby time of 0.59ms */
268#define BME68X_ODR_0_59_MS UINT8_C(0)
269
270/* Standby time of 62.5ms */
271#define BME68X_ODR_62_5_MS UINT8_C(1)
272
273/* Standby time of 125ms */
274#define BME68X_ODR_125_MS UINT8_C(2)
275
276/* Standby time of 250ms */
277#define BME68X_ODR_250_MS UINT8_C(3)
278
279/* Standby time of 500ms */
280#define BME68X_ODR_500_MS UINT8_C(4)
281
282/* Standby time of 1s */
283#define BME68X_ODR_1000_MS UINT8_C(5)
284
285/* Standby time of 10ms */
286#define BME68X_ODR_10_MS UINT8_C(6)
287
288/* Standby time of 20ms */
289#define BME68X_ODR_20_MS UINT8_C(7)
290
291/* No standby time */
292#define BME68X_ODR_NONE UINT8_C(8)
293
294/* Operating mode macros */
295
296/* Sleep operation mode */
297#define BME68X_SLEEP_MODE UINT8_C(0)
298
299/* Forced operation mode */
300#define BME68X_FORCED_MODE UINT8_C(1)
301
302/* Parallel operation mode */
303#define BME68X_PARALLEL_MODE UINT8_C(2)
304
305/* Sequential operation mode */
306#define BME68X_SEQUENTIAL_MODE UINT8_C(3)
307
308/* SPI page macros */
309
310/* SPI memory page 0 */
311#define BME68X_MEM_PAGE0 UINT8_C(0x10)
312
313/* SPI memory page 1 */
314#define BME68X_MEM_PAGE1 UINT8_C(0x00)
315
316/* Coefficient index macros */
317
318/* Length for all coefficients */
319#define BME68X_LEN_COEFF_ALL UINT8_C(42)
320
321/* Length for 1st group of coefficients */
322#define BME68X_LEN_COEFF1 UINT8_C(23)
323
324/* Length for 2nd group of coefficients */
325#define BME68X_LEN_COEFF2 UINT8_C(14)
326
327/* Length for 3rd group of coefficients */
328#define BME68X_LEN_COEFF3 UINT8_C(5)
329
330/* Length of the field */
331#define BME68X_LEN_FIELD UINT8_C(17)
332
333/* Length between two fields */
334#define BME68X_LEN_FIELD_OFFSET UINT8_C(17)
335
336/* Length of the configuration register */
337#define BME68X_LEN_CONFIG UINT8_C(5)
338
339/* Length of the interleaved buffer */
340#define BME68X_LEN_INTERLEAVE_BUFF UINT8_C(20)
341
342/* Coefficient index macros */
343
344/* Coefficient T2 LSB position */
345#define BME68X_IDX_T2_LSB (0)
346
347/* Coefficient T2 MSB position */
348#define BME68X_IDX_T2_MSB (1)
349
350/* Coefficient T3 position */
351#define BME68X_IDX_T3 (2)
352
353/* Coefficient P1 LSB position */
354#define BME68X_IDX_P1_LSB (4)
355
356/* Coefficient P1 MSB position */
357#define BME68X_IDX_P1_MSB (5)
358
359/* Coefficient P2 LSB position */
360#define BME68X_IDX_P2_LSB (6)
361
362/* Coefficient P2 MSB position */
363#define BME68X_IDX_P2_MSB (7)
364
365/* Coefficient P3 position */
366#define BME68X_IDX_P3 (8)
367
368/* Coefficient P4 LSB position */
369#define BME68X_IDX_P4_LSB (10)
370
371/* Coefficient P4 MSB position */
372#define BME68X_IDX_P4_MSB (11)
373
374/* Coefficient P5 LSB position */
375#define BME68X_IDX_P5_LSB (12)
376
377/* Coefficient P5 MSB position */
378#define BME68X_IDX_P5_MSB (13)
379
380/* Coefficient P7 position */
381#define BME68X_IDX_P7 (14)
382
383/* Coefficient P6 position */
384#define BME68X_IDX_P6 (15)
385
386/* Coefficient P8 LSB position */
387#define BME68X_IDX_P8_LSB (18)
388
389/* Coefficient P8 MSB position */
390#define BME68X_IDX_P8_MSB (19)
391
392/* Coefficient P9 LSB position */
393#define BME68X_IDX_P9_LSB (20)
394
395/* Coefficient P9 MSB position */
396#define BME68X_IDX_P9_MSB (21)
397
398/* Coefficient P10 position */
399#define BME68X_IDX_P10 (22)
400
401/* Coefficient H2 MSB position */
402#define BME68X_IDX_H2_MSB (23)
403
404/* Coefficient H2 LSB position */
405#define BME68X_IDX_H2_LSB (24)
406
407/* Coefficient H1 LSB position */
408#define BME68X_IDX_H1_LSB (24)
409
410/* Coefficient H1 MSB position */
411#define BME68X_IDX_H1_MSB (25)
412
413/* Coefficient H3 position */
414#define BME68X_IDX_H3 (26)
415
416/* Coefficient H4 position */
417#define BME68X_IDX_H4 (27)
418
419/* Coefficient H5 position */
420#define BME68X_IDX_H5 (28)
421
422/* Coefficient H6 position */
423#define BME68X_IDX_H6 (29)
424
425/* Coefficient H7 position */
426#define BME68X_IDX_H7 (30)
427
428/* Coefficient T1 LSB position */
429#define BME68X_IDX_T1_LSB (31)
430
431/* Coefficient T1 MSB position */
432#define BME68X_IDX_T1_MSB (32)
433
434/* Coefficient GH2 LSB position */
435#define BME68X_IDX_GH2_LSB (33)
436
437/* Coefficient GH2 MSB position */
438#define BME68X_IDX_GH2_MSB (34)
439
440/* Coefficient GH1 position */
441#define BME68X_IDX_GH1 (35)
442
443/* Coefficient GH3 position */
444#define BME68X_IDX_GH3 (36)
445
446/* Coefficient res heat value position */
447#define BME68X_IDX_RES_HEAT_VAL (37)
448
449/* Coefficient res heat range position */
450#define BME68X_IDX_RES_HEAT_RANGE (39)
451
452/* Coefficient range switching error position */
453#define BME68X_IDX_RANGE_SW_ERR (41)
454
455/* Gas measurement macros */
456
457/* Disable gas measurement */
458#define BME68X_DISABLE_GAS_MEAS UINT8_C(0x00)
459
460/* Enable gas measurement low */
461#define BME68X_ENABLE_GAS_MEAS_L UINT8_C(0x01)
462
463/* Enable gas measurement high */
464#define BME68X_ENABLE_GAS_MEAS_H UINT8_C(0x02)
465
466/* Heater control macros */
467
468/* Enable heater */
469#define BME68X_ENABLE_HEATER UINT8_C(0x00)
470
471/* Disable heater */
472#define BME68X_DISABLE_HEATER UINT8_C(0x01)
473
474#ifdef BME68X_USE_FPU
475
476/* 0 degree Celsius */
477#define BME68X_MIN_TEMPERATURE INT16_C(0)
478
479/* 60 degree Celsius */
480#define BME68X_MAX_TEMPERATURE INT16_C(60)
481
482/* 900 hecto Pascals */
483#define BME68X_MIN_PRESSURE UINT32_C(90000)
484
485/* 1100 hecto Pascals */
486#define BME68X_MAX_PRESSURE UINT32_C(110000)
487
488/* 20% relative humidity */
489#define BME68X_MIN_HUMIDITY UINT32_C(20)
490
491/* 80% relative humidity*/
492#define BME68X_MAX_HUMIDITY UINT32_C(80)
493#else
494
495/* 0 degree Celsius */
496#define BME68X_MIN_TEMPERATURE INT16_C(0)
497
498/* 60 degree Celsius */
499#define BME68X_MAX_TEMPERATURE INT16_C(6000)
500
501/* 900 hecto Pascals */
502#define BME68X_MIN_PRESSURE UINT32_C(90000)
503
504/* 1100 hecto Pascals */
505#define BME68X_MAX_PRESSURE UINT32_C(110000)
506
507/* 20% relative humidity */
508#define BME68X_MIN_HUMIDITY UINT32_C(20000)
509
510/* 80% relative humidity*/
511#define BME68X_MAX_HUMIDITY UINT32_C(80000)
512
513#endif
514
515#define BME68X_HEATR_DUR1 UINT16_C(1000)
516#define BME68X_HEATR_DUR2 UINT16_C(2000)
517#define BME68X_HEATR_DUR1_DELAY UINT32_C(1000000)
518#define BME68X_HEATR_DUR2_DELAY UINT32_C(2000000)
519#define BME68X_N_MEAS UINT8_C(6)
520#define BME68X_LOW_TEMP UINT8_C(150)
521#define BME68X_HIGH_TEMP UINT16_C(350)
522
523/* Mask macros */
524/* Mask for number of conversions */
525#define BME68X_NBCONV_MSK UINT8_C(0X0f)
526
527/* Mask for IIR filter */
528#define BME68X_FILTER_MSK UINT8_C(0X1c)
529
530/* Mask for ODR[3] */
531#define BME68X_ODR3_MSK UINT8_C(0x80)
532
533/* Mask for ODR[2:0] */
534#define BME68X_ODR20_MSK UINT8_C(0xe0)
535
536/* Mask for temperature oversampling */
537#define BME68X_OST_MSK UINT8_C(0Xe0)
538
539/* Mask for pressure oversampling */
540#define BME68X_OSP_MSK UINT8_C(0X1c)
541
542/* Mask for humidity oversampling */
543#define BME68X_OSH_MSK UINT8_C(0X07)
544
545/* Mask for heater control */
546#define BME68X_HCTRL_MSK UINT8_C(0x08)
547
548/* Mask for run gas */
549#define BME68X_RUN_GAS_MSK UINT8_C(0x30)
550
551/* Mask for operation mode */
552#define BME68X_MODE_MSK UINT8_C(0x03)
553
554/* Mask for res heat range */
555#define BME68X_RHRANGE_MSK UINT8_C(0x30)
556
557/* Mask for range switching error */
558#define BME68X_RSERROR_MSK UINT8_C(0xf0)
559
560/* Mask for new data */
561#define BME68X_NEW_DATA_MSK UINT8_C(0x80)
562
563/* Mask for gas index */
564#define BME68X_GAS_INDEX_MSK UINT8_C(0x0f)
565
566/* Mask for gas range */
567#define BME68X_GAS_RANGE_MSK UINT8_C(0x0f)
568
569/* Mask for gas measurement valid */
570#define BME68X_GASM_VALID_MSK UINT8_C(0x20)
571
572/* Mask for heater stability */
573#define BME68X_HEAT_STAB_MSK UINT8_C(0x10)
574
575/* Mask for SPI memory page */
576#define BME68X_MEM_PAGE_MSK UINT8_C(0x10)
577
578/* Mask for reading a register in SPI */
579#define BME68X_SPI_RD_MSK UINT8_C(0x80)
580
581/* Mask for writing a register in SPI */
582#define BME68X_SPI_WR_MSK UINT8_C(0x7f)
583
584/* Mask for the H1 calibration coefficient */
585#define BME68X_BIT_H1_DATA_MSK UINT8_C(0x0f)
586
587/* Position macros */
588
589/* Filter bit position */
590#define BME68X_FILTER_POS UINT8_C(2)
591
592/* Temperature oversampling bit position */
593#define BME68X_OST_POS UINT8_C(5)
594
595/* Pressure oversampling bit position */
596#define BME68X_OSP_POS UINT8_C(2)
597
598/* ODR[3] bit position */
599#define BME68X_ODR3_POS UINT8_C(7)
600
601/* ODR[2:0] bit position */
602#define BME68X_ODR20_POS UINT8_C(5)
603
604/* Run gas bit position */
605#define BME68X_RUN_GAS_POS UINT8_C(4)
606
607/* Heater control bit position */
608#define BME68X_HCTRL_POS UINT8_C(3)
609
610/* Macro to combine two 8 bit data's to form a 16 bit data */
611#define BME68X_CONCAT_BYTES(msb, lsb) (((uint16_t)msb << 8) | (uint16_t)lsb)
612
613/* Macro to set bits */
614#define BME68X_SET_BITS(reg_data, bitname, data) \
615 ((reg_data & ~(bitname##_MSK)) | \
616 ((data << bitname##_POS) & bitname##_MSK))
617
618/* Macro to get bits */
619#define BME68X_GET_BITS(reg_data, bitname) ((reg_data & (bitname##_MSK)) >> \
620 (bitname##_POS))
621
622/* Macro to set bits starting from position 0 */
623#define BME68X_SET_BITS_POS_0(reg_data, bitname, data) \
624 ((reg_data & ~(bitname##_MSK)) | \
625 (data & bitname##_MSK))
626
627/* Macro to get bits starting from position 0 */
628#define BME68X_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
629
630/**
631 * BME68X_INTF_RET_TYPE is the read/write interface return type which can be overwritten by the build system.
632 * The default is set to int8_t.
633 */
634#ifndef BME68X_INTF_RET_TYPE
635#define BME68X_INTF_RET_TYPE int8_t
636#endif
637
638/**
639 * BME68X_INTF_RET_SUCCESS is the success return value read/write interface return type which can be
640 * overwritten by the build system. The default is set to 0. It is used to check for a successful
641 * execution of the read/write functions
642 */
643#ifndef BME68X_INTF_RET_SUCCESS
644#define BME68X_INTF_RET_SUCCESS INT8_C(0)
645#endif
646
647/********************************************************* */
648/*! Function Pointers */
649/********************************************************* */
650
651/*!
652 * @brief Bus communication function pointer which should be mapped to
653 * the platform specific read functions of the user
654 *
655 * @param[in] reg_addr : 8bit register address of the sensor
656 * @param[out] reg_data : Data from the specified address
657 * @param[in] length : Length of the reg_data array
658 * @param[in,out] intf_ptr : Void pointer that can enable the linking of descriptors
659 * for interface related callbacks
660 * @retval 0 for Success
661 * @retval Non-zero for Failure
662 */
663typedef BME68X_INTF_RET_TYPE (*bme68x_read_fptr_t)(uint8_t reg_addr, uint8_t *reg_data, uint32_t length,
664 void *intf_ptr);
665
666/*!
667 * @brief Bus communication function pointer which should be mapped to
668 * the platform specific write functions of the user
669 *
670 * @param[in] reg_addr : 8bit register address of the sensor
671 * @param[out] reg_data : Data to the specified address
672 * @param[in] length : Length of the reg_data array
673 * @param[in,out] intf_ptr : Void pointer that can enable the linking of descriptors
674 * for interface related callbacks
675 * @retval 0 for Success
676 * @retval Non-zero for Failure
677 *
678 */
679typedef BME68X_INTF_RET_TYPE (*bme68x_write_fptr_t)(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length,
680 void *intf_ptr);
681
682/*!
683 * @brief Delay function pointer which should be mapped to
684 * delay function of the user
685 *
686 * @param period - The time period in microseconds
687 * @param[in,out] intf_ptr : Void pointer that can enable the linking of descriptors
688 * for interface related callbacks
689 */
690typedef void (*bme68x_delay_us_fptr_t)(uint32_t period, void *intf_ptr);
691
692/*
693 * @brief Generic communication function pointer
694 * @param[in] dev_id: Place holder to store the id of the device structure
695 * Can be used to store the index of the Chip select or
696 * I2C address of the device.
697 * @param[in] reg_addr: Used to select the register the where data needs to
698 * be read from or written to.
699 * @param[in,out] reg_data: Data array to read/write
700 * @param[in] len: Length of the data array
701 */
702
703/*
704 * @brief Interface selection Enumerations
705 */
706enum bme68x_intf {
707 /*! SPI interface */
708 BME68X_SPI_INTF,
709 /*! I2C interface */
710 BME68X_I2C_INTF
711};
712
713/* Structure definitions */
714
715/*
716 * @brief Sensor field data structure
717 */
718struct bme68x_data
719{
720 /*! Contains new_data, gasm_valid & heat_stab */
721 uint8_t status;
722
723 /*! The index of the heater profile used */
724 uint8_t gas_index;
725
726 /*! Measurement index to track order */
727 uint8_t meas_index;
728
729 /*! Heater resistance */
730 uint8_t res_heat;
731
732 /*! Current DAC */
733 uint8_t idac;
734
735 /*! Gas wait period */
736 uint8_t gas_wait;
737#ifndef BME68X_USE_FPU
738
739 /*! Temperature in degree celsius x100 */
740 int16_t temperature;
741
742 /*! Pressure in Pascal */
743 uint32_t pressure;
744
745 /*! Humidity in % relative humidity x1000 */
746 uint32_t humidity;
747
748 /*! Gas resistance in Ohms */
749 uint32_t gas_resistance;
750#else
751
752 /*! Temperature in degree celsius */
753 float temperature;
754
755 /*! Pressure in Pascal */
756 float pressure;
757
758 /*! Humidity in % relative humidity x1000 */
759 float humidity;
760
761 /*! Gas resistance in Ohms */
762 float gas_resistance;
763
764#endif
765
766};
767
768/*
769 * @brief Structure to hold the calibration coefficients
770 */
771struct bme68x_calib_data
772{
773 /*! Calibration coefficient for the humidity sensor */
774 uint16_t par_h1;
775
776 /*! Calibration coefficient for the humidity sensor */
777 uint16_t par_h2;
778
779 /*! Calibration coefficient for the humidity sensor */
780 int8_t par_h3;
781
782 /*! Calibration coefficient for the humidity sensor */
783 int8_t par_h4;
784
785 /*! Calibration coefficient for the humidity sensor */
786 int8_t par_h5;
787
788 /*! Calibration coefficient for the humidity sensor */
789 uint8_t par_h6;
790
791 /*! Calibration coefficient for the humidity sensor */
792 int8_t par_h7;
793
794 /*! Calibration coefficient for the gas sensor */
795 int8_t par_gh1;
796
797 /*! Calibration coefficient for the gas sensor */
798 int16_t par_gh2;
799
800 /*! Calibration coefficient for the gas sensor */
801 int8_t par_gh3;
802
803 /*! Calibration coefficient for the temperature sensor */
804 uint16_t par_t1;
805
806 /*! Calibration coefficient for the temperature sensor */
807 int16_t par_t2;
808
809 /*! Calibration coefficient for the temperature sensor */
810 int8_t par_t3;
811
812 /*! Calibration coefficient for the pressure sensor */
813 uint16_t par_p1;
814
815 /*! Calibration coefficient for the pressure sensor */
816 int16_t par_p2;
817
818 /*! Calibration coefficient for the pressure sensor */
819 int8_t par_p3;
820
821 /*! Calibration coefficient for the pressure sensor */
822 int16_t par_p4;
823
824 /*! Calibration coefficient for the pressure sensor */
825 int16_t par_p5;
826
827 /*! Calibration coefficient for the pressure sensor */
828 int8_t par_p6;
829
830 /*! Calibration coefficient for the pressure sensor */
831 int8_t par_p7;
832
833 /*! Calibration coefficient for the pressure sensor */
834 int16_t par_p8;
835
836 /*! Calibration coefficient for the pressure sensor */
837 int16_t par_p9;
838
839 /*! Calibration coefficient for the pressure sensor */
840 uint8_t par_p10;
841#ifndef BME68X_USE_FPU
842
843 /*! Variable to store the intermediate temperature coefficient */
844 int32_t t_fine;
845#else
846
847 /*! Variable to store the intermediate temperature coefficient */
848 float t_fine;
849#endif
850
851 /*! Heater resistance range coefficient */
852 uint8_t res_heat_range;
853
854 /*! Heater resistance value coefficient */
855 int8_t res_heat_val;
856
857 /*! Gas resistance range switching error coefficient */
858 int8_t range_sw_err;
859};
860
861/*
862 * @brief BME68X sensor settings structure which comprises of ODR,
863 * over-sampling and filter settings.
864 */
865struct bme68x_conf
866{
867 /*! Humidity oversampling. Refer @ref osx*/
868 uint8_t os_hum;
869
870 /*! Temperature oversampling. Refer @ref osx */
871 uint8_t os_temp;
872
873 /*! Pressure oversampling. Refer @ref osx */
874 uint8_t os_pres;
875
876 /*! Filter coefficient. Refer @ref filter*/
877 uint8_t filter;
878
879 /*!
880 * Standby time between sequential mode measurement profiles.
881 * Refer @ref odr
882 */
883 uint8_t odr;
884};
885
886/*
887 * @brief BME68X gas heater configuration
888 */
889struct bme68x_heatr_conf
890{
891 /*! Enable gas measurement. Refer @ref en_dis */
892 uint8_t enable;
893
894 /*! Store the heater temperature for forced mode degree Celsius */
895 uint16_t heatr_temp;
896
897 /*! Store the heating duration for forced mode in milliseconds */
898 uint16_t heatr_dur;
899
900 /*! Store the heater temperature profile in degree Celsius */
901 uint16_t *heatr_temp_prof;
902
903 /*! Store the heating duration profile in milliseconds */
904 uint16_t *heatr_dur_prof;
905
906 /*! Variable to store the length of the heating profile */
907 uint8_t profile_len;
908
909 /*!
910 * Variable to store heating duration for parallel mode
911 * in milliseconds
912 */
913 uint16_t shared_heatr_dur;
914};
915
916/*
917 * @brief BME68X device structure
918 */
919struct bme68x_dev
920{
921 /*! Chip Id */
922 uint8_t chip_id;
923
924 /*!
925 * The interface pointer is used to enable the user
926 * to link their interface descriptors for reference during the
927 * implementation of the read and write interfaces to the
928 * hardware.
929 */
930 void *intf_ptr;
931
932 /*!
933 * Variant id
934 * ----------------------------------------
935 * Value | Variant
936 * ----------------------------------------
937 * 0 | BME68X_VARIANT_GAS_LOW
938 * 1 | BME68X_VARIANT_GAS_HIGH
939 * ----------------------------------------
940 */
941 uint32_t variant_id;
942
943 /*! SPI/I2C interface */
944 enum bme68x_intf intf;
945
946 /*! Memory page used */
947 uint8_t mem_page;
948
949 /*! Ambient temperature in Degree C*/
950 int8_t amb_temp;
951
952 /*! Sensor calibration data */
953 struct bme68x_calib_data calib;
954
955 /*! Read function pointer */
956 bme68x_read_fptr_t read;
957
958 /*! Write function pointer */
959 bme68x_write_fptr_t write;
960
961 /*! Delay function pointer */
962 bme68x_delay_us_fptr_t delay_us;
963
964 /*! To store interface pointer error */
965 BME68X_INTF_RET_TYPE intf_rslt;
966
967 /*! Store the info messages */
968 uint8_t info_msg;
969};
970
971#endif /* BME68X_DEFS_H_ */
972/*! @endcond */