- Compensation equation in "calc_pressure" API updated
- Corrected get_gas_config API corrected - Integer lookup tables kept inside "calc_gas_resistance" API - Added documentation for initialization of the amb_temp parameter - Removed changelog - Corrected typos
This commit is contained in:
parent
be1dc2d562
commit
313a58a9c5
15
README.md
15
README.md
@ -7,9 +7,9 @@ The sensor driver package includes bme680.h, bme680.c and bme680_defs.h files
|
||||
## Version
|
||||
File | Version | Date
|
||||
--------------|---------|-------------
|
||||
bme680.c | 3.5.7 | 05 Feb 2018
|
||||
bme680.h | 3.5.7 | 05 Feb 2018
|
||||
bme680_defs.h | 3.5.7 | 05 Feb 2018
|
||||
bme680.c | 3.5.8 | 22 Feb 2018
|
||||
bme680.h | 3.5.8 | 22 Feb 2018
|
||||
bme680_defs.h | 3.5.8 | 22 Feb 2018
|
||||
|
||||
## Integration details
|
||||
* Integrate bme680.h, bme680_defs.h and bme680.c file in to your project.
|
||||
@ -43,6 +43,10 @@ fill in the various parameters as shown below
|
||||
gas_sensor.read = user_spi_read;
|
||||
gas_sensor.write = user_spi_write;
|
||||
gas_sensor.delay_ms = user_delay_ms;
|
||||
/* amb_temp can be set to 25 prior to configuring the gas sensor
|
||||
* or by performing a few temperature readings without operating the gas sensor.
|
||||
*/
|
||||
gas_sensor.amb_temp = 25;
|
||||
|
||||
int8_t rslt = BME680_OK;
|
||||
rslt = bme680_init(&gas_sensor);
|
||||
@ -57,6 +61,11 @@ fill in the various parameters as shown below
|
||||
gas_sensor.read = user_i2c_read;
|
||||
gas_sensor.write = user_i2c_write;
|
||||
gas_sensor.delay_ms = user_delay_ms;
|
||||
/* amb_temp can be set to 25 prior to configuring the gas sensor
|
||||
* or by performing a few temperature readings without operating the gas sensor.
|
||||
*/
|
||||
gas_sensor.amb_temp = 25;
|
||||
|
||||
|
||||
int8_t rslt = BME680_OK;
|
||||
rslt = bme680_init(&gas_sensor);
|
||||
|
55
bme680.c
55
bme680.c
@ -40,8 +40,8 @@
|
||||
* patent rights of the copyright holder.
|
||||
*
|
||||
* File bme680.c
|
||||
* @date 05 Feb 2018
|
||||
* @version 3.5.7
|
||||
* @date 22 Feb 2018
|
||||
* @version 3.5.8
|
||||
*
|
||||
*/
|
||||
|
||||
@ -49,18 +49,6 @@
|
||||
@brief Sensor driver for BME680 sensor */
|
||||
#include "bme680.h"
|
||||
|
||||
/**static variables */
|
||||
/**Look up table for the possible gas range values */
|
||||
uint32_t lookupTable1[16] = { UINT32_C(2147483647), UINT32_C(2147483647), UINT32_C(2147483647), UINT32_C(2147483647),
|
||||
UINT32_C(2147483647), UINT32_C(2126008810), UINT32_C(2147483647), UINT32_C(2130303777), UINT32_C(2147483647),
|
||||
UINT32_C(2147483647), UINT32_C(2143188679), UINT32_C(2136746228), UINT32_C(2147483647), UINT32_C(2126008810),
|
||||
UINT32_C(2147483647), UINT32_C(2147483647) };
|
||||
/**Look up table for the possible gas range values */
|
||||
uint32_t lookupTable2[16] = { UINT32_C(4096000000), UINT32_C(2048000000), UINT32_C(1024000000), UINT32_C(512000000),
|
||||
UINT32_C(255744255), UINT32_C(127110228), UINT32_C(64000000), UINT32_C(32258064), UINT32_C(16016016), UINT32_C(
|
||||
8000000), UINT32_C(4000000), UINT32_C(2000000), UINT32_C(1000000), UINT32_C(500000), UINT32_C(250000),
|
||||
UINT32_C(125000) };
|
||||
|
||||
/*!
|
||||
* @brief This internal API is used to read the calibrated data from the sensor.
|
||||
*
|
||||
@ -90,6 +78,8 @@ static int8_t set_gas_config(struct bme680_dev *dev);
|
||||
|
||||
/*!
|
||||
* @brief This internal API is used to get the gas configuration of the sensor.
|
||||
* @note heatr_temp and heatr_dur values are currently register data
|
||||
* and not the actual values set
|
||||
*
|
||||
* @param[in] dev :Structure instance of bme680_dev.
|
||||
*
|
||||
@ -606,7 +596,7 @@ int8_t bme680_set_sensor_mode(struct bme680_dev *dev)
|
||||
/* Check for null pointer in the device structure*/
|
||||
rslt = null_ptr_check(dev);
|
||||
if (rslt == BME680_OK) {
|
||||
/* Call recursively until in sleep */
|
||||
/* Call repeatedly until in sleep */
|
||||
do {
|
||||
rslt = bme680_get_regs(BME680_CONF_T_P_MODE_ADDR, &tmp_pow_mode, 1, dev);
|
||||
if (rslt == BME680_OK) {
|
||||
@ -843,6 +833,8 @@ static int8_t set_gas_config(struct bme680_dev *dev)
|
||||
|
||||
/*!
|
||||
* @brief This internal API is used to get the gas configuration of the sensor.
|
||||
* @note heatr_temp and heatr_dur values are currently register data
|
||||
* and not the actual values set
|
||||
*/
|
||||
static int8_t get_gas_config(struct bme680_dev *dev)
|
||||
{
|
||||
@ -850,8 +842,7 @@ static int8_t get_gas_config(struct bme680_dev *dev)
|
||||
/* starting address of the register array for burst read*/
|
||||
uint8_t reg_addr1 = BME680_ADDR_SENS_CONF_START;
|
||||
uint8_t reg_addr2 = BME680_ADDR_GAS_CONF_START;
|
||||
uint8_t data_array[BME680_GAS_HEATER_PROF_LEN_MAX] = { 0 };
|
||||
uint8_t index;
|
||||
uint8_t reg_data = 0;
|
||||
|
||||
/* Check for null pointer in the device structure*/
|
||||
rslt = null_ptr_check(dev);
|
||||
@ -862,16 +853,14 @@ static int8_t get_gas_config(struct bme680_dev *dev)
|
||||
}
|
||||
|
||||
if (rslt == BME680_OK) {
|
||||
rslt = bme680_get_regs(reg_addr1, data_array, BME680_GAS_HEATER_PROF_LEN_MAX, dev);
|
||||
rslt = bme680_get_regs(reg_addr1, ®_data, 1, dev);
|
||||
if (rslt == BME680_OK) {
|
||||
for (index = 0; index < BME680_GAS_HEATER_PROF_LEN_MAX; index++)
|
||||
dev->gas_sett.heatr_temp = data_array[index];
|
||||
}
|
||||
|
||||
rslt = bme680_get_regs(reg_addr2, data_array, BME680_GAS_HEATER_PROF_LEN_MAX, dev);
|
||||
if (rslt == BME680_OK) {
|
||||
for (index = 0; index < BME680_GAS_HEATER_PROF_LEN_MAX; index++)
|
||||
dev->gas_sett.heatr_dur = data_array[index];
|
||||
dev->gas_sett.heatr_temp = reg_data;
|
||||
rslt = bme680_get_regs(reg_addr2, ®_data, 1, dev);
|
||||
if (rslt == BME680_OK) {
|
||||
/* Heating duration register value */
|
||||
dev->gas_sett.heatr_dur = reg_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -909,7 +898,6 @@ static uint32_t calc_pressure(uint32_t pres_adc, const struct bme680_dev *dev)
|
||||
int32_t var1 = 0;
|
||||
int32_t var2 = 0;
|
||||
int32_t var3 = 0;
|
||||
int32_t var4 = 0;
|
||||
int32_t pressure_comp = 0;
|
||||
|
||||
var1 = (((int32_t)dev->calib.t_fine) >> 1) - 64000;
|
||||
@ -924,8 +912,7 @@ static uint32_t calc_pressure(uint32_t pres_adc, const struct bme680_dev *dev)
|
||||
var1 = ((32768 + var1) * (int32_t)dev->calib.par_p1) >> 15;
|
||||
pressure_comp = 1048576 - pres_adc;
|
||||
pressure_comp = (int32_t)((pressure_comp - (var2 >> 12)) * ((uint32_t)3125));
|
||||
var4 = (1 << 30);
|
||||
if (pressure_comp >= var4)
|
||||
if (pressure_comp >= BME680_MAX_OVERFLOW_VAL)
|
||||
pressure_comp = ((pressure_comp / (uint32_t)var1) << 1);
|
||||
else
|
||||
pressure_comp = ((pressure_comp << 1) / (uint32_t)var1);
|
||||
@ -989,6 +976,16 @@ static uint32_t calc_gas_resistance(uint16_t gas_res_adc, uint8_t gas_range, con
|
||||
uint64_t var2;
|
||||
int64_t var3;
|
||||
uint32_t calc_gas_res;
|
||||
/**Look up table 1 for the possible gas range values */
|
||||
uint32_t lookupTable1[16] = { UINT32_C(2147483647), UINT32_C(2147483647), UINT32_C(2147483647), UINT32_C(2147483647),
|
||||
UINT32_C(2147483647), UINT32_C(2126008810), UINT32_C(2147483647), UINT32_C(2130303777),
|
||||
UINT32_C(2147483647), UINT32_C(2147483647), UINT32_C(2143188679), UINT32_C(2136746228),
|
||||
UINT32_C(2147483647), UINT32_C(2126008810), UINT32_C(2147483647), UINT32_C(2147483647) };
|
||||
/**Look up table 2 for the possible gas range values */
|
||||
uint32_t lookupTable2[16] = { UINT32_C(4096000000), UINT32_C(2048000000), UINT32_C(1024000000), UINT32_C(512000000),
|
||||
UINT32_C(255744255), UINT32_C(127110228), UINT32_C(64000000), UINT32_C(32258064), UINT32_C(16016016),
|
||||
UINT32_C(8000000), UINT32_C(4000000), UINT32_C(2000000), UINT32_C(1000000), UINT32_C(500000),
|
||||
UINT32_C(250000), UINT32_C(125000) };
|
||||
|
||||
var1 = (int64_t) ((1340 + (5 * (int64_t) dev->calib.range_sw_err)) *
|
||||
((int64_t) lookupTable1[gas_range])) >> 16;
|
||||
|
4
bme680.h
4
bme680.h
@ -40,8 +40,8 @@
|
||||
* patent rights of the copyright holder.
|
||||
*
|
||||
* @file bme680.h
|
||||
* @date 05 Feb 2018
|
||||
* @version 3.5.7
|
||||
* @date 22 Feb 2018
|
||||
* @version 3.5.8
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
|
@ -40,8 +40,8 @@
|
||||
* patent rights of the copyright holder.
|
||||
*
|
||||
* @file bme680_defs.h
|
||||
* @date 05 Feb 2018
|
||||
* @version 3.5.7
|
||||
* @date 22 Feb 2018
|
||||
* @version 3.5.8
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
@ -226,7 +226,6 @@
|
||||
#define BME680_REG_BUFFER_LENGTH UINT8_C(6)
|
||||
#define BME680_FIELD_DATA_LENGTH UINT8_C(3)
|
||||
#define BME680_GAS_REG_BUF_LENGTH UINT8_C(20)
|
||||
#define BME680_GAS_HEATER_PROF_LEN_MAX UINT8_C(10)
|
||||
|
||||
/** Settings selector */
|
||||
#define BME680_OST_SEL UINT16_C(1)
|
||||
@ -317,6 +316,14 @@
|
||||
#define BME680_REG_RUN_GAS_INDEX UINT8_C(1)
|
||||
#define BME680_REG_HCTRL_INDEX UINT8_C(0)
|
||||
|
||||
/** BME680 pressure calculation macros */
|
||||
/*! This max value is used to provide precedence to multiplication or division
|
||||
* in pressure compensation equation to achieve least loss of precision and
|
||||
* avoiding overflows.
|
||||
* i.e Comparing value, BME680_MAX_OVERFLOW_VAL = INT32_C(1 << 30)
|
||||
*/
|
||||
#define BME680_MAX_OVERFLOW_VAL INT32_C(0x40000000)
|
||||
|
||||
/** Macro to combine two 8 bit data's to form a 16 bit data */
|
||||
#define BME680_CONCAT_BYTES(msb, lsb) (((uint16_t)msb << 8) | (uint16_t)lsb)
|
||||
|
||||
@ -334,7 +341,7 @@
|
||||
#define BME680_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
|
||||
|
||||
/** Type definitions */
|
||||
/*
|
||||
/*!
|
||||
* Generic communication function pointer
|
||||
* @param[in] dev_id: Place holder to store the id of the device structure
|
||||
* Can be used to store the index of the Chip select or
|
||||
@ -346,7 +353,7 @@
|
||||
*/
|
||||
typedef int8_t (*bme680_com_fptr_t)(uint8_t dev_id, uint8_t reg_addr, uint8_t *data, uint16_t len);
|
||||
|
||||
/*
|
||||
/*!
|
||||
* Delay function pointer
|
||||
* @param[in] period: Time period in milliseconds
|
||||
*/
|
||||
@ -489,9 +496,9 @@ struct bme680_gas_sett {
|
||||
uint8_t heatr_ctrl;
|
||||
/*! Run gas enable value */
|
||||
uint8_t run_gas;
|
||||
/*! Pointer to store heater temperature */
|
||||
/*! Heater temperature value */
|
||||
uint16_t heatr_temp;
|
||||
/*! Pointer to store duration profile */
|
||||
/*! Duration profile value */
|
||||
uint16_t heatr_dur;
|
||||
};
|
||||
|
||||
@ -507,7 +514,7 @@ struct bme680_dev {
|
||||
enum bme680_intf intf;
|
||||
/*! Memory page used */
|
||||
uint8_t mem_page;
|
||||
/*! Ambient temperature in Degree C*/
|
||||
/*! Ambient temperature in Degree C */
|
||||
int8_t amb_temp;
|
||||
/*! Sensor calibration data */
|
||||
struct bme680_calib_data calib;
|
||||
@ -521,11 +528,11 @@ struct bme680_dev {
|
||||
uint8_t new_fields;
|
||||
/*! Store the info messages */
|
||||
uint8_t info_msg;
|
||||
/*! Burst read structure */
|
||||
/*! Bus read function pointer */
|
||||
bme680_com_fptr_t read;
|
||||
/*! Burst write structure */
|
||||
/*! Bus write function pointer */
|
||||
bme680_com_fptr_t write;
|
||||
/*! Delay in ms */
|
||||
/*! delay function pointer */
|
||||
bme680_delay_fptr_t delay_ms;
|
||||
/*! Communication function result */
|
||||
int8_t com_rslt;
|
||||
|
66
changelog.md
66
changelog.md
@ -1,66 +0,0 @@
|
||||
# Change Log
|
||||
All notable changes to the BME680 Sensor API will be documented in this file.
|
||||
|
||||
## v3.5.7, 05 Feb 2018
|
||||
### Fixed
|
||||
- Integer overflow issue fixed in "calc_pressure" API
|
||||
|
||||
## v3.5.6, 19 Jan 2018
|
||||
### Added
|
||||
- Floating point support added for the API
|
||||
- Lower temperature cap removed in "calc_heater_res" APIs
|
||||
|
||||
## v3.5.5, 20 Nov 2017
|
||||
### Changed
|
||||
- Updated the buffer size in "get_calib_data" API
|
||||
|
||||
## v3.5.4, 16 Nov 2017
|
||||
### Changed
|
||||
- Updated the set/get gas profile duration logic
|
||||
|
||||
## v3.5.3, 30 Oct 2017
|
||||
### Changed
|
||||
- Changed the compensation equation formulae to use shifting operation
|
||||
- Updated the "bme680_get_profile_dur" API
|
||||
- Fixed Checkpatch and made linux compatible
|
||||
|
||||
## v3.5.2, 18 Oct 2017
|
||||
### Changed
|
||||
- Fixed bug of temperature compensation in pressure
|
||||
|
||||
## v3.5.1, 5 Jul 2017
|
||||
### Changed
|
||||
- Fixed bug with overwriting of the result with communication results
|
||||
- Added member in the dev structure to store communication results
|
||||
- Updated set profile duration API to not return a result.
|
||||
- Added new API to get the duration for the existing profile
|
||||
- Fixed bug with setting gas configuration. Reduced to writing only relevant bytes
|
||||
- Updated readme
|
||||
- Updated documentation for the type definitions
|
||||
- Removed mode check for get sensor data and setting and getting profile dur
|
||||
|
||||
## v3.5.0, 28 Jun 2017
|
||||
### Changed
|
||||
- Fixed bug with getting and setting mem pages
|
||||
- Changed initialization sequence to be more robust
|
||||
- Added additional tries while reading data in case of inadequate delay
|
||||
|
||||
## v3.4.0, 8 Jun 2017
|
||||
### Changed
|
||||
- Modified the bme680_get_sensor_data API. User has to now pass the struct that stores the data rather than retrieving from the bme680_dev structure.
|
||||
- Fixed possible bugs
|
||||
|
||||
## v3.3.0, 24 May 2017
|
||||
### Changed
|
||||
- Name changes in the BME680 device structure.
|
||||
- Removed sequential and parallel modes.
|
||||
- Removed ODR related sensor settings
|
||||
- Modified get sensor settings API with user selection.
|
||||
- Removed sort sensor data and swap fields API which are not required.
|
||||
|
||||
### Added
|
||||
- BME680 set profile duration API.
|
||||
|
||||
## v3.2.1, 17 May 2017
|
||||
### Added
|
||||
- Took the reference as base version 3.2.1 of BME680 sensor and added.
|
Loading…
Reference in New Issue
Block a user