]> git.itanic.dy.fi Git - BME280_driver/commitdiff
Created Bosch Sensortec BME280 driver
authorSridharan <sridharan.paulpandian@in.bosch.com>
Wed, 17 Dec 2014 10:29:54 +0000 (15:59 +0530)
committerSridharan <sridharan.paulpandian@in.bosch.com>
Wed, 17 Dec 2014 10:29:54 +0000 (15:59 +0530)
bme280.c [new file with mode: 0644]
bme280.h [new file with mode: 0644]
bme280_support.c [new file with mode: 0644]

diff --git a/bme280.c b/bme280.c
new file mode 100644 (file)
index 0000000..b555110
--- /dev/null
+++ b/bme280.c
@@ -0,0 +1,2164 @@
+/*
+****************************************************************************
+* Copyright (C) 2013 - 2014 Bosch Sensortec GmbH
+*
+* bme280.c
+* Date: 2014/12/12
+* Revision: 2.0.3(Pressure and Temperature compensation code revision is 1.1
+*               and Humidity compensation code revision is 1.0)
+*
+* Usage: Sensor Driver file for BME280 sensor
+*
+****************************************************************************
+* 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.
+**************************************************************************/
+
+#include "bme280.h"
+static struct bme280_t *p_bme280; /**< pointer to BME280 */
+
+/*!
+ *     @brief This function is used for initialize
+ *     the bus read and bus write functions
+ *  and assign the chip id and I2C address of the BME280 sensor
+ *     chip id is read in the register 0xD0 bit from 0 to 7
+ *
+ *      @param bme280 structure pointer.
+ *
+ *     @note While changing the parameter of the bme280_t
+ *     @note consider the following point:
+ *     Changing the reference value of the parameter
+ *     will changes the local copy or local reference
+ *     make sure your changes will not
+ *     affect the reference value of the parameter
+ *     (Better case don't change the reference value of the parameter)
+ *
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_init(struct bme280_t *bme280)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       p_bme280 = bme280;
+       /* assign BME280 ptr */
+       com_rslt = p_bme280->BME280_BUS_READ_FUNC(p_bme280->dev_addr,
+       BME280_CHIP_ID_REG, &v_data_u8, BME280_ONE_U8X);
+       /* read Chip Id */
+       p_bme280->chip_id = v_data_u8;
+
+       bme280_get_calib_param();
+       /* readout bme280 calibparam structure */
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to read uncompensated temperature
+ *     in the registers 0xFA, 0xFB and 0xFC
+ *     @note 0xFA -> MSB -> bit from 0 to 7
+ *     @note 0xFB -> LSB -> bit from 0 to 7
+ *     @note 0xFC -> LSB -> bit from 4 to 7
+ *
+ * @param v_uncomp_temperature_s32 : The value of uncompensated temperature
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_uncomp_temperature(
+s32 *v_uncomp_temperature_s32)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       /* Array holding the MSB and LSb value
+       a_data_u8r[0] - Temperature MSB
+       a_data_u8r[1] - Temperature LSB
+       a_data_u8r[2] - Temperature LSB
+       */
+       u8 a_data_u8r[ARRAY_SIZE_THREE] = {
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X};
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_TEMPERATURE_MSB_REG,
+                       a_data_u8r, BME280_THREE_U8X);
+                       *v_uncomp_temperature_s32 = (s32)(((
+                       (u32) (a_data_u8r[INDEX_ZERO]))
+                       << SHIFT_LEFT_12_POSITION) |
+                       (((u32)(a_data_u8r[INDEX_ONE]))
+                       << SHIFT_LEFT_4_POSITION)
+                       | ((u32)a_data_u8r[INDEX_TWO] >>
+                       SHIFT_RIGHT_4_POSITION));
+               }
+       return com_rslt;
+}
+/*!
+ * @brief Reads actual temperature from uncompensated temperature
+ * @note Returns the value in 0.01 degree Centigrade
+ * Output value of "5123" equals 51.23 DegC.
+ *
+ *
+ *
+ *  @param  v_uncomp_temperature_s32 : value of uncompensated temperature
+ *
+ *
+ *  @return Returns the actual temperature
+ *
+*/
+s32 bme280_compensate_T_int32(s32 v_uncomp_temperature_s32)
+{
+       s32 v_x1_u32r = BME280_ZERO_U8X;
+       s32 v_x2_u32r = BME280_ZERO_U8X;
+       s32 temperature = BME280_ZERO_U8X;
+
+       v_x1_u32r  = ((((v_uncomp_temperature_s32
+       >> SHIFT_RIGHT_3_POSITION) - ((s32)
+       p_bme280->cal_param.dig_T1 << SHIFT_LEFT_1_POSITION))) *
+       ((s32)p_bme280->cal_param.dig_T2))
+       >> SHIFT_RIGHT_11_POSITION;
+       v_x2_u32r  = (((((v_uncomp_temperature_s32
+       >> SHIFT_RIGHT_4_POSITION) -
+       ((s32)p_bme280->cal_param.dig_T1))
+       * ((v_uncomp_temperature_s32 >> SHIFT_RIGHT_4_POSITION) -
+       ((s32)p_bme280->cal_param.dig_T1)))
+       >> SHIFT_RIGHT_12_POSITION) *
+       ((s32)p_bme280->cal_param.dig_T3))
+       >> SHIFT_RIGHT_14_POSITION;
+       p_bme280->cal_param.t_fine = v_x1_u32r + v_x2_u32r;
+       temperature  = (p_bme280->cal_param.t_fine
+       * BME280_FIVE_U8X + BME280_ONE_TWENTY_EIGHT_U8X)
+       >> SHIFT_RIGHT_8_POSITION;
+       return temperature;
+}
+/*!
+ * @brief Reads actual temperature from uncompensated temperature
+ * @note Returns the value with 500LSB/DegC centred around 24 DegC
+ * output value of "5123" equals(5123/500)+24 = 34.246DegC
+ *
+ *
+ *  @param v_uncomp_temperature_s32: value of uncompensated temperature
+ *
+ *
+ *
+ *  @return Return the actual temperature as s16 output
+ *
+*/
+s16 bme280_compensate_T_int32_sixteen_bit_output(
+s32 v_uncomp_temperature_s32)
+{
+       s16 temperature = BME280_ZERO_U8X;
+       bme280_compensate_T_int32(v_uncomp_temperature_s32);
+       temperature  = (s16)((((
+       p_bme280->cal_param.t_fine
+       - BME280_TEMP_1_2_2_8_8_0_DATA)
+       * BME280_TWENTY_FIVE_U8X)
+       + BME280_ONE_TWENTY_EIGHT_U8X)
+       >> SHIFT_RIGHT_8_POSITION);
+
+       return temperature;
+}
+/*!
+ *     @brief This API is used to read uncompensated pressure.
+ *     in the registers 0xF7, 0xF8 and 0xF9
+ *     @note 0xF7 -> MSB -> bit from 0 to 7
+ *     @note 0xF8 -> LSB -> bit from 0 to 7
+ *     @note 0xF9 -> LSB -> bit from 4 to 7
+ *
+ *
+ *
+ *     @param v_uncomp_pressure_s32 : The value of uncompensated pressure
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_uncomp_pressure(
+s32 *v_uncomp_pressure_s32)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       /* Array holding the MSB and LSb value
+       a_data_u8[0] - Pressure MSB
+       a_data_u8[1] - Pressure LSB
+       a_data_u8[2] - Pressure LSB
+       */
+       u8 a_data_u8[ARRAY_SIZE_THREE] = {
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X};
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_PRESSURE_MSB_REG,
+                       a_data_u8, BME280_THREE_U8X);
+                       *v_uncomp_pressure_s32 = (s32)((
+                       ((u32)(a_data_u8[INDEX_ZERO]))
+                       << SHIFT_LEFT_12_POSITION) |
+                       (((u32)(a_data_u8[INDEX_ONE]))
+                       << SHIFT_LEFT_4_POSITION) |
+                       ((u32)a_data_u8[INDEX_TWO] >>
+                       SHIFT_RIGHT_4_POSITION));
+               }
+       return com_rslt;
+}
+/*!
+ * @brief Reads actual pressure from uncompensated pressure
+ * @note Returns the value in Pascal(Pa)
+ * Output value of "96386" equals 96386 Pa =
+ * 963.86 hPa = 963.86 millibar
+ *
+ *
+ *
+ *  @param v_uncomp_pressure_s32 : value of uncompensated pressure
+ *
+ *
+ *
+ *  @return Return the actual pressure output as u32
+ *
+*/
+u32 bme280_compensate_P_int32(s32 v_uncomp_pressure_s32)
+{
+       s32 v_x1_u32 = BME280_ZERO_U8X;
+       s32 v_x2_u32 = BME280_ZERO_U8X;
+       u32 v_pressure_u32 = BME280_ZERO_U8X;
+
+       v_x1_u32 = (((s32)p_bme280->cal_param.t_fine)
+       >> SHIFT_RIGHT_1_POSITION) -
+       (s32)BME280_PRESSURE_6_4_0_0_0_DATA;
+       v_x2_u32 = (((v_x1_u32 >> SHIFT_RIGHT_2_POSITION)
+       * (v_x1_u32 >> SHIFT_RIGHT_2_POSITION))
+       >> SHIFT_RIGHT_11_POSITION) *
+       ((s32)p_bme280->cal_param.dig_P6);
+       v_x2_u32 = v_x2_u32 + ((v_x1_u32 *
+       ((s32)p_bme280->cal_param.dig_P5))
+       << SHIFT_LEFT_1_POSITION);
+       v_x2_u32 = (v_x2_u32 >> SHIFT_RIGHT_2_POSITION) +
+       (((s32)p_bme280->cal_param.dig_P4)
+       << SHIFT_LEFT_16_POSITION);
+       v_x1_u32 = (((p_bme280->cal_param.dig_P3
+       * (((v_x1_u32 >> SHIFT_RIGHT_2_POSITION) *
+       (v_x1_u32 >> SHIFT_RIGHT_2_POSITION))
+       >> SHIFT_RIGHT_13_POSITION)) >> SHIFT_RIGHT_3_POSITION) +
+       ((((s32)p_bme280->cal_param.dig_P2) *
+       v_x1_u32) >> SHIFT_RIGHT_1_POSITION))
+       >> SHIFT_RIGHT_18_POSITION;
+       v_x1_u32 = ((((BME280_PRESSURE_3_2_7_6_8_DATA + v_x1_u32)) *
+       ((s32)p_bme280->cal_param.dig_P1))
+       >> SHIFT_RIGHT_15_POSITION);
+       v_pressure_u32 =
+       (((u32)(((s32)BME280_PRESSURE_1_0_4_8_5_7_6_DATA)
+       - v_uncomp_pressure_s32) -
+       (v_x2_u32 >> SHIFT_RIGHT_12_POSITION)))
+       * BME280_PRESSURE_3_1_2_5_DATA;
+       if (v_pressure_u32
+       < BME280_HEX_PRESSURE_8_0_0_0_0_0_0_0_DATA)
+               /* Avoid exception caused by division by zero */
+               if (v_x1_u32 != BME280_ZERO_U8X)
+                       v_pressure_u32 =
+                       (v_pressure_u32 << SHIFT_LEFT_1_POSITION) /
+                       ((u32)v_x1_u32);
+               else
+                       return BME280_ZERO_U8X;
+       else
+               /* Avoid exception caused by division by zero */
+               if (v_x1_u32 != BME280_ZERO_U8X)
+                       v_pressure_u32 = (v_pressure_u32
+                       / (u32)v_x1_u32) * BME280_TWO_U8X;
+               else
+                       return BME280_ZERO_U8X;
+
+               v_x1_u32 = (((s32)p_bme280->cal_param.dig_P9) *
+               ((s32)(((v_pressure_u32 >> SHIFT_RIGHT_3_POSITION)
+               * (v_pressure_u32 >> SHIFT_RIGHT_3_POSITION))
+               >> SHIFT_RIGHT_13_POSITION)))
+               >> SHIFT_RIGHT_12_POSITION;
+               v_x2_u32 = (((s32)(v_pressure_u32
+               >> SHIFT_RIGHT_2_POSITION)) *
+               ((s32)p_bme280->cal_param.dig_P8))
+               >> SHIFT_RIGHT_13_POSITION;
+               v_pressure_u32 = (u32)((s32)v_pressure_u32 +
+               ((v_x1_u32 + v_x2_u32 + p_bme280->cal_param.dig_P7)
+               >> SHIFT_RIGHT_4_POSITION));
+
+       return v_pressure_u32;
+}
+/*!
+ *     @brief This API is used to read uncompensated humidity.
+ *     in the registers 0xF7, 0xF8 and 0xF9
+ *     @note 0xFD -> MSB -> bit from 0 to 7
+ *     @note 0xFE -> LSB -> bit from 0 to 7
+ *
+ *
+ *
+ *     @param v_uncomp_humidity_s32 : The value of uncompensated humidity
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_uncomp_humidity(
+s32 *v_uncomp_humidity_s32)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       /* Array holding the MSB and LSb value
+       a_data_u8[0] - Humidity MSB
+       a_data_u8[1] - Humidity LSB
+       */
+       u8 a_data_u8[ARRAY_SIZE_TWO] = {
+       BME280_ZERO_U8X, BME280_ZERO_U8X};
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_HUMIDITY_MSB_REG, a_data_u8, BME280_TWO_U8X);
+                       *v_uncomp_humidity_s32 = (s32)(
+                       (((u32)(a_data_u8[INDEX_ZERO]))
+                       << SHIFT_LEFT_8_POSITION)|
+                       ((u32)(a_data_u8[INDEX_ONE])));
+               }
+       return com_rslt;
+}
+/*!
+ * @brief Reads actual humidity from uncompensated humidity
+ * @note Returns the value in %rH as unsigned 32bit integer
+ * in Q22.10 format(22 integer 10 fractional bits).
+ * @note An output value of 42313
+ * represents 42313 / 1024 = 41.321 %rH
+ *
+ *
+ *
+ *  @param  v_uncomp_humidity_s32: value of uncompensated humidity
+ *
+ *  @return Return the actual relative humidity output as u32
+ *
+*/
+u32 bme280_compensate_H_int32(s32 v_uncomp_humidity_s32)
+{
+       s32 v_x1_u32;
+       v_x1_u32 = (p_bme280->cal_param.t_fine
+       - ((s32)BME280_HUMIDITY_7_6_8_0_0_DATA));
+       v_x1_u32 = (((((v_uncomp_humidity_s32
+       << SHIFT_LEFT_14_POSITION) -
+       (((s32)p_bme280->cal_param.dig_H4)
+       << SHIFT_LEFT_20_POSITION) -
+       (((s32)p_bme280->cal_param.dig_H5) * v_x1_u32)) +
+       ((s32)BME280_HUMIDITY_1_6_3_8_4_DATA))
+       >> SHIFT_RIGHT_15_POSITION) *
+       (((((((v_x1_u32 *
+       ((s32)p_bme280->cal_param.dig_H6))
+       >> SHIFT_RIGHT_10_POSITION) *
+       (((v_x1_u32 * ((s32)p_bme280->cal_param.dig_H3))
+       >> SHIFT_RIGHT_11_POSITION) +
+       ((s32)BME280_HUMIDITY_3_2_7_6_8_DATA)))
+       >> SHIFT_RIGHT_10_POSITION) +
+       ((s32)BME280_HUMIDITY_2_0_9_7_1_5_2_DATA)) *
+       ((s32)p_bme280->cal_param.dig_H2)
+       + BME280_HUMIDITY_8_1_9_2_DATA)
+       >> SHIFT_RIGHT_14_POSITION));
+       v_x1_u32 = (v_x1_u32 - (((((v_x1_u32
+       >> SHIFT_RIGHT_15_POSITION) *
+       (v_x1_u32 >> SHIFT_RIGHT_15_POSITION))
+       >> SHIFT_RIGHT_7_POSITION) *
+       ((s32)p_bme280->cal_param.dig_H1))
+       >> SHIFT_RIGHT_4_POSITION));
+       v_x1_u32 = (v_x1_u32 < BME280_ZERO_U8X
+       ? BME280_ZERO_U8X : v_x1_u32);
+       v_x1_u32 =
+       (v_x1_u32 > BME280_HUMIDITY_4_1_9_4_3_0_4_0_0_DATA ?
+       BME280_HUMIDITY_4_1_9_4_3_0_4_0_0_DATA : v_x1_u32);
+       return (u32)(v_x1_u32 >> SHIFT_RIGHT_12_POSITION);
+}
+/*!
+ * @brief Reads actual humidity from uncompensated humidity
+ * @note Returns the value in %rH as unsigned 16bit integer
+ * @note An output value of 42313
+ * represents 42313/512 = 82.643 %rH
+ *
+ *
+ *
+ *  @param v_uncomp_humidity_s32: value of uncompensated humidity
+ *
+ *
+ *  @return Return the actual relative humidity output as u16
+ *
+*/
+u16 bme280_compensate_H_int32_sixteen_bit_output(s32 v_uncomp_humidity_s32)
+{
+       u32 v_x1_u32;
+       u16 v_x2_u32;
+       v_x1_u32 =  bme280_compensate_H_int32(v_uncomp_humidity_s32);
+       v_x2_u32 = (u16)(v_x1_u32 >> SHIFT_RIGHT_1_POSITION);
+       return v_x2_u32;
+}
+/*!
+ * @brief This API used to read uncompensated
+ * pressure,temperature and humidity
+ *
+ *
+ *
+ *
+ *  @param  v_uncomp_pressure_s32: The value of uncompensated pressure.
+ *  @param  v_uncomp_temperature_s32: The value of uncompensated temperature
+ *  @param  v_uncomp_humidity_s32: The value of uncompensated humidity.
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_uncomp_pressure_temperature_humidity(
+s32 *v_uncomp_pressure_s32,
+s32 *v_uncomp_temperature_s32, s32 *v_uncomp_humidity_s32)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       /* Array holding the MSB and LSb value of
+       a_data_u8[0] - Pressure MSB
+       a_data_u8[1] - Pressure LSB
+       a_data_u8[1] - Pressure LSB
+       a_data_u8[1] - Temperature MSB
+       a_data_u8[1] - Temperature LSB
+       a_data_u8[1] - Temperature LSB
+       a_data_u8[1] - Humidity MSB
+       a_data_u8[1] - Humidity LSB
+       */
+       u8 a_data_u8[ARRAY_SIZE_EIGHT] = {
+       BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X};
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_PRESSURE_MSB_REG,
+                       a_data_u8, BME280_EIGHT_U8X);
+                       /*Pressure*/
+                       *v_uncomp_pressure_s32 = (s32)((
+                       ((u32)(a_data_u8[INDEX_ZERO]))
+                       << SHIFT_LEFT_12_POSITION) |
+                       (((u32)(a_data_u8[INDEX_ONE]))
+                       << SHIFT_LEFT_4_POSITION) |
+                       ((u32)a_data_u8[INDEX_TWO] >>
+                       SHIFT_RIGHT_4_POSITION));
+
+                       /* Temperature */
+                       *v_uncomp_temperature_s32 = (s32)(((
+                       (u32) (a_data_u8[INDEX_THREE]))
+                       << SHIFT_LEFT_12_POSITION) |
+                       (((u32)(a_data_u8[INDEX_FOUR]))
+                       << SHIFT_LEFT_4_POSITION)
+                       | ((u32)a_data_u8[INDEX_FIVE]
+                       >> SHIFT_RIGHT_4_POSITION));
+
+                       /*Humidity*/
+                       *v_uncomp_humidity_s32 = (s32)((
+                       ((u32)(a_data_u8[INDEX_SIX]))
+                       << SHIFT_LEFT_8_POSITION)|
+                       ((u32)(a_data_u8[INDEX_SEVEN])));
+               }
+       return com_rslt;
+}
+/*!
+ * @brief This API used to read true pressure, temperature and humidity
+ *
+ *
+ *
+ *
+ *     @param  v_pressure_u32 : The value of compensated pressure.
+ *     @param  v_temperature_s32 : The value of compensated temperature.
+ *     @param  v_humidity_u32 : The value of compensated humidity.
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_pressure_temperature_humidity(
+u32 *v_pressure_u32, s32 *v_temperature_s32, u32 *v_humidity_u32)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       s32 v_uncomp_pressure_s32 = BME280_ZERO_U8X;
+       s32 v_uncom_temperature_s32 = BME280_ZERO_U8X;
+       s32 v_uncom_humidity_s32 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       /* read the uncompensated pressure,
+                       temperature and humidity*/
+                       com_rslt =
+                       bme280_read_uncomp_pressure_temperature_humidity(
+                       &v_uncomp_pressure_s32, &v_uncom_temperature_s32,
+                       &v_uncom_humidity_s32);
+                       /* read the true pressure, temperature and humidity*/
+                       *v_temperature_s32 = bme280_compensate_T_int32(
+                       v_uncom_temperature_s32);
+                       *v_pressure_u32 = bme280_compensate_P_int32(
+                       v_uncomp_pressure_s32);
+                       *v_humidity_u32 = bme280_compensate_H_int32(
+                       v_uncom_humidity_s32);
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to
+ *     calibration parameters used for calculation in the registers
+ *
+ *  parameter | Register address |   bit
+ *------------|------------------|----------------
+ *     dig_T1    |  0x88 and 0x89   | from 0 : 7 to 8: 15
+ *     dig_T2    |  0x8A and 0x8B   | from 0 : 7 to 8: 15
+ *     dig_T3    |  0x8C and 0x8D   | from 0 : 7 to 8: 15
+ *     dig_P1    |  0x8E and 0x8F   | from 0 : 7 to 8: 15
+ *     dig_P2    |  0x90 and 0x91   | from 0 : 7 to 8: 15
+ *     dig_P3    |  0x92 and 0x93   | from 0 : 7 to 8: 15
+ *     dig_P4    |  0x94 and 0x95   | from 0 : 7 to 8: 15
+ *     dig_P5    |  0x96 and 0x97   | from 0 : 7 to 8: 15
+ *     dig_P6    |  0x98 and 0x99   | from 0 : 7 to 8: 15
+ *     dig_P7    |  0x9A and 0x9B   | from 0 : 7 to 8: 15
+ *     dig_P8    |  0x9C and 0x9D   | from 0 : 7 to 8: 15
+ *     dig_P9    |  0x9E and 0x9F   | from 0 : 7 to 8: 15
+ *     dig_H1    |         0xA1     | from 0 to 7
+ *     dig_H2    |  0xE1 and 0xE2   | from 0 : 7 to 8: 15
+ *     dig_H3    |         0xE3     | from 0 to 7
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_calib_param()
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 a_data_u8[ARRAY_SIZE_TWENTY_SIX] = {
+       BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X,
+       BME280_ZERO_U8X, BME280_ZERO_U8X, BME280_ZERO_U8X};
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_DIG_T1_LSB_REG,
+                       a_data_u8, BME280_TWENTY_SIX_U8X);
+
+                       p_bme280->cal_param.dig_T1 = (u16)(((
+                       (u16)((u8)a_data_u8[INDEX_ONE])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_ZERO]);
+                       p_bme280->cal_param.dig_T2 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_THREE])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_TWO]);
+                       p_bme280->cal_param.dig_T3 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_FIVE])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_FOUR]);
+                       p_bme280->cal_param.dig_P1 = (u16)(((
+                       (u16)((u8)a_data_u8[INDEX_SEVEN])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_SIX]);
+                       p_bme280->cal_param.dig_P2 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_NINE])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_EIGHT]);
+                       p_bme280->cal_param.dig_P3 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_ELEVEN])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_TEN]);
+                       p_bme280->cal_param.dig_P4 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_THIRTEEN])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_TWELVE]);
+                       p_bme280->cal_param.dig_P5 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_FIVETEEN])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_FOURTEEN]);
+                       p_bme280->cal_param.dig_P6 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_SEVENTEEN])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_SIXTEEN]);
+                       p_bme280->cal_param.dig_P7 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_NINETEEN])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_EIGHTEEN]);
+                       p_bme280->cal_param.dig_P8 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_TWENTY_ONE])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_TWENTY]);
+                       p_bme280->cal_param.dig_P9 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_TWENTY_THREE])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_TWENTY_TWO]);
+                       p_bme280->cal_param.dig_H1 =
+                       a_data_u8[INDEX_TWENTY_FIVE];
+                       com_rslt += p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_DIG_H2_LSB_REG, a_data_u8, BME280_SEVEN_U8X);
+                       p_bme280->cal_param.dig_H2 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_ONE])) <<
+                       SHIFT_LEFT_8_POSITION) | a_data_u8[INDEX_ZERO]);
+                       p_bme280->cal_param.dig_H3 = a_data_u8[INDEX_TWO];
+                       p_bme280->cal_param.dig_H4 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_THREE])) <<
+                       SHIFT_LEFT_4_POSITION) |
+                       (((u8)BME280_HEX_CALIB_0_F_DATA)
+                       & a_data_u8[INDEX_FOUR]));
+                       p_bme280->cal_param.dig_H5 = (s16)(((
+                       (s16)((s8)a_data_u8[INDEX_FIVE])) <<
+                       SHIFT_LEFT_4_POSITION) | (a_data_u8[INDEX_FOUR] >>
+                       SHIFT_RIGHT_4_POSITION));
+                       p_bme280->cal_param.dig_H6 = (s8)a_data_u8[INDEX_SIX];
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to get
+ *     the temperature oversampling setting in the register 0xF4
+ *     bits from 5 to 7
+ *
+ *     value               |   Temperature oversampling
+ * ---------------------|---------------------------------
+ *     0x00                | Skipped
+ *     0x01                | BME280_OVERSAMP_1X
+ *     0x02                | BME280_OVERSAMP_2X
+ *     0x03                | BME280_OVERSAMP_4X
+ *     0x04                | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07  | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param v_value_u8 : The value of temperature over sampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_oversamp_temperature(
+u8 *v_value_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       *v_value_u8 = BME280_GET_BITSLICE(v_data_u8,
+                       BME280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE);
+
+                       p_bme280->oversamp_temperature = *v_value_u8;
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to set
+ *     the temperature oversampling setting in the register 0xF4
+ *     bits from 5 to 7
+ *
+ *     value               |   Temperature oversampling
+ * ---------------------|---------------------------------
+ *     0x00                | Skipped
+ *     0x01                | BME280_OVERSAMP_1X
+ *     0x02                | BME280_OVERSAMP_2X
+ *     0x03                | BME280_OVERSAMP_4X
+ *     0x04                | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07  | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param v_value_u8 : The value of temperature over sampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_oversamp_temperature(
+u8 v_value_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       u8 v_prev_pow_mode_u8 = BME280_ZERO_U8X;
+       u8 v_pre_ctrl_hum_value_u8 = BME280_ZERO_U8X;
+       u8 v_pre_config_value_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       v_data_u8 = p_bme280->ctrl_meas_reg;
+                       v_data_u8 =
+                       BME280_SET_BITSLICE(v_data_u8,
+                       BME280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE, v_value_u8);
+                       com_rslt = bme280_get_power_mode(&v_prev_pow_mode_u8);
+                       if (v_prev_pow_mode_u8 != BME280_SLEEP_MODE) {
+                               com_rslt += bme280_set_soft_rst();
+                               p_bme280->delay_msec(BME280_3MS_DELAY);
+                               /* write previous value
+                               of configuration register*/
+                               v_pre_config_value_u8 = p_bme280->config_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CONFIG_REG,
+                               &v_pre_config_value_u8, BME280_ONE_U8X);
+                               /* write previous value
+                               of humidity oversampling*/
+                               v_pre_ctrl_hum_value_u8 =
+                               p_bme280->ctrl_hum_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_pre_ctrl_hum_value_u8, BME280_ONE_U8X);
+                               /* write previous and updated value
+                               of configuration register*/
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                       } else {
+                               com_rslt = p_bme280->BME280_BUS_WRITE_FUNC(
+                               p_bme280->dev_addr,
+                               BME280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                       }
+                               p_bme280->oversamp_temperature = v_value_u8;
+                               /* read the control measurement register value*/
+                               com_rslt = bme280_read_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               p_bme280->ctrl_meas_reg = v_data_u8;
+                               /* read the control humidity register value*/
+                               com_rslt += bme280_read_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               p_bme280->ctrl_hum_reg = v_data_u8;
+                               /* read the control
+                               configuration register value*/
+                               com_rslt += bme280_read_register(
+                                       BME280_CONFIG_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               p_bme280->config_reg = v_data_u8;
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to get
+ *     the pressure oversampling setting in the register 0xF4
+ *     bits from 2 to 4
+ *
+ *     value              | Pressure oversampling
+ * --------------------|--------------------------
+ *     0x00               | Skipped
+ *     0x01               | BME280_OVERSAMP_1X
+ *     0x02               | BME280_OVERSAMP_2X
+ *     0x03               | BME280_OVERSAMP_4X
+ *     0x04               | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07 | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param v_value_u8 : The value of pressure oversampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_oversamp_pressure(
+u8 *v_value_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       *v_value_u8 = BME280_GET_BITSLICE(
+                       v_data_u8,
+                       BME280_CTRL_MEAS_REG_OVERSAMP_PRESSURE);
+
+                       p_bme280->oversamp_pressure = *v_value_u8;
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to set
+ *     the pressure oversampling setting in the register 0xF4
+ *     bits from 2 to 4
+ *
+ *     value              | Pressure oversampling
+ * --------------------|--------------------------
+ *     0x00               | Skipped
+ *     0x01               | BME280_OVERSAMP_1X
+ *     0x02               | BME280_OVERSAMP_2X
+ *     0x03               | BME280_OVERSAMP_4X
+ *     0x04               | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07 | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param v_value_u8 : The value of pressure oversampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_oversamp_pressure(
+u8 v_value_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       u8 v_prev_pow_mode_u8 = BME280_ZERO_U8X;
+       u8 v_pre_ctrl_hum_value_u8 = BME280_ZERO_U8X;
+       u8 v_pre_config_value_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       v_data_u8 = p_bme280->ctrl_meas_reg;
+                       v_data_u8 =
+                       BME280_SET_BITSLICE(v_data_u8,
+                       BME280_CTRL_MEAS_REG_OVERSAMP_PRESSURE, v_value_u8);
+                       com_rslt = bme280_get_power_mode(&v_prev_pow_mode_u8);
+                       if (v_prev_pow_mode_u8 != BME280_SLEEP_MODE) {
+                               com_rslt += bme280_set_soft_rst();
+                               p_bme280->delay_msec(BME280_3MS_DELAY);
+                               /* write previous value of
+                               configuration register*/
+                               v_pre_config_value_u8 = p_bme280->config_reg;
+                               com_rslt = bme280_write_register(
+                                       BME280_CONFIG_REG,
+                               &v_pre_config_value_u8, BME280_ONE_U8X);
+                               /* write previous value of
+                               humidity oversampling*/
+                               v_pre_ctrl_hum_value_u8 =
+                               p_bme280->ctrl_hum_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_pre_ctrl_hum_value_u8, BME280_ONE_U8X);
+                               /* write previous and updated value of
+                               control measurement register*/
+                               bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                       } else {
+                               com_rslt = p_bme280->BME280_BUS_WRITE_FUNC(
+                               p_bme280->dev_addr,
+                               BME280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                       }
+                               p_bme280->oversamp_pressure = v_value_u8;
+                               /* read the control measurement register value*/
+                               com_rslt = bme280_read_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               p_bme280->ctrl_meas_reg = v_data_u8;
+                               /* read the control humidity register value*/
+                               com_rslt += bme280_read_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               p_bme280->ctrl_hum_reg = v_data_u8;
+                               /* read the control
+                               configuration register value*/
+                               com_rslt += bme280_read_register(
+                                       BME280_CONFIG_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               p_bme280->config_reg = v_data_u8;
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to get
+ *     the humidity oversampling setting in the register 0xF2
+ *     bits from 0 to 2
+ *
+ *     value               | Humidity oversampling
+ * ---------------------|-------------------------
+ *     0x00                | Skipped
+ *     0x01                | BME280_OVERSAMP_1X
+ *     0x02                | BME280_OVERSAMP_2X
+ *     0x03                | BME280_OVERSAMP_4X
+ *     0x04                | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07  | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param  v_value_u8 : The value of humidity over sampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_oversamp_humidity(
+u8 *v_value_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY__REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       *v_value_u8 = BME280_GET_BITSLICE(
+                       v_data_u8,
+                       BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY);
+
+                       p_bme280->oversamp_humidity = *v_value_u8;
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to set
+ *     the humidity oversampling setting in the register 0xF2
+ *     bits from 0 to 2
+ *
+ *     value               | Humidity oversampling
+ * ---------------------|-------------------------
+ *     0x00                | Skipped
+ *     0x01                | BME280_OVERSAMP_1X
+ *     0x02                | BME280_OVERSAMP_2X
+ *     0x03                | BME280_OVERSAMP_4X
+ *     0x04                | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07  | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param  v_value_u8 : The value of humidity over sampling
+ *
+ *
+ *
+ * @note The "BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY"
+ * register sets the humidity
+ * data acquisition options of the device.
+ * @note changes to this registers only become
+ * effective after a write operation to
+ * "BME280_CTRL_MEAS_REG" register.
+ * @note In the code automated reading and writing of
+ *     "BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY"
+ * @note register first set the
+ * "BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY"
+ *  and then read and write
+ *  the "BME280_CTRL_MEAS_REG" register in the function.
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_oversamp_humidity(
+u8 v_value_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       u8 pre_ctrl_meas_value = BME280_ZERO_U8X;
+       u8 v_pre_config_value_u8 = BME280_ZERO_U8X;
+       u8 v_prev_pow_mode_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       /* write humidity oversampling*/
+                       v_data_u8 = p_bme280->ctrl_hum_reg;
+                       v_data_u8 =
+                       BME280_SET_BITSLICE(v_data_u8,
+                       BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY, v_value_u8);
+                       com_rslt = bme280_get_power_mode(&v_prev_pow_mode_u8);
+                       if (v_prev_pow_mode_u8 != BME280_SLEEP_MODE) {
+                               com_rslt += bme280_set_soft_rst();
+                               p_bme280->delay_msec(BME280_3MS_DELAY);
+                               /* write previous value of
+                               configuration register*/
+                               v_pre_config_value_u8 = p_bme280->config_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CONFIG_REG,
+                               &v_pre_config_value_u8, BME280_ONE_U8X);
+                               /* write the value of control humidity*/
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               /* write previous value of
+                               control measurement register*/
+                               pre_ctrl_meas_value =
+                               p_bme280->ctrl_meas_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &pre_ctrl_meas_value, BME280_ONE_U8X);
+                       } else {
+                               com_rslt +=
+                               p_bme280->BME280_BUS_WRITE_FUNC(
+                               p_bme280->dev_addr,
+                               BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY__REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               /* Control humidity write will effective only
+                               after the control measurement register*/
+                               pre_ctrl_meas_value =
+                               p_bme280->ctrl_meas_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &pre_ctrl_meas_value, BME280_ONE_U8X);
+                       }
+                       p_bme280->oversamp_humidity = v_value_u8;
+                       /* read the control measurement register value*/
+                       com_rslt += bme280_read_register(BME280_CTRL_MEAS_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_meas_reg = v_data_u8;
+                       /* read the control humidity register value*/
+                       com_rslt += bme280_read_register(
+                       BME280_CTRL_HUMIDITY_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_hum_reg = v_data_u8;
+                       /* read the control configuration register value*/
+                       com_rslt += bme280_read_register(BME280_CONFIG_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->config_reg = v_data_u8;
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API used to get the
+ *     Operational Mode from the sensor in the register 0xF4 bit 0 and 1
+ *
+ *
+ *
+ *     @param v_power_mode_u8 : The value of power mode
+ *  value           |    mode
+ * -----------------|------------------
+ *     0x00            | BME280_SLEEP_MODE
+ *     0x01 and 0x02   | BME280_FORCED_MODE
+ *     0x03            | BME280_NORMAL_MODE
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_power_mode(u8 *v_power_mode_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_mode_u8r = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_CTRL_MEAS_REG_POWER_MODE__REG,
+                       &v_mode_u8r, BME280_ONE_U8X);
+                       *v_power_mode_u8 = BME280_GET_BITSLICE(v_mode_u8r,
+                       BME280_CTRL_MEAS_REG_POWER_MODE);
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API used to set the
+ *     Operational Mode from the sensor in the register 0xF4 bit 0 and 1
+ *
+ *
+ *
+ *     @param v_power_mode_u8 : The value of power mode
+ *  value           |    mode
+ * -----------------|------------------
+ *     0x00            | BME280_SLEEP_MODE
+ *     0x01 and 0x02   | BME280_FORCED_MODE
+ *     0x03            | BME280_NORMAL_MODE
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_power_mode(u8 v_power_mode_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_mode_u8r = BME280_ZERO_U8X;
+       u8 v_prev_pow_mode_u8 = BME280_ZERO_U8X;
+       u8 v_pre_ctrl_hum_value_u8 = BME280_ZERO_U8X;
+       u8 v_pre_config_value_u8 = BME280_ZERO_U8X;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       if (v_power_mode_u8 < BME280_FOUR_U8X) {
+                               v_mode_u8r = p_bme280->ctrl_meas_reg;
+                               v_mode_u8r =
+                               BME280_SET_BITSLICE(v_mode_u8r,
+                               BME280_CTRL_MEAS_REG_POWER_MODE,
+                               v_power_mode_u8);
+                               com_rslt = bme280_get_power_mode(
+                                       &v_prev_pow_mode_u8);
+                               if (v_prev_pow_mode_u8 != BME280_SLEEP_MODE) {
+                                       com_rslt += bme280_set_soft_rst();
+                                       p_bme280->delay_msec(BME280_3MS_DELAY);
+                                       /* write previous value of
+                                       configuration register*/
+                                       v_pre_config_value_u8 =
+                                       p_bme280->config_reg;
+                                       com_rslt = bme280_write_register(
+                                               BME280_CONFIG_REG,
+                                       &v_pre_config_value_u8, BME280_ONE_U8X);
+                                       /* write previous value of
+                                       humidity oversampling*/
+                                       v_pre_ctrl_hum_value_u8 =
+                                       p_bme280->ctrl_hum_reg;
+                                       com_rslt += bme280_write_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                                       &v_pre_ctrl_hum_value_u8,
+                                       BME280_ONE_U8X);
+                                       /* write previous and updated value of
+                                       control measurement register*/
+                                       com_rslt += bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                                       &v_mode_u8r, BME280_ONE_U8X);
+                               } else {
+                                       com_rslt =
+                                       p_bme280->BME280_BUS_WRITE_FUNC(
+                                       p_bme280->dev_addr,
+                                       BME280_CTRL_MEAS_REG_POWER_MODE__REG,
+                                       &v_mode_u8r, BME280_ONE_U8X);
+                               }
+                               /* read the control measurement register value*/
+                               com_rslt = bme280_read_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               p_bme280->ctrl_meas_reg = v_data_u8;
+                               /* read the control humidity register value*/
+                               com_rslt += bme280_read_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               p_bme280->ctrl_hum_reg = v_data_u8;
+                               /* read the config register value*/
+                               com_rslt += bme280_read_register(
+                                       BME280_CONFIG_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               p_bme280->config_reg = v_data_u8;
+                       } else {
+                       com_rslt = E_BME280_OUT_OF_RANGE;
+                       }
+               }
+       return com_rslt;
+}
+/*!
+ * @brief Used to reset the sensor
+ * The value 0xB6 is written to the 0xE0
+ * register the device is reset using the
+ * complete power-on-reset procedure.
+ * @note Soft reset can be easily set using bme280_set_softreset().
+ * @note Usage Hint : bme280_set_softreset()
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_soft_rst()
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_SOFT_RESET_CODE;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_WRITE_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_RST_REG, &v_data_u8, BME280_ONE_U8X);
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API used to get the sensor
+ *     SPI mode(communication type) in the register 0xF5 bit 0
+ *
+ *
+ *
+ *     @param v_enable_disable_u8 : The value of SPI enable
+ *     value  | Description
+ * --------|--------------
+ *   0     | Disable
+ *   1     | Enable
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_spi3(u8 *v_enable_disable_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_CONFIG_REG_SPI3_ENABLE__REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       *v_enable_disable_u8 = BME280_GET_BITSLICE(
+                       v_data_u8,
+                       BME280_CONFIG_REG_SPI3_ENABLE);
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API used to set the sensor
+ *     SPI mode(communication type) in the register 0xF5 bit 0
+ *
+ *
+ *
+ *     @param v_enable_disable_u8 : The value of SPI enable
+ *     value  | Description
+ * --------|--------------
+ *   0     | Disable
+ *   1     | Enable
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_spi3(u8 v_enable_disable_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       u8 pre_ctrl_meas_value = BME280_ZERO_U8X;
+       u8 v_prev_pow_mode_u8 = BME280_ZERO_U8X;
+       u8 v_pre_ctrl_hum_value_u8 =  BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       v_data_u8 = p_bme280->config_reg;
+                       v_data_u8 =
+                       BME280_SET_BITSLICE(v_data_u8,
+                       BME280_CONFIG_REG_SPI3_ENABLE, v_enable_disable_u8);
+                       com_rslt = bme280_get_power_mode(&v_prev_pow_mode_u8);
+                       if (v_prev_pow_mode_u8 != BME280_SLEEP_MODE) {
+                               com_rslt += bme280_set_soft_rst();
+                               p_bme280->delay_msec(BME280_3MS_DELAY);
+                               /* write previous and updated value of
+                               configuration register*/
+                               com_rslt += bme280_write_register(
+                                       BME280_CONFIG_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               /* write previous value of
+                               humidity oversampling*/
+                               v_pre_ctrl_hum_value_u8 =
+                               p_bme280->ctrl_hum_reg;
+                               com_rslt +=  bme280_write_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_pre_ctrl_hum_value_u8, BME280_ONE_U8X);
+                               /* write previous value of
+                               control measurement register*/
+                               pre_ctrl_meas_value =
+                               p_bme280->ctrl_meas_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &pre_ctrl_meas_value, BME280_ONE_U8X);
+                       } else {
+                               com_rslt =
+                               p_bme280->BME280_BUS_WRITE_FUNC(
+                               p_bme280->dev_addr,
+                               BME280_CONFIG_REG_SPI3_ENABLE__REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                       }
+                       /* read the control measurement register value*/
+                       com_rslt += bme280_read_register(
+                               BME280_CTRL_MEAS_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_meas_reg = v_data_u8;
+                       /* read the control humidity register value*/
+                       com_rslt += bme280_read_register(
+                               BME280_CTRL_HUMIDITY_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_hum_reg = v_data_u8;
+                       /* read the control configuration register value*/
+                       com_rslt += bme280_read_register(
+                               BME280_CONFIG_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->config_reg = v_data_u8;
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to reads filter setting
+ *     in the register 0xF5 bit 3 and 4
+ *
+ *
+ *
+ *     @param v_value_u8 : The value of IIR filter coefficient
+ *
+ *     value       |   Filter coefficient
+ * -------------|-------------------------
+ *     0x00        | BME280_FILTER_COEFF_OFF
+ *     0x01        | BME280_FILTER_COEFF_2
+ *     0x02        | BME280_FILTER_COEFF_4
+ *     0x03        | BME280_FILTER_COEFF_8
+ *     0x04        | BME280_FILTER_COEFF_16
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_filter(u8 *v_value_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_CONFIG_REG_FILTER__REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       *v_value_u8 = BME280_GET_BITSLICE(v_data_u8,
+                       BME280_CONFIG_REG_FILTER);
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API is used to write filter setting
+ *     in the register 0xF5 bit 3 and 4
+ *
+ *
+ *
+ *     @param v_value_u8 : The value of IIR filter coefficient
+ *
+ *     value       |   Filter coefficient
+ * -------------|-------------------------
+ *     0x00        | BME280_FILTER_COEFF_OFF
+ *     0x01        | BME280_FILTER_COEFF_2
+ *     0x02        | BME280_FILTER_COEFF_4
+ *     0x03        | BME280_FILTER_COEFF_8
+ *     0x04        | BME280_FILTER_COEFF_16
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_filter(u8 v_value_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       u8 pre_ctrl_meas_value = BME280_ZERO_U8X;
+       u8 v_prev_pow_mode_u8 = BME280_ZERO_U8X;
+       u8 v_pre_ctrl_hum_value_u8 =  BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       v_data_u8 = p_bme280->config_reg;
+                       v_data_u8 =
+                       BME280_SET_BITSLICE(v_data_u8,
+                       BME280_CONFIG_REG_FILTER, v_value_u8);
+                       com_rslt = bme280_get_power_mode(&v_prev_pow_mode_u8);
+                       if (v_prev_pow_mode_u8 != BME280_SLEEP_MODE) {
+                               com_rslt += bme280_set_soft_rst();
+                               p_bme280->delay_msec(BME280_3MS_DELAY);
+                               /* write previous and updated value of
+                               configuration register*/
+                               com_rslt += bme280_write_register(
+                                       BME280_CONFIG_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               /* write previous value of
+                               humidity oversampling*/
+                               v_pre_ctrl_hum_value_u8 =
+                               p_bme280->ctrl_hum_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_pre_ctrl_hum_value_u8, BME280_ONE_U8X);
+                               /* write previous value of
+                               control measurement register*/
+                               pre_ctrl_meas_value =
+                               p_bme280->ctrl_meas_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &pre_ctrl_meas_value, BME280_ONE_U8X);
+                       } else {
+                               com_rslt =
+                               p_bme280->BME280_BUS_WRITE_FUNC(
+                               p_bme280->dev_addr,
+                               BME280_CONFIG_REG_FILTER__REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                       }
+                       /* read the control measurement register value*/
+                       com_rslt += bme280_read_register(BME280_CTRL_MEAS_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_meas_reg = v_data_u8;
+                       /* read the control humidity register value*/
+                       com_rslt += bme280_read_register(
+                       BME280_CTRL_HUMIDITY_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_hum_reg = v_data_u8;
+                       /* read the configuration register value*/
+                       com_rslt += bme280_read_register(BME280_CONFIG_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->config_reg = v_data_u8;
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API used to Read the
+ *     standby duration time from the sensor in the register 0xF5 bit 5 to 7
+ *
+ *     @param v_standby_durn_u8 : The value of standby duration time value.
+ *  value       | standby duration
+ * -------------|-----------------------
+ *    0x00      | BME280_STANDBY_TIME_1_MS
+ *    0x01      | BME280_STANDBY_TIME_63_MS
+ *    0x02      | BME280_STANDBY_TIME_125_MS
+ *    0x03      | BME280_STANDBY_TIME_250_MS
+ *    0x04      | BME280_STANDBY_TIME_500_MS
+ *    0x05      | BME280_STANDBY_TIME_1000_MS
+ *    0x06      | BME280_STANDBY_TIME_2000_MS
+ *    0x07      | BME280_STANDBY_TIME_4000_MS
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_standby_durn(u8 *v_standby_durn_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       BME280_CONFIG_REG_TSB__REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       *v_standby_durn_u8 = BME280_GET_BITSLICE(
+                       v_data_u8, BME280_CONFIG_REG_TSB);
+               }
+       return com_rslt;
+}
+/*!
+ *     @brief This API used to write the
+ *     standby duration time from the sensor in the register 0xF5 bit 5 to 7
+ *
+ *     @param v_standby_durn_u8 : The value of standby duration time value.
+ *  value       | standby duration
+ * -------------|-----------------------
+ *    0x00      | BME280_STANDBY_TIME_1_MS
+ *    0x01      | BME280_STANDBY_TIME_63_MS
+ *    0x02      | BME280_STANDBY_TIME_125_MS
+ *    0x03      | BME280_STANDBY_TIME_250_MS
+ *    0x04      | BME280_STANDBY_TIME_500_MS
+ *    0x05      | BME280_STANDBY_TIME_1000_MS
+ *    0x06      | BME280_STANDBY_TIME_2000_MS
+ *    0x07      | BME280_STANDBY_TIME_4000_MS
+ *
+ *     @note Normal mode comprises an automated perpetual
+ *     cycling between an (active)
+ *     Measurement period and an (inactive) standby period.
+ *     @note The standby time is determined by
+ *     the contents of the register t_sb.
+ *     Standby time can be set using BME280_STANDBY_TIME_125_MS.
+ *
+ *     @note Usage Hint : bme280_set_standby_durn(BME280_STANDBY_TIME_125_MS)
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_standby_durn(u8 v_standby_durn_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       u8 pre_ctrl_meas_value = BME280_ZERO_U8X;
+       u8 v_prev_pow_mode_u8 = BME280_ZERO_U8X;
+       u8 v_pre_ctrl_hum_value_u8 =  BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       v_data_u8 = p_bme280->config_reg;
+                       v_data_u8 =
+                       BME280_SET_BITSLICE(v_data_u8,
+                       BME280_CONFIG_REG_TSB, v_standby_durn_u8);
+                       com_rslt = bme280_get_power_mode(&v_prev_pow_mode_u8);
+                       if (v_prev_pow_mode_u8 != BME280_SLEEP_MODE) {
+                               com_rslt += bme280_set_soft_rst();
+                               p_bme280->delay_msec(BME280_3MS_DELAY);
+                               /* write previous and updated value of
+                               configuration register*/
+                               com_rslt += bme280_write_register(
+                                       BME280_CONFIG_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                               /* write previous value of
+                               humidity oversampling*/
+                               v_pre_ctrl_hum_value_u8 =
+                               p_bme280->ctrl_hum_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_pre_ctrl_hum_value_u8, BME280_ONE_U8X);
+                               /* write previous value of control
+                               measurement register*/
+                               pre_ctrl_meas_value =
+                               p_bme280->ctrl_meas_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &pre_ctrl_meas_value, BME280_ONE_U8X);
+                       } else {
+                               com_rslt =
+                               p_bme280->BME280_BUS_WRITE_FUNC(
+                               p_bme280->dev_addr,
+                               BME280_CONFIG_REG_TSB__REG,
+                               &v_data_u8, BME280_ONE_U8X);
+                       }
+                       /* read the control measurement register value*/
+                       com_rslt += bme280_read_register(BME280_CTRL_MEAS_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_meas_reg = v_data_u8;
+                       /* read the control humidity register value*/
+                       com_rslt += bme280_read_register(
+                       BME280_CTRL_HUMIDITY_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_hum_reg = v_data_u8;
+                       /* read the configuration register value*/
+                       com_rslt += bme280_read_register(BME280_CONFIG_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->config_reg = v_data_u8;
+               }
+       return com_rslt;
+}
+/*
+ * @brief Writes the working mode to the sensor
+ *
+ *
+ *
+ *
+ *  @param v_work_mode_u8 : Mode to be set
+ *  value    | Working mode
+ * ----------|--------------------
+ *   0       | BME280_ULTRALOWPOWER_MODE
+ *   1       | BME280_LOWPOWER_MODE
+ *   2       | BME280_STANDARDRESOLUTION_MODE
+ *   3       | BME280_HIGHRESOLUTION_MODE
+ *   4       | BME280_ULTRAHIGHRESOLUTION_MODE
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+/*BME280_RETURN_FUNCTION_TYPE bme280_set_work_mode(u8 v_work_mode_u8)
+{
+BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+u8 v_data_u8 = BME280_ZERO_U8X;
+if (p_bme280 == BME280_NULL) {
+       return E_BME280_NULL_PTR;
+} else {
+       if (v_work_mode_u8 <= BME280_FOUR_U8X) {
+               com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,     BME280_CTRL_MEAS_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+               if (com_rslt == SUCCESS) {
+                       switch (v_work_mode_u8) {
+                       case BME280_ULTRALOWPOWER_MODE:
+                               p_bme280->oversamp_temperature =
+                               BME280_ULTRALOWPOWER_OSRS_T;
+                               p_bme280->osrs_p =
+                               BME280_ULTRALOWPOWER_OSRS_P;
+                               break;
+                       case BME280_LOWPOWER_MODE:
+                               p_bme280->oversamp_temperature =
+                               BME280_LOWPOWER_OSRS_T;
+                               p_bme280->osrs_p = BME280_LOWPOWER_OSRS_P;
+                               break;
+                       case BME280_STANDARDRESOLUTION_MODE:
+                               p_bme280->oversamp_temperature =
+                               BME280_STANDARDRESOLUTION_OSRS_T;
+                               p_bme280->osrs_p =
+                               BME280_STANDARDRESOLUTION_OSRS_P;
+                               break;
+                       case BME280_HIGHRESOLUTION_MODE:
+                               p_bme280->oversamp_temperature =
+                               BME280_HIGHRESOLUTION_OSRS_T;
+                               p_bme280->osrs_p = BME280_HIGHRESOLUTION_OSRS_P;
+                               break;
+                       case BME280_ULTRAHIGHRESOLUTION_MODE:
+                               p_bme280->oversamp_temperature =
+                               BME280_ULTRAHIGHRESOLUTION_OSRS_T;
+                               p_bme280->osrs_p =
+                               BME280_ULTRAHIGHRESOLUTION_OSRS_P;
+                               break;
+                       }
+                       v_data_u8 = BME280_SET_BITSLICE(v_data_u8,
+                               BME280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE,
+                               p_bme280->oversamp_temperature);
+                       v_data_u8 = BME280_SET_BITSLICE(v_data_u8,
+                               BME280_CTRL_MEAS_REG_OVERSAMP_PRESSURE,
+                               p_bme280->osrs_p);
+                       com_rslt += p_bme280->BME280_BUS_WRITE_FUNC(
+                               p_bme280->dev_addr,     BME280_CTRL_MEAS_REG,
+                               &v_data_u8, BME280_ONE_U8X);
+               }
+       } else {
+               com_rslt = E_BME280_OUT_OF_RANGE;
+       }
+}
+return com_rslt;
+}*/
+/*!
+ * @brief This API used to read uncompensated
+ * temperature,pressure and humidity in forced mode
+ *
+ *
+ *     @param v_uncom_pressure_s32: The value of uncompensated pressure
+ *     @param v_uncom_temperature_s32: The value of uncompensated temperature
+ *     @param v_uncom_humidity_s32: The value of uncompensated humidity
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE
+bme280_get_forced_uncomp_pressure_temperature_humidity(
+s32 *v_uncom_pressure_s32,
+s32 *v_uncom_temperature_s32, s32 *v_uncom_humidity_s32)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       u8 v_data_u8 = BME280_ZERO_U8X;
+       u8 v_waittime_u8r = BME280_ZERO_U8X;
+       u8 v_prev_pow_mode_u8 = BME280_ZERO_U8X;
+       u8 v_mode_u8r = BME280_ZERO_U8X;
+       u8 pre_ctrl_config_value = BME280_ZERO_U8X;
+       u8 v_pre_ctrl_hum_value_u8 = BME280_ZERO_U8X;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       v_mode_u8r = p_bme280->ctrl_meas_reg;
+                       v_mode_u8r =
+                       BME280_SET_BITSLICE(v_mode_u8r,
+                       BME280_CTRL_MEAS_REG_POWER_MODE, BME280_FORCED_MODE);
+                       com_rslt = bme280_get_power_mode(&v_prev_pow_mode_u8);
+                       if (v_prev_pow_mode_u8 != BME280_SLEEP_MODE) {
+                               com_rslt += bme280_set_soft_rst();
+                               p_bme280->delay_msec(BME280_3MS_DELAY);
+                               /* write previous and updated value of
+                               configuration register*/
+                               pre_ctrl_config_value = p_bme280->config_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CONFIG_REG,
+                               &pre_ctrl_config_value, BME280_ONE_U8X);
+                               /* write previous value of
+                               humidity oversampling*/
+                               v_pre_ctrl_hum_value_u8 =
+                               p_bme280->ctrl_hum_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_pre_ctrl_hum_value_u8, BME280_ONE_U8X);
+                               /* write the force mode  */
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &v_mode_u8r, BME280_ONE_U8X);
+                       } else {
+                               /* write previous value of
+                               humidity oversampling*/
+                               v_pre_ctrl_hum_value_u8 =
+                               p_bme280->ctrl_hum_reg;
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_HUMIDITY_REG,
+                               &v_pre_ctrl_hum_value_u8, BME280_ONE_U8X);
+                               /* write the force mode  */
+                               com_rslt += bme280_write_register(
+                                       BME280_CTRL_MEAS_REG,
+                               &v_mode_u8r, BME280_ONE_U8X);
+                       }
+                       bme280_compute_wait_time(&v_waittime_u8r);
+                       p_bme280->delay_msec(v_waittime_u8r);
+                       /* read the force-mode value of pressure
+                       temperature and humidity*/
+                       com_rslt +=
+                       bme280_read_uncomp_pressure_temperature_humidity(
+                       v_uncom_pressure_s32, v_uncom_temperature_s32,
+                       v_uncom_humidity_s32);
+
+                       /* read the control humidity register value*/
+                       com_rslt += bme280_read_register(
+                       BME280_CTRL_HUMIDITY_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_hum_reg = v_data_u8;
+                       /* read the configuration register value*/
+                       com_rslt += bme280_read_register(BME280_CONFIG_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->config_reg = v_data_u8;
+
+                       /* read the control measurement register value*/
+                       com_rslt += bme280_read_register(BME280_CTRL_MEAS_REG,
+                       &v_data_u8, BME280_ONE_U8X);
+                       p_bme280->ctrl_meas_reg = v_data_u8;
+               }
+       return com_rslt;
+}
+/*!
+ * @brief
+ *     This API write the data to
+ *     the given register
+ *
+ *
+ *     @param v_addr_u8 -> Address of the register
+ *     @param v_data_u8 -> The data from the register
+ *     @param v_len_u8 -> no of bytes to read
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+ */
+BME280_RETURN_FUNCTION_TYPE bme280_write_register(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_WRITE_FUNC(
+                       p_bme280->dev_addr,
+                       v_addr_u8, v_data_u8, v_len_u8);
+               }
+       return com_rslt;
+}
+/*!
+ * @brief
+ *     This API reads the data from
+ *     the given register
+ *
+ *
+ *     @param v_addr_u8 -> Address of the register
+ *     @param v_data_u8 -> The data from the register
+ *     @param v_len_u8 -> no of bytes to read
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+ */
+BME280_RETURN_FUNCTION_TYPE bme280_read_register(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
+       /* check the p_bme280 structure pointer as NULL*/
+       if (p_bme280 == BME280_NULL) {
+               return E_BME280_NULL_PTR;
+               } else {
+                       com_rslt = p_bme280->BME280_BUS_READ_FUNC(
+                       p_bme280->dev_addr,
+                       v_addr_u8, v_data_u8, v_len_u8);
+               }
+       return com_rslt;
+}
+#ifdef BME280_ENABLE_FLOAT
+/*!
+ * @brief Reads actual temperature from uncompensated temperature
+ * @note returns the value in Degree centigrade
+ * @note Output value of "51.23" equals 51.23 DegC.
+ *
+ *
+ *
+ *  @param v_uncom_temperature_s32 : value of uncompensated temperature
+ *
+ *
+ *
+ *  @return  Return the actual temperature in floating point
+ *
+*/
+double bme280_compensate_T_double(s32 v_uncom_temperature_s32)
+{
+       double v_x1_u32 = BME280_ZERO_U8X;
+       double v_x2_u32 = BME280_ZERO_U8X;
+       double temperature = BME280_ZERO_U8X;
+
+       v_x1_u32  = (((double)v_uncom_temperature_s32)
+       / BME280_FLOAT_TRUE_TEMP_1_6_3_8_4_DATA -
+       ((double)p_bme280->cal_param.dig_T1)
+       / BME280_FLOAT_TRUE_TEMP_1_0_2_4_DATA) *
+       ((double)p_bme280->cal_param.dig_T2);
+       v_x2_u32  = ((((double)v_uncom_temperature_s32)
+       / BME280_FLOAT_TRUE_TEMP_1_3_1_0_7_2_DATA -
+       ((double)p_bme280->cal_param.dig_T1)
+       / BME280_FLOAT_TRUE_TEMP_8_1_9_2_DATA) *
+       (((double)v_uncom_temperature_s32) /
+       BME280_FLOAT_TRUE_TEMP_1_3_1_0_7_2_DATA -
+       ((double)p_bme280->cal_param.dig_T1) /
+       BME280_FLOAT_TRUE_TEMP_8_1_9_2_DATA)) *
+       ((double)p_bme280->cal_param.dig_T3);
+       p_bme280->cal_param.t_fine = (s32)(v_x1_u32 + v_x2_u32);
+       temperature  = (v_x1_u32 + v_x2_u32) /
+       BME280_FLOAT_TRUE_TEMP_5_1_2_0_DATA;
+
+
+       return temperature;
+}
+/*!
+ * @brief Reads actual pressure from uncompensated pressure
+ * @note Returns pressure in Pa as double.
+ * @note Output value of "96386.2"
+ * equals 96386.2 Pa = 963.862 hPa.
+ *
+ *
+ *  @param v_uncom_pressure_s32 : value of uncompensated pressure
+ *
+ *
+ *  @return  Return the actual pressure in floating point
+ *
+*/
+double bme280_compensate_P_double(s32 v_uncom_pressure_s32)
+{
+       double v_x1_u32 = BME280_ZERO_U8X;
+       double v_x2_u32 = BME280_ZERO_U8X;
+       double pressure = BME280_ZERO_U8X;
+
+       v_x1_u32 = ((double)p_bme280->cal_param.t_fine /
+       BME280_FLAOT_TRUE_PRESSURE_2_DATA) -
+       BME280_FLAOT_TRUE_PRESSURE_6_4_0_0_0_DATA;
+       v_x2_u32 = v_x1_u32 * v_x1_u32 *
+       ((double)p_bme280->cal_param.dig_P6) /
+       BME280_FLAOT_TRUE_PRESSURE_3_2_7_6_8_DATA;
+       v_x2_u32 = v_x2_u32 + v_x1_u32 *
+       ((double)p_bme280->cal_param.dig_P5) *
+       BME280_FLAOT_TRUE_PRESSURE_2_DATA;
+       v_x2_u32 = (v_x2_u32 / BME280_FLAOT_TRUE_PRESSURE_4_DATA) +
+       (((double)p_bme280->cal_param.dig_P4) *
+       BME280_FLAOT_TRUE_PRESSURE_6_5_5_3_6_DATA);
+       v_x1_u32 = (((double)p_bme280->cal_param.dig_P3) *
+       v_x1_u32 * v_x1_u32
+       / BME280_FLAOT_TRUE_PRESSURE_5_2_4_2_8_8_DATA +
+       ((double)p_bme280->cal_param.dig_P2) * v_x1_u32) /
+       BME280_FLAOT_TRUE_PRESSURE_5_2_4_2_8_8_DATA;
+       v_x1_u32 = (BME280_FLAOT_TRUE_PRESSURE_1_DATA + v_x1_u32
+       / BME280_FLAOT_TRUE_PRESSURE_3_2_7_6_8_DATA) *
+       ((double)p_bme280->cal_param.dig_P1);
+       pressure = BME280_FLAOT_TRUE_PRESSURE_1_0_4_8_5_7_6_DATA
+       - (double)v_uncom_pressure_s32;
+       /* Avoid exception caused by division by zero */
+       if (v_x1_u32 != BME280_ZERO_U8X)
+               pressure = (pressure - (v_x2_u32
+               / BME280_FLAOT_TRUE_PRESSURE_4_0_9_6_DATA))
+               * BME280_FLAOT_TRUE_PRESSURE_6_2_5_0_DATA / v_x1_u32;
+       else
+               return BME280_ZERO_U8X;
+       v_x1_u32 = ((double)p_bme280->cal_param.dig_P9) *
+       pressure * pressure /
+       BME280_FLAOT_TRUE_PRESSURE_2_1_4_7_4_8_3_6_4_8_DATA;
+       v_x2_u32 = pressure * ((double)p_bme280->cal_param.dig_P8)
+       / BME280_FLAOT_TRUE_PRESSURE_3_2_7_6_8_DATA;
+       pressure = pressure + (v_x1_u32 + v_x2_u32 +
+       ((double)p_bme280->cal_param.dig_P7))
+       / BME280_FLAOT_TRUE_PRESSURE_1_6_DATA;
+
+       return pressure;
+}
+/*!
+ * @brief Reads actual humidity from uncompensated humidity
+ * @note returns the value in relative humidity (%rH)
+ * @note Output value of "42.12" equals 42.12 %rH
+ *
+ *  @param v_uncom_humidity_s32 : value of uncompensated humidity
+ *
+ *
+ *
+ *  @return Return the actual humidity in floating point
+ *
+*/
+double bme280_compensate_H_double(s32 v_uncom_humidity_s32)
+{
+       double var_h = BME280_ZERO_U8X;
+       var_h = (((double)p_bme280->cal_param.t_fine)
+       - BME280_TRUE_HUMIDITY_7_6_8_0_0_DATA);
+       if (var_h != BME280_ZERO_U8X)
+               var_h = (v_uncom_humidity_s32 -
+               (((double)p_bme280->cal_param.dig_H4)
+               * BME280_TRUE_HUMIDITY_6_4_DATA +
+               ((double)p_bme280->cal_param.dig_H5)
+               / BME280_TRUE_HUMIDITY_1_6_3_8_4_DATA * var_h))*
+               (((double)p_bme280->cal_param.dig_H2)
+               /BME280_TRUE_HUMIDITY_6_5_5_3_6_DATA *
+               (BME280_TRUE_HUMIDITY_1_DATA + ((double)
+               p_bme280->cal_param.dig_H6)
+               / BME280_TRUE_HUMIDITY_6_7_1_0_8_8_6_4_DATA
+               * var_h * (BME280_TRUE_HUMIDITY_1_DATA + ((double)
+               p_bme280->cal_param.dig_H3)
+               / BME280_TRUE_HUMIDITY_6_7_1_0_8_8_6_4_DATA * var_h)));
+       else
+               return BME280_ZERO_U8X;
+       var_h = var_h * (BME280_TRUE_HUMIDITY_1_DATA - ((double)
+       p_bme280->cal_param.dig_H1)*var_h
+       / BME280_TRUE_HUMIDITY_5_2_4_2_8_8_DATA);
+       if (var_h > BME280_TRUE_HUMIDITY_1_0_0_DATA)
+               var_h = BME280_TRUE_HUMIDITY_1_0_0_DATA;
+       else if (var_h < BME280_TRUE_HUMIDITY_0_DATA)
+               var_h = BME280_TRUE_HUMIDITY_0_DATA;
+       return var_h;
+
+}
+#endif
+#if defined(BME280_ENABLE_INT64) && defined(BME280_64BITSUPPORT_PRESENT)
+/*!
+ * @brief Reads actual pressure from uncompensated pressure
+ * @note Returns the value in Pa as unsigned 32 bit
+ * integer in Q24.8 format (24 integer bits and
+ * 8 fractional bits).
+ * @note Output value of "24674867"
+ * represents 24674867 / 256 = 96386.2 Pa = 963.862 hPa
+ *
+ *
+ *
+ *  @param  v_uncom_pressure_s32 : value of uncompensated temperature
+ *
+ *
+ *  @return Return the actual pressure in u32
+ *
+*/
+u32 bme280_compensate_P_int64(s32 v_uncom_pressure_s32)
+{
+       s64 v_x1_s64r = BME280_ZERO_U8X;
+       s64 v_x2_s64r = BME280_ZERO_U8X;
+       s64 pressure = BME280_ZERO_U8X;
+       v_x1_s64r = ((s64)p_bme280->cal_param.t_fine)
+       - BME280_TRUE_PRESSURE_1_2_8_0_0_0_DATA;
+       v_x2_s64r = v_x1_s64r * v_x1_s64r *
+       (s64)p_bme280->cal_param.dig_P6;
+       v_x2_s64r = v_x2_s64r + ((v_x1_s64r *
+       (s64)p_bme280->cal_param.dig_P5)
+       << SHIFT_LEFT_17_POSITION);
+       v_x2_s64r = v_x2_s64r +
+       (((s64)p_bme280->cal_param.dig_P4)
+       << SHIFT_LEFT_35_POSITION);
+       v_x1_s64r = ((v_x1_s64r * v_x1_s64r *
+       (s64)p_bme280->cal_param.dig_P3)
+       >> SHIFT_RIGHT_8_POSITION) +
+       ((v_x1_s64r * (s64)p_bme280->cal_param.dig_P2)
+       << SHIFT_LEFT_12_POSITION);
+       v_x1_s64r = (((((s64)BME280_ONE_U8X)
+       << SHIFT_LEFT_47_POSITION) + v_x1_s64r)) *
+       ((s64)p_bme280->cal_param.dig_P1)
+       >> SHIFT_RIGHT_33_POSITION;
+       pressure = BME280_TRUE_PRESSURE_1_0_4_8_5_7_6_DATA
+       - v_uncom_pressure_s32;
+       /* Avoid exception caused by division by zero */
+       if (v_x1_s64r != BME280_ZERO_U8X)
+               #if defined __KERNEL__
+                       pressure = div64_s64((((pressure
+                       << SHIFT_LEFT_31_POSITION) - v_x2_s64r)
+                       * BME280_TRUE_PRESSURE_3_1_2_5_DATA),
+                       v_x1_s64r);
+               #else
+                       pressure = (((pressure
+                       << SHIFT_LEFT_31_POSITION) - v_x2_s64r)
+                       * BME280_TRUE_PRESSURE_3_1_2_5_DATA) / v_x1_s64r;
+               #endif
+       else
+               return BME280_ZERO_U8X;
+       v_x1_s64r = (((s64)p_bme280->cal_param.dig_P9) *
+       (pressure >> SHIFT_RIGHT_13_POSITION) *
+       (pressure >> SHIFT_RIGHT_13_POSITION))
+       >> SHIFT_RIGHT_25_POSITION;
+       v_x2_s64r = (((s64)p_bme280->cal_param.dig_P8) *
+       pressure) >> SHIFT_RIGHT_19_POSITION;
+       pressure = (((pressure + v_x1_s64r +
+       v_x2_s64r) >> SHIFT_RIGHT_8_POSITION) +
+       (((s64)p_bme280->cal_param.dig_P7)
+       << SHIFT_LEFT_4_POSITION));
+
+       return (u32)pressure;
+}
+/*!
+ * @brief Reads actual pressure from uncompensated pressure
+ * @note Returns the value in Pa.
+ * @note Output value of "12337434"
+ * @note represents 12337434 / 128 = 96386.2 Pa = 963.862 hPa
+ *
+ *
+ *
+ *  @param v_uncom_pressure_s32 : value of uncompensated pressure
+ *
+ *
+ *  @return the actual pressure in u32
+ *
+*/
+u32 bme280_compensate_P_int64_twentyfour_bit_output(s32 v_uncom_pressure_s32)
+{
+       u32 pressure = BME280_ZERO_U8X;
+       pressure = bme280_compensate_P_int64(v_uncom_pressure_s32);
+       pressure = (u32)(pressure >> SHIFT_RIGHT_1_POSITION);
+       return pressure;
+}
+#endif
+/*!
+ * @brief Computing waiting time for sensor data read
+ *
+ *
+ *
+ *
+ *  @param v_delaytime_u8 : The value of delay time for force mode
+ *
+ *
+ *     @retval 0 -> Success
+ *
+ *
+ */
+BME280_RETURN_FUNCTION_TYPE bme280_compute_wait_time(u8
+*v_delaytime_u8)
+{
+       /* used to return the communication result*/
+       BME280_RETURN_FUNCTION_TYPE com_rslt = SUCCESS;
+
+       *v_delaytime_u8 = (T_INIT_MAX +
+       T_MEASURE_PER_OSRS_MAX *
+       (((BME280_ONE_U8X
+       << p_bme280->oversamp_temperature)
+       >> SHIFT_RIGHT_1_POSITION) +
+       ((BME280_ONE_U8X << p_bme280->oversamp_pressure)
+       >> SHIFT_RIGHT_1_POSITION) +
+       ((BME280_ONE_U8X << p_bme280->oversamp_humidity)
+       >> SHIFT_RIGHT_1_POSITION))+
+       (p_bme280->oversamp_pressure ?
+       T_SETUP_PRESSURE_MAX : BME280_ZERO_U8X) +
+       (p_bme280->oversamp_humidity ?
+       T_SETUP_HUMIDITY_MAX : BME280_ZERO_U8X)
+       + BME280_FIVETEEN_U8X) / BME280_SIXTEEN_U8X;
+       return com_rslt;
+}
diff --git a/bme280.h b/bme280.h
new file mode 100644 (file)
index 0000000..8c75028
--- /dev/null
+++ b/bme280.h
@@ -0,0 +1,1776 @@
+/** \mainpage
+*
+****************************************************************************
+* Copyright (C) 2013 - 2014 Bosch Sensortec GmbH
+*
+* File : bme280.h
+*
+* Date : 2014/12/12
+*
+* Revision : 2.0.3(Pressure and Temperature compensation code revision is 1.1
+*               and Humidity compensation code revision is 1.0)
+*
+* Usage: Sensor Driver for BME280 sensor
+*
+****************************************************************************
+*
+* \section 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 bme280.h
+    \brief BME280 Sensor Driver Support Header File */
+#ifndef __BME280_H__
+#define __BME280_H__
+
+
+/*!
+* @brief The following definition uses for define the data types
+*
+* @note While porting the API please consider the following
+* @note Please check the version of C standard
+* @note Are you using Linux platform
+*/
+
+/*!
+* @brief For the Linux platform support
+* Please use the types.h for your data types definitions
+*/
+#ifdef __KERNEL__
+
+#include <linux/types.h>
+#include <linux/math64.h>
+#define BME280_64BITSUPPORT_PRESENT
+/* singed integer type*/
+typedef        int8_t s8;/**< used for signed 8bit */
+typedef        int16_t s16;/**< used for signed 16bit */
+typedef        int32_t s32;/**< used for signed 32bit */
+typedef        int64_t s64;/**< used for signed 64bit */
+
+typedef        u_int8_t u8;/**< used for unsigned 8bit */
+typedef        u_int16_t u16;/**< used for unsigned 16bit */
+typedef        u_int32_t u32;/**< used for unsigned 32bit */
+typedef        u_int64_t u64;/**< used for unsigned 64bit */
+
+
+
+#else /* ! __KERNEL__ */
+/**********************************************************
+* These definition uses for define the C
+* standard version data types
+***********************************************************/
+# if !defined(__STDC_VERSION__)
+
+/************************************************
+ * compiler is C11 C standard
+************************************************/
+#if (__STDC_VERSION__ == 201112L)
+
+/************************************************/
+#include <stdint.h>
+/************************************************/
+
+/*unsigned integer types*/
+typedef        uint8_t u8;/**< used for unsigned 8bit */
+typedef        uint16_t u16;/**< used for unsigned 16bit */
+typedef        uint32_t u32;/**< used for unsigned 32bit */
+typedef        uint64_t u64;/**< used for unsigned 64bit */
+
+/*signed integer types*/
+typedef        int8_t s8;/**< used for signed 8bit */
+typedef        int16_t s16;/**< used for signed 16bit */
+typedef        int32_t s32;/**< used for signed 32bit */
+typedef        int64_t s64;/**< used for signed 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+/************************************************
+ * compiler is C99 C standard
+************************************************/
+
+#elif (__STDC_VERSION__ == 199901L)
+
+/* stdint.h is a C99 supported c library.
+which is used to fixed the integer size*/
+/************************************************/
+#include <stdint.h>
+/************************************************/
+
+/*unsigned integer types*/
+typedef        uint8_t u8;/**< used for unsigned 8bit */
+typedef        uint16_t u16;/**< used for unsigned 16bit */
+typedef        uint32_t u32;/**< used for unsigned 32bit */
+typedef        uint64_t u64;/**< used for unsigned 64bit */
+
+/*signed integer types*/
+typedef int8_t s8;/**< used for signed 8bit */
+typedef        int16_t s16;/**< used for signed 16bit */
+typedef        int32_t s32;/**< used for signed 32bit */
+typedef        int64_t s64;/**< used for signed 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+/************************************************
+ * compiler is C89 or other C standard
+************************************************/
+
+#else /*  !defined(__STDC_VERSION__) */
+/*!
+* @brief By default it is defined as 32 bit machine configuration
+*      define your data types based on your
+*      machine/compiler/controller configuration
+*/
+#define  MACHINE_32_BIT
+
+/*! @brief
+ *     If your machine support 16 bit
+ *     define the MACHINE_16_BIT
+ */
+#ifdef MACHINE_16_BIT
+#include <limits.h>
+/*signed integer types*/
+typedef        signed char  s8;/**< used for signed 8bit */
+typedef        signed short int s16;/**< used for signed 16bit */
+typedef        signed long int s32;/**< used for signed 32bit */
+
+#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
+typedef long int s64;/**< used for signed 64bit */
+typedef unsigned long int u64;/**< used for unsigned 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
+typedef long long int s64;/**< used for signed 64bit */
+typedef unsigned long long int u64;/**< used for unsigned 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+#else
+#warning Either the correct data type for signed 64 bit integer \
+could not be found, or 64 bit integers are not supported in your environment.
+#warning The API will only offer 32 bit pressure calculation.This will \
+slightly impede accuracy(noise of ~1 pascal RMS will be added to output).
+#warning If 64 bit integers are supported on your platform, \
+please set s64 manually and "#define(BMPE80_64BITSUPPORT_PRESENT)" manually.
+#endif
+
+/*unsigned integer types*/
+typedef        unsigned char u8;/**< used for unsigned 8bit */
+typedef        unsigned short int u16;/**< used for unsigned 16bit */
+typedef        unsigned long int u32;/**< used for unsigned 32bit */
+
+/* If your machine support 32 bit
+define the MACHINE_32_BIT*/
+#elif defined MACHINE_32_BIT
+/*signed integer types*/
+typedef        signed char  s8;/**< used for signed 8bit */
+typedef        signed short int s16;/**< used for signed 16bit */
+typedef        signed int s32;/**< used for signed 32bit */
+typedef        signed long long int s64;/**< used for signed 64bit */
+
+/*unsigned integer types*/
+typedef        unsigned char u8;/**< used for unsigned 8bit */
+typedef        unsigned short int u16;/**< used for unsigned 16bit */
+typedef        unsigned int u32;/**< used for unsigned 32bit */
+typedef        unsigned long long int u64;/**< used for unsigned 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+
+/* If your machine support 64 bit
+define the MACHINE_64_BIT*/
+#elif defined MACHINE_64_BIT
+/*signed integer types*/
+typedef        signed char  s8;/**< used for signed 8bit */
+typedef        signed short int s16;/**< used for signed 16bit */
+typedef        signed int s32;/**< used for signed 32bit */
+typedef        signed long int s64;/**< used for signed 64bit */
+
+/*unsigned integer types*/
+typedef        unsigned char u8;/**< used for unsigned 8bit */
+typedef        unsigned short int u16;/**< used for unsigned 16bit */
+typedef        unsigned int u32;/**< used for unsigned 32bit */
+typedef        unsigned long int u64;/**< used for unsigned 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+
+#else
+#warning The data types defined above which not supported \
+define the data types manually
+#endif
+#endif
+
+/*** This else will execute for the compilers
+ *     which are not supported the C standards
+ *     Like C89/C99/C11***/
+#else
+/*!
+* @brief By default it is defined as 32 bit machine configuration
+*      define your data types based on your
+*      machine/compiler/controller configuration
+*/
+#define  MACHINE_32_BIT
+
+/* If your machine support 16 bit
+define the MACHINE_16_BIT*/
+#ifdef MACHINE_16_BIT
+#include <limits.h>
+/*signed integer types*/
+typedef        signed char  s8;/**< used for signed 8bit */
+typedef        signed short int s16;/**< used for signed 16bit */
+typedef        signed long int s32;/**< used for signed 32bit */
+
+#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
+typedef long int s64;/**< used for signed 64bit */
+typedef unsigned long int u64;/**< used for unsigned 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
+typedef long long int s64;/**< used for signed 64bit */
+typedef unsigned long long int u64;/**< used for unsigned 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+#else
+#warning Either the correct data type for signed 64 bit integer \
+could not be found, or 64 bit integers are not supported in your environment.
+#warning The API will only offer 32 bit pressure calculation.This will \
+slightly impede accuracy(noise of ~1 pascal RMS will be added to output).
+#warning If 64 bit integers are supported on your platform, \
+please set s64 manually and "#define(BME280_64BITSUPPORT_PRESENT)" manually.
+#endif
+
+/*unsigned integer types*/
+typedef        unsigned char u8;/**< used for unsigned 8bit */
+typedef        unsigned short int u16;/**< used for unsigned 16bit */
+typedef        unsigned long int u32;/**< used for unsigned 32bit */
+
+/*! @brief If your machine support 32 bit
+define the MACHINE_32_BIT*/
+#elif defined MACHINE_32_BIT
+/*signed integer types*/
+typedef        signed char  s8;/**< used for signed 8bit */
+typedef        signed short int s16;/**< used for signed 16bit */
+typedef        signed int s32;/**< used for signed 32bit */
+typedef        signed long long int s64;/**< used for signed 64bit */
+
+/*unsigned integer types*/
+typedef        unsigned char u8;/**< used for unsigned 8bit */
+typedef        unsigned short int u16;/**< used for unsigned 16bit */
+typedef        unsigned int u32;/**< used for unsigned 32bit */
+typedef        unsigned long long int u64;/**< used for unsigned 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+
+/* If your machine support 64 bit
+define the MACHINE_64_BIT*/
+#elif defined MACHINE_64_BIT
+/*signed integer types*/
+typedef        signed char  s8;/**< used for signed 8bit */
+typedef        signed short int s16;/**< used for signed 16bit */
+typedef        signed int s32;/**< used for signed 32bit */
+typedef        signed long int s64;/**< used for signed 64bit */
+
+/*unsigned integer types*/
+typedef        unsigned char u8;/**< used for unsigned 8bit */
+typedef        unsigned short int u16;/**< used for unsigned 16bit */
+typedef        unsigned int u32;/**< used for unsigned 32bit */
+typedef        unsigned long int u64;/**< used for unsigned 64bit */
+#define BME280_64BITSUPPORT_PRESENT
+
+#else
+#warning The data types defined above which not supported \
+define the data types manually
+#endif
+#endif
+#endif
+/********************************************/
+/**\name       ENABLE FLATING OUTPUT      */
+/**************************************/
+/*!
+* @brief If the user wants to support floating point calculations, please set
+       the following define. If floating point
+       calculation is not wanted or allowed
+       (e.g. in Linux kernel), please do not set the define. */
+#define BME280_ENABLE_FLOAT
+/*!
+* @brief If the user wants to support 64 bit integer calculation
+       (needed for optimal pressure accuracy) please set
+       the following define. If int64 calculation is not wanted
+       (e.g. because it would include
+       large libraries), please do not set the define. */
+#define BME280_ENABLE_INT64
+/***************************************************************/
+/**\name       BUS READ AND WRITE FUNCTION POINTERS        */
+/***************************************************************/
+/*!
+       @brief Define the calling convention of YOUR bus communication routine.
+       @note This includes types of parameters. This example shows the
+       configuration for an SPI bus link.
+
+    If your communication function looks like this:
+
+    write_my_bus_xy(u8 device_addr, u8 register_addr,
+    u8 * data, u8 length);
+
+    The BME280_WR_FUNC_PTR would equal:
+
+       BME280_WR_FUNC_PTR s8 (* bus_write)(u8,
+    u8, u8 *, u8)
+
+    Parameters can be mixed as needed refer to the
+    refer BME280_BUS_WRITE_FUNC  macro.
+
+
+*/
+/** defines the return parameter type of the BME280_WR_FUNCTION */
+#define BME280_BUS_WR_RETURN_TYPE s8
+
+/* links the order of parameters defined in
+BME280_BUS_WR_PARAM_TYPE to function calls used inside the API*/
+#define BME280_BUS_WR_PARAM_TYPES u8, u8,\
+               u8 *, u8
+
+/* links the order of parameters defined in
+BME280_BUS_WR_PARAM_TYPE to function calls used inside the API*/
+#define BME280_BUS_WR_PARAM_ORDER(device_addr, register_addr,\
+               register_data, wr_len)
+
+/* never change this line */
+#define BME280_BUS_WRITE_FUNC(device_addr, register_addr,\
+register_data, wr_len) bus_write(device_addr, register_addr,\
+               register_data, wr_len)
+/*!
+       @brief link macro between API function calls and bus read function
+       @note The bus write function can change since this is a
+       system dependant issue.
+
+    If the bus_read parameter calling order is like: reg_addr,
+    reg_data, wr_len it would be as it is here.
+
+    If the parameters are differently ordered or your communication
+    function like I2C need to know the device address,
+    you can change this macro accordingly.
+
+
+    BME280_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
+    bus_read(dev_addr, reg_addr, reg_data, wr_len)
+
+    This macro lets all API functions call YOUR communication routine in a
+    way that equals your definition in the
+    refer BME280_WR_FUNC_PTR definition.
+
+    @note: this macro also includes the "MSB='1'
+    for reading BME280 addresses.
+
+*/
+/*defines the return parameter type of the BME280_RD_FUNCTION
+*/
+#define BME280_BUS_RD_RETURN_TYPE s8
+
+/**\brief defines the calling parameter types of the BME280_RD_FUNCTION
+*/
+#define BME280_BUS_RD_PARAM_TYPES (u8, u8,\
+               u8 *, u8)
+
+/* links the order of parameters defined in \
+BME280_BUS_RD_PARAM_TYPE to function calls used inside the API
+*/
+#define BME280_BUS_RD_PARAM_ORDER (device_addr, register_addr,\
+               register_data)
+
+/* never change this line */
+#define BME280_BUS_READ_FUNC(device_addr, register_addr,\
+               register_data, rd_len)bus_read(device_addr, register_addr,\
+               register_data, rd_len)
+/****************************************/
+/**\name       DELAY       */
+/****************************************/
+/* defines the return parameter type of the BME280_DELAY_FUNCTION
+*/
+#define BME280_DELAY_RETURN_TYPE void
+
+/* defines the calling parameter types of the BME280_DELAY_FUNCTION
+*/
+#define BME280_DELAY_PARAM_TYPES u16
+/***************************************************************/
+/**\name       GET AND SET BITSLICE FUNCTIONS       */
+/***************************************************************/
+/* never change this line */
+#define BME280_DELAY_FUNC(delay_in_msec)\
+               delay_func(delay_in_msec)
+
+#define BME280_GET_BITSLICE(regvar, bitname)\
+               ((regvar & bitname##__MSK) >> bitname##__POS)
+
+#define BME280_SET_BITSLICE(regvar, bitname, val)\
+((regvar & ~bitname##__MSK) | ((val<<bitname##__POS)&bitname##__MSK))
+
+/***************************************************************/
+/**\name       COMMON USED CONSTANTS      */
+/***************************************************************/
+/* Constants */
+#define BME280_NULL                          0
+#define BME280_RETURN_FUNCTION_TYPE          s8
+/* right shift definitions*/
+#define SHIFT_RIGHT_1_POSITION                          1
+#define SHIFT_RIGHT_2_POSITION                          2
+#define SHIFT_RIGHT_3_POSITION                          3
+#define SHIFT_RIGHT_4_POSITION                          4
+#define SHIFT_RIGHT_7_POSITION                          7
+#define SHIFT_RIGHT_8_POSITION                          8
+#define SHIFT_RIGHT_10_POSITION                                 10
+#define SHIFT_RIGHT_11_POSITION                                 11
+#define SHIFT_RIGHT_12_POSITION                                 12
+#define SHIFT_RIGHT_13_POSITION                                 13
+#define SHIFT_RIGHT_14_POSITION                                 14
+#define SHIFT_RIGHT_15_POSITION                                 15
+#define SHIFT_RIGHT_18_POSITION                                 18
+#define SHIFT_RIGHT_19_POSITION                                 19
+#define SHIFT_RIGHT_25_POSITION                                 25
+#define SHIFT_RIGHT_33_POSITION                                 33
+/* left shift definitions*/
+#define SHIFT_LEFT_1_POSITION                1
+#define SHIFT_LEFT_2_POSITION                2
+#define SHIFT_LEFT_4_POSITION                4
+#define SHIFT_LEFT_5_POSITION                5
+#define SHIFT_LEFT_8_POSITION                8
+#define SHIFT_LEFT_12_POSITION               12
+#define SHIFT_LEFT_13_POSITION               13
+#define SHIFT_LEFT_14_POSITION               14
+#define SHIFT_LEFT_16_POSITION               16
+#define SHIFT_LEFT_17_POSITION               17
+#define SHIFT_LEFT_20_POSITION               20
+#define SHIFT_LEFT_31_POSITION               31
+#define SHIFT_LEFT_35_POSITION               35
+#define SHIFT_LEFT_47_POSITION               47
+/* numeric definitions*/
+#define BME280_ONE_U8X                       1
+#define BME280_TWO_U8X                       2
+#define BME280_THREE_U8X                     3
+#define BME280_FOUR_U8X                      4
+#define BME280_FIVE_U8X                      5
+#define BME280_SEVEN_U8X                     7
+#define BME280_ZERO_U8X                      0
+#define BME280_EIGHT_U8X                     8
+#define BME280_FIVETEEN_U8X                  15
+#define BME280_SIXTEEN_U8X                   16
+#define BME280_TWENTY_FIVE_U8X               25
+#define BME280_TWENTY_SIX_U8X                26
+#define BME280_ONE_TWENTY_EIGHT_U8X          128
+
+/***************************************************************/
+/**\name       PRESSURE AND TEMPERATURE DEFINITIONS     */
+/***************************************************************/
+#define BME280_TEMP_1_2_2_8_8_0_DATA           122880
+#define BME280_PRESSURE_6_4_0_0_0_DATA         64000
+#define BME280_PRESSURE_3_1_2_5_DATA           3125
+#define BME280_PRESSURE_3_2_7_6_8_DATA         32768
+#define BME280_PRESSURE_1_0_4_8_5_7_6_DATA                     1048576
+#define BME280_HEX_PRESSURE_8_0_0_0_0_0_0_0_DATA       0x80000000
+/***************************************************************/
+/**\name       HUMIDITY DEFINITIONS      */
+/***************************************************************/
+#define BME280_HUMIDITY_7_6_8_0_0_DATA                         76800
+#define BME280_HUMIDITY_1_6_3_8_4_DATA                         16384
+#define BME280_HUMIDITY_3_2_7_6_8_DATA                         32768
+#define BME280_HUMIDITY_2_0_9_7_1_5_2_DATA                     2097152
+#define BME280_HUMIDITY_8_1_9_2_DATA                           8192
+#define BME280_HUMIDITY_4_1_9_4_3_0_4_0_0_DATA         419430400
+/***************************************************************/
+/**\name       CALIBRATION MASK DEFINITION      */
+/***************************************************************/
+#define BME280_HEX_CALIB_0_F_DATA              0x0F
+
+/****************************************************/
+/**\name       TRUE TEMPERATURE CALUCULATION PARAMETERS  */
+/***************************************************/
+#define BME280_DEC_TRUE_TEMP_FIVE_DATA                                 5
+#define BME280_DEC_TRUE_TEMP_ONE_TWO_EIGHT_DATA                        128
+/****************************************************/
+/**\name       TRUE PRESSURE CALUCULATION PARAMETERS  */
+/***************************************************/
+#define BME280_DEC_TRUE_PRESSURE_6_4_0_0_0_DATA                        64000
+#define BME280_DEC_TRUE_PRESSURE_TWO_DATA                              2
+#define BME280_DEC_TRUE_PRESSURE_3_2_7_6_8_DATA                        32768
+#define BME280_DEC_TRUE_PRESSURE_1_0_4_8_5_7_6_DATA            1048576
+#define BME280_DEC_TRUE_PRESSURE_3_1_2_5_DATA                  3125
+#define BME280_HEX_TRUE_PRESSURE_8_0_0_0_0_0_0_0_DATA  0x80000000
+
+/****************************************************/
+/**\name       TRUE TEMPERATURE CALUCULATION FLOAT RETURN  */
+/***************************************************/
+#define BME280_FLOAT_TRUE_TEMP_1_6_3_8_4_DATA          16384.0
+#define BME280_FLOAT_TRUE_TEMP_1_0_2_4_DATA                    1024.0
+#define BME280_FLOAT_TRUE_TEMP_1_3_1_0_7_2_DATA                131072.0
+#define BME280_FLOAT_TRUE_TEMP_8_1_9_2_DATA                    8192.0
+#define BME280_FLOAT_TRUE_TEMP_5_1_2_0_DATA                    5120.0
+
+/****************************************************/
+/**\name       TRUE PRESSURE CALUCULATION FLOAT RETURN  */
+/***************************************************/
+#define        BME280_FLAOT_TRUE_PRESSURE_1_DATA               1.0
+#define        BME280_FLAOT_TRUE_PRESSURE_0_DATA               0.0
+#define        BME280_FLAOT_TRUE_PRESSURE_2_DATA               2.0
+#define        BME280_FLAOT_TRUE_PRESSURE_4_DATA               4.0
+#define        BME280_FLAOT_TRUE_PRESSURE_1_6_DATA                             16.0
+#define        BME280_FLAOT_TRUE_PRESSURE_6_4_0_0_0_DATA               64000.0
+#define        BME280_FLAOT_TRUE_PRESSURE_3_2_7_6_8_DATA               32768.0
+#define        BME280_FLAOT_TRUE_PRESSURE_6_5_5_3_6_DATA               65536.0
+#define        BME280_FLAOT_TRUE_PRESSURE_5_2_4_2_8_8_DATA             524288.0
+#define        BME280_FLAOT_TRUE_PRESSURE_1_0_4_8_5_7_6_DATA   1048576.0
+#define        BME280_FLAOT_TRUE_PRESSURE_4_0_9_6_DATA                 4096.0
+#define        BME280_FLAOT_TRUE_PRESSURE_6_2_5_0_DATA                 6250.0
+#define        BME280_FLAOT_TRUE_PRESSURE_2_1_4_7_4_8_3_6_4_8_DATA             \
+2147483648.0
+
+/****************************************************/
+/**\name       TRUE PRESSURE CALUCULATION 64BIT RETURN  */
+/***************************************************/
+#define BME280_TRUE_PRESSURE_1_2_8_0_0_0_DATA          128000
+#define BME280_TRUE_PRESSURE_1_0_4_8_5_7_6_DATA                1048576
+#define BME280_TRUE_PRESSURE_3_1_2_5_DATA                      3125
+#define BME280_TRUE_PRESSURE_1_DATA                                    1
+/****************************************************/
+/**\name       TRUE HUMIDITY CALUCULATION FLOAT RETURN  */
+/***************************************************/
+#define BME280_TRUE_HUMIDITY_7_6_8_0_0_DATA                    76800.0
+#define BME280_TRUE_HUMIDITY_6_4_DATA                          64.0
+#define BME280_TRUE_HUMIDITY_1_6_3_8_4_DATA                    16384.0
+#define BME280_TRUE_HUMIDITY_6_5_5_3_6_DATA                    65536.0
+#define BME280_TRUE_HUMIDITY_0_DATA                                    0.0
+#define BME280_TRUE_HUMIDITY_1_DATA                                    1.0
+#define BME280_TRUE_HUMIDITY_1_0_0_DATA                                100.0
+#define BME280_TRUE_HUMIDITY_6_7_1_0_8_8_6_4_DATA      67108864.0
+#define BME280_TRUE_HUMIDITY_5_2_4_2_8_8_DATA          524288.0
+#define BME280_TRUE_HUMIDITY_
+/****************************************************/
+/**\name       ERROR CODE DEFINITIONS  */
+/***************************************************/
+#define        SUCCESS                                 ((u8)0)
+#define E_BME280_NULL_PTR       ((s8)-127)
+#define E_BME280_COMM_RES       ((s8)-1)
+#define E_BME280_OUT_OF_RANGE   ((s8)-2)
+#define ERROR                                  ((s8)-1)
+/****************************************************/
+/**\name       I2C ADDRESS DEFINITIONS  */
+/***************************************************/
+#define BME280_I2C_ADDRESS1                  0x76
+#define BME280_I2C_ADDRESS2                  0x77
+/****************************************************/
+/**\name       POWER MODE DEFINITIONS  */
+/***************************************************/
+/* Sensor Specific constants */
+#define BME280_SLEEP_MODE                    0x00
+#define BME280_FORCED_MODE                   0x01
+#define BME280_NORMAL_MODE                   0x03
+#define BME280_SOFT_RESET_CODE               0xB6
+/****************************************************/
+/**\name       STANDBY DEFINITIONS  */
+/***************************************************/
+#define BME280_STANDBY_TIME_1_MS              0x00
+#define BME280_STANDBY_TIME_63_MS             0x01
+#define BME280_STANDBY_TIME_125_MS                       0x02
+#define BME280_STANDBY_TIME_250_MS            0x03
+#define BME280_STANDBY_TIME_500_MS            0x04
+#define BME280_STANDBY_TIME_1000_MS           0x05
+#define BME280_STANDBY_TIME_10_MS             0x06
+#define BME280_STANDBY_TIME_20_MS             0x07
+/****************************************************/
+/**\name       OVER SAMPLING DEFINITIONS  */
+/***************************************************/
+#define BME280_OVERSAMP_SKIPPED          0x00
+#define BME280_OVERSAMP_1X               0x01
+#define BME280_OVERSAMP_2X               0x02
+#define BME280_OVERSAMP_4X               0x03
+#define BME280_OVERSAMP_8X               0x04
+#define BME280_OVERSAMP_16X              0x05
+/****************************************************/
+/**\name       WORK MODE DEFINITIONS  */
+/***************************************************/
+/*#define BME280_ULTRALOWPOWER_MODE            0x00
+#define BME280_LOWPOWER_MODE                 0x01
+#define BME280_STANDARDRESOLUTION_MODE       0x02
+#define BME280_HIGHRESOLUTION_MODE           0x03
+#define BME280_ULTRAHIGHRESOLUTION_MODE      0x04
+
+#define BME280_ULTRALOWPOWER_OSRS_P          BME280_OVERSAMP_1X
+#define BME280_ULTRALOWPOWER_OSRS_T          BME280_OVERSAMP_1X
+
+#define BME280_LOWPOWER_OSRS_P               BME280_OVERSAMP_2X
+#define BME280_LOWPOWER_OSRS_T               BME280_OVERSAMP_1X
+
+#define BME280_STANDARDRESOLUTION_OSRS_P     BME280_OVERSAMP_4X
+#define BME280_STANDARDRESOLUTION_OSRS_T     BME280_OVERSAMP_1X
+
+#define BME280_HIGHRESOLUTION_OSRS_P         BME280_OVERSAMP_8X
+#define BME280_HIGHRESOLUTION_OSRS_T         BME280_OVERSAMP_1X
+
+#define BME280_ULTRAHIGHRESOLUTION_OSRS_P    BME280_OVERSAMP_16X
+#define BME280_ULTRAHIGHRESOLUTION_OSRS_T    BME280_OVERSAMP_2X */
+
+#define BME280_STANDARD_OVERSAMP_HUMIDITY      BME280_OVERSAMP_1X
+/****************************************************/
+/**\name       FILTER DEFINITIONS  */
+/***************************************************/
+#define BME280_FILTER_COEFF_OFF               0x00
+#define BME280_FILTER_COEFF_2                 0x01
+#define BME280_FILTER_COEFF_4                 0x02
+#define BME280_FILTER_COEFF_8                 0x03
+#define BME280_FILTER_COEFF_16                0x04
+/****************************************************/
+/**\name       DELAY DEFINITIONS  */
+/***************************************************/
+#define T_INIT_MAX                             20
+               /* 20/16 = 1.25 ms */
+#define T_MEASURE_PER_OSRS_MAX                 37
+               /* 37/16 = 2.3125 ms*/
+
+#define T_SETUP_PRESSURE_MAX                   10
+               /* 10/16 = 0.625 ms */
+
+#define T_SETUP_HUMIDITY_MAX                   10
+               /* 10/16 = 0.625 ms */
+/****************************************************/
+/**\name       ARRAY SIZE DEFINITIONS      */
+/***************************************************/
+#define ARRAY_SIZE_TWO         2
+#define ARRAY_SIZE_THREE       3
+#define ARRAY_SIZE_SIX         6
+#define ARRAY_SIZE_FIVE                5
+#define ARRAY_SIZE_EIGHT       8
+#define ARRAY_SIZE_TWELVE      12
+#define ARRAY_SIZE_FOURTEEN    14
+#define ARRAY_SIZE_TWENTY_SIX  26
+
+#define INDEX_ZERO             0
+#define INDEX_ONE              1
+#define INDEX_TWO              2
+#define INDEX_THREE            3
+#define INDEX_FOUR             4
+#define INDEX_FIVE             5
+#define INDEX_SIX              6
+#define INDEX_SEVEN            7
+#define INDEX_EIGHT            8
+#define INDEX_NINE             9
+#define INDEX_TEN              10
+#define INDEX_ELEVEN   11
+#define INDEX_TWELVE   12
+#define INDEX_THIRTEEN 13
+#define INDEX_FOURTEEN 14
+#define INDEX_FIVETEEN 15
+#define INDEX_SIXTEEN  16
+#define INDEX_SEVENTEEN        17
+#define INDEX_EIGHTEEN 18
+#define INDEX_NINETEEN 19
+#define INDEX_TWENTY   20
+#define INDEX_TWENTY_ONE       21
+#define INDEX_TWENTY_TWO       22
+#define INDEX_TWENTY_THREE     23
+#define INDEX_TWENTY_FIVE      25
+/****************************************************/
+/**\name       ARRAY PARAMETERS      */
+/***************************************************/
+#define LSB_ZERO       0
+#define MSB_ONE                1
+#define LSB_TWO                2
+#define MSB_THREE      3
+#define LSB_FOUR       4
+#define MSB_FIVE       5
+#define LSB_SIX                6
+#define MSB_SEVEN      7
+/****************************************************/
+/**\name       CALIBRATION REGISTER ADDRESS DEFINITIONS  */
+/***************************************************/
+/*calibration parameters */
+#define BME280_DIG_T1_LSB_REG                0x88
+#define BME280_DIG_T1_MSB_REG                0x89
+#define BME280_DIG_T2_LSB_REG                0x8A
+#define BME280_DIG_T2_MSB_REG                0x8B
+#define BME280_DIG_T3_LSB_REG                0x8C
+#define BME280_DIG_T3_MSB_REG                0x8D
+#define BME280_DIG_P1_LSB_REG                0x8E
+#define BME280_DIG_P1_MSB_REG                0x8F
+#define BME280_DIG_P2_LSB_REG                0x90
+#define BME280_DIG_P2_MSB_REG                0x91
+#define BME280_DIG_P3_LSB_REG                0x92
+#define BME280_DIG_P3_MSB_REG                0x93
+#define BME280_DIG_P4_LSB_REG                0x94
+#define BME280_DIG_P4_MSB_REG                0x95
+#define BME280_DIG_P5_LSB_REG                0x96
+#define BME280_DIG_P5_MSB_REG                0x97
+#define BME280_DIG_P6_LSB_REG                0x98
+#define BME280_DIG_P6_MSB_REG                0x99
+#define BME280_DIG_P7_LSB_REG                0x9A
+#define BME280_DIG_P7_MSB_REG                0x9B
+#define BME280_DIG_P8_LSB_REG                0x9C
+#define BME280_DIG_P8_MSB_REG                0x9D
+#define BME280_DIG_P9_LSB_REG                0x9E
+#define BME280_DIG_P9_MSB_REG                0x9F
+
+#define BME280_DIG_H1_REG                    0xA1
+
+#define BME280_DIG_H2_LSB_REG                0xE1
+#define BME280_DIG_H2_MSB_REG                0xE2
+#define BME280_DIG_H3_REG                    0xE3
+#define BME280_DIG_H4_MSB_REG                0xE4
+#define BME280_DIG_H5_LSB_H4_LSB_REG         0xE5
+#define BME280_DIG_H5_MSB_REG                0xE6
+#define BME280_DIG_H6_REG                    0xE7
+/****************************************************/
+/**\name       REGISTER ADDRESS DEFINITIONS  */
+/***************************************************/
+#define BME280_CHIP_ID_REG                   0xD0  /*Chip ID Register */
+#define BME280_RST_REG                       0xE0  /*Softreset Register */
+#define BME280_STAT_REG                      0xF3  /*Status Register */
+#define BME280_CTRL_MEAS_REG                 0xF4  /*Ctrl Measure Register */
+#define BME280_CTRL_HUMIDITY_REG             0xF2  /*Ctrl Humidity Register*/
+#define BME280_CONFIG_REG                    0xF5  /*Configuration Register */
+#define BME280_PRESSURE_MSB_REG              0xF7  /*Pressure MSB Register */
+#define BME280_PRESSURE_LSB_REG              0xF8  /*Pressure LSB Register */
+#define BME280_PRESSURE_XLSB_REG             0xF9  /*Pressure XLSB Register */
+#define BME280_TEMPERATURE_MSB_REG           0xFA  /*Temperature MSB Reg */
+#define BME280_TEMPERATURE_LSB_REG           0xFB  /*Temperature LSB Reg */
+#define BME280_TEMPERATURE_XLSB_REG          0xFC  /*Temperature XLSB Reg */
+#define BME280_HUMIDITY_MSB_REG              0xFD  /*Humidity MSB Reg */
+#define BME280_HUMIDITY_LSB_REG              0xFE  /*Humidity LSB Reg */
+/****************************************************/
+/**\name       BIT MASK, LENGTH AND POSITION DEFINITIONS  */
+/***************************************************/
+/* Status Register */
+#define BME280_STAT_REG_MEASURING__POS           3
+#define BME280_STAT_REG_MEASURING__MSK           0x08
+#define BME280_STAT_REG_MEASURING__LEN           1
+#define BME280_STAT_REG_MEASURING__REG           BME280_STAT_REG
+
+#define BME280_STAT_REG_IM_UPDATE__POS            0
+#define BME280_STAT_REG_IM_UPDATE__MSK            0x01
+#define BME280_STAT_REG_IM_UPDATE__LEN            1
+#define BME280_STAT_REG_IM_UPDATE__REG            BME280_STAT_REG
+/****************************************************/
+/**\name       BIT MASK, LENGTH AND POSITION DEFINITIONS
+FOR TEMPERATURE OVERSAMPLING  */
+/***************************************************/
+/* Control Measurement Register */
+#define BME280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__POS             5
+#define BME280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__MSK             0xE0
+#define BME280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__LEN             3
+#define BME280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__REG             \
+BME280_CTRL_MEAS_REG
+/****************************************************/
+/**\name       BIT MASK, LENGTH AND POSITION DEFINITIONS
+FOR PRESSURE OVERSAMPLING  */
+/***************************************************/
+#define BME280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__POS             2
+#define BME280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__MSK             0x1C
+#define BME280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__LEN             3
+#define BME280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__REG             \
+BME280_CTRL_MEAS_REG
+/****************************************************/
+/**\name       BIT MASK, LENGTH AND POSITION DEFINITIONS
+FOR POWER MODE  */
+/***************************************************/
+#define BME280_CTRL_MEAS_REG_POWER_MODE__POS              0
+#define BME280_CTRL_MEAS_REG_POWER_MODE__MSK              0x03
+#define BME280_CTRL_MEAS_REG_POWER_MODE__LEN              2
+#define BME280_CTRL_MEAS_REG_POWER_MODE__REG              \
+BME280_CTRL_MEAS_REG
+/****************************************************/
+/**\name       BIT MASK, LENGTH AND POSITION DEFINITIONS
+FOR HUMIDITY OVERSAMPLING  */
+/***************************************************/
+#define BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY__POS             0
+#define BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY__MSK             0x07
+#define BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY__LEN             3
+#define BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY__REG            \
+BME280_CTRL_HUMIDITY_REG
+/****************************************************/
+/**\name       BIT MASK, LENGTH AND POSITION DEFINITIONS
+FOR STANDBY TIME  */
+/***************************************************/
+/* Configuration Register */
+#define BME280_CONFIG_REG_TSB__POS                 5
+#define BME280_CONFIG_REG_TSB__MSK                 0xE0
+#define BME280_CONFIG_REG_TSB__LEN                 3
+#define BME280_CONFIG_REG_TSB__REG                 BME280_CONFIG_REG
+/****************************************************/
+/**\name       BIT MASK, LENGTH AND POSITION DEFINITIONS
+FOR FILTER */
+/***************************************************/
+#define BME280_CONFIG_REG_FILTER__POS              2
+#define BME280_CONFIG_REG_FILTER__MSK              0x1C
+#define BME280_CONFIG_REG_FILTER__LEN              3
+#define BME280_CONFIG_REG_FILTER__REG              BME280_CONFIG_REG
+/****************************************************/
+/**\name       BIT MASK, LENGTH AND POSITION DEFINITIONS
+FOR SPI ENABLE  */
+/***************************************************/
+#define BME280_CONFIG_REG_SPI3_ENABLE__POS             0
+#define BME280_CONFIG_REG_SPI3_ENABLE__MSK             0x01
+#define BME280_CONFIG_REG_SPI3_ENABLE__LEN             1
+#define BME280_CONFIG_REG_SPI3_ENABLE__REG             BME280_CONFIG_REG
+/****************************************************/
+/**\name       BIT MASK, LENGTH AND POSITION DEFINITIONS
+FOR PRESSURE AND TEMPERATURE DATA  */
+/***************************************************/
+/* Data Register */
+#define BME280_PRESSURE_XLSB_REG_DATA__POS         4
+#define BME280_PRESSURE_XLSB_REG_DATA__MSK         0xF0
+#define BME280_PRESSURE_XLSB_REG_DATA__LEN         4
+#define BME280_PRESSURE_XLSB_REG_DATA__REG         BME280_PRESSURE_XLSB_REG
+
+#define BME280_TEMPERATURE_XLSB_REG_DATA__POS      4
+#define BME280_TEMPERATURE_XLSB_REG_DATA__MSK      0xF0
+#define BME280_TEMPERATURE_XLSB_REG_DATA__LEN      4
+#define BME280_TEMPERATURE_XLSB_REG_DATA__REG      BME280_TEMPERATURE_XLSB_REG
+/****************************************************/
+/**\name       BUS READ AND WRITE FUNCTION POINTERS */
+/***************************************************/
+#define BME280_WR_FUNC_PTR\
+               s8 (*bus_write)(u8, u8,\
+               u8 *, u8)
+
+#define BME280_RD_FUNC_PTR\
+               s8 (*bus_read)(u8, u8,\
+               u8 *, u8)
+
+#define BME280_MDELAY_DATA_TYPE u16
+
+#define        BME280_3MS_DELAY        3
+/**************************************************************/
+/**\name       STRUCTURE DEFINITIONS                         */
+/**************************************************************/
+/*!
+ * @brief This structure holds all device specific calibration parameters
+ */
+struct bme280_calibration_param_t {
+       u16 dig_T1;/**<calibration T1 data*/
+       s16 dig_T2;/**<calibration T2 data*/
+       s16 dig_T3;/**<calibration T3 data*/
+       u16 dig_P1;/**<calibration P1 data*/
+       s16 dig_P2;/**<calibration P2 data*/
+       s16 dig_P3;/**<calibration P3 data*/
+       s16 dig_P4;/**<calibration P4 data*/
+       s16 dig_P5;/**<calibration P5 data*/
+       s16 dig_P6;/**<calibration P6 data*/
+       s16 dig_P7;/**<calibration P7 data*/
+       s16 dig_P8;/**<calibration P8 data*/
+       s16 dig_P9;/**<calibration P9 data*/
+
+       u8  dig_H1;/**<calibration H1 data*/
+       s16 dig_H2;/**<calibration H2 data*/
+       u8  dig_H3;/**<calibration H3 data*/
+       s16 dig_H4;/**<calibration H4 data*/
+       s16 dig_H5;/**<calibration H5 data*/
+       s8  dig_H6;/**<calibration H6 data*/
+
+       s32 t_fine;/**<calibration T_FINE data*/
+};
+/*!
+ * @brief This structure holds BME280 initialization parameters
+ */
+struct bme280_t {
+       struct bme280_calibration_param_t cal_param;
+       /**< calibration parameters*/
+
+       u8 chip_id;/**< chip id of the sensor*/
+       u8 dev_addr;/**< device address of the sensor*/
+
+       u8 oversamp_temperature;/**< temperature over sampling*/
+       u8 oversamp_pressure;/**< pressure over sampling*/
+       u8 oversamp_humidity;/**< humidity over sampling*/
+       u8 ctrl_hum_reg;/**< status of control humidity register*/
+       u8 ctrl_meas_reg;/**< status of control measurement register*/
+       u8 config_reg;/**< status of configuration register*/
+       BME280_WR_FUNC_PTR;/**< bus write function pointer*/
+       BME280_RD_FUNC_PTR;/**< bus read function pointer*/
+       void(*delay_msec)(BME280_MDELAY_DATA_TYPE);/**< delay function pointer*/
+};
+/**************************************************************/
+/**\name       FUNCTION DECLARATIONS                         */
+/**************************************************************/
+/**************************************************************/
+/**\name       FUNCTION FOR  INTIALIZATION                       */
+/**************************************************************/
+/*!
+ *     @brief This function is used for initialize
+ *     the bus read and bus write functions
+ *  and assign the chip id and I2C address of the BME280 sensor
+ *     chip id is read in the register 0xD0 bit from 0 to 7
+ *
+ *      @param bme280 structure pointer.
+ *
+ *     @note While changing the parameter of the bme280_t
+ *     @note consider the following point:
+ *     Changing the reference value of the parameter
+ *     will changes the local copy or local reference
+ *     make sure your changes will not
+ *     affect the reference value of the parameter
+ *     (Better case don't change the reference value of the parameter)
+ *
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_init(struct bme280_t *bme280);
+/**************************************************************/
+/**\name       FUNCTION FOR  INTIALIZATION UNCOMPENSATED TEMPERATURE */
+/**************************************************************/
+/*!
+ *     @brief This API is used to read uncompensated temperature
+ *     in the registers 0xFA, 0xFB and 0xFC
+ *     @note 0xFA -> MSB -> bit from 0 to 7
+ *     @note 0xFB -> LSB -> bit from 0 to 7
+ *     @note 0xFC -> LSB -> bit from 4 to 7
+ *
+ * @param v_uncomp_temperature_s32 : The value of uncompensated temperature
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_uncomp_temperature(
+s32 *v_uncomp_temperature_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR  INTIALIZATION TRUE TEMPERATURE */
+/**************************************************************/
+/*!
+ * @brief Reads actual temperature from uncompensated temperature
+ * @note Returns the value in 0.01 degree Centigrade
+ * Output value of "5123" equals 51.23 DegC.
+ *
+ *
+ *
+ *  @param  v_uncomp_temperature_s32 : value of uncompensated temperature
+ *
+ *
+ *  @return Returns the actual temperature
+ *
+*/
+s32 bme280_compensate_T_int32(s32 v_uncomp_temperature_s32);
+/*!
+ * @brief Reads actual temperature from uncompensated temperature
+ * @note Returns the value with 500LSB/DegC centred around 24 DegC
+ * output value of "5123" equals(5123/500)+24 = 34.246DegC
+ *
+ *
+ *  @param v_uncomp_temperature_s32: value of uncompensated temperature
+ *
+ *
+ *
+ *  @return Return the actual temperature as s16 output
+ *
+*/
+s16 bme280_compensate_T_int32_sixteen_bit_output(s32 v_uncomp_temperature_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR  INTIALIZATION UNCOMPENSATED PRESSURE */
+/**************************************************************/
+/*!
+ *     @brief This API is used to read uncompensated pressure.
+ *     in the registers 0xF7, 0xF8 and 0xF9
+ *     @note 0xF7 -> MSB -> bit from 0 to 7
+ *     @note 0xF8 -> LSB -> bit from 0 to 7
+ *     @note 0xF9 -> LSB -> bit from 4 to 7
+ *
+ *
+ *
+ *     @param v_uncomp_pressure_s32 : The value of uncompensated pressure
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_uncomp_pressure(
+s32 *v_uncomp_pressure_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR  INTIALIZATION TRUE PRESSURE */
+/**************************************************************/
+/*!
+ * @brief Reads actual pressure from uncompensated pressure
+ * @note Returns the value in Pascal(Pa)
+ * Output value of "96386" equals 96386 Pa =
+ * 963.86 hPa = 963.86 millibar
+ *
+ *
+ *
+ *  @param v_uncomp_pressure_s32 : value of uncompensated pressure
+ *
+ *
+ *
+ *  @return Return the actual pressure output as u32
+ *
+*/
+u32 bme280_compensate_P_int32(s32 v_uncomp_pressure_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR  INTIALIZATION UNCOMPENSATED HUMIDITY */
+/**************************************************************/
+/*!
+ *     @brief This API is used to read uncompensated humidity.
+ *     in the registers 0xF7, 0xF8 and 0xF9
+ *     @note 0xFD -> MSB -> bit from 0 to 7
+ *     @note 0xFE -> LSB -> bit from 0 to 7
+ *
+ *
+ *
+ *     @param v_uncomp_humidity_s32 : The value of uncompensated humidity
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_uncomp_humidity(
+s32 *v_uncomp_humidity_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR  INTIALIZATION RELATIVE HUMIDITY */
+/**************************************************************/
+/*!
+ * @brief Reads actual humidity from uncompensated humidity
+ * @note Returns the value in %rH as unsigned 32bit integer
+ * in Q22.10 format(22 integer 10 fractional bits).
+ * @note An output value of 42313
+ * represents 42313 / 1024 = 41.321 %rH
+ *
+ *
+ *
+ *  @param  v_uncomp_humidity_s32: value of uncompensated humidity
+ *
+ *  @return Return the actual relative humidity output as u32
+ *
+*/
+u32 bme280_compensate_H_int32(s32 v_uncomp_humidity_s32);
+/*!
+ * @brief Reads actual humidity from uncompensated humidity
+ * @note Returns the value in %rH as unsigned 16bit integer
+ * @note An output value of 42313
+ * represents 42313/512 = 82.643 %rH
+ *
+ *
+ *
+ *  @param v_uncomp_humidity_s32: value of uncompensated humidity
+ *
+ *
+ *  @return Return the actual relative humidity output as u16
+ *
+*/
+u16 bme280_compensate_H_int32_sixteen_bit_output(s32 v_uncomp_humidity_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR  INTIALIZATION UNCOMPENSATED PRESSURE,
+ TEMPERATURE AND HUMIDITY */
+/**************************************************************/
+/*!
+ * @brief This API used to read uncompensated
+ * pressure,temperature and humidity
+ *
+ *
+ *
+ *
+ *  @param  v_uncomp_pressure_s32: The value of uncompensated pressure.
+ *  @param  v_uncomp_temperature_s32: The value of uncompensated temperature
+ *  @param  v_uncomp_humidity_s32: The value of uncompensated humidity.
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_uncomp_pressure_temperature_humidity(
+s32 *v_uncomp_pressure_s32,
+s32 *v_uncomp_temperature_s32, s32 *v_uncomp_humidity_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR TRUE UNCOMPENSATED PRESSURE,
+ TEMPERATURE AND HUMIDITY */
+/**************************************************************/
+/*!
+ * @brief This API used to read true pressure, temperature and humidity
+ *
+ *
+ *
+ *
+ *     @param  v_pressure_u32 : The value of compensated pressure.
+ *     @param  v_temperature_s32 : The value of compensated temperature.
+ *     @param  v_humidity_u32 : The value of compensated humidity.
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_read_pressure_temperature_humidity(
+u32 *v_pressure_u32, s32 *v_temperature_s32, u32 *v_humidity_u32);
+/**************************************************************/
+/**\name       FUNCTION FOR CALIBRATION */
+/**************************************************************/
+/*!
+ *     @brief This API is used to
+ *     calibration parameters used for calculation in the registers
+ *
+ *  parameter | Register address |   bit
+ *------------|------------------|----------------
+ *     dig_T1    |  0x88 and 0x89   | from 0 : 7 to 8: 15
+ *     dig_T2    |  0x8A and 0x8B   | from 0 : 7 to 8: 15
+ *     dig_T3    |  0x8C and 0x8D   | from 0 : 7 to 8: 15
+ *     dig_P1    |  0x8E and 0x8F   | from 0 : 7 to 8: 15
+ *     dig_P2    |  0x90 and 0x91   | from 0 : 7 to 8: 15
+ *     dig_P3    |  0x92 and 0x93   | from 0 : 7 to 8: 15
+ *     dig_P4    |  0x94 and 0x95   | from 0 : 7 to 8: 15
+ *     dig_P5    |  0x96 and 0x97   | from 0 : 7 to 8: 15
+ *     dig_P6    |  0x98 and 0x99   | from 0 : 7 to 8: 15
+ *     dig_P7    |  0x9A and 0x9B   | from 0 : 7 to 8: 15
+ *     dig_P8    |  0x9C and 0x9D   | from 0 : 7 to 8: 15
+ *     dig_P9    |  0x9E and 0x9F   | from 0 : 7 to 8: 15
+ *     dig_H1    |         0xA1     | from 0 to 7
+ *     dig_H2    |  0xE1 and 0xE2   | from 0 : 7 to 8: 15
+ *     dig_H3    |         0xE3     | from 0 to 7
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_calib_param(void);
+/**************************************************************/
+/**\name       FUNCTION FOR TEMPERATURE OVER SAMPLING */
+/**************************************************************/
+/*!
+ *     @brief This API is used to get
+ *     the temperature oversampling setting in the register 0xF4
+ *     bits from 5 to 7
+ *
+ *     value               |   Temperature oversampling
+ * ---------------------|---------------------------------
+ *     0x00                | Skipped
+ *     0x01                | BME280_OVERSAMP_1X
+ *     0x02                | BME280_OVERSAMP_2X
+ *     0x03                | BME280_OVERSAMP_4X
+ *     0x04                | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07  | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param v_value_u8 : The value of temperature over sampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_oversamp_temperature(
+u8 *v_value_u8);
+/*!
+ *     @brief This API is used to set
+ *     the temperature oversampling setting in the register 0xF4
+ *     bits from 5 to 7
+ *
+ *     value               |   Temperature oversampling
+ * ---------------------|---------------------------------
+ *     0x00                | Skipped
+ *     0x01                | BME280_OVERSAMP_1X
+ *     0x02                | BME280_OVERSAMP_2X
+ *     0x03                | BME280_OVERSAMP_4X
+ *     0x04                | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07  | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param v_value_u8 : The value of temperature over sampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_oversamp_temperature(
+u8 v_value_u8);
+/**************************************************************/
+/**\name       FUNCTION FOR PRESSURE OVER SAMPLING */
+/**************************************************************/
+/*!
+ *     @brief This API is used to get
+ *     the pressure oversampling setting in the register 0xF4
+ *     bits from 2 to 4
+ *
+ *     value              | Pressure oversampling
+ * --------------------|--------------------------
+ *     0x00               | Skipped
+ *     0x01               | BME280_OVERSAMP_1X
+ *     0x02               | BME280_OVERSAMP_2X
+ *     0x03               | BME280_OVERSAMP_4X
+ *     0x04               | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07 | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param v_value_u8 : The value of pressure oversampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_oversamp_pressure(
+u8 *v_value_u8);
+/*!
+ *     @brief This API is used to set
+ *     the pressure oversampling setting in the register 0xF4
+ *     bits from 2 to 4
+ *
+ *     value              | Pressure oversampling
+ * --------------------|--------------------------
+ *     0x00               | Skipped
+ *     0x01               | BME280_OVERSAMP_1X
+ *     0x02               | BME280_OVERSAMP_2X
+ *     0x03               | BME280_OVERSAMP_4X
+ *     0x04               | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07 | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param v_value_u8 : The value of pressure oversampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_oversamp_pressure(
+u8 v_value_u8);
+/**************************************************************/
+/**\name       FUNCTION FOR HUMIDITY OVER SAMPLING */
+/**************************************************************/
+/*!
+ *     @brief This API is used to get
+ *     the humidity oversampling setting in the register 0xF2
+ *     bits from 0 to 2
+ *
+ *     value               | Humidity oversampling
+ * ---------------------|-------------------------
+ *     0x00                | Skipped
+ *     0x01                | BME280_OVERSAMP_1X
+ *     0x02                | BME280_OVERSAMP_2X
+ *     0x03                | BME280_OVERSAMP_4X
+ *     0x04                | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07  | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param  v_value_u8 : The value of humidity over sampling
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_oversamp_humidity(u8 *v_value_u8);
+/*!
+ *     @brief This API is used to set
+ *     the humidity oversampling setting in the register 0xF2
+ *     bits from 0 to 2
+ *
+ *     value               | Humidity oversampling
+ * ---------------------|-------------------------
+ *     0x00                | Skipped
+ *     0x01                | BME280_OVERSAMP_1X
+ *     0x02                | BME280_OVERSAMP_2X
+ *     0x03                | BME280_OVERSAMP_4X
+ *     0x04                | BME280_OVERSAMP_8X
+ *     0x05,0x06 and 0x07  | BME280_OVERSAMP_16X
+ *
+ *
+ *  @param  v_value_u8 : The value of humidity over sampling
+ *
+ *
+ *
+ * @note The "BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY"
+ * register sets the humidity
+ * data acquisition options of the device.
+ * @note changes to this registers only become
+ * effective after a write operation to
+ * "BME280_CTRL_MEAS_REG" register.
+ * @note In the code automated reading and writing of
+ *     "BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY"
+ * @note register first set the
+ * "BME280_CTRL_HUMIDITY_REG_OVERSAM_HUMIDITY"
+ *  and then read and write
+ *  the "BME280_CTRL_MEAS_REG" register in the function.
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_oversamp_humidity(
+u8 v_value_u8);
+/**************************************************************/
+/**\name       FUNCTION FOR POWER MODE*/
+/**************************************************************/
+/*!
+ *     @brief This API used to get the
+ *     Operational Mode from the sensor in the register 0xF4 bit 0 and 1
+ *
+ *
+ *
+ *     @param v_power_mode_u8 : The value of power mode
+ *  value           |    mode
+ * -----------------|------------------
+ *     0x00            | BME280_SLEEP_MODE
+ *     0x01 and 0x02   | BME280_FORCED_MODE
+ *     0x03            | BME280_NORMAL_MODE
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_power_mode(u8 *v_power_mode_u8);
+/*!
+ *     @brief This API used to set the
+ *     Operational Mode from the sensor in the register 0xF4 bit 0 and 1
+ *
+ *
+ *
+ *     @param v_power_mode_u8 : The value of power mode
+ *  value           |    mode
+ * -----------------|------------------
+ *     0x00            | BME280_SLEEP_MODE
+ *     0x01 and 0x02   | BME280_FORCED_MODE
+ *     0x03            | BME280_NORMAL_MODE
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_power_mode(u8 v_power_mode_u8);
+/**************************************************************/
+/**\name       FUNCTION FOR SOFT RESET*/
+/**************************************************************/
+/*!
+ * @brief Used to reset the sensor
+ * The value 0xB6 is written to the 0xE0
+ * register the device is reset using the
+ * complete power-on-reset procedure.
+ * @note Soft reset can be easily set using bme280_set_softreset().
+ * @note Usage Hint : bme280_set_softreset()
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_soft_rst(void);
+/**************************************************************/
+/**\name       FUNCTION FOR SPI ENABLE*/
+/**************************************************************/
+/*!
+ *     @brief This API used to get the sensor
+ *     SPI mode(communication type) in the register 0xF5 bit 0
+ *
+ *
+ *
+ *     @param v_enable_disable_u8 : The value of SPI enable
+ *     value  | Description
+ * --------|--------------
+ *   0     | Disable
+ *   1     | Enable
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_spi3(u8 *v_enable_disable_u8);
+/*!
+ *     @brief This API used to set the sensor
+ *     SPI mode(communication type) in the register 0xF5 bit 0
+ *
+ *
+ *
+ *     @param v_enable_disable_u8 : The value of SPI enable
+ *     value  | Description
+ * --------|--------------
+ *   0     | Disable
+ *   1     | Enable
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_spi3(u8 v_enable_disable_u8);
+/**************************************************************/
+/**\name       FUNCTION FOR IIR FILTER*/
+/**************************************************************/
+/*!
+ *     @brief This API is used to reads filter setting
+ *     in the register 0xF5 bit 3 and 4
+ *
+ *
+ *
+ *     @param v_value_u8 : The value of IIR filter coefficient
+ *
+ *     value       |   Filter coefficient
+ * -------------|-------------------------
+ *     0x00        | BME280_FILTER_COEFF_OFF
+ *     0x01        | BME280_FILTER_COEFF_2
+ *     0x02        | BME280_FILTER_COEFF_4
+ *     0x03        | BME280_FILTER_COEFF_8
+ *     0x04        | BME280_FILTER_COEFF_16
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_filter(u8 *v_value_u8);
+/*!
+ *     @brief This API is used to write filter setting
+ *     in the register 0xF5 bit 3 and 4
+ *
+ *
+ *
+ *     @param v_value_u8 : The value of IIR filter coefficient
+ *
+ *     value       |   Filter coefficient
+ * -------------|-------------------------
+ *     0x00        | BME280_FILTER_COEFF_OFF
+ *     0x01        | BME280_FILTER_COEFF_2
+ *     0x02        | BME280_FILTER_COEFF_4
+ *     0x03        | BME280_FILTER_COEFF_8
+ *     0x04        | BME280_FILTER_COEFF_16
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_filter(u8 v_value_u8);
+/**************************************************************/
+/**\name       FUNCTION FOR STANDBY DURATION*/
+/**************************************************************/
+/*!
+ *     @brief This API used to Read the
+ *     standby duration time from the sensor in the register 0xF5 bit 5 to 7
+ *
+ *     @param v_standby_durn_u8 : The value of standby duration time value.
+ *  value       | standby duration
+ * -------------|-----------------------
+ *    0x00      | BME280_STANDBY_TIME_1_MS
+ *    0x01      | BME280_STANDBY_TIME_63_MS
+ *    0x02      | BME280_STANDBY_TIME_125_MS
+ *    0x03      | BME280_STANDBY_TIME_250_MS
+ *    0x04      | BME280_STANDBY_TIME_500_MS
+ *    0x05      | BME280_STANDBY_TIME_1000_MS
+ *    0x06      | BME280_STANDBY_TIME_2000_MS
+ *    0x07      | BME280_STANDBY_TIME_4000_MS
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_get_standby_durn(u8 *v_standby_durn_u8);
+/*!
+ *     @brief This API used to write the
+ *     standby duration time from the sensor in the register 0xF5 bit 5 to 7
+ *
+ *     @param v_standby_durn_u8 : The value of standby duration time value.
+ *  value       | standby duration
+ * -------------|-----------------------
+ *    0x00      | BME280_STANDBY_TIME_1_MS
+ *    0x01      | BME280_STANDBY_TIME_63_MS
+ *    0x02      | BME280_STANDBY_TIME_125_MS
+ *    0x03      | BME280_STANDBY_TIME_250_MS
+ *    0x04      | BME280_STANDBY_TIME_500_MS
+ *    0x05      | BME280_STANDBY_TIME_1000_MS
+ *    0x06      | BME280_STANDBY_TIME_2000_MS
+ *    0x07      | BME280_STANDBY_TIME_4000_MS
+ *
+ *     @note Normal mode comprises an automated perpetual
+ *     cycling between an (active)
+ *     Measurement period and an (inactive) standby period.
+ *     @note The standby time is determined by
+ *     the contents of the register t_sb.
+ *     Standby time can be set using BME280_STANDBY_TIME_125_MS.
+ *
+ *     @note Usage Hint : bme280_set_standby_durn(BME280_STANDBY_TIME_125_MS)
+ *
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE bme280_set_standby_durn(u8 v_standby_durn_u8);
+/**************************************************************/
+/**\name       FUNCTION FOR WORK MODE*/
+/**************************************************************/
+/*
+ * @brief Writes the working mode to the sensor
+ *
+ *
+ *
+ *
+ *  @param v_work_mode_u8 : Mode to be set
+ *  value    | Working mode
+ * ----------|--------------------
+ *   0       | BME280_ULTRALOWPOWER_MODE
+ *   1       | BME280_LOWPOWER_MODE
+ *   2       | BME280_STANDARDRESOLUTION_MODE
+ *   3       | BME280_HIGHRESOLUTION_MODE
+ *   4       | BME280_ULTRAHIGHRESOLUTION_MODE
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+/*BME280_RETURN_FUNCTION_TYPE bme280_set_work_mode(u8 v_work_mode_u8);*/
+/**************************************************************/
+/**\name       FUNCTION FOR FORCE MODE DATA READ*/
+/**************************************************************/
+/*!
+ * @brief This API used to read uncompensated
+ * temperature,pressure and humidity in forced mode
+ *
+ *
+ *     @param v_uncom_pressure_s32: The value of uncompensated pressure
+ *     @param v_uncom_temperature_s32: The value of uncompensated temperature
+ *     @param v_uncom_humidity_s32: The value of uncompensated humidity
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+*/
+BME280_RETURN_FUNCTION_TYPE
+bme280_get_forced_uncomp_pressure_temperature_humidity(
+s32 *v_uncom_pressure_s32,
+s32 *v_uncom_temperature_s32, s32 *v_uncom_humidity_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR COMMON READ AND WRITE */
+/**************************************************************/
+/*!
+ * @brief
+ *     This API write the data to
+ *     the given register
+ *
+ *
+ *     @param v_addr_u8 -> Address of the register
+ *     @param v_data_u8 -> The data from the register
+ *     @param v_len_u8 -> no of bytes to read
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+ */
+BME280_RETURN_FUNCTION_TYPE bme280_write_register(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8);
+/*!
+ * @brief
+ *     This API reads the data from
+ *     the given register
+ *
+ *
+ *     @param v_addr_u8 -> Address of the register
+ *     @param v_data_u8 -> The data from the register
+ *     @param v_len_u8 -> no of bytes to read
+ *
+ *
+ *     @return results of bus communication function
+ *     @retval 0 -> Success
+ *     @retval -1 -> Error
+ *
+ *
+ */
+BME280_RETURN_FUNCTION_TYPE bme280_read_register(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8);
+/**************************************************************/
+/**\name       FUNCTION FOR FLOAT OUTPUT TEMPERATURE*/
+/**************************************************************/
+#ifdef BME280_ENABLE_FLOAT
+/*!
+ * @brief Reads actual temperature from uncompensated temperature
+ * @note returns the value in Degree centigrade
+ * @note Output value of "51.23" equals 51.23 DegC.
+ *
+ *
+ *
+ *  @param v_uncom_temperature_s32 : value of uncompensated temperature
+ *
+ *
+ *
+ *  @return  Return the actual temperature in floating point
+ *
+*/
+double bme280_compensate_T_double(s32 v_uncom_temperature_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR FLOAT OUTPUT PRESSURE*/
+/**************************************************************/
+/*!
+ * @brief Reads actual pressure from uncompensated pressure
+ * @note Returns pressure in Pa as double.
+ * @note Output value of "96386.2"
+ * equals 96386.2 Pa = 963.862 hPa.
+ *
+ *
+ *  @param v_uncom_pressure_s32 : value of uncompensated pressure
+ *
+ *
+ *  @return  Return the actual pressure in floating point
+ *
+*/
+double bme280_compensate_P_double(s32 v_uncom_pressure_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR FLOAT OUTPUT HUMIDITY*/
+/**************************************************************/
+/*!
+ * @brief Reads actual humidity from uncompensated humidity
+ * @note returns the value in relative humidity (%rH)
+ * @note Output value of "42.12" equals 42.12 %rH
+ *
+ *  @param v_uncom_humidity_s32 : value of uncompensated humidity
+ *
+ *
+ *
+ *  @return Return the actual humidity in floating point
+ *
+*/
+double bme280_compensate_H_double(s32 v_uncom_humidity_s32);
+#endif
+/**************************************************************/
+/**\name       FUNCTION FOR 64BIT OUTPUT PRESSURE*/
+/**************************************************************/
+#if defined(BME280_ENABLE_INT64) && defined(BME280_64BITSUPPORT_PRESENT)
+/*!
+ * @brief Reads actual pressure from uncompensated pressure
+ * @note Returns the value in Pa as unsigned 32 bit
+ * integer in Q24.8 format (24 integer bits and
+ * 8 fractional bits).
+ * @note Output value of "24674867"
+ * represents 24674867 / 256 = 96386.2 Pa = 963.862 hPa
+ *
+ *
+ *
+ *  @param  v_uncom_pressure_s32 : value of uncompensated temperature
+ *
+ *
+ *  @return Return the actual pressure in u32
+ *
+*/
+u32 bme280_compensate_P_int64(s32 v_uncom_pressure_s32);
+/**************************************************************/
+/**\name       FUNCTION FOR 24BIT OUTPUT PRESSURE*/
+/**************************************************************/
+/*!
+ * @brief Reads actual pressure from uncompensated pressure
+ * @note Returns the value in Pa.
+ * @note Output value of "12337434"
+ * @note represents 12337434 / 128 = 96386.2 Pa = 963.862 hPa
+ *
+ *
+ *
+ *  @param v_uncom_pressure_s32 : value of uncompensated pressure
+ *
+ *
+ *  @return the actual pressure in u32
+ *
+*/
+u32 bme280_compensate_P_int64_twentyfour_bit_output(s32 v_uncom_pressure_s32);
+#endif
+/**************************************************************/
+/**\name       FUNCTION FOR WAIT PERIOD*/
+/**************************************************************/
+/*!
+ * @brief Computing waiting time for sensor data read
+ *
+ *
+ *
+ *
+ *  @param v_delaytime_u8 : The value of delay time for force mode
+ *
+ *
+ *     @retval 0 -> Success
+ *
+ *
+ */
+BME280_RETURN_FUNCTION_TYPE bme280_compute_wait_time(u8
+*v_delaytime_u8r);
+#endif
diff --git a/bme280_support.c b/bme280_support.c
new file mode 100644 (file)
index 0000000..4d62047
--- /dev/null
@@ -0,0 +1,459 @@
+/*
+****************************************************************************
+* Copyright (C) 2014 Bosch Sensortec GmbH
+*
+* bme280_support.c
+* Date: 2014/12/12
+* Revision: 1.0.4 $
+*
+* Usage: Sensor Driver support file for BME280 sensor
+*
+****************************************************************************
+* 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.
+**************************************************************************/
+/*---------------------------------------------------------------------------*/
+/* Includes*/
+/*---------------------------------------------------------------------------*/
+#include "bme280.h"
+
+/*----------------------------------------------------------------------------*
+*  The following functions are used for reading and writing of
+*      sensor data using I2C or SPI communication
+*----------------------------------------------------------------------------*/
+#ifdef BME280_API
+/*     \Brief: The function is used as I2C bus read
+ *     \Return : Status of the I2C read
+ *     \param dev_addr : The device address of the sensor
+ *     \param reg_addr : Address of the first register, will data is going to be read
+ *     \param reg_data : This data read from the sensor, which is hold in an array
+ *     \param cnt : The no of byte of data to be read
+ */
+s8 BME280_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
+ /*    \Brief: The function is used as I2C bus write
+ *     \Return : Status of the I2C write
+ *     \param dev_addr : The device address of the sensor
+ *     \param reg_addr : Address of the first register, will data is going to be written
+ *     \param reg_data : It is a value hold in the array,
+ *             will be used for write the value into the register
+ *     \param cnt : The no of byte of data to be write
+ */
+s8 BME280_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
+/*     \Brief: The function is used as SPI bus write
+ *     \Return : Status of the SPI write
+ *     \param dev_addr : The device address of the sensor
+ *     \param reg_addr : Address of the first register, will data is going to be written
+ *     \param reg_data : It is a value hold in the array,
+ *             will be used for write the value into the register
+ *     \param cnt : The no of byte of data to be write
+ */
+s8 BME280_SPI_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
+/*     \Brief: The function is used as SPI bus read
+ *     \Return : Status of the SPI read
+ *     \param dev_addr : The device address of the sensor
+ *     \param reg_addr : Address of the first register, will data is going to be read
+ *     \param reg_data : This data read from the sensor, which is hold in an array
+ *     \param cnt : The no of byte of data to be read */
+s8 BME280_SPI_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
+/*
+ * \Brief: SPI/I2C init routine
+*/
+s8 I2C_routine(void);
+s8 SPI_routine(void);
+#endif
+/********************End of I2C/SPI function declarations***********************/
+/*     Brief : The delay routine
+ *     \param : delay in ms
+*/
+void BME280_delay_msek(u32 msek);
+/* This function is an example for reading sensor data
+ *     \param: None
+ *     \return: communication result
+ */
+s32 bme280_data_readout_template(void);
+/*----------------------------------------------------------------------------*
+ *  struct bme280_t parameters can be accessed by using bme280
+ *     bme280_t having the following parameters
+ *     Bus write function pointer: BME280_WR_FUNC_PTR
+ *     Bus read function pointer: BME280_RD_FUNC_PTR
+ *     Delay function pointer: delay_msec
+ *     I2C address: dev_addr
+ *     Chip id of the sensor: chip_id
+ *---------------------------------------------------------------------------*/
+struct bme280_t bme280;
+/* This function is an example for reading sensor data
+ *     \param: None
+ *     \return: communication result
+ */
+s32 bme280_data_readout_template(void)
+{
+       /* The variable used to assign the standby time*/
+       u8 v_stand_by_time_u8 = BME280_ZERO_U8X;
+       /* The variable used to read uncompensated temperature*/
+       s32 v_data_uncomp_tem_s32 = BME280_ZERO_U8X;
+       /* The variable used to read uncompensated pressure*/
+       s32 v_data_uncomp_pres_s32 = BME280_ZERO_U8X;
+       /* The variable used to read uncompensated pressure*/
+       s32 v_data_uncomp_hum_s32 = BME280_ZERO_U8X;
+       /* The variable used to read real temperature*/
+       s32 v_actual_temp_s32 = BME280_ZERO_U8X;
+       /* The variable used to read real pressure*/
+       u32 v_actual_press_u32 = BME280_ZERO_U8X;
+       /* The variable used to read real humidity*/
+       u32 v_actual_humity_u32 = BME280_ZERO_U8X;
+       /* result of communication results*/
+       s32 com_rslt = ERROR;
+
+
+
+ /*********************** START INITIALIZATION ************************/
+  /*   Based on the user need configure I2C or SPI interface.
+  *    It is example code to explain how to use the bme280 API*/
+  #ifdef BME280_API
+       I2C_routine();
+       /*SPI_routine(); */
+       #endif
+/*--------------------------------------------------------------------------*
+ *  This function used to assign the value/reference of
+ *     the following parameters
+ *     I2C address
+ *     Bus Write
+ *     Bus read
+ *     Chip id
+*-------------------------------------------------------------------------*/
+       com_rslt = bme280_init(&bme280);
+
+       /*      For initialization it is required to set the mode of
+        *      the sensor as "NORMAL"
+        *      data acquisition/read/write is possible in this mode
+        *      by using the below API able to set the power mode as NORMAL*/
+       /* Set the power mode as NORMAL*/
+       com_rslt += bme280_set_power_mode(BME280_NORMAL_MODE);
+       /*      For reading the pressure, humidity and temperature data it is required to
+        *      set the OSS setting of humidity, pressure and temperature
+        * The "BME280_CTRLHUM_REG_OSRSH" register sets the humidity
+        * data acquisition options of the device.
+        * changes to this registers only become effective after a write operation to
+        * "BME280_CTRLMEAS_REG" register.
+        * In the code automated reading and writing of "BME280_CTRLHUM_REG_OSRSH"
+        * register first set the "BME280_CTRLHUM_REG_OSRSH" and then read and write
+        * the "BME280_CTRLMEAS_REG" register in the function*/
+       com_rslt += bme280_set_oversamp_humidity(BME280_OVERSAMP_1X);
+
+       /* set the pressure oversampling*/
+       com_rslt += bme280_set_oversamp_pressure(BME280_OVERSAMP_2X);
+       /* set the temperature oversampling*/
+       com_rslt += bme280_set_oversamp_temperature(BME280_OVERSAMP_4X);
+/*--------------------------------------------------------------------------*/
+/*------------------------------------------------------------------------*
+************************* START GET and SET FUNCTIONS DATA ****************
+*---------------------------------------------------------------------------*/
+       /* This API used to Write the standby time of the sensor input
+        *      value have to be given
+        *      Normal mode comprises an automated perpetual cycling between an (active)
+        *      Measurement period and an (inactive) standby period.
+        *      The standby time is determined by the contents of the register t_sb.
+        *      Standby time can be set using BME280_STANDBYTIME_125_MS.
+        *      Usage Hint : bme280_set_standbydur(BME280_STANDBYTIME_125_MS)*/
+
+       com_rslt += bme280_set_standby_durn(BME280_STANDBY_TIME_1_MS);
+
+       /* This API used to read back the written value of standby time*/
+       com_rslt += bme280_get_standby_durn(&v_stand_by_time_u8);
+/*-----------------------------------------------------------------*
+************************* END GET and SET FUNCTIONS ****************
+*------------------------------------------------------------------*/
+
+/************************* END INITIALIZATION *************************/
+
+/*------------------------------------------------------------------*
+************ START READ UNCOMPENSATED PRESSURE, TEMPERATURE
+AND HUMIDITY DATA ********
+*---------------------------------------------------------------------*/
+       /* API is used to read the uncompensated temperature*/
+       com_rslt += bme280_read_uncomp_temperature(&v_data_uncomp_tem_s32);
+
+       /* API is used to read the uncompensated pressure*/
+       com_rslt += bme280_read_uncomp_pressure(&v_data_uncomp_pres_s32);
+
+       /* API is used to read the uncompensated humidity*/
+       com_rslt += bme280_read_uncomp_humidity(&v_data_uncomp_hum_s32);
+
+       /* API is used to read the uncompensated temperature,pressure
+       and humidity data */
+       com_rslt += bme280_read_uncomp_pressure_temperature_humidity(
+       &v_data_uncomp_tem_s32, &v_data_uncomp_pres_s32, &v_data_uncomp_hum_s32);
+/*--------------------------------------------------------------------*
+************ END READ UNCOMPENSATED PRESSURE AND TEMPERATURE********
+*-------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------*
+************ START READ TRUE PRESSURE, TEMPERATURE
+AND HUMIDITY DATA ********
+*---------------------------------------------------------------------*/
+       /* API is used to read the true temperature*/
+       /* Input value as uncompensated temperature and output format*/
+       com_rslt += bme280_compensate_T_int32(v_data_uncomp_tem_s32);
+
+       /* API is used to read the true pressure*/
+       /* Input value as uncompensated pressure */
+       com_rslt += bme280_compensate_P_int32(v_data_uncomp_pres_s32);
+
+       /* API is used to read the true humidity*/
+       /* Input value as uncompensated humidity and output format*/
+       com_rslt += bme280_compensate_H_int32(v_data_uncomp_hum_s32);
+
+       /* API is used to read the true temperature, humidity and pressure*/
+       com_rslt += bme280_read_pressure_temperature_humidity(
+       &v_actual_press_u32, &v_actual_temp_s32, &v_actual_humity_u32);
+/*--------------------------------------------------------------------*
+************ END READ TRUE PRESSURE, TEMPERATURE AND HUMIDITY ********
+*-------------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------*
+************************* START DE-INITIALIZATION ***********************
+*-------------------------------------------------------------------------*/
+       /*      For de-initialization it is required to set the mode of
+        *      the sensor as "SLEEP"
+        *      the device reaches the lowest power consumption only
+        *      In SLEEP mode no measurements are performed
+        *      All registers are accessible
+        *      by using the below API able to set the power mode as SLEEP*/
+        /* Set the power mode as SLEEP*/
+       com_rslt += bme280_set_power_mode(BME280_SLEEP_MODE);
+/*---------------------------------------------------------------------*
+************************* END DE-INITIALIZATION **********************
+*---------------------------------------------------------------------*/
+return com_rslt;
+}
+
+#ifdef BME280_API
+#define MASK_DATA1     0xFF
+#define MASK_DATA2     0x80
+#define MASK_DATA3     0x7F
+/*--------------------------------------------------------------------------*
+*      The following function is used to map the I2C bus read, write, delay and
+*      device address with global structure bme280
+*-------------------------------------------------------------------------*/
+s8 I2C_routine(void) {
+/*--------------------------------------------------------------------------*
+ *  By using bme280 the following structure parameter can be accessed
+ *     Bus write function pointer: BME280_WR_FUNC_PTR
+ *     Bus read function pointer: BME280_RD_FUNC_PTR
+ *     Delay function pointer: delay_msec
+ *     I2C address: dev_addr
+ *--------------------------------------------------------------------------*/
+       bme280.bus_write = BME280_I2C_bus_write;
+       bme280.bus_read = BME280_I2C_bus_read;
+       bme280.dev_addr = BME280_I2C_ADDRESS2;
+       bme280.delay_msec = BME280_delay_msek;
+
+       return BME280_ZERO_U8X;
+}
+
+/*---------------------------------------------------------------------------*
+ * The following function is used to map the SPI bus read, write and delay
+ * with global structure bme280
+ *--------------------------------------------------------------------------*/
+s8 SPI_routine(void) {
+/*--------------------------------------------------------------------------*
+ *  By using bme280 the following structure parameter can be accessed
+ *     Bus write function pointer: BME280_WR_FUNC_PTR
+ *     Bus read function pointer: BME280_RD_FUNC_PTR
+ *     Delay function pointer: delay_msec
+ *--------------------------------------------------------------------------*/
+
+       bme280.bus_write = BME280_SPI_bus_write;
+       bme280.bus_read = BME280_SPI_bus_read;
+       bme280.delay_msec = BME280_delay_msek;
+
+       return BME280_ZERO_U8X;
+}
+
+/************** I2C/SPI buffer length ******/
+#define        I2C_BUFFER_LEN 8
+#define SPI_BUFFER_LEN 5
+
+/*-------------------------------------------------------------------*
+*      This is a sample code for read and write the data by using I2C/SPI
+*      Use either I2C or SPI based on your need
+*      The device address defined in the bme280.h file
+*-----------------------------------------------------------------------*/
+ /*    \Brief: The function is used as I2C bus write
+ *     \Return : Status of the I2C write
+ *     \param dev_addr : The device address of the sensor
+ *     \param reg_addr : Address of the first register, will data is going to be written
+ *     \param reg_data : It is a value hold in the array,
+ *             will be used for write the value into the register
+ *     \param cnt : The no of byte of data to be write
+ */
+s8 BME280_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
+{
+       s32 iError = BME280_ZERO_U8X;
+       u8 array[I2C_BUFFER_LEN];
+       u8 stringpos = BME280_ZERO_U8X;
+       array[BME280_ZERO_U8X] = reg_addr;
+       for (stringpos = BME280_ZERO_U8X; stringpos < cnt; stringpos++) {
+               array[stringpos + BME280_ONE_U8X] = *(reg_data + stringpos);
+       }
+       /*
+       * Please take the below function as your reference for
+       * write the data using I2C communication
+       * "IERROR = I2C_WRITE_STRING(DEV_ADDR, ARRAY, CNT+1)"
+       * add your I2C write function here
+       * iError is an return value of I2C read function
+       * Please select your valid return value
+       * In the driver SUCCESS defined as 0
+    * and FAILURE defined as -1
+       * Note :
+       * This is a full duplex operation,
+       * The first read data is discarded, for that extra write operation
+       * have to be initiated. For that cnt+1 operation done in the I2C write string function
+       * For more information please refer data sheet SPI communication:
+       */
+       return (s8)iError;
+}
+
+ /*    \Brief: The function is used as I2C bus read
+ *     \Return : Status of the I2C read
+ *     \param dev_addr : The device address of the sensor
+ *     \param reg_addr : Address of the first register, will data is going to be read
+ *     \param reg_data : This data read from the sensor, which is hold in an array
+ *     \param cnt : The no of data byte of to be read
+ */
+s8 BME280_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
+{
+       s32 iError = BME280_ZERO_U8X;
+       u8 array[I2C_BUFFER_LEN] = {BME280_ZERO_U8X};
+       u8 stringpos = BME280_ZERO_U8X;
+       array[BME280_ZERO_U8X] = reg_addr;
+       /* Please take the below function as your reference
+        * for read the data using I2C communication
+        * add your I2C rad function here.
+        * "IERROR = I2C_WRITE_READ_STRING(DEV_ADDR, ARRAY, ARRAY, 1, CNT)"
+        * iError is an return value of SPI write function
+        * Please select your valid return value
+     * In the driver SUCCESS defined as 0
+     * and FAILURE defined as -1
+        */
+       for (stringpos = BME280_ZERO_U8X; stringpos < cnt; stringpos++) {
+               *(reg_data + stringpos) = array[stringpos];
+       }
+       return (s8)iError;
+}
+
+/*     \Brief: The function is used as SPI bus read
+ *     \Return : Status of the SPI read
+ *     \param dev_addr : The device address of the sensor
+ *     \param reg_addr : Address of the first register, will data is going to be read
+ *     \param reg_data : This data read from the sensor, which is hold in an array
+ *     \param cnt : The no of byte of data to be read
+ */
+s8 BME280_SPI_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
+{
+       s32 iError=BME280_ZERO_U8X;
+       u8 array[SPI_BUFFER_LEN]={MASK_DATA1};
+       u8 stringpos;
+       /*      For the SPI mode only 7 bits of register addresses are used.
+       The MSB of register address is declared the bit what functionality it is
+       read/write (read as 1/write as BME280_ZERO_U8X)*/
+       array[BME280_ZERO_U8X] = reg_addr|MASK_DATA2;/*read routine is initiated register address is mask with 0x80*/
+       /*
+       * Please take the below function as your reference for
+       * read the data using SPI communication
+       * " IERROR = SPI_READ_WRITE_STRING(ARRAY, ARRAY, CNT+1)"
+       * add your SPI read function here
+       * iError is an return value of SPI read function
+       * Please select your valid return value
+       * In the driver SUCCESS defined as 0
+    * and FAILURE defined as -1
+       * Note :
+       * This is a full duplex operation,
+       * The first read data is discarded, for that extra write operation
+       * have to be initiated. For that cnt+1 operation done in the SPI read
+       * and write string function
+       * For more information please refer data sheet SPI communication:
+       */
+       for (stringpos = BME280_ZERO_U8X; stringpos < cnt; stringpos++) {
+               *(reg_data + stringpos) = array[stringpos+BME280_ONE_U8X];
+       }
+       return (s8)iError;
+}
+
+/*     \Brief: The function is used as SPI bus write
+ *     \Return : Status of the SPI write
+ *     \param dev_addr : The device address of the sensor
+ *     \param reg_addr : Address of the first register, will data is going to be written
+ *     \param reg_data : It is a value hold in the array,
+ *             will be used for write the value into the register
+ *     \param cnt : The no of byte of data to be write
+ */
+s8 BME280_SPI_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
+{
+       s32 iError = BME280_ZERO_U8X;
+       u8 array[SPI_BUFFER_LEN * BME280_TWO_U8X];
+       u8 stringpos = BME280_ZERO_U8X;
+       for (stringpos = BME280_ZERO_U8X; stringpos < cnt; stringpos++) {
+               /* the operation of (reg_addr++)&0x7F done: because it ensure the
+                  BME280_ZERO_U8X and 1 of the given value
+                  It is done only for 8bit operation*/
+               array[stringpos * BME280_TWO_U8X] = (reg_addr++) & MASK_DATA3;
+               array[stringpos * BME280_TWO_U8X + BME280_ONE_U8X] = *(reg_data + stringpos);
+       }
+       /* Please take the below function as your reference
+        * for write the data using SPI communication
+        * add your SPI write function here.
+        * "IERROR = SPI_WRITE_STRING(ARRAY, CNT*2)"
+        * iError is an return value of SPI write function
+        * Please select your valid return value
+        * In the driver SUCCESS defined as 0
+     * and FAILURE defined as -1
+        */
+       return (s8)iError;
+}
+
+/*     Brief : The delay routine
+ *     \param : delay in ms
+*/
+void BME280_delay_msek(u32 msek)
+{
+       /*Here you can write your own delay routine*/
+}
+#endif