diff --git a/bme68x.c b/bme68x.c
index 1a31e27..7b45b57 100644
--- a/bme68x.c
+++ b/bme68x.c
@@ -31,8 +31,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bme68x.c
-* @date 2020-11-02
-* @version v4.4.2
+* @date 2021-03-18
+* @version v4.4.4
*
*/
@@ -84,9 +84,12 @@ static uint8_t calc_res_heat(uint16_t temp, const struct bme68x_dev *dev);
#endif
-/* This internal API is used to calculate the field data of sensor */
+/* This internal API is used to read a single data of the sensor */
static int8_t read_field_data(uint8_t index, struct bme68x_data *data, struct bme68x_dev *dev);
+/* This internal API is used to read all data fields of the sensor */
+static int8_t read_all_field_data(struct bme68x_data * const data[], struct bme68x_dev *dev);
+
/* This internal API is used to switch between SPI memory pages */
static int8_t set_mem_page(uint8_t reg_addr, struct bme68x_dev *dev);
@@ -478,31 +481,49 @@ int8_t bme68x_get_op_mode(uint8_t *op_mode, struct bme68x_dev *dev)
/*
* @brief This API is used to get the remaining duration that can be used for heating.
*/
-uint16_t bme68x_get_meas_dur(const uint8_t op_mode, const struct bme68x_conf *conf)
+uint32_t bme68x_get_meas_dur(const uint8_t op_mode, struct bme68x_conf *conf, struct bme68x_dev *dev)
{
- uint32_t tph_dur = 0; /* Calculate in us */
+ int8_t rslt;
+ uint32_t meas_dur = 0; /* Calculate in us */
uint32_t meas_cycles;
uint8_t os_to_meas_cycles[6] = { 0, 1, 2, 4, 8, 16 };
if (conf != NULL)
{
- meas_cycles = os_to_meas_cycles[conf->os_temp];
- meas_cycles += os_to_meas_cycles[conf->os_pres];
- meas_cycles += os_to_meas_cycles[conf->os_hum];
-
- /* TPH measurement duration */
- tph_dur = meas_cycles * UINT32_C(1963);
- tph_dur += UINT32_C(477 * 4); /* TPH switching duration */
- tph_dur += UINT32_C(477 * 5); /* Gas measurement duration */
- tph_dur += UINT32_C(500); /* Get it to the closest integer when converted to ms.*/
- tph_dur /= UINT32_C(1000); /* Convert to ms */
- if (op_mode != BME68X_PARALLEL_MODE)
+ /* Boundary check for temperature oversampling */
+ rslt = boundary_check(&conf->os_temp, BME68X_OS_16X, dev);
+
+ if (rslt == BME68X_OK)
+ {
+ /* Boundary check for pressure oversampling */
+ rslt = boundary_check(&conf->os_pres, BME68X_OS_16X, dev);
+ }
+
+ if (rslt == BME68X_OK)
{
- tph_dur += UINT32_C(1); /* Wake up duration of 1ms */
+ /* Boundary check for humidity oversampling */
+ rslt = boundary_check(&conf->os_hum, BME68X_OS_16X, dev);
+ }
+
+ if (rslt == BME68X_OK)
+ {
+ meas_cycles = os_to_meas_cycles[conf->os_temp];
+ meas_cycles += os_to_meas_cycles[conf->os_pres];
+ meas_cycles += os_to_meas_cycles[conf->os_hum];
+
+ /* TPH measurement duration */
+ meas_dur = meas_cycles * UINT32_C(1963);
+ meas_dur += UINT32_C(477 * 4); /* TPH switching duration */
+ meas_dur += UINT32_C(477 * 5); /* Gas measurement duration */
+
+ if (op_mode != BME68X_PARALLEL_MODE)
+ {
+ meas_dur += UINT32_C(1000); /* Wake up duration of 1ms */
+ }
}
}
- return (uint16_t)tph_dur;
+ return meas_dur;
}
/*
@@ -514,8 +535,8 @@ int8_t bme68x_get_data(uint8_t op_mode, struct bme68x_data *data, uint8_t *n_dat
{
int8_t rslt;
uint8_t i = 0, j = 0, new_fields = 0;
- struct bme68x_data *field_ptr[3];
- struct bme68x_data field_data[3];
+ struct bme68x_data *field_ptr[3] = { 0 };
+ struct bme68x_data field_data[3] = { { 0 } };
field_ptr[0] = &field_data[0];
field_ptr[1] = &field_data[1];
@@ -544,9 +565,11 @@ int8_t bme68x_get_data(uint8_t op_mode, struct bme68x_data *data, uint8_t *n_dat
else if ((op_mode == BME68X_PARALLEL_MODE) || (op_mode == BME68X_SEQUENTIAL_MODE))
{
/* Read the 3 fields and count the number of new data fields */
- for (i = 0; ((i < 3) && (rslt == BME68X_OK)); i++)
+ rslt = read_all_field_data(field_ptr, dev);
+
+ new_fields = 0;
+ for (i = 0; (i < 3) && (rslt == BME68X_OK); i++)
{
- rslt = read_field_data(i, field_ptr[i], dev);
if (field_ptr[i]->status & BME68X_NEW_DATA_MSK)
{
new_fields++;
@@ -1126,7 +1149,7 @@ static uint8_t calc_gas_wait(uint16_t dur)
return durval;
}
-/* This internal API is used to calculate the field data of sensor */
+/* This internal API is used to read a single data of the sensor */
static int8_t read_field_data(uint8_t index, struct bme68x_data *data, struct bme68x_dev *dev)
{
int8_t rslt = BME68X_OK;
@@ -1215,6 +1238,84 @@ static int8_t read_field_data(uint8_t index, struct bme68x_data *data, struct bm
return rslt;
}
+/* This internal API is used to read all data fields of the sensor */
+static int8_t read_all_field_data(struct bme68x_data * const data[], struct bme68x_dev *dev)
+{
+ int8_t rslt = BME68X_OK;
+ uint8_t buff[BME68X_LEN_FIELD * 3] = { 0 };
+ uint8_t gas_range_l, gas_range_h;
+ uint32_t adc_temp;
+ uint32_t adc_pres;
+ uint16_t adc_hum;
+ uint16_t adc_gas_res_low, adc_gas_res_high;
+ uint8_t off;
+ uint8_t set_val[30] = { 0 }; /* idac, res_heat, gas_wait */
+ uint8_t i;
+
+ if (!data[0] && !data[1] && !data[2])
+ {
+ rslt = BME68X_E_NULL_PTR;
+ }
+
+ if (rslt == BME68X_OK)
+ {
+ rslt = bme68x_get_regs(BME68X_REG_FIELD0, buff, (uint32_t) BME68X_LEN_FIELD * 3, dev);
+ }
+
+ if (rslt == BME68X_OK)
+ {
+ rslt = bme68x_get_regs(BME68X_REG_IDAC_HEAT0, set_val, 30, dev);
+ }
+
+ for (i = 0; ((i < 3) && (rslt == BME68X_OK)); i++)
+ {
+ off = (uint8_t)(i * BME68X_LEN_FIELD);
+ data[i]->status = buff[off] & BME68X_NEW_DATA_MSK;
+ data[i]->gas_index = buff[off] & BME68X_GAS_INDEX_MSK;
+ data[i]->meas_index = buff[off + 1];
+
+ /* read the raw data from the sensor */
+ adc_pres =
+ (uint32_t) (((uint32_t) buff[off + 2] * 4096) | ((uint32_t) buff[off + 3] * 16) |
+ ((uint32_t) buff[off + 4] / 16));
+ adc_temp =
+ (uint32_t) (((uint32_t) buff[off + 5] * 4096) | ((uint32_t) buff[off + 6] * 16) |
+ ((uint32_t) buff[off + 7] / 16));
+ adc_hum = (uint16_t) (((uint32_t) buff[off + 8] * 256) | (uint32_t) buff[off + 9]);
+ adc_gas_res_low = (uint16_t) ((uint32_t) buff[off + 13] * 4 | (((uint32_t) buff[off + 14]) / 64));
+ adc_gas_res_high = (uint16_t) ((uint32_t) buff[off + 15] * 4 | (((uint32_t) buff[off + 16]) / 64));
+ gas_range_l = buff[off + 14] & BME68X_GAS_RANGE_MSK;
+ gas_range_h = buff[off + 16] & BME68X_GAS_RANGE_MSK;
+ if (dev->variant_id == BME68X_VARIANT_GAS_HIGH)
+ {
+ data[i]->status |= buff[off + 16] & BME68X_GASM_VALID_MSK;
+ data[i]->status |= buff[off + 16] & BME68X_HEAT_STAB_MSK;
+ }
+ else
+ {
+ data[i]->status |= buff[off + 14] & BME68X_GASM_VALID_MSK;
+ data[i]->status |= buff[off + 14] & BME68X_HEAT_STAB_MSK;
+ }
+
+ data[i]->idac = set_val[data[i]->gas_index];
+ data[i]->res_heat = set_val[10 + data[i]->gas_index];
+ data[i]->gas_wait = set_val[20 + data[i]->gas_index];
+ data[i]->temperature = calc_temperature(adc_temp, dev);
+ data[i]->pressure = calc_pressure(adc_pres, dev);
+ data[i]->humidity = calc_humidity(adc_hum, dev);
+ if (dev->variant_id == BME68X_VARIANT_GAS_HIGH)
+ {
+ data[i]->gas_resistance = calc_gas_resistance(adc_gas_res_high, gas_range_h, dev);
+ }
+ else
+ {
+ data[i]->gas_resistance = calc_gas_resistance(adc_gas_res_low, gas_range_l, dev);
+ }
+ }
+
+ return rslt;
+}
+
/* This internal API is used to switch between SPI memory pages */
static int8_t set_mem_page(uint8_t reg_addr, struct bme68x_dev *dev)
{
@@ -1380,7 +1481,7 @@ static int8_t set_conf(const struct bme68x_heatr_conf *conf, uint8_t op_mode, ui
rh_reg_addr[i] = BME68X_REG_RES_HEAT0 + i;
rh_reg_data[i] = calc_res_heat(conf->heatr_temp_prof[i], dev);
gw_reg_addr[i] = BME68X_REG_GAS_WAIT0 + i;
- gw_reg_data[i] = (uint8_t)conf->heatr_dur_prof[i];
+ gw_reg_data[i] = (uint8_t) conf->heatr_dur_prof[i];
}
(*nb_conv) = conf->profile_len;
diff --git a/bme68x.h b/bme68x.h
index 5d4e550..33e5a44 100644
--- a/bme68x.h
+++ b/bme68x.h
@@ -31,15 +31,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bme68x.h
-* @date 2020-11-02
-* @version v4.4.2
+* @date 2021-03-18
+* @version v4.4.4
*
*/
/*!
* @defgroup bme68x BME68X
- * @brief Product Overview
- * and Sensor API Source Code
+ * @brief Product Overview
+ * and Sensor API Source Code
*/
#ifndef BME68X_H_
@@ -186,15 +186,17 @@ int8_t bme68x_get_op_mode(uint8_t *op_mode, struct bme68x_dev *dev);
* \ingroup bme68xApiConfig
* \page bme68x_api_bme68x_get_meas_dur bme68x_get_meas_dur
* \code
- * uint16_t bme68x_get_meas_dur(const uint8_t op_mode, const struct bme68x_conf *conf);
+ * uint32_t bme68x_get_meas_dur(const uint8_t op_mode, struct bme68x_conf *conf, struct bme68x_dev *dev);
* \endcode
* @details This API is used to get the remaining duration that can be used for heating.
*
- * @return Result of API execution status
- * @retval 0 -> Success
- * @retval < 0 -> Fail
+ * @param[in] op_mode : Desired operation mode.
+ * @param[in] conf : Desired sensor configuration.
+ * @param[in] dev : Structure instance of bme68x_dev
+ *
+ * @return Measurement duration calculated in microseconds
*/
-uint16_t bme68x_get_meas_dur(const uint8_t op_mode, const struct bme68x_conf *conf);
+uint32_t bme68x_get_meas_dur(const uint8_t op_mode, struct bme68x_conf *conf, struct bme68x_dev *dev);
/**
* \ingroup bme68x
diff --git a/bme68x_defs.h b/bme68x_defs.h
index 5fea5be..2b38687 100644
--- a/bme68x_defs.h
+++ b/bme68x_defs.h
@@ -31,8 +31,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bme68x_defs.h
-* @date 2020-11-02
-* @version v4.4.2
+* @date 2021-03-18
+* @version v4.4.4
*
*/
@@ -687,7 +687,7 @@ typedef BME68X_INTF_RET_TYPE (*bme68x_write_fptr_t)(uint8_t reg_addr, const uint
* @param[in,out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related callbacks
*/
-typedef void (*bm68x_delay_us_fptr_t)(uint32_t period, void *intf_ptr);
+typedef void (*bme68x_delay_us_fptr_t)(uint32_t period, void *intf_ptr);
/*
* @brief Generic communication function pointer
@@ -959,7 +959,7 @@ struct bme68x_dev
bme68x_write_fptr_t write;
/*! Delay function pointer */
- bm68x_delay_us_fptr_t delay_us;
+ bme68x_delay_us_fptr_t delay_us;
/*! To store interface pointer error */
BME68X_INTF_RET_TYPE intf_rslt;
diff --git a/examples/common/common.c b/examples/common/common.c
index f7a7ffd..06556f5 100644
--- a/examples/common/common.c
+++ b/examples/common/common.c
@@ -81,19 +81,25 @@ void bme68x_check_rslt(const char api_name[], int8_t rslt)
/* Do nothing */
break;
case BME68X_E_NULL_PTR:
- printf("Error [%d] : Null pointer\r\n", rslt);
+ printf("API name [%s] Error [%d] : Null pointer\r\n", api_name, rslt);
break;
case BME68X_E_COM_FAIL:
- printf("Error [%d] : Communication failure\r\n", rslt);
+ printf("API name [%s] Error [%d] : Communication failure\r\n", api_name, rslt);
break;
case BME68X_E_INVALID_LENGTH:
- printf("Error [%d] : Incorrect length parameter\r\n", rslt);
+ printf("API name [%s] Error [%d] : Incorrect length parameter\r\n", api_name, rslt);
break;
case BME68X_E_DEV_NOT_FOUND:
- printf("Error [%d] : Device not found\r\n", rslt);
+ printf("API name [%s] Error [%d] : Device not found\r\n", api_name, rslt);
+ break;
+ case BME68X_E_SELF_TEST:
+ printf("API name [%s] Error [%d] : Self test error\r\n", api_name, rslt);
+ break;
+ case BME68X_W_NO_NEW_DATA:
+ printf("API name [%s] Warning [%d] : No new data found\r\n", api_name, rslt);
break;
default:
- printf("Error [%d] : Unknown error code\r\n", rslt);
+ printf("API name [%s] Error [%d] : Unknown error code\r\n", api_name, rslt);
break;
}
}
@@ -173,5 +179,13 @@ int8_t bme68x_interface_init(struct bme68x_dev *bme, uint8_t intf)
void bme68x_coines_deinit(void)
{
+ fflush(stdout);
+
+ coines_set_shuttleboard_vdd_vddio_config(0, 0);
+ coines_delay_msec(1000);
+
+ /* Coines interface reset */
+ coines_soft_reset();
+ coines_delay_msec(1000);
coines_close_comm_intf(COINES_COMM_INTF_USB);
}
diff --git a/examples/forced_mode/forced_mode.c b/examples/forced_mode/forced_mode.c
index 36a73fb..435311a 100644
--- a/examples/forced_mode/forced_mode.c
+++ b/examples/forced_mode/forced_mode.c
@@ -11,6 +11,17 @@
#include "common.h"
#include "coines.h"
+/***********************************************************************/
+/* Macros */
+/***********************************************************************/
+
+/* Macro for count of samples to be displayed */
+#define SAMPLE_COUNT UINT16_C(300)
+
+/***********************************************************************/
+/* Test code */
+/***********************************************************************/
+
int main(void)
{
struct bme68x_dev bme;
@@ -18,7 +29,7 @@ int main(void)
struct bme68x_conf conf;
struct bme68x_heatr_conf heatr_conf;
struct bme68x_data data;
- uint16_t del_period;
+ uint32_t del_period;
uint32_t time_ms = 0;
uint8_t n_fields;
uint16_t sample_count = 1;
@@ -49,37 +60,43 @@ int main(void)
rslt = bme68x_set_heatr_conf(BME68X_FORCED_MODE, &heatr_conf, &bme);
bme68x_check_rslt("bme68x_set_heatr_conf", rslt);
- /* Check if rslt == BME68X_OK, report or handle if otherwise */
printf("Sample, TimeStamp(ms), Temperature(deg C), Pressure(Pa), Humidity(%%), Gas resistance(ohm), Status\n");
- while (sample_count <= 300)
+
+ while (sample_count <= SAMPLE_COUNT)
{
rslt = bme68x_set_op_mode(BME68X_FORCED_MODE, &bme);
bme68x_check_rslt("bme68x_set_op_mode", rslt);
- /* Check if rslt == BME68X_OK, report or handle if otherwise */
- del_period = bme68x_get_meas_dur(BME68X_FORCED_MODE, &conf) + heatr_conf.heatr_dur;
- bme.delay_us(del_period * 1000, bme.intf_ptr);
+ /* Calculate delay period in microseconds */
+ del_period = bme68x_get_meas_dur(BME68X_FORCED_MODE, &conf, &bme) + (heatr_conf.heatr_dur * 1000);
+ bme.delay_us(del_period, bme.intf_ptr);
time_ms = coines_get_millis();
+ /* Check if rslt == BME68X_OK, report or handle if otherwise */
rslt = bme68x_get_data(BME68X_FORCED_MODE, &data, &n_fields, &bme);
bme68x_check_rslt("bme68x_get_data", rslt);
- /* Check if rslt == BME68X_OK, report or handle if otherwise */
if (n_fields)
{
#ifdef BME68X_USE_FPU
- printf("%u, %u, %.2f, %.2f, %.2f, %.2f, 0x%x\n",
+ printf("%u, %lu, %.2f, %.2f, %.2f, %.2f, 0x%x\n",
sample_count,
- time_ms,
+ (long unsigned int)time_ms,
data.temperature,
data.pressure,
data.humidity,
data.gas_resistance,
data.status);
#else
- printf("%u, %u, %d, %u, %u, %u, 0x%x\n", sample_count, time_ms, (data.temperature / 100), data.pressure,
- (data.humidity / 1000), data.gas_resistance, data.status);
+ printf("%u, %lu, %d, %lu, %lu, %lu, 0x%x\n",
+ sample_count,
+ (long unsigned int)time_ms,
+ (data.temperature / 100),
+ (long unsigned int)data.pressure,
+ (long unsigned int)(data.humidity / 1000),
+ (long unsigned int)data.gas_resistance,
+ data.status);
#endif
sample_count++;
}
diff --git a/examples/parallel_mode/parallel_mode.c b/examples/parallel_mode/parallel_mode.c
index b18f19b..7a5a064 100644
--- a/examples/parallel_mode/parallel_mode.c
+++ b/examples/parallel_mode/parallel_mode.c
@@ -11,12 +11,23 @@
#include "common.h"
#include "coines.h"
+/***********************************************************************/
+/* Macros */
+/***********************************************************************/
+
/*
* Macro definition for valid new data (0x80) AND
* heater stability (0x10) AND gas resistance (0x20) values
*/
#define BME68X_VALID_DATA UINT8_C(0xB0)
+/* Macro for count of samples to be displayed */
+#define SAMPLE_COUNT UINT8_C(50)
+
+/***********************************************************************/
+/* Test code */
+/***********************************************************************/
+
int main(void)
{
struct bme68x_dev bme;
@@ -24,7 +35,7 @@ int main(void)
struct bme68x_conf conf;
struct bme68x_heatr_conf heatr_conf;
struct bme68x_data data[3];
- uint16_t del_period;
+ uint32_t del_period;
uint8_t n_fields;
uint32_t time_ms = 0;
uint16_t sample_count = 1;
@@ -52,8 +63,8 @@ int main(void)
/* Check if rslt == BME68X_OK, report or handle if otherwise */
conf.filter = BME68X_FILTER_OFF;
conf.odr = BME68X_ODR_NONE;
- conf.os_hum = BME68X_OS_16X;
- conf.os_pres = BME68X_OS_1X;
+ conf.os_hum = BME68X_OS_1X;
+ conf.os_pres = BME68X_OS_16X;
conf.os_temp = BME68X_OS_2X;
rslt = bme68x_set_conf(&conf, &bme);
bme68x_check_rslt("bme68x_set_conf", rslt);
@@ -64,7 +75,7 @@ int main(void)
heatr_conf.heatr_dur_prof = mul_prof;
/* Shared heating duration in milliseconds */
- heatr_conf.shared_heatr_dur = 140 - bme68x_get_meas_dur(BME68X_PARALLEL_MODE, &conf);
+ heatr_conf.shared_heatr_dur = 140 - (bme68x_get_meas_dur(BME68X_PARALLEL_MODE, &conf, &bme) / 1000);
heatr_conf.profile_len = 10;
rslt = bme68x_set_heatr_conf(BME68X_PARALLEL_MODE, &heatr_conf, &bme);
@@ -80,10 +91,11 @@ int main(void)
/* Check if rslt == BME68X_OK, report or handle if otherwise */
printf(
"Sample, TimeStamp(ms), Temperature(deg C), Pressure(Pa), Humidity(%%), Gas resistance(ohm), Status, Gas index, Meas index\n");
- while (sample_count <= 50)
+ while (sample_count <= SAMPLE_COUNT)
{
- del_period = bme68x_get_meas_dur(BME68X_PARALLEL_MODE, &conf) + heatr_conf.shared_heatr_dur;
- bme.delay_us(del_period * 1000, bme.intf_ptr);
+ /* Calculate delay period in microseconds */
+ del_period = bme68x_get_meas_dur(BME68X_PARALLEL_MODE, &conf, &bme) + (heatr_conf.shared_heatr_dur * 1000);
+ bme.delay_us(del_period, bme.intf_ptr);
time_ms = coines_get_millis();
@@ -96,9 +108,9 @@ int main(void)
if (data[i].status == BME68X_VALID_DATA)
{
#ifdef BME68X_USE_FPU
- printf("%u, %u, %.2f, %.2f, %.2f, %.2f, 0x%x, %d, %d\n",
+ printf("%u, %lu, %.2f, %.2f, %.2f, %.2f, 0x%x, %d, %d\n",
sample_count,
- time_ms,
+ (long unsigned int)time_ms,
data[i].temperature,
data[i].pressure,
data[i].humidity,
@@ -107,13 +119,13 @@ int main(void)
data[i].gas_index,
data[i].meas_index);
#else
- printf("%u, %u, %d, %u, %u, %u, 0x%x, %d, %d\n",
+ printf("%u, %lu, %d, %lu, %lu, %lu, 0x%x, %d, %d\n",
sample_count,
- time_ms,
+ (long unsigned int)time_ms,
(data[i].temperature / 100),
- data[i].pressure,
- (data[i].humidity / 1000),
- data[i].gas_resistance,
+ (long unsigned int)data[i].pressure,
+ (long unsigned int)(data[i].humidity / 1000),
+ (long unsigned int)data[i].gas_resistance,
data[i].status,
data[i].gas_index,
data[i].meas_index);
diff --git a/examples/sequential_mode/sequential_mode.c b/examples/sequential_mode/sequential_mode.c
index 9056afe..3979738 100644
--- a/examples/sequential_mode/sequential_mode.c
+++ b/examples/sequential_mode/sequential_mode.c
@@ -11,6 +11,17 @@
#include "common.h"
#include "coines.h"
+/***********************************************************************/
+/* Macros */
+/***********************************************************************/
+
+/* Macro for count of samples to be displayed */
+#define SAMPLE_COUNT UINT8_C(300)
+
+/***********************************************************************/
+/* Test code */
+/***********************************************************************/
+
int main(void)
{
struct bme68x_dev bme;
@@ -18,7 +29,7 @@ int main(void)
struct bme68x_conf conf;
struct bme68x_heatr_conf heatr_conf;
struct bme68x_data data[3];
- uint16_t del_period;
+ uint32_t del_period;
uint32_t time_ms = 0;
uint8_t n_fields;
uint16_t sample_count = 1;
@@ -67,10 +78,11 @@ int main(void)
/* Check if rslt == BME68X_OK, report or handle if otherwise */
printf(
"Sample, TimeStamp(ms), Temperature(deg C), Pressure(Pa), Humidity(%%), Gas resistance(ohm), Status, Profile index, Measurement index\n");
- while (sample_count <= 300)
+ while (sample_count <= SAMPLE_COUNT)
{
- del_period = bme68x_get_meas_dur(BME68X_SEQUENTIAL_MODE, &conf) + heatr_conf.heatr_dur_prof[0];
- bme.delay_us(del_period * 1000, bme.intf_ptr);
+ /* Calculate delay period in microseconds */
+ del_period = bme68x_get_meas_dur(BME68X_SEQUENTIAL_MODE, &conf, &bme) + (heatr_conf.heatr_dur_prof[0] * 1000);
+ bme.delay_us(del_period, bme.intf_ptr);
time_ms = coines_get_millis();
@@ -81,9 +93,9 @@ int main(void)
for (uint8_t i = 0; i < n_fields; i++)
{
#ifdef BME68X_USE_FPU
- printf("%u, %u, %.2f, %.2f, %.2f, %.2f, 0x%x, %d, %d\n",
+ printf("%u, %lu, %.2f, %.2f, %.2f, %.2f, 0x%x, %d, %d\n",
sample_count,
- time_ms,
+ (long unsigned int)time_ms,
data[i].temperature,
data[i].pressure,
data[i].humidity,
@@ -92,13 +104,13 @@ int main(void)
data[i].gas_index,
data[i].meas_index);
#else
- printf("%u, %u, %d, %u, %u, %u, 0x%x, %d, %d\n",
+ printf("%u, %lu, %d, %lu, %lu, %lu, 0x%x, %d, %d\n",
sample_count,
- time_ms,
+ (long unsigned int)time_ms,
(data[i].temperature / 100),
- data[i].pressure,
- (data[i].humidity / 1000),
- data[i].gas_resistance,
+ (long unsigned int)data[i].pressure,
+ (long unsigned int)(data[i].humidity / 1000),
+ (long unsigned int)data[i].gas_resistance,
data[i].status,
data[i].gas_index,
data[i].meas_index);