- Compensation equation in "calc_pressure" API updated

This commit is contained in:
Bosch Sensortec 2018-06-29 11:35:29 +02:00 committed by Kevin Goveas
parent e6b9bbade9
commit 63bb5336db
4 changed files with 2418 additions and 2418 deletions

562
README.md
View File

@ -1,282 +1,282 @@
# BME680 sensor API # BME680 sensor API
## Introduction ## Introduction
This package contains the Bosch Sensortec's BME680 gas sensor API This package contains the Bosch Sensortec's BME680 gas sensor API
The sensor driver package includes bme680.h, bme680.c and bme680_defs.h files The sensor driver package includes bme680.h, bme680.c and bme680_defs.h files
## Version ## Version
File | Version | Date File | Version | Date
--------------|---------|------------- --------------|---------|-------------
bme680.c | 3.5.8 | 22 Feb 2018 bme680.c | 3.5.9 | 19 Jun 2018
bme680.h | 3.5.8 | 22 Feb 2018 bme680.h | 3.5.9 | 19 Jun 2018
bme680_defs.h | 3.5.8 | 22 Feb 2018 bme680_defs.h | 3.5.9 | 19 Jun 2018
## Integration details ## Integration details
* Integrate bme680.h, bme680_defs.h and bme680.c file in to your project. * Integrate bme680.h, bme680_defs.h and bme680.c file in to your project.
* Include the bme680.h file in your code like below. * Include the bme680.h file in your code like below.
``` c ``` c
#include "bme680.h" #include "bme680.h"
``` ```
## File information ## File information
* bme680_defs.h : This header file has the constants, macros and datatype declarations. * bme680_defs.h : This header file has the constants, macros and datatype declarations.
* bme680.h : This header file contains the declarations of the sensor driver APIs. * bme680.h : This header file contains the declarations of the sensor driver APIs.
* bme680.c : This source file contains the definitions of the sensor driver APIs. * bme680.c : This source file contains the definitions of the sensor driver APIs.
## Supported sensor interfaces ## Supported sensor interfaces
* SPI 4-wire * SPI 4-wire
* I2C * I2C
## Usage guide ## Usage guide
### Initializing the sensor ### Initializing the sensor
To initialize the sensor, you will first need to create a device structure. You To initialize the sensor, you will first need to create a device structure. You
can do this by creating an instance of the structure bme680_dev. Then go on to can do this by creating an instance of the structure bme680_dev. Then go on to
fill in the various parameters as shown below fill in the various parameters as shown below
#### Example for SPI 4-Wire #### Example for SPI 4-Wire
``` c ``` c
struct bme680_dev gas_sensor; struct bme680_dev gas_sensor;
/* You may assign a chip select identifier to be handled later */ /* You may assign a chip select identifier to be handled later */
gas_sensor.dev_id = 0; gas_sensor.dev_id = 0;
gas_sensor.intf = BME680_SPI_INTF; gas_sensor.intf = BME680_SPI_INTF;
gas_sensor.read = user_spi_read; gas_sensor.read = user_spi_read;
gas_sensor.write = user_spi_write; gas_sensor.write = user_spi_write;
gas_sensor.delay_ms = user_delay_ms; gas_sensor.delay_ms = user_delay_ms;
/* amb_temp can be set to 25 prior to configuring the gas sensor /* 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. * or by performing a few temperature readings without operating the gas sensor.
*/ */
gas_sensor.amb_temp = 25; gas_sensor.amb_temp = 25;
int8_t rslt = BME680_OK; int8_t rslt = BME680_OK;
rslt = bme680_init(&gas_sensor); rslt = bme680_init(&gas_sensor);
``` ```
#### Example for I2C #### Example for I2C
``` c ``` c
struct bme680_dev gas_sensor; struct bme680_dev gas_sensor;
gas_sensor.dev_id = BME680_I2C_ADDR_PRIMARY; gas_sensor.dev_id = BME680_I2C_ADDR_PRIMARY;
gas_sensor.intf = BME680_I2C_INTF; gas_sensor.intf = BME680_I2C_INTF;
gas_sensor.read = user_i2c_read; gas_sensor.read = user_i2c_read;
gas_sensor.write = user_i2c_write; gas_sensor.write = user_i2c_write;
gas_sensor.delay_ms = user_delay_ms; gas_sensor.delay_ms = user_delay_ms;
/* amb_temp can be set to 25 prior to configuring the gas sensor /* 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. * or by performing a few temperature readings without operating the gas sensor.
*/ */
gas_sensor.amb_temp = 25; gas_sensor.amb_temp = 25;
int8_t rslt = BME680_OK; int8_t rslt = BME680_OK;
rslt = bme680_init(&gas_sensor); rslt = bme680_init(&gas_sensor);
``` ```
Regarding compensation functions for temperature, pressure, humidity and gas we have two implementations. Regarding compensation functions for temperature, pressure, humidity and gas we have two implementations.
- Integer version - Integer version
- floating point version - floating point version
By default, Integer version is used in the API By default, Integer version is used in the API
If the user needs the floating point version, the user has to un-comment BME680_FLOAT_POINT_COMPENSATION macro If the user needs the floating point version, the user has to un-comment BME680_FLOAT_POINT_COMPENSATION macro
in bme680_defs.h file or to add it in the compiler flags. in bme680_defs.h file or to add it in the compiler flags.
### Configuring the sensor ### Configuring the sensor
#### Example for configuring the sensor in forced mode #### Example for configuring the sensor in forced mode
``` c ``` c
uint8_t set_required_settings; uint8_t set_required_settings;
/* Set the temperature, pressure and humidity settings */ /* Set the temperature, pressure and humidity settings */
gas_sensor.tph_sett.os_hum = BME680_OS_2X; gas_sensor.tph_sett.os_hum = BME680_OS_2X;
gas_sensor.tph_sett.os_pres = BME680_OS_4X; gas_sensor.tph_sett.os_pres = BME680_OS_4X;
gas_sensor.tph_sett.os_temp = BME680_OS_8X; gas_sensor.tph_sett.os_temp = BME680_OS_8X;
gas_sensor.tph_sett.filter = BME680_FILTER_SIZE_3; gas_sensor.tph_sett.filter = BME680_FILTER_SIZE_3;
/* Set the remaining gas sensor settings and link the heating profile */ /* Set the remaining gas sensor settings and link the heating profile */
gas_sensor.gas_sett.run_gas = BME680_ENABLE_GAS_MEAS; gas_sensor.gas_sett.run_gas = BME680_ENABLE_GAS_MEAS;
/* Create a ramp heat waveform in 3 steps */ /* Create a ramp heat waveform in 3 steps */
gas_sensor.gas_sett.heatr_temp = 320; /* degree Celsius */ gas_sensor.gas_sett.heatr_temp = 320; /* degree Celsius */
gas_sensor.gas_sett.heatr_dur = 150; /* milliseconds */ gas_sensor.gas_sett.heatr_dur = 150; /* milliseconds */
/* Select the power mode */ /* Select the power mode */
/* Must be set before writing the sensor configuration */ /* Must be set before writing the sensor configuration */
gas_sensor.power_mode = BME680_FORCED_MODE; gas_sensor.power_mode = BME680_FORCED_MODE;
/* Set the required sensor settings needed */ /* Set the required sensor settings needed */
set_required_settings = BME680_OST_SEL | BME680_OSP_SEL | BME680_OSH_SEL | BME680_FILTER_SEL set_required_settings = BME680_OST_SEL | BME680_OSP_SEL | BME680_OSH_SEL | BME680_FILTER_SEL
| BME680_GAS_SENSOR_SEL; | BME680_GAS_SENSOR_SEL;
/* Set the desired sensor configuration */ /* Set the desired sensor configuration */
rslt = bme680_set_sensor_settings(set_required_settings,&gas_sensor); rslt = bme680_set_sensor_settings(set_required_settings,&gas_sensor);
/* Set the power mode */ /* Set the power mode */
rslt = bme680_set_sensor_mode(&gas_sensor); rslt = bme680_set_sensor_mode(&gas_sensor);
``` ```
### Reading sensor data ### Reading sensor data
#### Example for reading all sensor data #### Example for reading all sensor data
``` c ``` c
/* Get the total measurement duration so as to sleep or wait till the /* Get the total measurement duration so as to sleep or wait till the
* measurement is complete */ * measurement is complete */
uint16_t meas_period; uint16_t meas_period;
bme680_get_profile_dur(&meas_period, &gas_sensor); bme680_get_profile_dur(&meas_period, &gas_sensor);
struct bme680_field_data data; struct bme680_field_data data;
while(1) while(1)
{ {
user_delay_ms(meas_period); /* Delay till the measurement is ready */ user_delay_ms(meas_period); /* Delay till the measurement is ready */
rslt = bme680_get_sensor_data(&data, &gas_sensor); rslt = bme680_get_sensor_data(&data, &gas_sensor);
printf("T: %.2f degC, P: %.2f hPa, H %.2f %%rH ", data.temperature / 100.0f, printf("T: %.2f degC, P: %.2f hPa, H %.2f %%rH ", data.temperature / 100.0f,
data.pressure / 100.0f, data.humidity / 1000.0f ); data.pressure / 100.0f, data.humidity / 1000.0f );
/* Avoid using measurements from an unstable heating setup */ /* Avoid using measurements from an unstable heating setup */
if(data.status & BME680_GASM_VALID_MSK) if(data.status & BME680_GASM_VALID_MSK)
printf(", G: %d ohms", data.gas_resistance); printf(", G: %d ohms", data.gas_resistance);
printf("\r\n"); printf("\r\n");
/* Trigger the next measurement if you would like to read data out continuously */ /* Trigger the next measurement if you would like to read data out continuously */
if (gas_sensor.power_mode == BME680_FORCED_MODE) { if (gas_sensor.power_mode == BME680_FORCED_MODE) {
rslt = bme680_set_sensor_mode(&gas_sensor); rslt = bme680_set_sensor_mode(&gas_sensor);
} }
} }
``` ```
### Templates for function pointers ### Templates for function pointers
``` c ``` c
void user_delay_ms(uint32_t period) void user_delay_ms(uint32_t period)
{ {
/* /*
* Return control or wait, * Return control or wait,
* for a period amount of milliseconds * for a period amount of milliseconds
*/ */
} }
int8_t user_spi_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len) int8_t user_spi_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
{ {
int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */ int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
/* /*
* The parameter dev_id can be used as a variable to select which Chip Select pin has * The parameter dev_id can be used as a variable to select which Chip Select pin has
* to be set low to activate the relevant device on the SPI bus * to be set low to activate the relevant device on the SPI bus
*/ */
/* /*
* Data on the bus should be like * Data on the bus should be like
* |----------------+---------------------+-------------| * |----------------+---------------------+-------------|
* | MOSI | MISO | Chip Select | * | MOSI | MISO | Chip Select |
* |----------------+---------------------|-------------| * |----------------+---------------------|-------------|
* | (don't care) | (don't care) | HIGH | * | (don't care) | (don't care) | HIGH |
* | (reg_addr) | (don't care) | LOW | * | (reg_addr) | (don't care) | LOW |
* | (don't care) | (reg_data[0]) | LOW | * | (don't care) | (reg_data[0]) | LOW |
* | (....) | (....) | LOW | * | (....) | (....) | LOW |
* | (don't care) | (reg_data[len - 1]) | LOW | * | (don't care) | (reg_data[len - 1]) | LOW |
* | (don't care) | (don't care) | HIGH | * | (don't care) | (don't care) | HIGH |
* |----------------+---------------------|-------------| * |----------------+---------------------|-------------|
*/ */
return rslt; return rslt;
} }
int8_t user_spi_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len) int8_t user_spi_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
{ {
int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */ int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
/* /*
* The parameter dev_id can be used as a variable to select which Chip Select pin has * The parameter dev_id can be used as a variable to select which Chip Select pin has
* to be set low to activate the relevant device on the SPI bus * to be set low to activate the relevant device on the SPI bus
*/ */
/* /*
* Data on the bus should be like * Data on the bus should be like
* |---------------------+--------------+-------------| * |---------------------+--------------+-------------|
* | MOSI | MISO | Chip Select | * | MOSI | MISO | Chip Select |
* |---------------------+--------------|-------------| * |---------------------+--------------|-------------|
* | (don't care) | (don't care) | HIGH | * | (don't care) | (don't care) | HIGH |
* | (reg_addr) | (don't care) | LOW | * | (reg_addr) | (don't care) | LOW |
* | (reg_data[0]) | (don't care) | LOW | * | (reg_data[0]) | (don't care) | LOW |
* | (....) | (....) | LOW | * | (....) | (....) | LOW |
* | (reg_data[len - 1]) | (don't care) | LOW | * | (reg_data[len - 1]) | (don't care) | LOW |
* | (don't care) | (don't care) | HIGH | * | (don't care) | (don't care) | HIGH |
* |---------------------+--------------|-------------| * |---------------------+--------------|-------------|
*/ */
return rslt; return rslt;
} }
int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len) int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
{ {
int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */ int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
/* /*
* The parameter dev_id can be used as a variable to store the I2C address of the device * The parameter dev_id can be used as a variable to store the I2C address of the device
*/ */
/* /*
* Data on the bus should be like * Data on the bus should be like
* |------------+---------------------| * |------------+---------------------|
* | I2C action | Data | * | I2C action | Data |
* |------------+---------------------| * |------------+---------------------|
* | Start | - | * | Start | - |
* | Write | (reg_addr) | * | Write | (reg_addr) |
* | Stop | - | * | Stop | - |
* | Start | - | * | Start | - |
* | Read | (reg_data[0]) | * | Read | (reg_data[0]) |
* | Read | (....) | * | Read | (....) |
* | Read | (reg_data[len - 1]) | * | Read | (reg_data[len - 1]) |
* | Stop | - | * | Stop | - |
* |------------+---------------------| * |------------+---------------------|
*/ */
return rslt; return rslt;
} }
int8_t user_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len) int8_t user_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
{ {
int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */ int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
/* /*
* The parameter dev_id can be used as a variable to store the I2C address of the device * The parameter dev_id can be used as a variable to store the I2C address of the device
*/ */
/* /*
* Data on the bus should be like * Data on the bus should be like
* |------------+---------------------| * |------------+---------------------|
* | I2C action | Data | * | I2C action | Data |
* |------------+---------------------| * |------------+---------------------|
* | Start | - | * | Start | - |
* | Write | (reg_addr) | * | Write | (reg_addr) |
* | Write | (reg_data[0]) | * | Write | (reg_data[0]) |
* | Write | (....) | * | Write | (....) |
* | Write | (reg_data[len - 1]) | * | Write | (reg_data[len - 1]) |
* | Stop | - | * | Stop | - |
* |------------+---------------------| * |------------+---------------------|
*/ */
return rslt; return rslt;
} }
``` ```
## Copyright (C) 2017 - 2018 Bosch Sensortec GmbH ## Copyright (C) 2017 - 2018 Bosch Sensortec GmbH

