]> git.itanic.dy.fi Git - BME280_driver/blobdiff - bme280.h
Hide excess debug messages by default
[BME280_driver] / bme280.h
index 414b3bd346d0633e657ea15d4a7bb66cd1ced578..fd9599003177699ebe14b99fbef2e8d7a7c5d336 100644 (file)
--- a/bme280.h
+++ b/bme280.h
@@ -1,58 +1,51 @@
 /**\r
- * Copyright (C) 2018 - 2019 Bosch Sensortec GmbH\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions are met:\r
- *\r
- * Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- *\r
- * Neither the name of the copyright holder nor the names of the\r
- * contributors may be used to endorse or promote products derived from\r
- * this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\r
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR\r
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
- * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER\r
- * OR CONTRIBUTORS BE LIABLE FOR ANY\r
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\r
- * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
- * ANY WAY OUT OF THE USE OF THIS\r
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\r
- *\r
- * The information provided is believed to be accurate and reliable.\r
- * The copyright holder assumes no responsibility\r
- * for the consequences of use\r
- * of such information nor for any infringement of patents or\r
- * other rights of third parties which may result from its use.\r
- * No license is granted by implication or otherwise under any patent or\r
- * patent rights of the copyright holder.\r
- *\r
- * @file    bme280.h\r
- * @date    26 Aug 2019\r
- * @version 3.3.7\r
- * @brief\r
- *\r
- */\r
+* Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved.\r
+*\r
+* BSD-3-Clause\r
+*\r
+* Redistribution and use in source and binary forms, with or without\r
+* modification, are permitted provided that the following conditions are met:\r
+*\r
+* 1. Redistributions of source code must retain the above copyright\r
+*    notice, this list of conditions and the following disclaimer.\r
+*\r
+* 2. Redistributions in binary form must reproduce the above copyright\r
+*    notice, this list of conditions and the following disclaimer in the\r
+*    documentation and/or other materials provided with the distribution.\r
+*\r
+* 3. Neither the name of the copyright holder nor the names of its\r
+*    contributors may be used to endorse or promote products derived from\r
+*    this software without specific prior written permission.\r
+*\r
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
+* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\r
+* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+* POSSIBILITY OF SUCH DAMAGE.\r
+*\r
+* @file       bme280.h\r
+* @date       2020-03-28\r
+* @version    v3.5.0\r
+*\r
+*/\r
 \r
 /*! @file bme280.h\r
  * @brief Sensor driver for BME280 sensor\r
  */\r
 \r
 /*!\r
- * @defgroup BME280 SENSOR API\r
+ * @defgroup bme280 BME280\r
+ * @brief <a href="https://www.bosch-sensortec.com/bst/products/all_products/bme280">Product Overview</a>\r
+ * and  <a href="https://github.com/BoschSensortec/BME280_driver">Sensor API Source Code</a>\r
  */\r
+\r
 #ifndef BME280_H_\r
 #define BME280_H_\r
 \r
