55 #ifndef BME680_DEFS_H_ 56 #define BME680_DEFS_H_ 61 #include <linux/types.h> 67 #if (LONG_MAX) > 0x7fffffff 68 #define __have_long64 1 69 #elif (LONG_MAX) == 0x7fffffff 70 #define __have_long32 1 78 #define UINT8_C(x) x##U 82 #if !defined(UINT16_C) 84 #if (INT_MAX) > 0x7fff 87 #define UINT16_C(x) x##U 91 #if !defined(INT32_C) && !defined(UINT32_C) 93 #define INT32_C(x) x##L 94 #define UINT32_C(x) x##UL 97 #define UINT32_C(x) x##U 101 #if !defined(INT64_C) && !defined(UINT64_C) 103 #define INT64_C(x) x##L 104 #define UINT64_C(x) x##UL 106 #define INT64_C(x) x##LL 107 #define UINT64_C(x) x##ULL 118 #define NULL ((void *) 0) 123 #define BME680_POLL_PERIOD_MS UINT8_C(10) 126 #define BME680_I2C_ADDR_PRIMARY UINT8_C(0x76) 127 #define BME680_I2C_ADDR_SECONDARY UINT8_C(0x77) 130 #define BME680_CHIP_ID UINT8_C(0x61) 133 #define BME680_COEFF_SIZE UINT8_C(0x41) 134 #define BME680_COEFF_ADDR1_LEN UINT8_C(25) 135 #define BME680_COEFF_ADDR2_LEN UINT8_C(16) 138 #define BME680_FIELD_LENGTH UINT8_C(15) 139 #define BME680_FIELD_ADDR_OFFSET UINT8_C(17) 142 #define BME680_SOFT_RESET_CMD UINT8_C(0xb6) 145 #define BME680_OK INT8_C(0) 147 #define BME680_E_NULL_PTR INT8_C(-1) 148 #define BME680_E_COM_FAIL INT8_C(-2) 149 #define BME680_E_DEV_NOT_FOUND INT8_C(-3) 150 #define BME680_E_INVALID_LENGTH INT8_C(-4) 153 #define BME680_W_DEFINE_PWR_MODE INT8_C(1) 154 #define BME680_W_NO_NEW_DATA INT8_C(2) 157 #define BME680_I_MIN_CORRECTION UINT8_C(1) 158 #define BME680_I_MAX_CORRECTION UINT8_C(2) 162 #define BME680_ADDR_RES_HEAT_VAL_ADDR UINT8_C(0x00) 163 #define BME680_ADDR_RES_HEAT_RANGE_ADDR UINT8_C(0x02) 164 #define BME680_ADDR_RANGE_SW_ERR_ADDR UINT8_C(0x04) 165 #define BME680_ADDR_SENS_CONF_START UINT8_C(0x5A) 166 #define BME680_ADDR_GAS_CONF_START UINT8_C(0x64) 169 #define BME680_FIELD0_ADDR UINT8_C(0x1d) 172 #define BME680_RES_HEAT0_ADDR UINT8_C(0x5a) 173 #define BME680_GAS_WAIT0_ADDR UINT8_C(0x64) 176 #define BME680_CONF_HEAT_CTRL_ADDR UINT8_C(0x70) 177 #define BME680_CONF_ODR_RUN_GAS_NBC_ADDR UINT8_C(0x71) 178 #define BME680_CONF_OS_H_ADDR UINT8_C(0x72) 179 #define BME680_MEM_PAGE_ADDR UINT8_C(0xf3) 180 #define BME680_CONF_T_P_MODE_ADDR UINT8_C(0x74) 181 #define BME680_CONF_ODR_FILT_ADDR UINT8_C(0x75) 184 #define BME680_COEFF_ADDR1 UINT8_C(0x89) 185 #define BME680_COEFF_ADDR2 UINT8_C(0xe1) 188 #define BME680_CHIP_ID_ADDR UINT8_C(0xd0) 191 #define BME680_SOFT_RESET_ADDR UINT8_C(0xe0) 194 #define BME680_ENABLE_HEATER UINT8_C(0x00) 195 #define BME680_DISABLE_HEATER UINT8_C(0x08) 198 #define BME680_DISABLE_GAS_MEAS UINT8_C(0x00) 199 #define BME680_ENABLE_GAS_MEAS UINT8_C(0x01) 202 #define BME680_OS_NONE UINT8_C(0) 203 #define BME680_OS_1X UINT8_C(1) 204 #define BME680_OS_2X UINT8_C(2) 205 #define BME680_OS_4X UINT8_C(3) 206 #define BME680_OS_8X UINT8_C(4) 207 #define BME680_OS_16X UINT8_C(5) 210 #define BME680_FILTER_SIZE_0 UINT8_C(0) 211 #define BME680_FILTER_SIZE_1 UINT8_C(1) 212 #define BME680_FILTER_SIZE_3 UINT8_C(2) 213 #define BME680_FILTER_SIZE_7 UINT8_C(3) 214 #define BME680_FILTER_SIZE_15 UINT8_C(4) 215 #define BME680_FILTER_SIZE_31 UINT8_C(5) 216 #define BME680_FILTER_SIZE_63 UINT8_C(6) 217 #define BME680_FILTER_SIZE_127 UINT8_C(7) 220 #define BME680_SLEEP_MODE UINT8_C(0) 221 #define BME680_FORCED_MODE UINT8_C(1) 224 #define BME680_RESET_PERIOD UINT32_C(10) 227 #define BME680_MEM_PAGE0 UINT8_C(0x10) 228 #define BME680_MEM_PAGE1 UINT8_C(0x00) 231 #define BME680_HUM_REG_SHIFT_VAL UINT8_C(4) 234 #define BME680_RUN_GAS_DISABLE UINT8_C(0) 235 #define BME680_RUN_GAS_ENABLE UINT8_C(1) 238 #define BME680_TMP_BUFFER_LENGTH UINT8_C(40) 239 #define BME680_REG_BUFFER_LENGTH UINT8_C(6) 240 #define BME680_FIELD_DATA_LENGTH UINT8_C(3) 241 #define BME680_GAS_REG_BUF_LENGTH UINT8_C(20) 242 #define BME680_GAS_HEATER_PROF_LEN_MAX UINT8_C(10) 245 #define BME680_OST_SEL UINT16_C(1) 246 #define BME680_OSP_SEL UINT16_C(2) 247 #define BME680_OSH_SEL UINT16_C(4) 248 #define BME680_GAS_MEAS_SEL UINT16_C(8) 249 #define BME680_FILTER_SEL UINT16_C(16) 250 #define BME680_HCNTRL_SEL UINT16_C(32) 251 #define BME680_RUN_GAS_SEL UINT16_C(64) 252 #define BME680_NBCONV_SEL 128 253 #define BME680_GAS_SENSOR_SEL UINT16_C(BME680_GAS_MEAS_SEL | BME680_RUN_GAS_SEL | BME680_NBCONV_SEL) 256 #define BME680_NBCONV_MIN UINT8_C(0) 257 #define BME680_NBCONV_MAX UINT8_C(10) 260 #define BME680_GAS_MEAS_MSK UINT8_C(0x30) 261 #define BME680_NBCONV_MSK UINT8_C(0X0F) 262 #define BME680_FILTER_MSK UINT8_C(0X1C) 263 #define BME680_OST_MSK UINT8_C(0XE0) 264 #define BME680_OSP_MSK UINT8_C(0X1C) 265 #define BME680_OSH_MSK UINT8_C(0X07) 266 #define BME680_HCTRL_MSK UINT8_C(0x08) 267 #define BME680_RUN_GAS_MSK UINT8_C(0x10) 268 #define BME680_MODE_MSK UINT8_C(0x03) 269 #define BME680_RHRANGE_MSK UINT8_C(0x30) 270 #define BME680_RSERROR_MSK UINT8_C(0xf0) 271 #define BME680_NEW_DATA_MSK UINT8_C(0x80) 272 #define BME680_GAS_INDEX_MSK UINT8_C(0x0f) 273 #define BME680_GAS_RANGE_MSK UINT8_C(0x0f) 274 #define BME680_GASM_VALID_MSK UINT8_C(0x20) 275 #define BME680_HEAT_STAB_MSK UINT8_C(0x10) 276 #define BME680_MEM_PAGE_MSK UINT8_C(0x10) 277 #define BME680_SPI_RD_MSK UINT8_C(0x80) 278 #define BME680_SPI_WR_MSK UINT8_C(0x7f) 279 #define BME680_BIT_H1_DATA_MSK UINT8_C(0x0F) 282 #define BME680_GAS_MEAS_POS UINT8_C(4) 283 #define BME680_FILTER_POS UINT8_C(2) 284 #define BME680_OST_POS UINT8_C(5) 285 #define BME680_OSP_POS UINT8_C(2) 286 #define BME680_RUN_GAS_POS UINT8_C(4) 289 #define BME680_T2_LSB_REG (1) 290 #define BME680_T2_MSB_REG (2) 291 #define BME680_T3_REG (3) 292 #define BME680_P1_LSB_REG (5) 293 #define BME680_P1_MSB_REG (6) 294 #define BME680_P2_LSB_REG (7) 295 #define BME680_P2_MSB_REG (8) 296 #define BME680_P3_REG (9) 297 #define BME680_P4_LSB_REG (11) 298 #define BME680_P4_MSB_REG (12) 299 #define BME680_P5_LSB_REG (13) 300 #define BME680_P5_MSB_REG (14) 301 #define BME680_P7_REG (15) 302 #define BME680_P6_REG (16) 303 #define BME680_P8_LSB_REG (19) 304 #define BME680_P8_MSB_REG (20) 305 #define BME680_P9_LSB_REG (21) 306 #define BME680_P9_MSB_REG (22) 307 #define BME680_P10_REG (23) 308 #define BME680_H2_MSB_REG (25) 309 #define BME680_H2_LSB_REG (26) 310 #define BME680_H1_LSB_REG (26) 311 #define BME680_H1_MSB_REG (27) 312 #define BME680_H3_REG (28) 313 #define BME680_H4_REG (29) 314 #define BME680_H5_REG (30) 315 #define BME680_H6_REG (31) 316 #define BME680_H7_REG (32) 317 #define BME680_T1_LSB_REG (33) 318 #define BME680_T1_MSB_REG (34) 319 #define BME680_GH2_LSB_REG (35) 320 #define BME680_GH2_MSB_REG (36) 321 #define BME680_GH1_REG (37) 322 #define BME680_GH3_REG (38) 325 #define BME680_REG_FILTER_INDEX UINT8_C(5) 326 #define BME680_REG_TEMP_INDEX UINT8_C(4) 327 #define BME680_REG_PRES_INDEX UINT8_C(4) 328 #define BME680_REG_HUM_INDEX UINT8_C(2) 329 #define BME680_REG_NBCONV_INDEX UINT8_C(1) 330 #define BME680_REG_RUN_GAS_INDEX UINT8_C(1) 331 #define BME680_REG_HCTRL_INDEX UINT8_C(0) 334 #define BME680_CONCAT_BYTES(msb, lsb) (((uint16_t)msb << 8) | (uint16_t)lsb) 337 #define BME680_SET_BITS(reg_data, bitname, data) \ 338 ((reg_data & ~(bitname##_MSK)) | \ 339 ((data << bitname##_POS) & bitname##_MSK)) 340 #define BME680_GET_BITS(reg_data, bitname) ((reg_data & (bitname##_MSK)) >> \ 344 #define BME680_SET_BITS_POS_0(reg_data, bitname, data) \ 345 ((reg_data & ~(bitname##_MSK)) | \ 346 (data & bitname##_MSK)) 347 #define BME680_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK)) 366 typedef void (*bme680_delay_fptr_t)(uint32_t period);
522 bme680_delay_fptr_t delay_ms;
uint16_t heatr_temp
Definition: bme680_defs.h:486
uint8_t power_mode
Definition: bme680_defs.h:512
uint8_t nb_conv
Definition: bme680_defs.h:480
uint8_t os_pres
Definition: bme680_defs.h:469
int16_t temperature
Definition: bme680_defs.h:390
uint16_t par_t1
Definition: bme680_defs.h:424
uint8_t mem_page
Definition: bme680_defs.h:502
int32_t t_fine
Definition: bme680_defs.h:450
int8_t par_p6
Definition: bme680_defs.h:440
uint8_t par_p10
Definition: bme680_defs.h:448
int8_t par_h5
Definition: bme680_defs.h:412
int16_t par_gh2
Definition: bme680_defs.h:420
int8_t(* bme680_com_fptr_t)(uint8_t dev_id, uint8_t reg_addr, uint8_t *data, uint16_t len)
Definition: bme680_defs.h:360
uint8_t filter
Definition: bme680_defs.h:471
uint8_t meas_index
Definition: bme680_defs.h:388
int8_t par_h7
Definition: bme680_defs.h:416
Definition: bme680_defs.h:375
uint8_t new_fields
Definition: bme680_defs.h:514
uint8_t par_h6
Definition: bme680_defs.h:414
int8_t res_heat_val
Definition: bme680_defs.h:454
uint32_t humidity
Definition: bme680_defs.h:394
int8_t par_gh3
Definition: bme680_defs.h:422
uint8_t os_temp
Definition: bme680_defs.h:467
uint8_t heatr_ctrl
Definition: bme680_defs.h:482
int8_t par_p7
Definition: bme680_defs.h:442
uint8_t info_msg
Definition: bme680_defs.h:516
int8_t par_t3
Definition: bme680_defs.h:428
BME680 gas sensor which comprises of gas settings and status parameters.
Definition: bme680_defs.h:478
uint8_t res_heat_range
Definition: bme680_defs.h:452
uint8_t gas_index
Definition: bme680_defs.h:386
bme680_intf
Interface selection Enumerations.
Definition: bme680_defs.h:371
uint32_t gas_resistance
Definition: bme680_defs.h:396
int16_t par_p9
Definition: bme680_defs.h:446
uint16_t par_h1
Definition: bme680_defs.h:404
uint8_t status
Definition: bme680_defs.h:384
uint16_t par_h2
Definition: bme680_defs.h:406
int8_t par_gh1
Definition: bme680_defs.h:418
int8_t par_h3
Definition: bme680_defs.h:408
bme680_com_fptr_t write
Definition: bme680_defs.h:520
int8_t par_p3
Definition: bme680_defs.h:434
uint8_t dev_id
Definition: bme680_defs.h:498
int8_t range_sw_err
Definition: bme680_defs.h:456
uint16_t heatr_dur
Definition: bme680_defs.h:488
uint8_t os_hum
Definition: bme680_defs.h:465
int16_t par_p5
Definition: bme680_defs.h:438
int16_t par_t2
Definition: bme680_defs.h:426
Definition: bme680_defs.h:373
Structure to hold the Calibration data.
Definition: bme680_defs.h:402
uint8_t chip_id
Definition: bme680_defs.h:496
uint32_t pressure
Definition: bme680_defs.h:392
int8_t par_h4
Definition: bme680_defs.h:410
bme680_com_fptr_t read
Definition: bme680_defs.h:518
Sensor field data structure.
Definition: bme680_defs.h:382
int16_t par_p2
Definition: bme680_defs.h:432
int8_t amb_temp
Definition: bme680_defs.h:504
BME680 sensor settings structure which comprises of ODR, over-sampling and filter settings...
Definition: bme680_defs.h:463
uint16_t par_p1
Definition: bme680_defs.h:430
BME680 device structure.
Definition: bme680_defs.h:494
uint8_t run_gas
Definition: bme680_defs.h:484
int16_t par_p8
Definition: bme680_defs.h:444
int8_t com_rslt
Definition: bme680_defs.h:524
int16_t par_p4
Definition: bme680_defs.h:436