2734
bme680.c

File diff suppressed because it is too large Load Diff

450
bme680.h
View File

@ -1,225 +1,225 @@
/** /**
* Copyright (C) 2017 - 2018 Bosch Sensortec GmbH * Copyright (C) 2017 - 2018 Bosch Sensortec GmbH
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* Redistributions in binary form must reproduce the above copyright * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* Neither the name of the copyright holder nor the names of the * Neither the name of the copyright holder nor the names of the
* contributors may be used to endorse or promote products derived from * contributors may be used to endorse or promote products derived from
* this software without specific prior written permission. * this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
* OR CONTRIBUTORS BE LIABLE FOR ANY * OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS * ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
* *
* The information provided is believed to be accurate and reliable. * The information provided is believed to be accurate and reliable.
* The copyright holder assumes no responsibility * The copyright holder assumes no responsibility
* for the consequences of use * for the consequences of use
* of such information nor for any infringement of patents or * of such information nor for any infringement of patents or
* other rights of third parties which may result from its use. * other rights of third parties which may result from its use.
* No license is granted by implication or otherwise under any patent or * No license is granted by implication or otherwise under any patent or
* patent rights of the copyright holder. * patent rights of the copyright holder.
* *
* @file bme680.h * @file bme680.h
* @date 22 Feb 2018 * @date 19 Jun 2018
* @version 3.5.8 * @version 3.5.9
* @brief * @brief
* *
*/ */
/*! @file bme680.h /*! @file bme680.h
@brief Sensor driver for BME680 sensor */ @brief Sensor driver for BME680 sensor */
/*! /*!
* @defgroup BME680 SENSOR API * @defgroup BME680 SENSOR API
* @{*/ * @{*/
#ifndef BME680_H_ #ifndef BME680_H_
#define BME680_H_ #define BME680_H_
/*! CPP guard */ /*! CPP guard */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
/* Header includes */ /* Header includes */
#include "bme680_defs.h" #include "bme680_defs.h"
/* function prototype declarations */ /* function prototype declarations */
/*! /*!
* @brief This API is the entry point. * @brief This API is the entry point.
* It reads the chip-id and calibration data from the sensor. * It reads the chip-id and calibration data from the sensor.
* *
* @param[in,out] dev : Structure instance of bme680_dev * @param[in,out] dev : Structure instance of bme680_dev
* *
* @return Result of API execution status * @return Result of API execution status
* @retval zero -> Success / +ve value -> Warning / -ve value -> Error * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
*/ */
int8_t bme680_init(struct bme680_dev *dev); int8_t bme680_init(struct bme680_dev *dev);
/*! /*!
* @brief This API writes the given data to the register address * @brief This API writes the given data to the register address
* of the sensor. * of the sensor.
* *
* @param[in] reg_addr : Register address from where the data to be written. * @param[in] reg_addr : Register address from where the data to be written.
* @param[in] reg_data : Pointer to data buffer which is to be written * @param[in] reg_data : Pointer to data buffer which is to be written
* in the sensor. * in the sensor.
* @param[in] len : No of bytes of data to write.. * @param[in] len : No of bytes of data to write..
* @param[in] dev : Structure instance of bme680_dev. * @param[in] dev : Structure instance of bme680_dev.
* *
* @return Result of API execution status * @return Result of API execution status
* @retval zero -> Success / +ve value -> Warning / -ve value -> Error * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
*/ */
int8_t bme680_set_regs(const uint8_t *reg_addr, const uint8_t *reg_data, uint8_t len, struct bme680_dev *dev); int8_t bme680_set_regs(const uint8_t *reg_addr, const uint8_t *reg_data, uint8_t len, struct bme680_dev *dev);
/*! /*!
* @brief This API reads the data from the given register address of the sensor. * @brief This API reads the data from the given register address of the sensor.
* *
* @param[in] reg_addr : Register address from where the data to be read * @param[in] reg_addr : Register address from where the data to be read
* @param[out] reg_data : Pointer to data buffer to store the read data. * @param[out] reg_data : Pointer to data buffer to store the read data.
* @param[in] len : No of bytes of data to be read. * @param[in] len : No of bytes of data to be read.
* @param[in] dev : Structure instance of bme680_dev. * @param[in] dev : Structure instance of bme680_dev.
* *
* @return Result of API execution status * @return Result of API execution status
* @retval zero -> Success / +ve value -> Warning / -ve value -> Error * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
*/ */
int8_t bme680_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, struct bme680_dev *dev); int8_t bme680_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, struct bme680_dev *dev);
/*! /*!
* @brief This API performs the soft reset of the sensor. * @brief This API performs the soft reset of the sensor.
* *
* @param[in] dev : Structure instance of bme680_dev. * @param[in] dev : Structure instance of bme680_dev.
* *
* @return Result of API execution status * @return Result of API execution status
* @retval zero -> Success / +ve value -> Warning / -ve value -> Error. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
*/ */
int8_t bme680_soft_reset(struct bme680_dev *dev); int8_t bme680_soft_reset(struct bme680_dev *dev);
/*! /*!
* @brief This API is used to set the power mode of the sensor. * @brief This API is used to set the power mode of the sensor.
* *
* @param[in] dev : Structure instance of bme680_dev * @param[in] dev : Structure instance of bme680_dev
* @note : Pass the value to bme680_dev.power_mode structure variable. * @note : Pass the value to bme680_dev.power_mode structure variable.
* *
* value | mode * value | mode
* -------------|------------------ * -------------|------------------
* 0x00 | BME680_SLEEP_MODE * 0x00 | BME680_SLEEP_MODE
* 0x01 | BME680_FORCED_MODE * 0x01 | BME680_FORCED_MODE
* *
* * @return Result of API execution status * * @return Result of API execution status
* @retval zero -> Success / +ve value -> Warning / -ve value -> Error * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
*/ */
int8_t bme680_set_sensor_mode(struct bme680_dev *dev); int8_t bme680_set_sensor_mode(struct bme680_dev *dev);
/*! /*!
* @brief This API is used to get the power mode of the sensor. * @brief This API is used to get the power mode of the sensor.
* *
* @param[in] dev : Structure instance of bme680_dev * @param[in] dev : Structure instance of bme680_dev
* @note : bme680_dev.power_mode structure variable hold the power mode. * @note : bme680_dev.power_mode structure variable hold the power mode.
* *
* value | mode * value | mode
* ---------|------------------ * ---------|------------------
* 0x00 | BME680_SLEEP_MODE * 0x00 | BME680_SLEEP_MODE
* 0x01 | BME680_FORCED_MODE * 0x01 | BME680_FORCED_MODE
* *
* @return Result of API execution status * @return Result of API execution status
* @retval zero -> Success / +ve value -> Warning / -ve value -> Error * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
*/ */
int8_t bme680_get_sensor_mode(struct bme680_dev *dev); int8_t bme680_get_sensor_mode(struct bme680_dev *dev);
/*! /*!
* @brief This API is used to set the profile duration of the sensor. * @brief This API is used to set the profile duration of the sensor.
* *
* @param[in] dev : Structure instance of bme680_dev. * @param[in] dev : Structure instance of bme680_dev.
* @param[in] duration : Duration of the measurement in ms. * @param[in] duration : Duration of the measurement in ms.
* *
* @return Nothing * @return Nothing
*/ */
void bme680_set_profile_dur(uint16_t duration, struct bme680_dev *dev); void bme680_set_profile_dur(uint16_t duration, struct bme680_dev *dev);
/*! /*!
* @brief This API is used to get the profile duration of the sensor. * @brief This API is used to get the profile duration of the sensor.
* *
* @param[in] dev : Structure instance of bme680_dev. * @param[in] dev : Structure instance of bme680_dev.
* @param[in] duration : Duration of the measurement in ms. * @param[in] duration : Duration of the measurement in ms.
* *
* @return Nothing * @return Nothing
*/ */
void bme680_get_profile_dur(uint16_t *duration, const struct bme680_dev *dev); void bme680_get_profile_dur(uint16_t *duration, const struct bme680_dev *dev);
/*! /*!
* @brief This API reads the pressure, temperature and humidity and gas data * @brief This API reads the pressure, temperature and humidity and gas data
* from the sensor, compensates the data and store it in the bme680_data * from the sensor, compensates the data and store it in the bme680_data
* structure instance passed by the user. * structure instance passed by the user.
* *
* @param[out] data: Structure instance to hold the data. * @param[out] data: Structure instance to hold the data.
* @param[in] dev : Structure instance of bme680_dev. * @param[in] dev : Structure instance of bme680_dev.
* *
* @return Result of API execution status * @return Result of API execution status
* @retval zero -> Success / +ve value -> Warning / -ve value -> Error * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
*/ */
int8_t bme680_get_sensor_data(struct bme680_field_data *data, struct bme680_dev *dev); int8_t bme680_get_sensor_data(struct bme680_field_data *data, struct bme680_dev *dev);
/*! /*!
* @brief This API is used to set the oversampling, filter and T,P,H, gas selection * @brief This API is used to set the oversampling, filter and T,P,H, gas selection
* settings in the sensor. * settings in the sensor.
* *
* @param[in] dev : Structure instance of bme680_dev. * @param[in] dev : Structure instance of bme680_dev.
* @param[in] desired_settings : Variable used to select the settings which * @param[in] desired_settings : Variable used to select the settings which
* are to be set in the sensor. * are to be set in the sensor.
* *
* Macros | Functionality * Macros | Functionality
*---------------------------------|---------------------------------------------- *---------------------------------|----------------------------------------------
* BME680_OST_SEL | To set temperature oversampling. * BME680_OST_SEL | To set temperature oversampling.
* BME680_OSP_SEL | To set pressure oversampling. * BME680_OSP_SEL | To set pressure oversampling.
* BME680_OSH_SEL | To set humidity oversampling. * BME680_OSH_SEL | To set humidity oversampling.
* BME680_GAS_MEAS_SEL | To set gas measurement setting. * BME680_GAS_MEAS_SEL | To set gas measurement setting.
* BME680_FILTER_SEL | To set filter setting. * BME680_FILTER_SEL | To set filter setting.
* BME680_HCNTRL_SEL | To set humidity control setting. * BME680_HCNTRL_SEL | To set humidity control setting.
* BME680_RUN_GAS_SEL | To set run gas setting. * BME680_RUN_GAS_SEL | To set run gas setting.
* BME680_NBCONV_SEL | To set NB conversion setting. * BME680_NBCONV_SEL | To set NB conversion setting.
* BME680_GAS_SENSOR_SEL | To set all gas sensor related settings * BME680_GAS_SENSOR_SEL | To set all gas sensor related settings
* *
* @note : Below are the macros to be used by the user for selecting the * @note : Below are the macros to be used by the user for selecting the
* desired settings. User can do OR operation of these macros for configuring * desired settings. User can do OR operation of these macros for configuring
* multiple settings. * multiple settings.
* *
* @return Result of API execution status * @return Result of API execution status
* @retval zero -> Success / +ve value -> Warning / -ve value -> Error. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
*/ */
int8_t bme680_set_sensor_settings(uint16_t desired_settings, struct bme680_dev *dev); int8_t bme680_set_sensor_settings(uint16_t desired_settings, struct bme680_dev *dev);
/*! /*!
* @brief This API is used to get the oversampling, filter and T,P,H, gas selection * @brief This API is used to get the oversampling, filter and T,P,H, gas selection
* settings in the sensor. * settings in the sensor.
* *
* @param[in] dev : Structure instance of bme680_dev. * @param[in] dev : Structure instance of bme680_dev.
* @param[in] desired_settings : Variable used to select the settings which * @param[in] desired_settings : Variable used to select the settings which
* are to be get from the sensor. * are to be get from the sensor.
* *
* @return Result of API execution status * @return Result of API execution status
* @retval zero -> Success / +ve value -> Warning / -ve value -> Error. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
*/ */
int8_t bme680_get_sensor_settings(uint16_t desired_settings, struct bme680_dev *dev); int8_t bme680_get_sensor_settings(uint16_t desired_settings, struct bme680_dev *dev);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* End of CPP guard */ #endif /* End of CPP guard */
#endif /* BME680_H_ */ #endif /* BME680_H_ */
/** @}*/ /** @}*/

File diff suppressed because it is too large Load Diff