@@ -64,47 +57,97 @@ extern "C" {
 /* Header includes */\r
 #include "bme280_defs.h"\r
 \r
+/**\r
+ * \ingroup bme280\r
+ * \defgroup bme280ApiInit Initialization\r
+ * @brief Initialize the sensor and device structure\r
+ */\r
+\r
 /*!\r
- *  @brief This API is the entry point.\r
- *  It reads the chip-id and calibration data from the sensor.\r
+ * \ingroup bme280ApiInit\r
+ * \page bme280_api_bme280_init bme280_init\r
+ * \code\r
+ * int8_t bme280_init(struct bme280_dev *dev);\r
+ * \endcode\r
+ * @details This API reads the chip-id of the sensor which is the first step to\r
+ * verify the sensor and also calibrates the sensor\r
+ * As this API is the entry point, call this API before using other APIs.\r
+ *\r
+ * @param[in,out] dev : Structure instance of bme280_dev\r
+ *\r
+ * @return Result of API execution status.\r
  *\r
- *  @param[in,out] dev : Structure instance of bme280_dev\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
  *\r
- *  @return Result of API execution status\r
- *  @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
  */\r
 int8_t bme280_init(struct bme280_dev *dev);\r
 \r
+/**\r
+ * \ingroup bme280\r
+ * \defgroup bme280ApiRegister Registers\r
+ * @brief Generic API for accessing sensor registers\r
+ */\r
+\r
 /*!\r
- * @brief This API writes the given data to the register address\r
- * of the sensor.\r
- *\r
- * @param[in] reg_addr : Register address from where the data to be written.\r
+ * \ingroup bme280ApiRegister\r
+ * \page bme280_api_bme280_set_regs bme280_set_regs\r
+ * \code\r
+ * int8_t bme280_set_regs(const uint8_t reg_addr, const uint8_t *reg_data, uint8_t len, struct bme280_dev *dev);\r
+ * \endcode\r
+ * @details This API writes the given data to the register address of the sensor\r
+ *\r
+ * @param[in] reg_addr : Register addresses to where the data is to be written\r
  * @param[in] reg_data : Pointer to data buffer which is to be written\r
- * in the sensor.\r
- * @param[in] len : No of bytes of data to write..\r
- * @param[in] dev : Structure instance of bme280_dev.\r
+ *                       in the reg_addr of sensor.\r
+ * @param[in] len      : No of bytes of data to write\r
+ * @param[in,out] dev  : Structure instance of bme280_dev\r
+ *\r
+ * @return Result of API execution status.\r
+ *\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
  *\r
- * @return Result of API execution status\r
- * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
  */\r
-int8_t bme280_set_regs(uint8_t *reg_addr, const uint8_t *reg_data, uint8_t len, const struct bme280_dev *dev);\r
+int8_t bme280_set_regs(uint8_t *reg_addr, const uint8_t *reg_data, uint8_t len, struct bme280_dev *dev);\r
 \r
 /*!\r
- * @brief This API reads the data from the given register address of the sensor.\r
- *\r
- * @param[in] reg_addr : Register address from where the data to be read\r
+ * \ingroup bme280ApiRegister\r
+ * \page bme280_api_bme280_get_regs bme280_get_regs\r
+ * \code\r
+ * int8_t bme280_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint8_t len, struct bme280_dev *dev);\r
+ * \endcode\r
+ * @details This API reads the data from the given register address of sensor.\r
+ *\r
+ * @param[in] reg_addr  : Register address from where the data to be read\r
  * @param[out] reg_data : Pointer to data buffer to store the read data.\r
- * @param[in] len : No of bytes of data to be read.\r
- * @param[in] dev : Structure instance of bme280_dev.\r
+ * @param[in] len       : No of bytes of data to be read.\r
+ * @param[in,out] dev   : Structure instance of bme280_dev.\r
+ *\r
+ * @return Result of API execution status.\r
+ *\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
  *\r
- * @return Result of API execution status\r
- * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
  */\r
-int8_t bme280_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, const struct bme280_dev *dev);\r
+int8_t bme280_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, struct bme280_dev *dev);\r
+\r
+/**\r
+ * \ingroup bme280\r
+ * \defgroup bme280ApiSensorSettings Sensor Settings\r
+ * @brief Generic API for accessing sensor settings\r
+ */\r
 \r
 /*!\r
- * @brief This API sets the oversampling, filter and standby duration\r
+ * \ingroup bme280ApiSensorSettings\r
+ * \page bme280_api_bme280_set_sensor_settings bme280_set_sensor_settings\r
+ * \code\r
+ * int8_t bme280_set_sensor_settings(uint8_t desired_settings, const struct bme280_dev *dev);\r
+ * \endcode\r
+ * @details This API sets the oversampling, filter and standby duration\r
  * (normal mode) settings in the sensor.\r
  *\r
  * @param[in] dev : Structure instance of bme280_dev.\r
@@ -124,23 +167,47 @@ int8_t bme280_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, const
  * BME280_STANDBY_SEL  |   To set standby duration setting.\r
  *\r
  * @return Result of API execution status\r
- * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.\r
+ *\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
+ *\r
  */\r
