Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MERGE Sensor_iAQ_sgp30_bme_si7051 POCBreath_V2_smd_commercial
BME680.h
00001 /** 00002 * @brief BME680.h 00003 * @details Low power gas, pressure, temperature & humidity sensor. 00004 * Header file. 00005 * 00006 * 00007 * @return N/A 00008 * 00009 * @author Manuel Caballero 00010 * @date 21/July/2018 00011 * @version 21/July/2018 The ORIGIN 00012 * @pre This is just a port from Bosh driver to mBed ( c++ ) 00013 * @warning N/A 00014 * @pre This code belongs to Nimbus Centre ( http://www.nimbus.cit.ie ). 00015 */ 00016 /** 00017 * Copyright (C) 2017 - 2018 Bosch Sensortec GmbH 00018 * 00019 * Redistribution and use in source and binary forms, with or without 00020 * modification, are permitted provided that the following conditions are met: 00021 * 00022 * Redistributions of source code must retain the above copyright 00023 * notice, this list of conditions and the following disclaimer. 00024 * 00025 * Redistributions in binary form must reproduce the above copyright 00026 * notice, this list of conditions and the following disclaimer in the 00027 * documentation and/or other materials provided with the distribution. 00028 * 00029 * Neither the name of the copyright holder nor the names of the 00030 * contributors may be used to endorse or promote products derived from 00031 * this software without specific prior written permission. 00032 * 00033 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 00034 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00035 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00036 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00037 * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER 00038 * OR CONTRIBUTORS BE LIABLE FOR ANY 00039 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 00040 * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, 00041 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00042 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00043 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00044 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00045 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00046 * ANY WAY OUT OF THE USE OF THIS 00047 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00048 * 00049 * The information provided is believed to be accurate and reliable. 00050 * The copyright holder assumes no responsibility 00051 * for the consequences of use 00052 * of such information nor for any infringement of patents or 00053 * other rights of third parties which may result from its use. 00054 * No license is granted by implication or otherwise under any patent or 00055 * patent rights of the copyright holder. 00056 * 00057 * @file bme680.h 00058 * @date 19 Jun 2018 00059 * @version 3.5.9 00060 * @brief 00061 * 00062 */ 00063 /*! @file bme680.h 00064 @brief Sensor driver for BME680 sensor */ 00065 /*! 00066 * @defgroup BME680 SENSOR API 00067 * @{*/ 00068 #ifndef BME680_H_ 00069 #define BME680_H_ 00070 00071 #include "mbed.h" 00072 #include "bme680_defs.h" 00073 00074 00075 /** 00076 Example: 00077 @code 00078 #include "mbed.h" 00079 #include "BME680.h" 00080 00081 BME680 myBME680 ( I2C_SDA, I2C_SCL, 400000 ); 00082 Serial pc ( USBTX, USBRX ); 00083 00084 DigitalOut myled ( LED1 ); 00085 Ticker newReading; 00086 00087 uint32_t myState = 0; 00088 00089 00090 //@brief FUNCTION PROTOTYPES 00091 void changeDATA ( void ); 00092 void user_delay_ms ( uint32_t period ); 00093 int8_t user_i2c_read ( uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len ); 00094 int8_t user_i2c_write ( uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len ); 00095 00096 00097 //@brief FUNCTION FOR APPLICATION MAIN ENTRY. 00098 int main() 00099 { 00100 pc.baud ( 115200 ); 00101 00102 myled = 1; 00103 wait(3); 00104 myled = 0; 00105 00106 00107 struct bme680_dev gas_sensor; 00108 00109 gas_sensor.dev_id = BME680_I2C_ADDR_PRIMARY; 00110 gas_sensor.intf = BME680_I2C_INTF; 00111 gas_sensor.read = user_i2c_read; 00112 gas_sensor.write = user_i2c_write; 00113 gas_sensor.delay_ms = user_delay_ms; 00114 // amb_temp can be set to 25 prior to configuring the gas sensor 00115 // or by performing a few temperature readings without operating the gas sensor. 00116 gas_sensor.amb_temp = 25; 00117 00118 00119 int8_t rslt = BME680_OK; 00120 rslt = myBME680.bme680_init ( &gas_sensor ); 00121 00122 00123 uint8_t set_required_settings; 00124 00125 // Set the temperature, pressure and humidity settings 00126 gas_sensor.tph_sett.os_hum = BME680_OS_2X; 00127 gas_sensor.tph_sett.os_pres = BME680_OS_4X; 00128 gas_sensor.tph_sett.os_temp = BME680_OS_8X; 00129 gas_sensor.tph_sett.filter = BME680_FILTER_SIZE_3; 00130 00131 // Set the remaining gas sensor settings and link the heating profile 00132 gas_sensor.gas_sett.run_gas = BME680_ENABLE_GAS_MEAS; 00133 // Create a ramp heat waveform in 3 steps 00134 gas_sensor.gas_sett.heatr_temp = 320; // degree Celsius 00135 gas_sensor.gas_sett.heatr_dur = 150; // milliseconds 00136 00137 // Select the power mode 00138 // Must be set before writing the sensor configuration 00139 gas_sensor.power_mode = BME680_FORCED_MODE; 00140 00141 // Set the required sensor settings needed 00142 set_required_settings = BME680_OST_SEL | BME680_OSP_SEL | BME680_OSH_SEL | BME680_FILTER_SEL | BME680_GAS_SENSOR_SEL; 00143 00144 // Set the desired sensor configuration 00145 rslt = myBME680.bme680_set_sensor_settings ( set_required_settings, &gas_sensor ); 00146 00147 // Set the power mode 00148 rslt = myBME680.bme680_set_sensor_mode ( &gas_sensor ); 00149 00150 00151 // Get the total measurement duration so as to sleep or wait till the measurement is complete 00152 uint16_t meas_period; 00153 myBME680.bme680_get_profile_dur ( &meas_period, &gas_sensor ); 00154 00155 struct bme680_field_data data; 00156 00157 00158 newReading.attach( &changeDATA, 1 ); // the address of the function to be attached ( changeDATA ) and the interval ( 1s ) 00159 00160 // Let the callbacks take care of everything 00161 while(1) { 00162 sleep(); 00163 00164 myled = 1; 00165 00166 if ( myState == 1 ) { 00167 // Delay till the measurement is ready 00168 user_delay_ms ( meas_period ); 00169 00170 rslt = myBME680.bme680_get_sensor_data ( &data, &gas_sensor ); 00171 00172 // Prepare the data to be sent through the UART. NOTE: sprintf does NOT allow float numbers, that is why we round the number and plot them as integer 00173 // Avoid using measurements from an unstable heating setup 00174 if ( data.status & BME680_GASM_VALID_MSK ) { 00175 pc.printf( "T: %.2f degC, P: %.2f hPa, H %.2f %%rH, G: %d ohms\r\n", ( data.temperature/100.0f ), ( data.pressure / 100.0f ), ( data.humidity / 1000.0f ), data.gas_resistance ); 00176 } else { 00177 pc.printf( "T: %.2f degC, P: %.2f hPa, H %.2f %%rH\r\n", ( data.temperature/100.0f ), ( data.pressure / 100.0f ), ( data.humidity / 1000.0f ) ); 00178 } 00179 00180 00181 // Trigger the next measurement if you would like to read data out continuously 00182 if ( gas_sensor.power_mode == BME680_FORCED_MODE ) { 00183 rslt = myBME680.bme680_set_sensor_mode ( &gas_sensor ); 00184 } 00185 00186 myState = 0; // Reset the variable 00187 } 00188 00189 myled = 0; 00190 } 00191 } 00192 00193 00194 00195 00196 // @brief changeDATA ( void ) 00197 // 00198 // @details It changes myState variable 00199 // 00200 // @param[in] N/A 00201 // 00202 // @param[out] N/A. 00203 // 00204 // 00205 // @return N/A.. 00206 // 00207 // 00208 // @author Manuel Caballero 00209 // @date 21/July/2018 00210 // @version 21/July/2018 The ORIGIN 00211 // @pre N/A 00212 // @warning N/A. 00213 void changeDATA ( void ) 00214 { 00215 myState = 1; 00216 } 00217 00218 00219 00220 // @brief user_delay_ms ( uint32_t ) 00221 // 00222 // @details Return control or wait, for a period amount of milliseconds 00223 // 00224 // @param[in] period: Delay in milliseconds. 00225 // 00226 // @param[out] N/A. 00227 // 00228 // 00229 // @return N/A.. 00230 // 00231 // 00232 // @author Manuel Caballero 00233 // @date 21/July/2018 00234 // @version 21/July/2018 The ORIGIN 00235 // @pre This is a Bosh pointer function adapted to our system. 00236 // @warning N/A. 00237 void user_delay_ms ( uint32_t period ) 00238 { 00239 // Return control or wait, 00240 // for a period amount of milliseconds 00241 00242 wait_ms ( period ); 00243 } 00244 00245 00246 00247 // @brief user_i2c_read ( uint8_t , uint8_t reg_addr, uint8_t *reg_data, uint16_t len ) 00248 // 00249 // @details It adapts I2C reading functionality. 00250 // 00251 // @param[in] dev_id: I2C address. 00252 // @param[in] reg_addr: Register to be read. 00253 // @param[in] len: How many bytes to read. 00254 // 00255 // @param[out] reg_data: Result. 00256 // 00257 // 00258 // @return Status of user_i2c_read. 00259 // 00260 // 00261 // @author Manuel Caballero 00262 // @date 21/July/2018 00263 // @version 21/July/2018 The ORIGIN 00264 // @pre This is a Bosh pointer function adapted to our system. 00265 // @warning N/A. 00266 int8_t user_i2c_read ( uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len ) 00267 { 00268 int8_t rslt = 0; // Return 0 for Success, non-zero for failure 00269 00270 // The parameter dev_id can be used as a variable to store the I2C address of the device 00271 00272 00273 // Data on the bus should be like 00274 // |------------+---------------------| 00275 // | I2C action | Data | 00276 // |------------+---------------------| 00277 // | Start | - | 00278 // | Write | (reg_addr) | 00279 // | Stop | - | 00280 // | Start | - | 00281 // | Read | (reg_data[0]) | 00282 // | Read | (....) | 00283 // | Read | (reg_data[len - 1]) | 00284 // | Stop | - | 00285 // |------------+---------------------| 00286 00287 // Read data 00288 uint32_t aux = 0; 00289 aux = myBME680._i2c.write ( dev_id, (char*)®_addr, 1, true ); 00290 aux = myBME680._i2c.read ( dev_id, (char*)®_data[0], len ); 00291 00292 00293 00294 if ( aux == 0 ) { 00295 rslt = 0; 00296 } else { 00297 rslt = 0xFF; 00298 } 00299 00300 00301 return rslt; 00302 } 00303 00304 00305 00306 00307 // @brief user_i2c_write ( uint8_t , uint8_t reg_addr, uint8_t *reg_data, uint16_t len ) 00308 // 00309 // @details It adapts I2C writing functionality. 00310 // 00311 // @param[in] dev_id: I2C address. 00312 // @param[in] reg_addr: Register to be read. 00313 // @param[out] reg_data: Data to be written. 00314 // @param[in] len: How many bytes to read. 00315 // 00316 // @param[out] N/A. 00317 // 00318 // 00319 // @return Status of user_i2c_write. 00320 // 00321 // 00322 // @author Manuel Caballero 00323 // @date 21/July/2018 00324 // @version 21/July/2018 The ORIGIN 00325 // @pre This is a Bosh pointer function adapted to our system. 00326 // @warning N/A. 00327 int8_t user_i2c_write ( uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len ) 00328 { 00329 int8_t rslt = 0; // Return 0 for Success, non-zero for failure 00330 00331 // The parameter dev_id can be used as a variable to store the I2C address of the device 00332 00333 00334 // Data on the bus should be like 00335 // |------------+---------------------| 00336 // | I2C action | Data | 00337 // |------------+---------------------| 00338 // | Start | - | 00339 // | Write | (reg_addr) | 00340 // | Write | (reg_data[0]) | 00341 // | Write | (....) | 00342 // | Write | (reg_data[len - 1]) | 00343 // | Stop | - | 00344 // |------------+---------------------| 00345 00346 uint32_t aux = 0; 00347 char cmd[16] = { 0 }; 00348 uint32_t i = 0; 00349 00350 // Prepare the data to be sent 00351 cmd[0] = reg_addr; 00352 for ( i = 1; i <= len; i++ ) { 00353 cmd[i] = reg_data[i - 1]; 00354 } 00355 00356 // Write data 00357 aux = myBME680._i2c.write ( dev_id, &cmd[0], len + 1, false ); 00358 00359 00360 00361 if ( aux == 0 ) { 00362 rslt = 0; 00363 } else { 00364 rslt = 0xFF; 00365 } 00366 00367 00368 return rslt; 00369 } 00370 @endcode 00371 */ 00372 00373 00374 /*! 00375 Library for BME680 Low power gas, pressure, temperature & humidity sensor. 00376 */ 00377 class BME680 00378 { 00379 public: 00380 00381 /** Create an BME680 object connected to the specified I2C pins. 00382 * 00383 * @param sda I2C data pin 00384 * @param scl I2C clock pin 00385 * @param freq I2C frequency 00386 */ 00387 BME680 ( PinName sda, PinName scl, uint32_t freq ); 00388 00389 /** Delete BME680 object. 00390 */ 00391 ~BME680(); 00392 00393 /* function prototype declarations */ 00394 /*! 00395 * @brief This API is the entry point. 00396 * It reads the chip-id and calibration data from the sensor. 00397 * 00398 * @param[in,out] dev : Structure instance of bme680_dev 00399 * 00400 * @return Result of API execution status 00401 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00402 */ 00403 int8_t bme680_init(struct bme680_dev *dev); 00404 00405 /*! 00406 * @brief This API writes the given data to the register address 00407 * of the sensor. 00408 * 00409 * @param[in] reg_addr : Register address from where the data to be written. 00410 * @param[in] reg_data : Pointer to data buffer which is to be written 00411 * in the sensor. 00412 * @param[in] len : No of bytes of data to write.. 00413 * @param[in] dev : Structure instance of bme680_dev. 00414 * 00415 * @return Result of API execution status 00416 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00417 */ 00418 int8_t bme680_set_regs(const uint8_t *reg_addr, const uint8_t *reg_data, uint8_t len, struct bme680_dev *dev); 00419 00420 /*! 00421 * @brief This API reads the data from the given register address of the sensor. 00422 * 00423 * @param[in] reg_addr : Register address from where the data to be read 00424 * @param[out] reg_data : Pointer to data buffer to store the read data. 00425 * @param[in] len : No of bytes of data to be read. 00426 * @param[in] dev : Structure instance of bme680_dev. 00427 * 00428 * @return Result of API execution status 00429 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00430 */ 00431 int8_t bme680_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, struct bme680_dev *dev); 00432 00433 /*! 00434 * @brief This API performs the soft reset of the sensor. 00435 * 00436 * @param[in] dev : Structure instance of bme680_dev. 00437 * 00438 * @return Result of API execution status 00439 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error. 00440 */ 00441 int8_t bme680_soft_reset(struct bme680_dev *dev); 00442 00443 /*! 00444 * @brief This API is used to set the power mode of the sensor. 00445 * 00446 * @param[in] dev : Structure instance of bme680_dev 00447 * @note : Pass the value to bme680_dev.power_mode structure variable. 00448 * 00449 * value | mode 00450 * -------------|------------------ 00451 * 0x00 | BME680_SLEEP_MODE 00452 * 0x01 | BME680_FORCED_MODE 00453 * 00454 * * @return Result of API execution status 00455 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00456 */ 00457 int8_t bme680_set_sensor_mode(struct bme680_dev *dev); 00458 00459 /*! 00460 * @brief This API is used to get the power mode of the sensor. 00461 * 00462 * @param[in] dev : Structure instance of bme680_dev 00463 * @note : bme680_dev.power_mode structure variable hold the power mode. 00464 * 00465 * value | mode 00466 * ---------|------------------ 00467 * 0x00 | BME680_SLEEP_MODE 00468 * 0x01 | BME680_FORCED_MODE 00469 * 00470 * @return Result of API execution status 00471 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00472 */ 00473 int8_t bme680_get_sensor_mode(struct bme680_dev *dev); 00474 00475 /*! 00476 * @brief This API is used to set the profile duration of the sensor. 00477 * 00478 * @param[in] dev : Structure instance of bme680_dev. 00479 * @param[in] duration : Duration of the measurement in ms. 00480 * 00481 * @return Nothing 00482 */ 00483 void bme680_set_profile_dur(uint16_t duration, struct bme680_dev *dev); 00484 00485 /*! 00486 * @brief This API is used to get the profile duration of the sensor. 00487 * 00488 * @param[in] dev : Structure instance of bme680_dev. 00489 * @param[in] duration : Duration of the measurement in ms. 00490 * 00491 * @return Nothing 00492 */ 00493 void bme680_get_profile_dur(uint16_t *duration, const struct bme680_dev *dev); 00494 00495 /*! 00496 * @brief This API reads the pressure, temperature and humidity and gas data 00497 * from the sensor, compensates the data and store it in the bme680_data 00498 * structure instance passed by the user. 00499 * 00500 * @param[out] data: Structure instance to hold the data. 00501 * @param[in] dev : Structure instance of bme680_dev. 00502 * 00503 * @return Result of API execution status 00504 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00505 */ 00506 int8_t bme680_get_sensor_data(struct bme680_field_data *data, struct bme680_dev *dev); 00507 00508 /*! 00509 * @brief This API is used to set the oversampling, filter and T,P,H, gas selection 00510 * settings in the sensor. 00511 * 00512 * @param[in] dev : Structure instance of bme680_dev. 00513 * @param[in] desired_settings : Variable used to select the settings which 00514 * are to be set in the sensor. 00515 * 00516 * Macros | Functionality 00517 *---------------------------------|---------------------------------------------- 00518 * BME680_OST_SEL | To set temperature oversampling. 00519 * BME680_OSP_SEL | To set pressure oversampling. 00520 * BME680_OSH_SEL | To set humidity oversampling. 00521 * BME680_GAS_MEAS_SEL | To set gas measurement setting. 00522 * BME680_FILTER_SEL | To set filter setting. 00523 * BME680_HCNTRL_SEL | To set humidity control setting. 00524 * BME680_RUN_GAS_SEL | To set run gas setting. 00525 * BME680_NBCONV_SEL | To set NB conversion setting. 00526 * BME680_GAS_SENSOR_SEL | To set all gas sensor related settings 00527 * 00528 * @note : Below are the macros to be used by the user for selecting the 00529 * desired settings. User can do OR operation of these macros for configuring 00530 * multiple settings. 00531 * 00532 * @return Result of API execution status 00533 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error. 00534 */ 00535 int8_t bme680_set_sensor_settings(uint16_t desired_settings, struct bme680_dev *dev); 00536 00537 /*! 00538 * @brief This API is used to get the oversampling, filter and T,P,H, gas selection 00539 * settings in the sensor. 00540 * 00541 * @param[in] dev : Structure instance of bme680_dev. 00542 * @param[in] desired_settings : Variable used to select the settings which 00543 * are to be get from the sensor. 00544 * 00545 * @return Result of API execution status 00546 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error. 00547 */ 00548 int8_t bme680_get_sensor_settings(uint16_t desired_settings, struct bme680_dev *dev); 00549 00550 00551 I2C _i2c; 00552 00553 private: 00554 /*! 00555 * @brief This internal API is used to read the calibrated data from the sensor. 00556 * 00557 * This function is used to retrieve the calibration 00558 * data from the image registers of the sensor. 00559 * 00560 * @note Registers 89h to A1h for calibration data 1 to 24 00561 * from bit 0 to 7 00562 * @note Registers E1h to F0h for calibration data 25 to 40 00563 * from bit 0 to 7 00564 * @param[in] dev :Structure instance of bme680_dev. 00565 * 00566 * @return Result of API execution status. 00567 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00568 */ 00569 int8_t get_calib_data(struct bme680_dev *dev); 00570 00571 /*! 00572 * @brief This internal API is used to set the gas configuration of the sensor. 00573 * 00574 * @param[in] dev :Structure instance of bme680_dev. 00575 * 00576 * @return Result of API execution status. 00577 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00578 */ 00579 int8_t set_gas_config(struct bme680_dev *dev); 00580 00581 /*! 00582 * @brief This internal API is used to get the gas configuration of the sensor. 00583 * @note heatr_temp and heatr_dur values are currently register data 00584 * and not the actual values set 00585 * 00586 * @param[in] dev :Structure instance of bme680_dev. 00587 * 00588 * @return Result of API execution status. 00589 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00590 */ 00591 int8_t get_gas_config(struct bme680_dev *dev); 00592 00593 /*! 00594 * @brief This internal API is used to calculate the Heat duration value. 00595 * 00596 * @param[in] dur :Value of the duration to be shared. 00597 * 00598 * @return uint8_t threshold duration after calculation. 00599 */ 00600 uint8_t calc_heater_dur(uint16_t dur); 00601 00602 #ifndef BME680_FLOAT_POINT_COMPENSATION 00603 00604 /*! 00605 * @brief This internal API is used to calculate the temperature value. 00606 * 00607 * @param[in] dev :Structure instance of bme680_dev. 00608 * @param[in] temp_adc :Contains the temperature ADC value . 00609 * 00610 * @return uint32_t calculated temperature. 00611 */ 00612 int16_t calc_temperature(uint32_t temp_adc, struct bme680_dev *dev); 00613 00614 /*! 00615 * @brief This internal API is used to calculate the pressure value. 00616 * 00617 * @param[in] dev :Structure instance of bme680_dev. 00618 * @param[in] pres_adc :Contains the pressure ADC value . 00619 * 00620 * @return uint32_t calculated pressure. 00621 */ 00622 uint32_t calc_pressure(uint32_t pres_adc, const struct bme680_dev *dev); 00623 00624 /*! 00625 * @brief This internal API is used to calculate the humidity value. 00626 * 00627 * @param[in] dev :Structure instance of bme680_dev. 00628 * @param[in] hum_adc :Contains the humidity ADC value. 00629 * 00630 * @return uint32_t calculated humidity. 00631 */ 00632 uint32_t calc_humidity(uint16_t hum_adc, const struct bme680_dev *dev); 00633 00634 /*! 00635 * @brief This internal API is used to calculate the Gas Resistance value. 00636 * 00637 * @param[in] dev :Structure instance of bme680_dev. 00638 * @param[in] gas_res_adc :Contains the Gas Resistance ADC value. 00639 * @param[in] gas_range :Contains the range of gas values. 00640 * 00641 * @return uint32_t calculated gas resistance. 00642 */ 00643 uint32_t calc_gas_resistance(uint16_t gas_res_adc, uint8_t gas_range, const struct bme680_dev *dev); 00644 00645 /*! 00646 * @brief This internal API is used to calculate the Heat Resistance value. 00647 * 00648 * @param[in] dev : Structure instance of bme680_dev 00649 * @param[in] temp : Contains the target temperature value. 00650 * 00651 * @return uint8_t calculated heater resistance. 00652 */ 00653 uint8_t calc_heater_res(uint16_t temp, const struct bme680_dev *dev); 00654 00655 #else 00656 /*! 00657 * @brief This internal API is used to calculate the 00658 * temperature value value in float format 00659 * 00660 * @param[in] dev :Structure instance of bme680_dev. 00661 * @param[in] temp_adc :Contains the temperature ADC value . 00662 * 00663 * @return Calculated temperature in float 00664 */ 00665 float calc_temperature(uint32_t temp_adc, struct bme680_dev *dev); 00666 00667 /*! 00668 * @brief This internal API is used to calculate the 00669 * pressure value value in float format 00670 * 00671 * @param[in] dev :Structure instance of bme680_dev. 00672 * @param[in] pres_adc :Contains the pressure ADC value . 00673 * 00674 * @return Calculated pressure in float. 00675 */ 00676 float calc_pressure(uint32_t pres_adc, const struct bme680_dev *dev); 00677 00678 /*! 00679 * @brief This internal API is used to calculate the 00680 * humidity value value in float format 00681 * 00682 * @param[in] dev :Structure instance of bme680_dev. 00683 * @param[in] hum_adc :Contains the humidity ADC value. 00684 * 00685 * @return Calculated humidity in float. 00686 */ 00687 float calc_humidity(uint16_t hum_adc, const struct bme680_dev *dev); 00688 00689 /*! 00690 * @brief This internal API is used to calculate the 00691 * gas resistance value value in float format 00692 * 00693 * @param[in] dev :Structure instance of bme680_dev. 00694 * @param[in] gas_res_adc :Contains the Gas Resistance ADC value. 00695 * @param[in] gas_range :Contains the range of gas values. 00696 * 00697 * @return Calculated gas resistance in float. 00698 */ 00699 float calc_gas_resistance(uint16_t gas_res_adc, uint8_t gas_range, const struct bme680_dev *dev); 00700 00701 /*! 00702 * @brief This internal API is used to calculate the 00703 * heater resistance value in float format 00704 * 00705 * @param[in] temp : Contains the target temperature value. 00706 * @param[in] dev : Structure instance of bme680_dev. 00707 * 00708 * @return Calculated heater resistance in float. 00709 */ 00710 float calc_heater_res(uint16_t temp, const struct bme680_dev *dev); 00711 00712 #endif 00713 00714 /*! 00715 * @brief This internal API is used to calculate the field data of sensor. 00716 * 00717 * @param[out] data :Structure instance to hold the data 00718 * @param[in] dev :Structure instance of bme680_dev. 00719 * 00720 * @return int8_t result of the field data from sensor. 00721 */ 00722 int8_t read_field_data(struct bme680_field_data *data, struct bme680_dev *dev); 00723 00724 /*! 00725 * @brief This internal API is used to set the memory page 00726 * based on register address. 00727 * 00728 * The value of memory page 00729 * value | Description 00730 * --------|-------------- 00731 * 0 | BME680_PAGE0_SPI 00732 * 1 | BME680_PAGE1_SPI 00733 * 00734 * @param[in] dev :Structure instance of bme680_dev. 00735 * @param[in] reg_addr :Contains the register address array. 00736 * 00737 * @return Result of API execution status 00738 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00739 */ 00740 int8_t set_mem_page(uint8_t reg_addr, struct bme680_dev *dev); 00741 00742 /*! 00743 * @brief This internal API is used to get the memory page based 00744 * on register address. 00745 * 00746 * The value of memory page 00747 * value | Description 00748 * --------|-------------- 00749 * 0 | BME680_PAGE0_SPI 00750 * 1 | BME680_PAGE1_SPI 00751 * 00752 * @param[in] dev :Structure instance of bme680_dev. 00753 * 00754 * @return Result of API execution status 00755 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00756 */ 00757 int8_t get_mem_page(struct bme680_dev *dev); 00758 00759 /*! 00760 * @brief This internal API is used to validate the device pointer for 00761 * null conditions. 00762 * 00763 * @param[in] dev :Structure instance of bme680_dev. 00764 * 00765 * @return Result of API execution status 00766 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00767 */ 00768 int8_t null_ptr_check(const struct bme680_dev *dev); 00769 00770 /*! 00771 * @brief This internal API is used to check the boundary 00772 * conditions. 00773 * 00774 * @param[in] value :pointer to the value. 00775 * @param[in] min :minimum value. 00776 * @param[in] max :maximum value. 00777 * @param[in] dev :Structure instance of bme680_dev. 00778 * 00779 * @return Result of API execution status 00780 * @retval zero -> Success / +ve value -> Warning / -ve value -> Error 00781 */ 00782 int8_t boundary_check(uint8_t *value, uint8_t min, uint8_t max, struct bme680_dev *dev); 00783 00784 00785 00786 uint32_t _BME680_Addr; 00787 }; 00788 00789 #endif 00790 /** @}*/
Generated on Wed Jul 13 2022 22:21:17 by
1.7.2