Skip to content

Commit a68da01

Browse files
authored
Merge pull request #2407 from supervillain101/bmp3_overflow_prevention
This change adds protection against rollover at high altitudes.
2 parents 7a52e0b + da1b9d3 commit a68da01

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

hw/drivers/sensors/bmp388/src/bmp388.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,8 @@ compensate_pressure(const struct bmp3_uncomp_data *uncomp_data,
13431343
BMP388_LOG_ERROR("*****partial_data4 high32bit = 0x%x low32bit = 0x%x\n", (uint32_t)((partial_data4)>>32),(uint32_t)(partial_data4&0xffffffff));
13441344
#endif
13451345

1346-
partial_data5 = (partial_data4 * uncomp_data->pressure) / 512;
1346+
partial_data5 = (partial_data4 * (uncomp_data->pressure / 10)) / 512;
1347+
partial_data5 = partial_data5 * 10;
13471348

13481349
#if COMPENSTATE_DEBUG
13491350
BMP388_LOG_ERROR("*****partial_data5 high32bit = 0x%x low32bit = 0x%x\n", (uint32_t)((partial_data5)>>32),(uint32_t)(partial_data5&0xffffffff));

0 commit comments

Comments
 (0)