Merge pull request #26 from ESP32DE/patch-1
casting problem & Integer overflow issue fixed in "calc_pressure" API
This commit is contained in:
commit
be1dc2d562
2
bme680.c
2
bme680.c
@ -924,7 +924,7 @@ static uint32_t calc_pressure(uint32_t pres_adc, const struct bme680_dev *dev)
|
|||||||
var1 = ((32768 + var1) * (int32_t)dev->calib.par_p1) >> 15;
|
var1 = ((32768 + var1) * (int32_t)dev->calib.par_p1) >> 15;
|
||||||
pressure_comp = 1048576 - pres_adc;
|
pressure_comp = 1048576 - pres_adc;
|
||||||
pressure_comp = (int32_t)((pressure_comp - (var2 >> 12)) * ((uint32_t)3125));
|
pressure_comp = (int32_t)((pressure_comp - (var2 >> 12)) * ((uint32_t)3125));
|
||||||
var4 = (int32_t)(((uint32_t)1) << 31);
|
var4 = (1 << 30);
|
||||||
if (pressure_comp >= var4)
|
if (pressure_comp >= var4)
|
||||||
pressure_comp = ((pressure_comp / (uint32_t)var1) << 1);
|
pressure_comp = ((pressure_comp / (uint32_t)var1) << 1);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user