bme680.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /**
  2. * Copyright (C) 2017 - 2018 Bosch Sensortec GmbH
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. *
  10. * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * Neither the name of the copyright holder nor the names of the
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  19. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  20. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
  23. * OR CONTRIBUTORS BE LIABLE FOR ANY
  24. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  25. * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  33. *
  34. * The information provided is believed to be accurate and reliable.
  35. * The copyright holder assumes no responsibility
  36. * for the consequences of use
  37. * of such information nor for any infringement of patents or
  38. * other rights of third parties which may result from its use.
  39. * No license is granted by implication or otherwise under any patent or
  40. * patent rights of the copyright holder.
  41. *
  42. * @file bme680.h
  43. * @date 19 Jun 2018
  44. * @version 3.5.9
  45. * @brief
  46. *
  47. */
  48. /*! @file bme680.h
  49. @brief Sensor driver for BME680 sensor */
  50. /*!
  51. * @defgroup BME680 SENSOR API
  52. * @{*/
  53. #ifndef BME680_H_
  54. #define BME680_H_
  55. /*! CPP guard */
  56. #ifdef __cplusplus
  57. extern "C"
  58. {
  59. #endif
  60. /* Header includes */
  61. #include "bme680_defs.h"
  62. /* function prototype declarations */
  63. /*!
  64. * @brief This API is the entry point.
  65. * It reads the chip-id and calibration data from the sensor.
  66. *
  67. * @param[in,out] dev : Structure instance of bme680_dev
  68. *
  69. * @return Result of API execution status
  70. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
  71. */
  72. int8_t bme680_init(struct bme680_dev *dev);
  73. /*!
  74. * @brief This API writes the given data to the register address
  75. * of the sensor.
  76. *
  77. * @param[in] reg_addr : Register address from where the data to be written.
  78. * @param[in] reg_data : Pointer to data buffer which is to be written
  79. * in the sensor.
  80. * @param[in] len : No of bytes of data to write..
  81. * @param[in] dev : Structure instance of bme680_dev.
  82. *
  83. * @return Result of API execution status
  84. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
  85. */
  86. int8_t bme680_set_regs(const uint8_t *reg_addr, const uint8_t *reg_data, uint8_t len, struct bme680_dev *dev);
  87. /*!
  88. * @brief This API reads the data from the given register address of the sensor.
  89. *
  90. * @param[in] reg_addr : Register address from where the data to be read
  91. * @param[out] reg_data : Pointer to data buffer to store the read data.
  92. * @param[in] len : No of bytes of data to be read.
  93. * @param[in] dev : Structure instance of bme680_dev.
  94. *
  95. * @return Result of API execution status
  96. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
  97. */
  98. int8_t bme680_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, struct bme680_dev *dev);
  99. /*!
  100. * @brief This API performs the soft reset of the sensor.
  101. *
  102. * @param[in] dev : Structure instance of bme680_dev.
  103. *
  104. * @return Result of API execution status
  105. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
  106. */
  107. int8_t bme680_soft_reset(struct bme680_dev *dev);
  108. /*!
  109. * @brief This API is used to set the power mode of the sensor.
  110. *
  111. * @param[in] dev : Structure instance of bme680_dev
  112. * @note : Pass the value to bme680_dev.power_mode structure variable.
  113. *
  114. * value | mode
  115. * -------------|------------------
  116. * 0x00 | BME680_SLEEP_MODE
  117. * 0x01 | BME680_FORCED_MODE
  118. *
  119. * * @return Result of API execution status
  120. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
  121. */
  122. int8_t bme680_set_sensor_mode(struct bme680_dev *dev);
  123. /*!
  124. * @brief This API is used to get the power mode of the sensor.
  125. *
  126. * @param[in] dev : Structure instance of bme680_dev
  127. * @note : bme680_dev.power_mode structure variable hold the power mode.
  128. *
  129. * value | mode
  130. * ---------|------------------
  131. * 0x00 | BME680_SLEEP_MODE
  132. * 0x01 | BME680_FORCED_MODE
  133. *
  134. * @return Result of API execution status
  135. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
  136. */
  137. int8_t bme680_get_sensor_mode(struct bme680_dev *dev);
  138. /*!
  139. * @brief This API is used to set the profile duration of the sensor.
  140. *
  141. * @param[in] dev : Structure instance of bme680_dev.
  142. * @param[in] duration : Duration of the measurement in ms.
  143. *
  144. * @return Nothing
  145. */
  146. void bme680_set_profile_dur(uint16_t duration, struct bme680_dev *dev);
  147. /*!
  148. * @brief This API is used to get the profile duration of the sensor.
  149. *
  150. * @param[in] dev : Structure instance of bme680_dev.
  151. * @param[in] duration : Duration of the measurement in ms.
  152. *
  153. * @return Nothing
  154. */
  155. void bme680_get_profile_dur(uint16_t *duration, const struct bme680_dev *dev);
  156. /*!
  157. * @brief This API reads the pressure, temperature and humidity and gas data
  158. * from the sensor, compensates the data and store it in the bme680_data
  159. * structure instance passed by the user.
  160. *
  161. * @param[out] data: Structure instance to hold the data.
  162. * @param[in] dev : Structure instance of bme680_dev.
  163. *
  164. * @return Result of API execution status
  165. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error
  166. */
  167. int8_t bme680_get_sensor_data(struct bme680_field_data *data, struct bme680_dev *dev);
  168. /*!
  169. * @brief This API is used to set the oversampling, filter and T,P,H, gas selection
  170. * settings in the sensor.
  171. *
  172. * @param[in] dev : Structure instance of bme680_dev.
  173. * @param[in] desired_settings : Variable used to select the settings which
  174. * are to be set in the sensor.
  175. *
  176. * Macros | Functionality
  177. *---------------------------------|----------------------------------------------
  178. * BME680_OST_SEL | To set temperature oversampling.
  179. * BME680_OSP_SEL | To set pressure oversampling.
  180. * BME680_OSH_SEL | To set humidity oversampling.
  181. * BME680_GAS_MEAS_SEL | To set gas measurement setting.
  182. * BME680_FILTER_SEL | To set filter setting.
  183. * BME680_HCNTRL_SEL | To set humidity control setting.
  184. * BME680_RUN_GAS_SEL | To set run gas setting.
  185. * BME680_NBCONV_SEL | To set NB conversion setting.
  186. * BME680_GAS_SENSOR_SEL | To set all gas sensor related settings
  187. *
  188. * @note : Below are the macros to be used by the user for selecting the
  189. * desired settings. User can do OR operation of these macros for configuring
  190. * multiple settings.
  191. *
  192. * @return Result of API execution status
  193. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
  194. */
  195. int8_t bme680_set_sensor_settings(uint16_t desired_settings, struct bme680_dev *dev);
  196. /*!
  197. * @brief This API is used to get the oversampling, filter and T,P,H, gas selection
  198. * settings in the sensor.
  199. *
  200. * @param[in] dev : Structure instance of bme680_dev.
  201. * @param[in] desired_settings : Variable used to select the settings which
  202. * are to be get from the sensor.
  203. *
  204. * @return Result of API execution status
  205. * @retval zero -> Success / +ve value -> Warning / -ve value -> Error.
  206. */
  207. int8_t bme680_get_sensor_settings(uint16_t desired_settings, struct bme680_dev *dev);
  208. #ifdef __cplusplus
  209. }
  210. #endif /* End of CPP guard */
  211. #endif /* BME680_H_ */
  212. /** @}*/