Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: BME280.h
- Revision:
- 3:ab857b70346e
- Parent:
- 1:f01fab2521b1
- Child:
- 4:a1c46ef057a6
--- a/BME280.h Tue Sep 03 15:15:15 2019 +0000
+++ b/BME280.h Tue Sep 03 15:36:35 2019 +0000
@@ -276,9 +276,9 @@
/*!
- Library for BME680 Low power gas, pressure, temperature & humidity sensor.
+ Library for BME280 Combined humidity and pressure sensor.
*/
-class BME680
+class BME280
{
public:
/** Create an BME680 object connected to the specified I2C pins.
@@ -439,6 +439,297 @@
private:
/*!
+ * @brief This internal API puts the device to sleep mode.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ *
+ * @return Result of API execution status.
+ * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
+ */
+ int8_t put_device_to_sleep(const struct bme280_dev *dev);
+
+ /*!
+ * @brief This internal API writes the power mode in the sensor.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ * @param[in] sensor_mode : Variable which contains the power mode to be set.
+ *
+ * @return Result of API execution status.
+ * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
+ */
+ int8_t write_power_mode(uint8_t sensor_mode, const struct bme280_dev *dev);
+
+ /*!
+ * @brief This internal API is used to validate the device pointer for
+ * null conditions.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ *
+ * @return Result of API execution status
+ * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
+ */
+ int8_t null_ptr_check(const struct bme280_dev *dev);
+
+ /*!
+ * @brief This internal API interleaves the register address between the
+ * register data buffer for burst write operation.
+ *
+ * @param[in] reg_addr : Contains the register address array.
+ * @param[out] temp_buff : Contains the temporary buffer to store the
+ * register data and register address.
+ * @param[in] reg_data : Contains the register data to be written in the
+ * temporary buffer.
+ * @param[in] len : No of bytes of data to be written for burst write.
+ */
+ void interleave_reg_addr(const uint8_t *reg_addr, uint8_t *temp_buff, const uint8_t *reg_data, uint8_t len);
+
+ /*!
+ * @brief This internal API reads the calibration data from the sensor, parse
+ * it and store in the device structure.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ *
+ * @return Result of API execution status
+ * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
+ */
+ int8_t get_calib_data(struct bme280_dev *dev);
+
+ /*!
+ * @brief This internal API is used to parse the temperature and
+ * pressure calibration data and store it in the device structure.
+ *
+ * @param[out] dev : Structure instance of bme280_dev to store the calib data.
+ * @param[in] reg_data : Contains the calibration data to be parsed.
+ */
+ void parse_temp_press_calib_data(const uint8_t *reg_data, struct bme280_dev *dev);
+
+ /*!
+ * @brief This internal API is used to parse the humidity calibration data
+ * and store it in device structure.
+ *
+ * @param[out] dev : Structure instance of bme280_dev to store the calib data.
+ * @param[in] reg_data : Contains calibration data to be parsed.
+ */
+ void parse_humidity_calib_data(const uint8_t *reg_data, struct bme280_dev *dev);
+
+#ifdef BME280_FLOAT_ENABLE
+
+ /*!
+ * @brief This internal API is used to compensate the raw pressure data and
+ * return the compensated pressure data in double data type.
+ *
+ * @param[in] uncomp_data : Contains the uncompensated pressure data.
+ * @param[in] calib_data : Pointer to the calibration data structure.
+ *
+ * @return Compensated pressure data.
+ * @retval Compensated pressure data in double.
+ */
+ double compensate_pressure(const struct bme280_uncomp_data *uncomp_data,
+ const struct bme280_calib_data *calib_data);
+
+ /*!
+ * @brief This internal API is used to compensate the raw humidity data and
+ * return the compensated humidity data in double data type.
+ *
+ * @param[in] uncomp_data : Contains the uncompensated humidity data.
+ * @param[in] calib_data : Pointer to the calibration data structure.
+ *
+ * @return Compensated humidity data.
+ * @retval Compensated humidity data in double.
+ */
+ double compensate_humidity(const struct bme280_uncomp_data *uncomp_data,
+ const struct bme280_calib_data *calib_data);
+
+ /*!
+ * @brief This internal API is used to compensate the raw temperature data and
+ * return the compensated temperature data in double data type.
+ *
+ * @param[in] uncomp_data : Contains the uncompensated temperature data.
+ * @param[in] calib_data : Pointer to calibration data structure.
+ *
+ * @return Compensated temperature data.
+ * @retval Compensated temperature data in double.
+ */
+ double compensate_temperature(const struct bme280_uncomp_data *uncomp_data,
+ struct bme280_calib_data *calib_data);
+
+#else
+
+ /*!
+ * @brief This internal API is used to compensate the raw temperature data and
+ * return the compensated temperature data in integer data type.
+ *
+ * @param[in] uncomp_data : Contains the uncompensated temperature data.
+ * @param[in] calib_data : Pointer to calibration data structure.
+ *
+ * @return Compensated temperature data.
+ * @retval Compensated temperature data in integer.
+ */
+ int32_t compensate_temperature(const struct bme280_uncomp_data *uncomp_data,
+ struct bme280_calib_data *calib_data);
+
+ /*!
+ * @brief This internal API is used to compensate the raw pressure data and
+ * return the compensated pressure data in integer data type.
+ *
+ * @param[in] uncomp_data : Contains the uncompensated pressure data.
+ * @param[in] calib_data : Pointer to the calibration data structure.
+ *
+ * @return Compensated pressure data.
+ * @retval Compensated pressure data in integer.
+ */
+ uint32_t compensate_pressure(const struct bme280_uncomp_data *uncomp_data,
+ const struct bme280_calib_data *calib_data);
+
+ /*!
+ * @brief This internal API is used to compensate the raw humidity data and
+ * return the compensated humidity data in integer data type.
+ *
+ * @param[in] uncomp_data : Contains the uncompensated humidity data.
+ * @param[in] calib_data : Pointer to the calibration data structure.
+ *
+ * @return Compensated humidity data.
+ * @retval Compensated humidity data in integer.
+ */
+ uint32_t compensate_humidity(const struct bme280_uncomp_data *uncomp_data,
+ const struct bme280_calib_data *calib_data);
+
+#endif
+
+ /*!
+ * @brief This internal API is used to identify the settings which the user
+ * wants to modify in the sensor.
+ *
+ * @param[in] sub_settings : Contains the settings subset to identify particular
+ * group of settings which the user is interested to change.
+ * @param[in] desired_settings : Contains the user specified settings.
+ *
+ * @return Indicates whether user is interested to modify the settings which
+ * are related to sub_settings.
+ * @retval True -> User wants to modify this group of settings
+ * @retval False -> User does not want to modify this group of settings
+ */
+ uint8_t are_settings_changed(uint8_t sub_settings, uint8_t desired_settings);
+
+ /*!
+ * @brief This API sets the humidity oversampling settings of the sensor.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ *
+ * @return Result of API execution status
+ * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
+ */
+ int8_t set_osr_humidity_settings(const struct bme280_settings *settings, const struct bme280_dev *dev);
+
+ /*!
+ * @brief This internal API sets the oversampling settings for pressure,
+ * temperature and humidity in the sensor.
+ *
+ * @param[in] desired_settings : Variable used to select the settings which
+ * are to be set.
+ * @param[in] dev : Structure instance of bme280_dev.
+ *
+ * @return Result of API execution status
+ * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
+ */
+ int8_t set_osr_settings(uint8_t desired_settings,
+ const struct bme280_settings *settings,
+ const struct bme280_dev *dev);
+
+ /*!
+ * @brief This API sets the pressure and/or temperature oversampling settings
+ * in the sensor according to the settings selected by the user.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ * @param[in] desired_settings: variable to select the pressure and/or
+ * temperature oversampling settings.
+ *
+ * @return Result of API execution status
+ * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
+ */
+ int8_t set_osr_press_temp_settings(uint8_t desired_settings,
+ const struct bme280_settings *settings,
+ const struct bme280_dev *dev);
+
+ /*!
+ * @brief This internal API fills the pressure oversampling settings provided by
+ * the user in the data buffer so as to write in the sensor.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ * @param[out] reg_data : Variable which is filled according to the pressure
+ * oversampling data provided by the user.
+ */
+ void fill_osr_press_settings(uint8_t *reg_data, const struct bme280_settings *settings);
+
+ /*!
+ * @brief This internal API fills the temperature oversampling settings provided
+ * by the user in the data buffer so as to write in the sensor.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ * @param[out] reg_data : Variable which is filled according to the temperature
+ * oversampling data provided by the user.
+ */
+ void fill_osr_temp_settings(uint8_t *reg_data, const struct bme280_settings *settings);
+
+ /*!
+ * @brief This internal API sets the filter and/or standby duration settings
+ * in the sensor according to the settings selected by the user.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ * @param[in] desired_settings : variable to select the filter and/or
+ * standby duration settings.
+ *
+ * @return Result of API execution status
+ * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
+ */
+ int8_t set_filter_standby_settings(uint8_t desired_settings,
+ const struct bme280_settings *settings,
+ const struct bme280_dev *dev);
+
+ /*!
+ * @brief This internal API fills the filter settings provided by the user
+ * in the data buffer so as to write in the sensor.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ * @param[out] reg_data : Variable which is filled according to the filter
+ * settings data provided by the user.
+ */
+ void fill_filter_settings(uint8_t *reg_data, const struct bme280_settings *settings);
+
+ /*!
+ * @brief This internal API fills the standby duration settings provided by the
+ * user in the data buffer so as to write in the sensor.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ * @param[out] reg_data : Variable which is filled according to the standby
+ * settings data provided by the user.
+ */
+ void fill_standby_settings(uint8_t *reg_data, const struct bme280_settings *settings);
+
+ /*!
+ * @brief This internal API parse the oversampling(pressure, temperature
+ * and humidity), filter and standby duration settings and store in the
+ * device structure.
+ *
+ * @param[out] dev : Structure instance of bme280_dev.
+ * @param[in] reg_data : Register data to be parsed.
+ */
+ void parse_device_settings(const uint8_t *reg_data, struct bme280_settings *settings);
+
+ /*!
+ * @brief This internal API reloads the already existing device settings in the
+ * sensor after soft reset.
+ *
+ * @param[in] dev : Structure instance of bme280_dev.
+ * @param[in] settings : Pointer variable which contains the settings to
+ * be set in the sensor.
+ *
+ * @return Result of API execution status
+ * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
+ */
+ int8_t reload_device_settings(const struct bme280_settings *settings, const struct bme280_dev *dev);
+
+ /*!
* @brief This API is used to parse the pressure, temperature and
* humidity data and store it in the bme280_uncomp_data structure instance.
*