/* * **************************************************************************** * Copyright (C) 2015 Bosch Sensortec GmbH * * File : bme680.h * * Date : 2016/08/17 * * Revision: 2.0.1 * * Usage: Sensor Driver for BME680 sensor * **************************************************************************** * * Section Disclaimer * License: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the copyright holder nor the names of the * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER * OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE * * The information provided is believed to be accurate and reliable. * The copyright holder 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 the copyright holder. **************************************************************************/ /*! \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 #define BME680_INIT_VALUE ((u8)0) /* 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;/**