2 * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved.
\r
6 * Redistribution and use in source and binary forms, with or without
\r
7 * modification, are permitted provided that the following conditions are met:
\r
9 * 1. Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
12 * 2. Redistributions in binary form must reproduce the above copyright
\r
13 * notice, this list of conditions and the following disclaimer in the
\r
14 * documentation and/or other materials provided with the distribution.
\r
16 * 3. Neither the name of the copyright holder nor the names of its
\r
17 * contributors may be used to endorse or promote products derived from
\r
18 * this software without specific prior written permission.
\r
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
\r
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
\r
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
\r
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
\r
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
\r
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
\r
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
\r
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
31 * POSSIBILITY OF SUCH DAMAGE.
\r
40 * @brief Sensor driver for BME280 sensor
\r
44 * @defgroup BME280 SENSOR API
\r
54 /* Header includes */
\r
55 #include "bme280_defs.h"
\r
58 * @brief This API is the entry point.
\r
59 * It reads the chip-id and calibration data from the sensor.
\r
61 * @param[in,out] dev : Structure instance of bme280_dev
\r
63 * @return Result of API execution status
\r
64 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
66 int8_t bme280_init(struct bme280_dev *dev);
\r
69 * @brief This API writes the given data to the register address
\r
72 * @param[in] reg_addr : Register address from where the data to be written.
\r
73 * @param[in] reg_data : Pointer to data buffer which is to be written
\r
75 * @param[in] len : No of bytes of data to write..
\r
76 * @param[in] dev : Structure instance of bme280_dev.
\r
78 * @return Result of API execution status
\r
79 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
81 int8_t bme280_set_regs(uint8_t *reg_addr, const uint8_t *reg_data, uint8_t len, const struct bme280_dev *dev);
\r
84 * @brief This API reads the data from the given register address of the sensor.
\r
86 * @param[in] reg_addr : Register address from where the data to be read
\r
87 * @param[out] reg_data : Pointer to data buffer to store the read data.
\r
88 * @param[in] len : No of bytes of data to be read.
\r
89 * @param[in] dev : Structure instance of bme280_dev.
\r
91 * @return Result of API execution status
\r
92 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
94 int8_t bme280_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, const struct bme280_dev *dev);
\r
97 * @brief This API sets the oversampling, filter and standby duration
\r
98 * (normal mode) settings in the sensor.
\r
100 * @param[in] dev : Structure instance of bme280_dev.
\r
101 * @param[in] desired_settings : Variable used to select the settings which
\r
102 * are to be set in the sensor.
\r
104 * @note : Below are the macros to be used by the user for selecting the
\r
105 * desired settings. User can do OR operation of these macros for configuring
\r
106 * multiple settings.
\r
108 * Macros | Functionality
\r
109 * -----------------------|----------------------------------------------
\r
110 * BME280_OSR_PRESS_SEL | To set pressure oversampling.
\r
111 * BME280_OSR_TEMP_SEL | To set temperature oversampling.
\r
112 * BME280_OSR_HUM_SEL | To set humidity oversampling.
\r
113 * BME280_FILTER_SEL | To set filter setting.
\r
114 * BME280_STANDBY_SEL | To set standby duration setting.
\r
116 * @return Result of API execution status
\r
117 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
\r
119 int8_t bme280_set_sensor_settings(uint8_t desired_settings, const struct bme280_dev *dev);
\r
122 * @brief This API gets the oversampling, filter and standby duration
\r
123 * (normal mode) settings from the sensor.
\r
125 * @param[in,out] dev : Structure instance of bme280_dev.
\r
127 * @return Result of API execution status
\r
128 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
\r
130 int8_t bme280_get_sensor_settings(struct bme280_dev *dev);
\r
133 * @brief This API sets the power mode of the sensor.
\r
135 * @param[in] dev : Structure instance of bme280_dev.
\r
136 * @param[in] sensor_mode : Variable which contains the power mode to be set.
\r
138 * sensor_mode | Macros
\r
139 * ---------------------|-------------------
\r
140 * 0 | BME280_SLEEP_MODE
\r
141 * 1 | BME280_FORCED_MODE
\r
142 * 3 | BME280_NORMAL_MODE
\r
144 * @return Result of API execution status
\r
145 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
147 int8_t bme280_set_sensor_mode(uint8_t sensor_mode, const struct bme280_dev *dev);
\r
150 * @brief This API gets the power mode of the sensor.
\r
152 * @param[in] dev : Structure instance of bme280_dev.
\r
153 * @param[out] sensor_mode : Pointer variable to store the power mode.
\r
155 * sensor_mode | Macros
\r
156 * ---------------------|-------------------
\r
157 * 0 | BME280_SLEEP_MODE
\r
158 * 1 | BME280_FORCED_MODE
\r
159 * 3 | BME280_NORMAL_MODE
\r
161 * @return Result of API execution status
\r
162 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
164 int8_t bme280_get_sensor_mode(uint8_t *sensor_mode, const struct bme280_dev *dev);
\r
167 * @brief This API performs the soft reset of the sensor.
\r
169 * @param[in] dev : Structure instance of bme280_dev.
\r
171 * @return Result of API execution status
\r
172 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
\r
174 int8_t bme280_soft_reset(const struct bme280_dev *dev);
\r
177 * @brief This API reads the pressure, temperature and humidity data from the
\r
178 * sensor, compensates the data and store it in the bme280_data structure
\r
179 * instance passed by the user.
\r
181 * @param[in] sensor_comp : Variable which selects which data to be read from
\r
184 * sensor_comp | Macros
\r
185 * ------------|-------------------
\r
191 * @param[out] comp_data : Structure instance of bme280_data.
\r
192 * @param[in] dev : Structure instance of bme280_dev.
\r
194 * @return Result of API execution status
\r
195 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
\r
197 int8_t bme280_get_sensor_data(uint8_t sensor_comp, struct bme280_data *comp_data, struct bme280_dev *dev);
\r
200 * @brief This API is used to parse the pressure, temperature and
\r
201 * humidity data and store it in the bme280_uncomp_data structure instance.
\r
203 * @param[in] reg_data : Contains register data which needs to be parsed
\r
204 * @param[out] uncomp_data : Contains the uncompensated pressure, temperature
\r
205 * and humidity data.
\r
207 void bme280_parse_sensor_data(const uint8_t *reg_data, struct bme280_uncomp_data *uncomp_data);
\r
210 * @brief This API is used to compensate the pressure and/or
\r
211 * temperature and/or humidity data according to the component selected by the
\r
214 * @param[in] sensor_comp : Used to select pressure and/or temperature and/or
\r
216 * @param[in] uncomp_data : Contains the uncompensated pressure, temperature and
\r
218 * @param[out] comp_data : Contains the compensated pressure and/or temperature
\r
219 * and/or humidity data.
\r
220 * @param[in] calib_data : Pointer to the calibration data structure.
\r
222 * @return Result of API execution status.
\r
223 * @retval zero -> Success / -ve value -> Error
\r
225 int8_t bme280_compensate_data(uint8_t sensor_comp,
\r
226 const struct bme280_uncomp_data *uncomp_data,
\r
227 struct bme280_data *comp_data,
\r
228 struct bme280_calib_data *calib_data);
\r
231 * @brief This API is used to calculate the maximum delay in milliseconds required for the
\r
232 * temperature/pressure/humidity(which ever are enabled) measurement to complete.
\r
233 * The delay depends upon the number of sensors enabled and their oversampling configuration.
\r
235 * @param[in] settings : contains the oversampling configurations.
\r
237 * @return delay required in milliseconds.
\r
240 uint32_t bme280_cal_meas_delay(const struct bme280_settings *settings);
\r
244 #endif /* End of CPP guard */
\r
245 #endif /* BME280_H_ */
\r