-int8_t bme280_set_sensor_settings(uint8_t desired_settings, const struct bme280_dev *dev);\r
+int8_t bme280_set_sensor_settings(uint8_t desired_settings, struct bme280_dev *dev);\r
 \r
 /*!\r
- * @brief This API gets the oversampling, filter and standby duration\r
+ * \ingroup bme280ApiSensorSettings\r
+ * \page bme280_api_bme280_get_sensor_settings bme280_get_sensor_settings\r
+ * \code\r
+ * int8_t bme280_get_sensor_settings(struct bme280_dev *dev);\r
+ * \endcode\r
+ * @details This API gets the oversampling, filter and standby duration\r
  * (normal mode) settings from the sensor.\r
  *\r
  * @param[in,out] dev : Structure instance of bme280_dev.\r
  *\r
  * @return Result of API execution status\r
- * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.\r
+ *\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
+ *\r
  */\r
 int8_t bme280_get_sensor_settings(struct bme280_dev *dev);\r
 \r
+/**\r
+ * \ingroup bme280\r
+ * \defgroup bme280ApiSensorMode Sensor Mode\r
+ * @brief Generic API for configuring sensor power mode\r
+ */\r
+\r
 /*!\r
- * @brief This API sets the power mode of the sensor.\r
+ * \ingroup bme280ApiSensorMode\r
+ * \page bme280_api_bme280_set_sensor_mode bme280_set_sensor_mode\r
+ * \code\r
+ * int8_t bme280_set_sensor_mode(uint8_t sensor_mode, const struct bme280_dev *dev);\r
+ * \endcode\r
+ * @details This API sets the power mode of the sensor.\r
  *\r
  * @param[in] dev : Structure instance of bme280_dev.\r
  * @param[in] sensor_mode : Variable which contains the power mode to be set.\r
@@ -152,12 +219,21 @@ int8_t bme280_get_sensor_settings(struct bme280_dev *dev);
  *     3                | BME280_NORMAL_MODE\r
  *\r
  * @return Result of API execution status\r
- * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
+ *\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
+ *\r
  */\r
-int8_t bme280_set_sensor_mode(uint8_t sensor_mode, const struct bme280_dev *dev);\r
+int8_t bme280_set_sensor_mode(uint8_t sensor_mode, struct bme280_dev *dev);\r
 \r
 /*!\r
- * @brief This API gets the power mode of the sensor.\r
+ * \ingroup bme280ApiSensorMode\r
+ * \page bme280_api_bme280_get_sensor_mode bme280_get_sensor_mode\r
+ * \code\r
+ * int8_t bme280_get_sensor_mode(uint8_t *sensor_mode, const struct bme280_dev *dev);\r
+ * \endcode\r
+ * @details This API gets the power mode of the sensor.\r
  *\r
  * @param[in] dev : Structure instance of bme280_dev.\r
  * @param[out] sensor_mode : Pointer variable to store the power mode.\r
@@ -169,22 +245,52 @@ int8_t bme280_set_sensor_mode(uint8_t sensor_mode, const struct bme280_dev *dev)
  *     3                | BME280_NORMAL_MODE\r
  *\r
  * @return Result of API execution status\r
- * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
+ *\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
+ *\r
+ */\r
+int8_t bme280_get_sensor_mode(uint8_t *sensor_mode, struct bme280_dev *dev);\r
+\r
+/**\r
+ * \ingroup bme280\r
+ * \defgroup bme280ApiSystem System\r
+ * @brief API that performs system-level operations\r
  */\r
-int8_t bme280_get_sensor_mode(uint8_t *sensor_mode, const struct bme280_dev *dev);\r
 \r
 /*!\r
- * @brief This API performs the soft reset of the sensor.\r
+ * \ingroup bme280ApiSystem\r
+ * \page bme280_api_bme280_soft_reset bme280_soft_reset\r
+ * \code\r
+ * int8_t bme280_soft_reset(struct bme280_dev *dev);\r
+ * \endcode\r
+ * @details This API soft-resets the sensor.\r
  *\r
- * @param[in] dev : Structure instance of bme280_dev.\r
+ * @param[in,out] dev : Structure instance of bme280_dev.\r
  *\r
- * @return Result of API execution status\r
- * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.\r
+ * @return Result of API execution status.\r
+ *\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
+ *\r
+ */\r
+int8_t bme280_soft_reset(struct bme280_dev *dev);\r
+\r
+/**\r
+ * \ingroup bme280\r
+ * \defgroup bme280ApiSensorData Sensor Data\r
+ * @brief Data processing of sensor\r
  */\r
