/** * **************************************************************************** * Copyright (C) 2017 - 2018 Bosch Sensortec GmbH * * File : bme680.h * * Date: 5 May 2017 * * Revision : 2.2.0 $ * * Usage: Sensor Driver for BME680 sensor * **************************************************************************** * * \section Disclaimer * * Common: * Bosch Sensortec products are developed for the consumer goods industry. * They may only be used within the parameters of the respective valid * product data sheet. Bosch Sensortec products are provided with the * express understanding that there is no warranty of fitness for a * particular purpose.They are not fit for use in life-sustaining, * safety or security sensitive systems or any system or device * that may lead to bodily harm or property damage if the system * or device malfunctions. In addition,Bosch Sensortec products are * not fit for use in products which interact with motor vehicle systems. * The resale and or use of products are at the purchasers own risk and * his own responsibility. The examination of fitness for the intended use * is the sole responsibility of the Purchaser. * * The purchaser shall indemnify Bosch Sensortec from all third party * claims, including any claims for incidental, or consequential damages, * arising from any product use not covered by the parameters of * the respective valid product data sheet or not approved by * Bosch Sensortec and reimburse Bosch Sensortec for all costs in * connection with such claims. * * The purchaser must monitor the market for the purchased products, * particularly with regard to product safety and inform Bosch Sensortec * without delay of all security relevant incidents. * * Engineering Samples are marked with an asterisk (*) or (e). * Samples may vary from the valid technical specifications of the product * series. They are therefore not intended or fit for resale to third * parties or for use in end products. Their sole purpose is internal * client testing. The testing of an engineering sample may in no way * replace the testing of a product series. Bosch Sensortec assumes * no liability for the use of engineering samples. * By accepting the engineering samples, the Purchaser agrees to indemnify * Bosch Sensortec from all claims arising from the use of engineering * samples. * * Special: * This software module (hereinafter called "Software") and any information * on application-sheets (hereinafter called "Information") is provided * free of charge for the sole purpose to support your application work. * The Software and Information is subject to the following * terms and conditions: * * The Software is specifically designed for the exclusive use for * Bosch Sensortec products by personnel who have special experience * and training. Do not use this Software if you do not have the * proper experience or training. * * This Software package is provided `` as is `` and without any expressed * or implied warranties,including without limitation, the implied warranties * of merchantability and fitness for a particular purpose. * * Bosch Sensortec and their representatives and agents deny any liability * for the functional impairment * of this Software in terms of fitness, performance and safety. * Bosch Sensortec and their representatives and agents shall not be liable * for any direct or indirect damages or injury, except as * otherwise stipulated in mandatory applicable law. * * The Information provided is believed to be accurate and reliable. * Bosch Sensortec assumes no responsibility for the consequences of use * of such Information nor for any infringement of patents or * other rights of third parties which may result from its use. * No license is granted by implication or otherwise under any patent or * patent rights of Bosch. Specifications mentioned in the Information are * subject to change without notice. **************************************************************************/ /*! \file bme680.h \brief BME680 Sensor Driver Support Header File */ #ifndef __BME680_H__ #define __BME680_H__ #ifdef __cplusplus extern "C" { #endif /* BME680 Release version 2.0.0 BME680 Release Version format major_version.minor_version.point_version Example: 2.0.0 */ #define BME680_API_REL_MAJOR_VERSION (2) #define BME680_API_REL_MINOR_VERSION (0) #define BME680_API_REL_POINT_VERSION (1) /*************************************************************************** Header files ****************************************************************************/ #include "sensor_api_common_types.h" /* sensor_api_common_types.h */ /************************************************************************ Macros, Enums, Constants *************************************************************************/ #define BME680_PRESSURE (0U) #define BME680_TEMPERATURE (1U) #define BME680_HUMIDITY (2U) #define BME680_GAS (3U) #define BME680_ALL (4U) #define BME680_STATUS_DATA_LEN (2U) #define BME680_TEMPERATURE_DATA_LEN (3U) #define BME680_PRESSURE_DATA_LEN (3U) #define BME680_GAS_DATA_LEN (2U) #define BME680_HUMIDITY_DATA_LEN (2U) #define BME680_PRESENT_DATA_FIELD (1U) #define BME680_PRESENT_AND_PREVIOUS_DATA_FIELD (2U) #define BME680_ALL_DATA_FIELD (3U) #define BME680_MAX_FIELD_INDEX (3U) #define BME680_FIELD_INDEX0 (0U) #define BME680_FIELD_INDEX1 (1U) #define BME680_FIELD_INDEX2 (2U) /***************************************************************/ /**\name BUS READ AND WRITE FUNCTION POINTERS */ /***************************************************************/ /**< function pointer to the SPI or I2C burst read function */ typedef s8 (*sensor_burst_read)(u8 slave_addr, u8 reg_addr, u8 *data_u8, u32 length_u32); typedef s8 (*sensor_write)(u8 dev_addr, u8 reg_addr, u8 *reg_data_ptr, u8 data_len); /**< function pointer for Write operation in either I2C or SPI*/ typedef s8 (*sensor_read)(u8 dev_addr, u8 reg_addr, u8 *reg_data_ptr, u8 data_len); /**< function pointer for Read operation in either I2C or SPI*/ #define BME680_MAX_NO_OF_SENSOR (2) /**< This macro used for maximum number of sensor*/ #define BME680_MDELAY_DATA_TYPE u32 /**< This macro used for delay*/ #define BME680_CHIP_ID (0x61) /**< BME680 chip identifier */ #define BME680_SPECIFIC_FIELD_DATA_READ_ENABLED /**< This macro is used to prevent the compilation of single function calls when not used */ /* * Use below macro for fixed Point Calculation * else Floating Point calculation will be used */ /* #define FIXED_POINT_COMPENSATION */ /* temperature to Resistance formulae #defines */ /* * Use any of the below constants according to * the heater version of the sensor used */ #define HEATER_C1_ENABLE /* Sensor Specific constants */ #define BME680_SLEEP_MODE (0x00) #define BME680_FORCED_MODE (0x01) #define BME680_PARALLEL_MODE (0x02) #define BME680_SEQUENTIAL_MODE (0x03) #define BME680_GAS_PROFILE_TEMPERATURE_MIN (200) #define BME680_GAS_PROFILE_TEMPERATURE_MAX (400) #define BME680_GAS_RANGE_RL_LENGTH (16) #define BME680_SIGN_BIT_MASK (0x08) #ifdef FIXED_POINT_COMPENSATION /**< Multiply by 1000, In order to convert float value into fixed point */ #define BME680_MAX_HUMIDITY_VALUE (102400) #define BME680_MIN_HUMIDITY_VALUE (0) #else #define BME680_MAX_HUMIDITY_VALUE (double)(100.0) #define BME680_MIN_HUMIDITY_VALUE (double)(0.0) #endif /* BME680 I2C addresses */ #define BME680_I2C_ADDR_PRIMARY (0x76) #define BME680_I2C_ADDR_SECONDARY (0x77) /* Maximum no of gas profiles to be used */ #define BME680_MAX_PROFILES (10) /**************************************************************/ /**\name Interface selection macro */ /*************************************************************/ #define BME680_SPI_INTERFACE (1) #define BME680_I2C_INTERFACE (2) /* bme680_internal.h */ /***************************************************************/ /**\name COMMON USED CONSTANTS */ /***************************************************************/ /* Constants */ #define BME680_NULL_PTR ((void *)0) #define BME680_RETURN_FUNCTION_TYPE s8 /* Section 3.5: Function macros */ #define BME680_SET_REG(reg, data, mask, shift)\ ((reg & mask) | ((data << shift) & ~mask)) #define BME680_GET_REG(reg, mask, shift)\ ((reg & ~mask) >> shift) #define DIFF(a, b) ((a > b)?(a - b):(b - a)) /************************************************************* Module globals, typedefs **************************************************************/ /*! * @brief This structure holds all * calibration parameters */ struct bme680_calibration_param_t { s8 par_T3;/**