BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mangoh-drivers
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
mangoh-drivers
Commits
1de6b7ca
Commit
1de6b7ca
authored
Jun 13, 2018
by
David Clark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed gas resistance calculation (use of do_div())
parent
f5cf882b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
1 deletion
+48
-1
bme680-i2c.c
linux_kernel_modules/bme680/bme680-i2c.c
+1
-1
bme680.patch
linux_kernel_modules/bme680/bme680.patch
+47
-0
No files found.
linux_kernel_modules/bme680/bme680-i2c.c
View file @
1de6b7ca
...
...
@@ -108,7 +108,7 @@ static int bme680_read_raw(struct iio_dev *indio_dev,
switch
(
chan
->
type
)
{
case
IIO_GASRESISTANCE
:
if
(
data
->
field_data
.
status
&
BME680_GASM_VALID_MSK
)
{
dev_dbg
(
&
indio_dev
->
dev
,
"%s(): gas resistance(%d)
\n
"
,
dev_dbg
(
&
indio_dev
->
dev
,
"%s(): gas resistance(%d
ohms
)
\n
"
,
__func__
,
data
->
field_data
.
gas_resistance
);
*
val
=
data
->
field_data
.
gas_resistance
;
ret
=
IIO_VAL_INT
;
...
...
linux_kernel_modules/bme680/bme680.patch
0 → 100644
View file @
1de6b7ca
diff --git a/bme680.c b/bme680.c
index 5b6bfd7..8f82bf5 100644
--- a/bme680.c
+++ b/bme680.c
@@ -358,13 +358,20 @@ int8_t bme680_set_regs(const uint8_t *reg_addr, const uint8_t *reg_data, uint8_t
tmp_buff[(2 * index)] = reg_addr[index];
}
tmp_buff[(2 * index) + 1] = reg_data[index];
+#ifdef SIERRA
+ dev->com_rslt = dev->write(dev->dev_id, tmp_buff[2 * index], &tmp_buff[(2 * index) + 1], 1);
+ if (dev->com_rslt != 0)
+ rslt = BME680_E_COM_FAIL;
+#endif
}
+#ifndef SIERRA
/* Write the interleaved array */
if (rslt == BME680_OK) {
dev->com_rslt = dev->write(dev->dev_id, tmp_buff[0], &tmp_buff[1], (2 * len) - 1);
if (dev->com_rslt != 0)
rslt = BME680_E_COM_FAIL;
}
+#endif
} else {
rslt = BME680_E_INVALID_LENGTH;
}
@@ -770,6 +777,7 @@ static int8_t get_calib_data(struct bme680_dev *dev)
| (coeff_array[BME680_H1_LSB_REG] & BME680_BIT_H1_DATA_MSK));
dev->calib.par_h2 = (uint16_t) (((uint16_t) coeff_array[BME680_H2_MSB_REG] << BME680_HUM_REG_SHIFT_VAL)
| ((coeff_array[BME680_H2_LSB_REG]) >> BME680_HUM_REG_SHIFT_VAL));
+
dev->calib.par_h3 = (int8_t) coeff_array[BME680_H3_REG];
dev->calib.par_h4 = (int8_t) coeff_array[BME680_H4_REG];
dev->calib.par_h5 = (int8_t) coeff_array[BME680_H5_REG];
@@ -991,7 +999,13 @@ static uint32_t calc_gas_resistance(uint16_t gas_res_adc, uint8_t gas_range, con
((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;
+ do_div(var3, (int64_t) var2);
+ calc_gas_res = (uint32_t) var3;
+#else
calc_gas_res = (uint32_t) ((var3 + ((int64_t) var2 >> 1)) / (int64_t) var2);
+#endif
return calc_gas_res;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment