BigW Consortium Gitlab

Commit 354e27dd by David Clark

Added BME680 Sensor Driver

parent 3d5bc8b4
......@@ -44,3 +44,6 @@
[submodule "apps/LocationTriangulation"]
path = apps/LocationTriangulation
url = https://github.com/mangOH/LocationTriangulation
[submodule "linux_kernel_modules/bme680/BME680_driver"]
path = linux_kernel_modules/bme680/BME680_driver
url = https://github.com/BoschSensortec/BME680_driver.git
cflags:
{
// This driver depends on IIO
-DCONFIG_IIO
-DDEBUG
-DSIERRA
-I$MANGOH_ROOT/linux_kernel_modules/bme680/BME680_driver
}
sources:
{
./BME680_driver/bme680.c
bme680-i2c.c
bme680-regmap.c
}
#include <linux/device.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include "bme680_defs.h"
static bool bme680_is_writeable_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
case BME680_CONF_HEAT_CTRL_ADDR:
case BME680_CONF_ODR_RUN_GAS_NBC_ADDR:
case BME680_CONF_OS_H_ADDR:
case BME680_CONF_T_P_MODE_ADDR:
case BME680_SOFT_RESET_ADDR:
return true;
default:
if (((reg >= BME680_CONF_ODR_FILT_ADDR) &&
(reg <= BME680_CONF_ODR_FILT_ADDR + BME680_FILTER_SIZE_127)) ||
((reg >= BME680_ADDR_SENS_CONF_START) &&
(reg <= BME680_ADDR_SENS_CONF_START + BME680_FILTER_SIZE_7)))
return true;
dev_err(dev, "%s(): Error register(0x%04x) not writable\n", __func__, reg);
return false;
};
}
static bool bme680_is_volatile_reg(struct device *dev, unsigned int reg)
{
if (((reg >= BME680_ADDR_GAS_CONF_START) && (reg <= BME680_ADDR_GAS_CONF_START + 9)) ||
((reg >= BME680_ADDR_SENS_CONF_START) && (reg <= BME680_ADDR_SENS_CONF_START + 9)))
return true;
return false;
}
const struct regmap_config bme680_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = BME680_COEFF_ADDR2 + BME680_COEFF_ADDR2_LEN,
.cache_type = REGCACHE_RBTREE,
.writeable_reg = bme680_is_writeable_reg,
.volatile_reg = bme680_is_volatile_reg,
};
EXPORT_SYMBOL(bme680_regmap_config);
--- ./BME680_driver/bme680.c 2018-05-15 10:35:44.730819635 -0700
+++ ./bme680.c 2018-05-15 09:55:23.278858200 -0700
@@ -991,7 +991,12 @@
((int64_t) lookupTable1[gas_range])) >> 16;
var2 = (((int64_t) ((int64_t) gas_res_adc << 15) - (int64_t) (16777216)) + var1);
var3 = (((int64_t) lookupTable2[gas_range] * (int64_t) var1) >> 9);
+#ifdef SIERRA
+ var3 += (int64_t) var2 >> 1;
+ calc_gas_res = (uint32_t) do_div(var3, (int64_t) var2);
+#else
calc_gas_res = (uint32_t) ((var3 + ((int64_t) var2 >> 1)) / (int64_t) var2);
+#endif
return calc_gas_res;
}
......@@ -70,6 +70,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_CCT] = "cct",
[IIO_PRESSURE] = "pressure",
[IIO_HUMIDITYRELATIVE] = "humidityrelative",
[IIO_GASRESISTANCE] = "gasresistance",
};
static const char * const iio_modifier_names[] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment