]> git.itanic.dy.fi Git - BME280_driver/blob - bme280.h
Added a wait until the NVM copy was complete.
[BME280_driver] / bme280.h
1 /**\r
2  * Copyright (C) 2018 - 2019 Bosch Sensortec GmbH\r
3  *\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
6  *\r
7  * Redistributions of source code must retain the above copyright\r
8  * notice, this list of conditions and the following disclaimer.\r
9  *\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
13  *\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
17  *\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
33  *\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
41  *\r
42  * @file    bme280.h\r
43  * @date    26 Aug 2019\r
44  * @version 3.3.7\r
45  * @brief\r
46  *\r
47  */\r
48 \r
49 /*! @file bme280.h\r
50  * @brief Sensor driver for BME280 sensor\r
51  */\r
52 \r
53 /*!\r
54  * @defgroup BME280 SENSOR API\r
55  */\r
56 #ifndef BME280_H_\r
57 #define BME280_H_\r
58 \r
59 /*! CPP guard */\r
60 #ifdef __cplusplus\r
61 extern "C" {\r
62 #endif\r
63 \r
64 /* Header includes */\r
65 #include "bme280_defs.h"\r
66 \r
67 /*!\r
68  *  @brief This API is the entry point.\r
69  *  It reads the chip-id and calibration data from the sensor.\r
70  *\r
71  *  @param[in,out] dev : Structure instance of bme280_dev\r
72  *\r
73  *  @return Result of API execution status\r
74  *  @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
75  */\r
76 int8_t bme280_init(struct bme280_dev *dev);\r
77 \r
78 /*!\r
79  * @brief This API writes the given data to the register address\r
80  * of the sensor.\r
81  *\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
84  * in the sensor.\r
85  * @param[in] len : No of bytes of data to write..\r
86  * @param[in] dev : Structure instance of bme280_dev.\r
87  *\r
88  * @return Result of API execution status\r
89  * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
90  */\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
92 \r
93 /*!\r
94  * @brief This API reads the data from the given register address of the sensor.\r
95  *\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
100  *\r
101  * @return Result of API execution status\r
102  * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
103  */\r
104 int8_t bme280_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, const struct bme280_dev *dev);\r
105 \r
106 /*!\r
107  * @brief This API sets the oversampling, filter and standby duration\r
108  * (normal mode) settings in the sensor.\r
109  *\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
113  *\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
117  *\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
125  *\r
126  * @return Result of API execution status\r
127  * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.\r
128  */\r
129 int8_t bme280_set_sensor_settings(uint8_t desired_settings, const struct bme280_dev *dev);\r
130 \r
131 /*!\r
132  * @brief This API gets the oversampling, filter and standby duration\r
133  * (normal mode) settings from the sensor.\r
134  *\r
135  * @param[in,out] dev : Structure instance of bme280_dev.\r
136  *\r
137  * @return Result of API execution status\r
138  * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.\r
139  */\r
140 int8_t bme280_get_sensor_settings(struct bme280_dev *dev);\r
141 \r
142 /*!\r
143  * @brief This API sets the power mode of the sensor.\r
144  *\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
147  *\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
153  *\r
154  * @return Result of API execution status\r
155  * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
156  */\r
157 int8_t bme280_set_sensor_mode(uint8_t sensor_mode, const struct bme280_dev *dev);\r
158 \r
159 /*!\r
160  * @brief This API gets the power mode of the sensor.\r
161  *\r
162  * @param[in] dev : Structure instance of bme280_dev.\r
163  * @param[out] sensor_mode : Pointer variable to store the power mode.\r
164  *\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
170  *\r
171  * @return Result of API execution status\r
172  * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
173  */\r
174 int8_t bme280_get_sensor_mode(uint8_t *sensor_mode, const struct bme280_dev *dev);\r
175 \r
176 /*!\r
177  * @brief This API performs the soft reset of the sensor.\r
178  *\r
179  * @param[in] dev : Structure instance of bme280_dev.\r
180  *\r
181  * @return Result of API execution status\r
182  * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.\r
183  */\r
184 int8_t bme280_soft_reset(const struct bme280_dev *dev);\r
185 \r
186 /*!\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
190  *\r
191  * @param[in] sensor_comp : Variable which selects which data to be read from\r
192  * the sensor.\r
193  *\r
194  * sensor_comp |   Macros\r
195  * ------------|-------------------\r
196  *     1       | BME280_PRESS\r
197  *     2       | BME280_TEMP\r
198  *     4       | BME280_HUM\r
199  *     7       | BME280_ALL\r
200  *\r
201  * @param[out] comp_data : Structure instance of bme280_data.\r
202  * @param[in] dev : Structure instance of bme280_dev.\r
203  *\r
204  * @return Result of API execution status\r
205  * @retval zero -> Success / +ve value -> Warning / -ve value -> Error\r
206  */\r
207 int8_t bme280_get_sensor_data(uint8_t sensor_comp, struct bme280_data *comp_data, struct bme280_dev *dev);\r
208 \r
209 /*!\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
212  *\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
216  */\r
217 void bme280_parse_sensor_data(const uint8_t *reg_data, struct bme280_uncomp_data *uncomp_data);\r
218 \r
219 /*!\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
222  * user.\r
223  *\r
224  * @param[in] sensor_comp : Used to select pressure and/or temperature and/or\r
225  * humidity.\r
226  * @param[in] uncomp_data : Contains the uncompensated pressure, temperature and\r
227  * humidity data.\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
231  *\r
232  * @return Result of API execution status.\r
233  * @retval zero -> Success / -ve value -> Error\r
234  */\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
239 \r
240 #ifdef __cplusplus\r
241 }\r
242 #endif /* End of CPP guard */\r
243 #endif /* BME280_H_ */\r
244 /** @}*/\r