-int8_t bme280_soft_reset(const struct bme280_dev *dev);\r
 \r
 /*!\r
- * @brief This API reads the pressure, temperature and humidity data from the\r
+ * \ingroup bme280ApiSensorData\r
+ * \page bme280_api_bme280_get_sensor_data bme280_get_sensor_data\r
+ * \code\r
+ * int8_t bme280_get_sensor_data(uint8_t sensor_comp, struct bme280_data *comp_data, struct bme280_dev *dev);\r
+ * \endcode\r
+ * @details This API reads the pressure, temperature and humidity data from the\r
  * sensor, compensates the data and store it in the bme280_data structure\r
  * instance passed by the user.\r
  *\r
@@ -202,22 +308,40 @@ int8_t bme280_soft_reset(const struct bme280_dev *dev);
  * @param[in] dev : Structure instance of bme280_dev.\r
  *\r
  * @return Result of API execution status\r
- * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
+ *\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
+ *\r
  */\r
 int8_t bme280_get_sensor_data(uint8_t sensor_comp, struct bme280_data *comp_data, struct bme280_dev *dev);\r
 \r
 /*!\r
- *  @brief This API is used to parse the pressure, temperature and\r
+ * \ingroup bme280ApiSensorData\r
+ * \page bme280_api_bme280_parse_sensor_data bme280_parse_sensor_data\r
+ * \code\r
+ * void bme280_parse_sensor_data(const uint8_t *reg_data, struct bme280_uncomp_data *uncomp_data);\r
+ * \endcode\r
+ *  @details This API is used to parse the pressure, temperature and\r
  *  humidity data and store it in the bme280_uncomp_data structure instance.\r
  *\r
  *  @param[in] reg_data     : Contains register data which needs to be parsed\r
  *  @param[out] uncomp_data : Contains the uncompensated pressure, temperature\r
  *  and humidity data.\r
+ *\r
  */\r
 void bme280_parse_sensor_data(const uint8_t *reg_data, struct bme280_uncomp_data *uncomp_data);\r
 \r
 /*!\r
- * @brief This API is used to compensate the pressure and/or\r
+ * \ingroup bme280ApiSensorData\r
+ * \page bme280_api_bme280_compensate_data bme280_compensate_data\r
+ * \code\r
+ * int8_t bme280_compensate_data(uint8_t sensor_comp,\r
+ *                             const struct bme280_uncomp_data *uncomp_data,\r
+ *                             struct bme280_data *comp_data,\r
+ *                             struct bme280_calib_data *calib_data);\r
+ * \endcode\r
+ * @details This API is used to compensate the pressure and/or\r
  * temperature and/or humidity data according to the component selected by the\r
  * user.\r
  *\r
@@ -230,13 +354,40 @@ void bme280_parse_sensor_data(const uint8_t *reg_data, struct bme280_uncomp_data
  * @param[in] calib_data : Pointer to the calibration data structure.\r
  *\r
  * @return Result of API execution status.\r
- * @retval zero -> Success / -ve value -> Error\r
+ *\r
+ * @retval   0 -> Success.\r
+ * @retval > 0 -> Warning.\r
+ * @retval < 0 -> Fail.\r
+ *\r
  */\r
 int8_t bme280_compensate_data(uint8_t sensor_comp,\r
                               const struct bme280_uncomp_data *uncomp_data,\r
                               struct bme280_data *comp_data,\r
                               struct bme280_calib_data *calib_data);\r
 \r
+/**\r
+ * \ingroup bme280\r
+ * \defgroup bme280ApiSensorDelay Sensor Delay\r
+ * @brief Generic API for measuring sensor delay\r
+ */\r
+\r
+/*!\r
+ * \ingroup bme280ApiSensorDelay\r
+ * \page bme280_api_bme280_cal_meas_delay bme280_cal_meas_delay\r
+ * \code\r
+ * uint32_t bme280_cal_meas_delay(const struct bme280_settings *settings);\r
+ * \endcode\r
+ * @brief This API is used to calculate the maximum delay in milliseconds required for the\r
+ * temperature/pressure/humidity(which ever are enabled) measurement to complete.\r
+ * The delay depends upon the number of sensors enabled and their oversampling configuration.\r
+ *\r
+ * @param[in] settings : contains the oversampling configurations.\r
+ *\r
+ * @return delay required in milliseconds.\r
+ *\r
+ */\r
+uint32_t bme280_cal_meas_delay(const struct bme280_settings *settings);\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif /* End of CPP guard */\r