2 * Copyright (C) 2018 - 2019 Bosch Sensortec GmbH
\r
4 * Redistribution and use in source and binary forms, with or without
\r
5 * modification, are permitted provided that the following conditions are met:
\r
7 * Redistributions of source code must retain the above copyright
\r
8 * notice, this list of conditions and the following disclaimer.
\r
10 * Redistributions in binary form must reproduce the above copyright
\r
11 * notice, this list of conditions and the following disclaimer in the
\r
12 * documentation and/or other materials provided with the distribution.
\r
14 * Neither the name of the copyright holder nor the names of the
\r
15 * contributors may be used to endorse or promote products derived from
\r
16 * this software without specific prior written permission.
\r
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
\r
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
\r
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
22 * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
\r
23 * OR CONTRIBUTORS BE LIABLE FOR ANY
\r
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
\r
25 * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
\r
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
\r
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
\r
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
31 * ANY WAY OUT OF THE USE OF THIS
\r
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
\r
34 * The information provided is believed to be accurate and reliable.
\r
35 * The copyright holder assumes no responsibility
\r
36 * for the consequences of use
\r
37 * of such information nor for any infringement of patents or
\r
38 * other rights of third parties which may result from its use.
\r
39 * No license is granted by implication or otherwise under any patent or
\r
40 * patent rights of the copyright holder.
\r
50 * @brief Sensor driver for BME280 sensor
\r
54 * @defgroup BME280 SENSOR API
\r
64 /* Header includes */
\r
65 #include "bme280_defs.h"
\r
68 * @brief This API is the entry point.
\r
69 * It reads the chip-id and calibration data from the sensor.
\r
71 * @param[in,out] dev : Structure instance of bme280_dev
\r
73 * @return Result of API execution status
\r
74 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
76 int8_t bme280_init(struct bme280_dev *dev);
\r
79 * @brief This API writes the given data to the register address
\r
82 * @param[in] reg_addr : Register address from where the data to be written.
\r
83 * @param[in] reg_data : Pointer to data buffer which is to be written
\r
85 * @param[in] len : No of bytes of data to write..
\r
86 * @param[in] dev : Structure instance of bme280_dev.
\r
88 * @return Result of API execution status
\r
89 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
91 int8_t bme280_set_regs(uint8_t *reg_addr, const uint8_t *reg_data, uint8_t len, const struct bme280_dev *dev);
\r
94 * @brief This API reads the data from the given register address of the sensor.
\r
96 * @param[in] reg_addr : Register address from where the data to be read
\r
97 * @param[out] reg_data : Pointer to data buffer to store the read data.
\r
98 * @param[in] len : No of bytes of data to be read.
\r
99 * @param[in] dev : Structure instance of bme280_dev.
\r
101 * @return Result of API execution status
\r
102 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
104 int8_t bme280_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, const struct bme280_dev *dev);
\r
107 * @brief This API sets the oversampling, filter and standby duration
\r
108 * (normal mode) settings in the sensor.
\r
110 * @param[in] dev : Structure instance of bme280_dev.
\r
111 * @param[in] desired_settings : Variable used to select the settings which
\r
112 * are to be set in the sensor.
\r
114 * @note : Below are the macros to be used by the user for selecting the
\r
115 * desired settings. User can do OR operation of these macros for configuring
\r
116 * multiple settings.
\r
118 * Macros | Functionality
\r
119 * -----------------------|----------------------------------------------
\r
120 * BME280_OSR_PRESS_SEL | To set pressure oversampling.
\r
121 * BME280_OSR_TEMP_SEL | To set temperature oversampling.
\r
122 * BME280_OSR_HUM_SEL | To set humidity oversampling.
\r
123 * BME280_FILTER_SEL | To set filter setting.
\r
124 * BME280_STANDBY_SEL | To set standby duration setting.
\r
126 * @return Result of API execution status
\r
127 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
\r
129 int8_t bme280_set_sensor_settings(uint8_t desired_settings, const struct bme280_dev *dev);
\r
132 * @brief This API gets the oversampling, filter and standby duration
\r
133 * (normal mode) settings from the sensor.
\r
135 * @param[in,out] dev : Structure instance of bme280_dev.
\r
137 * @return Result of API execution status
\r
138 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
\r
140 int8_t bme280_get_sensor_settings(struct bme280_dev *dev);
\r
143 * @brief This API sets the power mode of the sensor.
\r
145 * @param[in] dev : Structure instance of bme280_dev.
\r
146 * @param[in] sensor_mode : Variable which contains the power mode to be set.
\r
148 * sensor_mode | Macros
\r
149 * ---------------------|-------------------
\r
150 * 0 | BME280_SLEEP_MODE
\r
151 * 1 | BME280_FORCED_MODE
\r
152 * 3 | BME280_NORMAL_MODE
\r
154 * @return Result of API execution status
\r
155 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
157 int8_t bme280_set_sensor_mode(uint8_t sensor_mode, const struct bme280_dev *dev);
\r
160 * @brief This API gets the power mode of the sensor.
\r
162 * @param[in] dev : Structure instance of bme280_dev.
\r
163 * @param[out] sensor_mode : Pointer variable to store the power mode.
\r
165 * sensor_mode | Macros
\r
166 * ---------------------|-------------------
\r
167 * 0 | BME280_SLEEP_MODE
\r
168 * 1 | BME280_FORCED_MODE
\r
169 * 3 | BME280_NORMAL_MODE
\r
171 * @return Result of API execution status
\r
172 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
174 int8_t bme280_get_sensor_mode(uint8_t *sensor_mode, const struct bme280_dev *dev);
\r
177 * @brief This API performs the soft reset of the sensor.
\r
179 * @param[in] dev : Structure instance of bme280_dev.
\r
181 * @return Result of API execution status
\r
182 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
\r
184 int8_t bme280_soft_reset(const struct bme280_dev *dev);
\r
187 * @brief This API reads the pressure, temperature and humidity data from the
\r
188 * sensor, compensates the data and store it in the bme280_data structure
\r
189 * instance passed by the user.
\r
191 * @param[in] sensor_comp : Variable which selects which data to be read from
\r
194 * sensor_comp | Macros
\r
195 * ------------|-------------------
\r
201 * @param[out] comp_data : Structure instance of bme280_data.
\r
202 * @param[in] dev : Structure instance of bme280_dev.
\r
204 * @return Result of API execution status
\r
205 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
207 int8_t bme280_get_sensor_data(uint8_t sensor_comp, struct bme280_data *comp_data, struct bme280_dev *dev);
\r
210 * @brief This API is used to parse the pressure, temperature and
\r
211 * humidity data and store it in the bme280_uncomp_data structure instance.
\r
213 * @param[in] reg_data : Contains register data which needs to be parsed
\r
214 * @param[out] uncomp_data : Contains the uncompensated pressure, temperature
\r
215 * and humidity data.
\r
217 void bme280_parse_sensor_data(const uint8_t *reg_data, struct bme280_uncomp_data *uncomp_data);
\r
220 * @brief This API is used to compensate the pressure and/or
\r
221 * temperature and/or humidity data according to the component selected by the
\r
224 * @param[in] sensor_comp : Used to select pressure and/or temperature and/or
\r
226 * @param[in] uncomp_data : Contains the uncompensated pressure, temperature and
\r
228 * @param[out] comp_data : Contains the compensated pressure and/or temperature
\r
229 * and/or humidity data.
\r
230 * @param[in] calib_data : Pointer to the calibration data structure.
\r
232 * @return Result of API execution status.
\r
233 * @retval zero -> Success / -ve value -> Error
\r
235 int8_t bme280_compensate_data(uint8_t sensor_comp,
\r
236 const struct bme280_uncomp_data *uncomp_data,
\r
237 struct bme280_data *comp_data,
\r
238 struct bme280_calib_data *calib_data);
\r
242 #endif /* End of CPP guard */
\r
243 #endif /* BME280_H_ */
\r