|
|
|
@ -39,6 +39,11 @@ |
|
|
|
|
#include "bme68x.h" |
|
|
|
|
#include <stdio.h> |
|
|
|
|
|
|
|
|
|
// for logging only
|
|
|
|
|
#include <sdkconfig.h> |
|
|
|
|
#include <esp_log.h> |
|
|
|
|
static const char *TAG = "bme68x"; |
|
|
|
|
|
|
|
|
|
/* This internal API is used to read the calibration coefficients */ |
|
|
|
|
static int8_t get_calib_data(struct bme68x_dev *dev); |
|
|
|
|
|
|
|
|
@ -160,13 +165,24 @@ int8_t bme68x_init(struct bme68x_dev *dev) |
|
|
|
|
{ |
|
|
|
|
/* Get the Calibration data */ |
|
|
|
|
rslt = get_calib_data(dev); |
|
|
|
|
|
|
|
|
|
if (rslt != BME68X_OK) { |
|
|
|
|
ESP_LOGE(TAG, "get_calib_data failed"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGE(TAG, "read_variant_id failed"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
ESP_LOGE(TAG, "bme68x_get_regs unknown chip id %x", dev->chip_id); |
|
|
|
|
rslt = BME68X_E_DEV_NOT_FOUND; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGE(TAG, "bme68x_get_regs failed"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGE(TAG, "bme68x_soft_reset failed"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return rslt; |
|
|
|
@ -212,17 +228,20 @@ int8_t bme68x_set_regs(const uint8_t *reg_addr, const uint8_t *reg_data, uint32_ |
|
|
|
|
dev->intf_rslt = dev->write(tmp_buff[0], &tmp_buff[1], (2 * len) - 1, dev->intf_ptr); |
|
|
|
|
if (dev->intf_rslt != 0) |
|
|
|
|
{ |
|
|
|
|
ESP_LOGE(TAG, "bme68x_set_regs: write failed"); |
|
|
|
|
rslt = BME68X_E_COM_FAIL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
ESP_LOGE(TAG, "bme68x_set_regs: invalid len"); |
|
|
|
|
rslt = BME68X_E_INVALID_LENGTH; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
ESP_LOGE(TAG, "bme68x_set_regs: null ptr"); |
|
|
|
|
rslt = BME68X_E_NULL_PTR; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -247,17 +266,21 @@ int8_t bme68x_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct |
|
|
|
|
if (rslt == BME68X_OK) |
|
|
|
|
{ |
|
|
|
|
reg_addr = reg_addr | BME68X_SPI_RD_MSK; |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGE(TAG, "bme68x_get_regs: set_mem_page fail"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dev->intf_rslt = dev->read(reg_addr, reg_data, len, dev->intf_ptr); |
|
|
|
|
if (dev->intf_rslt != 0) |
|
|
|
|
{ |
|
|
|
|
ESP_LOGE(TAG, "bme68x_get_regs: comm fail"); |
|
|
|
|
rslt = BME68X_E_COM_FAIL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
ESP_LOGE(TAG, "bme68x_get_regs: null ptr"); |
|
|
|
|
rslt = BME68X_E_NULL_PTR; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -298,8 +321,14 @@ int8_t bme68x_soft_reset(struct bme68x_dev *dev) |
|
|
|
|
{ |
|
|
|
|
rslt = get_mem_page(dev); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGE(TAG, "bme68x_soft_reset: bme68x_set_regs fail"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGE(TAG, "bme68x_soft_reset: get_mem_page fail"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGE(TAG, "bme68x_soft_reset: null ptr"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return rslt; |
|
|
|
@ -708,12 +737,17 @@ int8_t bme68x_get_heatr_conf(const struct bme68x_heatr_conf *conf, struct bme68x |
|
|
|
|
{ |
|
|
|
|
conf->heatr_dur_prof[i] = data_array[i]; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGE(TAG, "bme68x_get_heatr_conf: get regs err"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
ESP_LOGE(TAG, "bme68x_get_heatr_conf: null ptr"); |
|
|
|
|
rslt = BME68X_E_NULL_PTR; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGE(TAG, "bme68x_get_heatr_conf: bme68x_get_regs fail"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return rslt; |
|
|
|
|