CHENGQI YANG / BME680

Dependents:   Example_DS3231_test

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BME680.h Source File

BME680.h

00001 #ifndef UK_AC_HERTS_SMARTLAB_BME680
00002 #define UK_AC_HERTS_SMARTLAB_BME680
00003 
00004 #include "mbed.h"
00005 #include "stdint.h"
00006 
00007 /*
00008 * Use below macro for fixed Point Calculation
00009 * else Floating Point calculation will be used
00010 */
00011 #define FIXED_POINT_COMPENSATION
00012 
00013 // no idea what it is for
00014 //#define HEATER_C1_ENABLE
00015 
00016 // Sensor Specific constants */
00017 #define BME680_SLEEP_MODE               (0x00)
00018 #define BME680_FORCED_MODE              (0x01)
00019 #define BME680_PARALLEL_MODE            (0x02)
00020 #define BME680_SEQUENTIAL_MODE          (0x03)
00021 #define BME680_GAS_PROFILE_TEMPERATURE_MIN  (200)
00022 #define BME680_GAS_PROFILE_TEMPERATURE_MAX  (400)
00023 #define BME680_GAS_RANGE_RL_LENGTH      (16)
00024 #define BME680_SIGN_BIT_MASK            (0x08)
00025 
00026 #ifdef FIXED_POINT_COMPENSATION
00027 //< Multiply by 1000, In order to convert float value into fixed point
00028 #define BME680_MAX_HUMIDITY_VALUE       (102400)
00029 #define BME680_MIN_HUMIDITY_VALUE       (0)
00030 #else
00031 #define BME680_MAX_HUMIDITY_VALUE       (double)(100.0)
00032 #define BME680_MIN_HUMIDITY_VALUE       (double)(0.0)
00033 #endif
00034 
00035 /**
00036 * !! MUST CALL init() FIRST !!
00037 * read the chip id and calibration data of the BME680 sensor
00038 * BME680 integrated environmental sensor. This API supports FIXED and FLOATING compenstion.
00039 * By default it supports FIXED, to use FLOATING user need to disable "FIXED_POINT_COMPENSATION" in the BME680.h file.
00040 */
00041 class BME680
00042 {
00043 private:
00044     static const int FREQUENCY_STANDARD = 100000;
00045     static const int FREQUENCY_FULL = 400000;
00046     static const int FREQUENCY_FAST = 1000000;
00047     static const int FREQUENCY_HIGH = 3200000;
00048 
00049     I2C _i2c_bus;
00050     int _addr;
00051     uint8_t data[30];
00052 
00053     //static const double const_array1[];
00054     //static const double const_array2[];
00055     static const uint64_t lookup_k1_range[];
00056     static const uint64_t lookup_k2_range[];
00057     static const double _lookup_k1_range[];
00058     static const double _lookup_k2_range[];
00059 
00060     /* For Calibration Data*/
00061     static const int DIG_T2_LSB_REG = 1;
00062     static const int DIG_T2_MSB_REG = 2;
00063     static const int DIG_T3_REG = 3;
00064     static const int DIG_P1_LSB_REG = 5;
00065     static const int DIG_P1_MSB_REG = 6;
00066     static const int DIG_P2_LSB_REG = 7;
00067     static const int DIG_P2_MSB_REG = 8;
00068     static const int DIG_P3_REG = 9;
00069     static const int DIG_P4_LSB_REG = 11;
00070     static const int DIG_P4_MSB_REG = 12;
00071     static const int DIG_P5_LSB_REG = 13;
00072     static const int DIG_P5_MSB_REG = 14;
00073     static const int DIG_P7_REG = 15;
00074     static const int DIG_P6_REG = 16;
00075     static const int DIG_P8_LSB_REG = 19;
00076     static const int DIG_P8_MSB_REG = 20;
00077     static const int DIG_P9_LSB_REG = 21;
00078     static const int DIG_P9_MSB_REG = 22;
00079     static const int DIG_P10_REG = 23;
00080     static const int DIG_H2_MSB_REG = 25;
00081     static const int DIG_H2_LSB_REG = 26;
00082     static const int DIG_H1_LSB_REG = 26;
00083     static const int DIG_H1_MSB_REG  = 27;
00084     static const int DIG_H3_REG = 28;
00085     static const int DIG_H4_REG = 29;
00086     static const int DIG_H5_REG = 30;
00087     static const int DIG_H6_REG = 31;
00088     static const int DIG_H7_REG = 32;
00089     static const int DIG_T1_LSB_REG = 33;
00090     static const int DIG_T1_MSB_REG = 34;
00091     static const int DIG_GH2_LSB_REG = 35;
00092     static const int DIG_GH2_MSB_REG = 36;
00093     static const int DIG_GH1_REG = 37;
00094     static const int DIG_GH3_REG = 38;
00095 
00096     static const int BME680_BIT_MASK_H1_DATA = 0x0F;
00097 
00098     int8_t  par_T3;/**<calibration T3 data*/
00099     int8_t  par_P3;/**<calibration P3 data*/
00100     int8_t  par_P6;/**<calibration P6 data*/
00101     int8_t  par_P7;/**<calibration P7 data*/
00102     uint8_t  par_P10;/**<calibration P10 data*/
00103     int8_t  par_H3;/**<calibration H3 data*/
00104     int8_t  par_H4;/**<calibration H4 data*/
00105     int8_t  par_H5;/**<calibration H5 data*/
00106     uint8_t  par_H6;/**<calibration H6 data*/
00107     int8_t  par_H7;/**<calibration H7 data*/
00108     int8_t  par_GH1;/**<calibration GH1 data*/
00109     uint8_t  res_heat_range;/**<resistance calculation*/
00110     int8_t  res_heat_val; /**<correction factor*/
00111     int8_t  range_switching_error;/**<range switching error*/
00112     int16_t par_GH2;/**<calibration GH2 data*/
00113     uint16_t par_T1;/**<calibration T1 data*/
00114     int16_t par_T2;/**<calibration T2 data*/
00115     uint16_t par_P1;/**<calibration P1 data*/
00116     int16_t par_P2;/**<calibration P2 data*/
00117     int16_t par_P4;/**<calibration P4 data*/
00118     int16_t par_P5;/**<calibration P5 data*/
00119     int16_t par_P8;/**<calibration P8 data*/
00120     int16_t par_P9;/**<calibration P9 data*/
00121     uint16_t par_H1;/**<calibration H1 data*/
00122     uint16_t par_H2;/**<calibration H2 data*/
00123     int32_t t_fine;/**<calibration T_FINE data*/
00124     int8_t  par_GH3;/**<calibration GH3 data*/
00125 
00126     void readRegister(int reg, int size = 1);
00127 
00128     void writeRegister(int reg, int value);
00129 
00130 public:
00131 
00132     /**
00133     * TPHG measurements are performed.
00134     * continuously until mode change.
00135     * Between each cycle, the sensor enters stand-by for a period of time according to the odr<3:0> control register.
00136     * Gas sensor heater only operates during gas sub-measurement.
00137     * 100 ms gas wait time, T:X2, P:X16, H:X1
00138     */
00139     void setSequentialMode();
00140 
00141     /**
00142     * Single TPHG cycle is performed.
00143     * Sensor automatically returns to sleep mode afterwards.
00144     * Gas sensor heater only operates during gas sub-measureme.
00145     */
00146     void setForcedMode();
00147 
00148     /**
00149     * TPHG measurements are performed continuously until mode change.
00150     * No stand-by occurs between consecutive TPHG cycles.
00151     * Gas sensor heater operates in parallel with TPH measurements.
00152     */
00153     void setParallelMode();
00154 
00155     /*
00156     * @param sda I2C sda signal
00157     * @param scl I2C scl signal
00158     * @param SDO Slave address LSB (High->true, Low->false)
00159     */
00160     BME680(PinName sda, PinName scl, bool SDO);
00161 
00162     /**
00163     * !! MUST CALL THIS FIRST !!
00164     * read the chip id and calibration data of the BME680 sensor
00165     */
00166     bool init();
00167     // DATA #########################################################################
00168 
00169 #ifdef FIXED_POINT_COMPENSATION
00170     /**
00171     *  This function is used to convert the uncompensated
00172     *  temperature data to compensated temperature data using
00173     *  compensation formula(integer version)
00174     *  @note Returns the value in 0.01 degree Centigrade
00175     *  Output value of "5123" equals 51.23 DegC.
00176     *
00177     * @param field 0-2
00178     *
00179     *  @return Returns the compensated temperature data
00180     *
00181     */
00182     int32_t getCompensatedTemperature(int field = 0);
00183 
00184     /**
00185     * Reads actual temperature from uncompensated temperature
00186     * @note Returns the value with 500LSB/DegC centred around 24 DegC
00187     * output value of "5123" equals(5123/500)+24 = 34.246DegC
00188     *
00189     *
00190     *  @param v_uncomp_temperature_u32: value of uncompensated temperature
00191     *  @param bme680: structure pointer.
00192     *
00193     *
00194     *  @return Return the actual temperature as s16 output
00195     *
00196     */
00197     int16_t getTemperatureInt(int field = 0);
00198 
00199     /**
00200     *  @brief This function is used to convert the uncompensated
00201     *  humidity data to compensated humidity data using
00202     *  compensation formula(integer version)
00203     *
00204     *  @note Returns the value in %rH as unsigned 32bit integer
00205     *  in Q22.10 format(22 integer 10 fractional bits).
00206     *  @note An output value of 42313
00207     *  represents 42313 / 1024 = 41.321 %rH
00208     *
00209     *
00210     *
00211     *  @param  v_uncomp_humidity_u32: value of uncompensated humidity
00212     *  @param bme680: structure pointer.
00213     *
00214     *  @return Return the compensated humidity data
00215     *
00216     */
00217     int32_t getCompensateHumidity(int field = 0);
00218 
00219     /**
00220     * @brief Reads actual humidity from uncompensated humidity
00221     * @note Returns the value in %rH as unsigned 16bit integer
00222     * @note An output value of 42313
00223     * represents 42313/512 = 82.643 %rH
00224     *
00225     *
00226     *
00227     *  @param v_uncomp_humidity_u32: value of uncompensated humidity
00228     *  @param bme680: structure pointer.
00229     *
00230     *  @return Return the actual relative humidity output as u16
00231     *
00232     */
00233     uint16_t getHumidityInt(int field = 0);
00234 
00235     /**
00236     * @brief This function is used to convert the uncompensated
00237     *  pressure data to compensated pressure data data using
00238     *  compensation formula(integer version)
00239     *
00240     * @note Returns the value in Pascal(Pa)
00241     * Output value of "96386" equals 96386 Pa =
00242     * 963.86 hPa = 963.86 millibar
00243     *
00244     *
00245     *
00246     *  @param v_uncomp_pressure_u32 : value of uncompensated pressure
00247     *  @param bme680: structure pointer.
00248     *
00249     *  @return Return the compensated pressure data
00250     *
00251     */
00252     int32_t getCompensatePressure(int field = 0);
00253 
00254     /**
00255      * @brief Reads actual pressure from uncompensated pressure
00256      * @note Returns the value in Pa.
00257      * @note Output value of "12337434"
00258      * @note represents 12337434 / 128 = 96386.2 Pa = 963.862 hPa
00259      *
00260      *
00261      *
00262      *  @param v_uncomp_pressure_u32 : value of uncompensated pressure
00263      *  @param bme680: structure pointer.
00264      *
00265      *  @return the actual pressure in u32
00266      *
00267     */
00268     uint32_t getPressureInt(int field = 0);
00269 
00270     /**
00271      *  @brief This function is used to convert temperature to resistance
00272      *  using the integer compensation formula
00273      *
00274      *  @param heater_temp_u16: The value of heater temperature
00275      *  @param ambient_temp_s16: The value of ambient temperature
00276      *  @param bme680: structure pointer.
00277      *
00278      *  @return calculated resistance from temperature
00279      *
00280      *
00281      *
00282     */
00283     uint8_t convertTemperatureResistanceInt(uint16_t heater, int16_t ambient);
00284 
00285 
00286     /**
00287      *  @brief This function is used to convert uncompensated gas data to
00288      *  compensated gas data using compensation formula(integer version)
00289      *
00290      *  @param gas_adc_u16: The value of gas resistance calculated
00291      *       using temperature
00292      *  @param gas_range_u8: The value of gas range form register value
00293      *  @param bme680: structure pointer.
00294      *
00295      *  @return calculated compensated gas from compensation formula
00296      *  @retval compensated gas data
00297      *
00298      *
00299     */
00300     int32_t getCalculateGasInt(int field = 0);
00301 
00302 #else
00303     /**
00304     * This function used to convert temperature data
00305     * to uncompensated temperature data using compensation formula
00306     * @note returns the value in Degree centigrade
00307     * @note Output value of "51.23" equals 51.23 DegC.
00308     * @param field 0-2
00309     * @return  Return the actual temperature in floating point
00310     */
00311     double getTemperatureDouble(int field = 0);
00312 
00313     /**
00314     * @brief This function is used to convert the uncompensated
00315     *  humidity data to compensated humidity data data using
00316     *  compensation formula
00317     * @note returns the value in relative humidity (%rH)
00318     * @note Output value of "42.12" equals 42.12 %rH
00319     *
00320     *  @param uncom_humidity_u16 : value of uncompensated humidity
00321     *  @param comp_temperature   : value of compensated temperature
00322     *  @param bme680: structure pointer.
00323     *
00324     *
00325     *  @return Return the compensated humidity data in floating point
00326     *
00327     */
00328     double getHumidityDouble(int field = 0);
00329 
00330     /**
00331      * @brief This function is used to convert the uncompensated
00332      * pressure data to compensated data using compensation formula
00333      * @note Returns pressure in Pa as double.
00334      * @note Output value of "96386.2"
00335      * equals 96386.2 Pa = 963.862 hPa.
00336      *
00337      *
00338      *  @param uncom_pressure_u32 : value of uncompensated pressure
00339      *  @param bme680: structure pointer.
00340      *
00341      *  @return  Return the compensated pressure data in floating point
00342      *
00343     */
00344     double getPressureDouble(int field = 0);
00345 
00346     /**
00347      *  @brief This function is used to convert temperature to resistance
00348      *  using the compensation formula
00349      *
00350      *  @param heater_temp_u16: The value of heater temperature
00351      *  @param ambient_temp_s16: The value of ambient temperature
00352      *  @param bme680: structure pointer.
00353      *
00354      *  @return calculated resistance from temperature
00355      *
00356      *
00357      *
00358     */
00359     double convertTemperatureResistanceDouble(uint16_t heater, int16_t ambient);
00360 
00361     /**
00362      *  @brief This function is used to convert uncompensated gas data to
00363      *  compensated gas data using compensation formula
00364      *
00365      *  @param gas_adc_u16: The value of gas resistance calculated
00366      *       using temperature
00367      *  @param gas_range_u8: The value of gas range form register value
00368      *  @param bme680: structure pointer.
00369      *
00370      *  @return calculated compensated gas from compensation formula
00371      *  @retval compensated gas
00372      *
00373      *
00374     */
00375     double getCalculateGasDouble(int field = 0);
00376 #endif
00377 
00378 
00379     /**
00380     * [press_msb] [press_lsb] [press_xlsb]
00381     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00382     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00383     * the three latest measurements are available for the user; if the last but one conversion was written
00384     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00385     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00386     * data if update of the data registers comes simultaneously with serial interface reading out.
00387     * Note: Only field0 will be updated in forced mode
00388     * @param field 0-2
00389     */
00390     uint32_t getUncompensatedPressureData(int field = 0);
00391 
00392     /**
00393     * [temp1_msb] [temp1_lsb] [temp1_xlsb]
00394     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00395     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00396     * the three latest measurements are available for the user; if the last but one conversion was written
00397     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00398     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00399     * data if update of the data registers comes simultaneously with serial interface reading out.
00400     * Note: Only field0 will be updated in forced mode
00401     * @param field 0-2
00402     */
00403     uint32_t getUncompensatedTemp1Data(int field = 0);
00404 
00405     /**
00406     * [hum_msb] [hum_lsb]
00407     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00408     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00409     * the three latest measurements are available for the user; if the last but one conversion was written
00410     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00411     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00412     * data if update of the data registers comes simultaneously with serial interface reading out.
00413     * Note: Only field0 will be updated in forced mode
00414     * @param field 0-2
00415     */
00416     uint32_t getUncompensatedHumidityData(int field = 0);
00417 
00418     /**
00419     * [gas_rl]
00420     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00421     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00422     * the three latest measurements are available for the user; if the last but one conversion was written
00423     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00424     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00425     * data if update of the data registers comes simultaneously with serial interface reading out.
00426     * Note: Only field0 will be updated in forced mode
00427     * @param field 0-2
00428     */
00429     uint16_t getUncompensatedGasResistanceData(int field = 0);
00430 
00431     /**
00432     * [gas_range_rl]
00433     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00434     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00435     * the three latest measurements are available for the user; if the last but one conversion was written
00436     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00437     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00438     * data if update of the data registers comes simultaneously with serial interface reading out.
00439     * Contains ADC range of measured gas resistance
00440     * Note: Only field0 will be updated in forced mode
00441     * @param field 0-2
00442     */
00443     uint8_t getGasResistanceRange(int field = 0);
00444 
00445 
00446     // STATUS #########################################################################
00447 
00448     /**
00449     * [new_data_x]
00450     * The measured data are stored into the output data registers at the end of each TPHG conversion
00451     * phase along with status flags and index of measurement. The part of the register map for output
00452     * data storage is composed of 3 data fields (TPHG data field0|1|2)) keeping results from the last 3
00453     * measurements. Availability of new (yet unread) results is indicated by new_data_0|1|2 flags.
00454     * @param field 0-2
00455     */
00456     bool isNewData(int field = 0);
00457 
00458     /**
00459     * [gas_measuring]
00460     * Measuring bit is set to “1‟ only during gas measurements, goes to “0‟ as soon as measurement
00461     * is completed and data transferred to data registers. The registers storing the configuration values
00462     * for the measurement (gas_wait_shared, gas_wait_x, res_heat_x, idac_heat_x, image registers)
00463     * should not be changed when the device is measuring.
00464     * @param field 0-2
00465     */
00466     bool isGasMeasuring(int field = 0);
00467 
00468     /**
00469     * [measuring]
00470     * Measuring status will be set to ‘1’ whenever a conversion (Pressure, Temperature, humidity &
00471     * gas) is running and back to ‘0’ when the results have been transferred to the data registers.
00472     * @param field 0-2
00473     */
00474     bool isMeasuring(int field = 0);
00475 
00476     /**
00477     * [gas_meas_index_x]
00478     * User can program a sequence of up to 10 conversions by setting nb_conv<3:0>. Each conversion
00479     * has its own heater resistance target but 3 field registers to store conversion results. The actual
00480     * gas conversion number in the measurement sequence (up to 10 conversions numbered from 0
00481     * to 9) is stored in gas_meas_index register.
00482     * @param field 0-2
00483     */
00484     int getGasMeasurementIndex(int field = 0);
00485 
00486     /**
00487     * [sub_meas_index_x]
00488     * sub_meas_index_x registers form “virtual time sensor” and contain a snapshot of the internal 8
00489     * bit conversion counter. Conversion counter is incremented with each TPHG conversion; the
00490     * counter thus contains the number of conversions modulo 256 executed since the last change of
00491     * device mode.
00492     * Note: This index is incremented only if gas conversion is active.
00493     * @param field 0-2
00494     */
00495     int getSubMeasurementIndex(int field = 0);
00496 
00497     /**
00498     * [gas_valid_rl]
00499     * In parallel mode, each TPHG sequence contains a gas measurement slot, either a real one which
00500     * result is used or a dummy one to keep a constant sampling rate and predictable device timing. A
00501     * real gas conversion (i.e., not a dummy one) is indicated by the gas_valid_rl status register.
00502     * @param field 0-2
00503     */
00504     bool isGasValid(int field = 0);
00505 
00506     /**
00507     * [heat_stab_rl]
00508     * Heater temperature stability for target heater resistance is indicated heat_stab_x status bits.
00509     * @param field 0-2
00510     */
00511     bool isHeaterStable(int field = 0);
00512 
00513     // GAS CONTROL #########################################################################
00514 
00515     /**
00516     * [idac_heat_x]
00517     * BME680 contains a heater control block that will inject enough current into the heater resistance
00518     * to achieve the requested heater temperature. There is a control loop which periodically measures
00519     * heater resistance value and adapts the value of current injected from a DAC.
00520     * BME680 heater operation could be speeded up by setting an initial heater current for a target
00521     * heater temperature by using register idac_heat_x<7:0>. This step is optional since the control
00522     * loop will find the current after a few iterations anyway.
00523     * Current injected to the heater in mA = (idac_heat_7_1 + 1) / 8
00524     * Where: idac_heat_7_1 = decimal value stored in idac_heat<7:1> (unsigned, value from 0 to 127)
00525     * @param setPoint 0-9
00526     */
00527     uint8_t getHeaterCurrent(int setPoint);
00528 
00529     /**
00530     * [idac_heat_x]
00531     * BME680 contains a heater control block that will inject enough current into the heater resistance
00532     * to achieve the requested heater temperature. There is a control loop which periodically measures
00533     * heater resistance value and adapts the value of current injected from a DAC.
00534     * BME680 heater operation could be speeded up by setting an initial heater current for a target
00535     * heater temperature by using register idac_heat_x<7:0>. This step is optional since the control
00536     * loop will find the current after a few iterations anyway.
00537     * Current injected to the heater in mA = (idac_heat_7_1 + 1) / 8
00538     * Where: idac_heat_7_1 = decimal value stored in idac_heat<7:1> (unsigned, value from 0 to 127)
00539     * @param setPoint 0-9
00540     */
00541     void setHeaterCurrent(int setPoint, uint8_t value);
00542 
00543     /**
00544     * [res_heat_x]
00545     * Target heater resistance is programmed by user through res_heat_x<7:0> registers.
00546     * res_heat_x = 3.4* ((R_Target*(4/4+res_heat_range))-25) / ((res_heat_val * 0.002) + 1))
00547     * Where
00548     * R_Target is the target heater resistance in Ohm
00549     * res_heat_x is the decimal value that needs to be stored in register with same name
00550     * res_heat_range is heater range stored in register address 0x02 <5:4>
00551     * res_heat_val is heater resistance correction factor stored in register address 0x00 (signed, value from -128 to 127)
00552     * @param setPoint 0-9
00553     */
00554     int8_t getTargetHeaterResistance(int setPoint);
00555 
00556     /**
00557     * [res_heat_x]
00558     * Target heater resistance is programmed by user through res_heat_x<7:0> registers.
00559     * res_heat_x = 3.4* ((R_Target*(4/4+res_heat_range))-25) / ((res_heat_val * 0.002) + 1))
00560     * Where
00561     * R_Target is the target heater resistance in Ohm
00562     * res_heat_x is the decimal value that needs to be stored in register with same name
00563     * res_heat_range is heater range stored in register address 0x02 <5:4>
00564     * res_heat_val is heater resistance correction factor stored in register address 0x00 (signed, value from -128 to 127)
00565     * @param setPoint 0-9
00566     */
00567     void setTargetHeaterResistance(int setPoint, int8_t value);
00568 
00569     /**
00570     * [gas_wait_x]
00571     * gas_wait_x controls heater timing of the gas sensor. Functionality of this register will vary based on power modes.
00572     * Forced Mode & Sequential mode
00573     * Time between beginning of heat phase and start of sensor resistance conversion depend on gas_wait_x settings as mentioned below.
00574     * Parallel Mode
00575     * The number of TPHG sub-measurement sequences within the one Gas conversion for one target
00576     * temperature resistance is defined by gas_wait_x settings.
00577     * Note: Please take care about gas_wait_x on shifting modes between parallel & sequential/forced mode as register functionality will change.
00578     * @return result * 0.477 ms
00579     * @param setPoint 0-9
00580     */
00581     int getGasWaitTime(int setPoint);
00582 
00583     /**
00584     * [gas_wait_x]
00585     * gas_wait_x controls heater timing of the gas sensor. Functionality of this register will vary based on power modes.
00586     * Forced Mode & Sequential mode
00587     * Time between beginning of heat phase and start of sensor resistance conversion depend on gas_wait_x settings as mentioned below.
00588     * Parallel Mode
00589     * The number of TPHG sub-measurement sequences within the one Gas conversion for one target
00590     * temperature resistance is defined by gas_wait_x settings.
00591     * Note: Please take care about gas_wait_x on shifting modes between parallel & sequential/forced mode as register functionality will change.
00592     * @return result * 0.477 ms
00593     * @param setPoint 0-9
00594     * @param time 64 timer values with 1ms step sizes, all zeros means no wait.
00595     * @param multiplication [0, 1, 2, 3] -> [1, 4, 16, 64]
00596     */
00597     void setGasWaitTime(int setPoint, int time, int multiplication);
00598 
00599     /**
00600     * [gas_wait_shared]
00601     * The programmable wait time between two TPHG sub-measurement sequences of parallel mode depends on gas_wait_shared settings as follows
00602     */
00603     int getGasWaitShared();
00604 
00605     /**
00606     * [gas_wait_shared]
00607     * The programmable wait time between two TPHG sub-measurement sequences of parallel mode depends on gas_wait_shared settings as follows
00608     * @param setPoint 0-9
00609     * @param time 64 timer values with 0.477 ms step sizes, all zeros means no wait.
00610     * @param multiplication [0x00, 0x01, 0x10, 0x11] -> [1, 4, 16, 64]
00611     */
00612     void setGasWaitShared(int time, int multiplication);
00613 
00614     /**
00615     * [heat_off]
00616     * Turn off current injected to heater
00617     */
00618     void setHeaterOff();
00619 
00620     /**
00621     * [nb_conv]
00622     * is used to select heater set-points of BME680
00623     * Sequential & Parallel Mode
00624     * User can program a sequence of up to 10 conversions by setting nb_conv<3:0>. Each conversion has its own heater resistance target but 3 field registers to store conversion results. The actual
00625     * gas conversion number in the measurement sequence (up to 10 conversions numbered from 0 to 9) is stored in gas measurement index register
00626     * In parallel mode, no TPH conversions are ran at all. In sequential mode, TPH conversions are run according to osrs_t|p|h settings, gas is skipped
00627     * @return Sequential & Parallel : number of profiles (0-10), 0 means no gas conversion
00628     * @return Forced : indicates index of heater profile
00629     */
00630     int getHeaterProfile();
00631 
00632     /**
00633     * [nb_conv]
00634     * is used to select heater set-points of BME680
00635     * Sequential & Parallel Mode
00636     * User can program a sequence of up to 10 conversions by setting nb_conv<3:0>. Each conversion has its own heater resistance target but 3 field registers to store conversion results. The actual
00637     * gas conversion number in the measurement sequence (up to 10 conversions numbered from 0 to 9) is stored in gas measurement index register
00638     * In parallel mode, no TPH conversions are ran at all. In sequential mode, TPH conversions are run according to osrs_t|p|h settings, gas is skipped
00639     * @param Sequential & Parallel : number of profiles (0-10), 0 means no gas conversion
00640     * @param Forced : indicates index of heater profile
00641     */
00642     void setHeaterProfile(int value);
00643 
00644     /**
00645     * [run_gas_l]
00646     * The gas conversions are started only in appropriate mode if run_gas_l=1
00647     */
00648     void runGasConversion();
00649 
00650     /**
00651     * [odr]
00652     * Wake period in sequential mode – odr
00653     * In the sequential mode operation the device periodically enters stand-by state and returns to an operational state after a given wake-up period. Wake period can be programmed by odr<3:0> register as shown below
00654     * @return in ms, 0 means device does not go to standby
00655     */
00656     float getWakePeriod();
00657 
00658     /**
00659     * [odr]
00660     * Wake period in sequential mode – odr
00661     * In the sequential mode operation the device periodically enters stand-by state and returns to an operational state after a given wake-up period. Wake period can be programmed by odr<3:0> register as shown below
00662     * @param value : [0 - 8+] [0.59,62.5,125,250,500,1000,10,20,no standby]
00663     */
00664     void setWakePeriod(int value);
00665 
00666     // PRESSURE TEMPERATURE HUMIDITY CONTROL #########################################################################
00667 
00668     /**
00669     * [osrs_h]
00670     * @return value : [0,1,2,4,8,16] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00671     */
00672     int getOversamplingHumidity();
00673 
00674     /**
00675     * [osrs_h]
00676     * @param value : [0,1,2,3,4,5] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00677     */
00678     void setOversamplingHumidity(int value);
00679 
00680     /**
00681     * [osrs_p]
00682     * @return value : [0,1,2,4,8,16] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00683     */
00684     int getOversamplingPressure();
00685 
00686     /**
00687     * [osrs_p]
00688     * @param value : [0,1,2,3,4,5] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00689     */
00690     void setOversamplingPressure(int value);
00691 
00692     /**
00693     * [osrs_t]
00694     * @return value : [0,1,2,4,8,16] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00695     */
00696     int getOversamplingTemperature();
00697 
00698     /**
00699     * [osrs_t]
00700     * @param value : [0,1,2,3,4,5] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00701     */
00702     void setOversamplingTemperature(int value);
00703 
00704     /**
00705     * [filter]
00706     * IIR filter control
00707     * IIR filter applies to temperature and pressure data but not to humidity and gas data. The data
00708     * coming from the ADC are filtered and then loaded into the data registers. The T, P result registers
00709     * are updated together at the same time at the end of measurement. IIR filter output resolution is
00710     * 20 bits. The T, P result registers are reset to value 0x80000 when the T, P measurements have
00711     * been skipped (osrs_x=”000‟). The appropriate filter memory is kept unchanged (the value fromt he last measurement is kept). When the appropriate OSRS register is set back to nonzero, then
00712     * the first value stored to the T, P result register is filtered.
00713     * @return value : [0,1,3,7,15,31,63,127]
00714     */
00715     int getIIRfilterCoefficient();
00716 
00717     /**
00718     * [filter]
00719     * IIR filter control
00720     * IIR filter applies to temperature and pressure data but not to humidity and gas data. The data
00721     * coming from the ADC are filtered and then loaded into the data registers. The T, P result registers
00722     * are updated together at the same time at the end of measurement. IIR filter output resolution is
00723     * 20 bits. The T, P result registers are reset to value 0x80000 when the T, P measurements have
00724     * been skipped (osrs_x=”000‟). The appropriate filter memory is kept unchanged (the value fromt he last measurement is kept). When the appropriate OSRS register is set back to nonzero, then
00725     * the first value stored to the T, P result register is filtered.
00726     * @param value : [0,1,2,3,4,5,6,7] -> [0,1,3,7,15,31,63,127]
00727     */
00728     void setIIRfilterCoefficient(int value);
00729 
00730     // GENERAL CONTROL #########################################################################
00731 
00732     /**
00733     * [mode]
00734     * Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced
00735     * mode.Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced mode.
00736     * @param mode : [0,1,2,3] -> [Sleep, Forced, Parallel, Sequential]
00737     */
00738     void setMode(int mode);
00739 
00740     /**
00741     * [mode]
00742     * Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced
00743     * mode.Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced mode.
00744     * @return value : [0,1,2,3] -> [Sleep, Forced, Parallel, Sequential]
00745     */
00746     int getMode();
00747 
00748     /**
00749     * [chip_id]
00750     * Chip id of the device, this should give 0x61
00751     */
00752     int getChipID();
00753 };
00754 
00755 #endif