drivers/bmp180: fix conversion
This commit is contained in:
parent
fbac2d47bb
commit
04d346667b
@ -147,8 +147,8 @@ uint32_t bmp180_read_pressure(const bmp180_t *dev)
|
|||||||
x1 = ((int32_t)dev->calibration.ac3 * b6) >> 13;
|
x1 = ((int32_t)dev->calibration.ac3 * b6) >> 13;
|
||||||
x2 = ((int32_t)dev->calibration.b1 * (b6 * b6) >> 12) >> 16;
|
x2 = ((int32_t)dev->calibration.b1 * (b6 * b6) >> 12) >> 16;
|
||||||
x3 = ((x1 + x2) + 2) >> 2;
|
x3 = ((x1 + x2) + 2) >> 2;
|
||||||
b4 = (int32_t)dev->calibration.ac4 * (uint32_t)(x3+32768) >> 15;
|
b4 = ((uint32_t)dev->calibration.ac4 * (uint32_t)(x3 + 32768)) >> 15;
|
||||||
b7 = ((uint32_t)up - b3) * (uint32_t)(50000UL >> OVERSAMPLING);
|
b7 = (uint32_t)(up - b3) * (uint32_t)(50000UL >> OVERSAMPLING);
|
||||||
if (b7 < 0x80000000) {
|
if (b7 < 0x80000000) {
|
||||||
p = (b7 * 2) / b4;
|
p = (b7 * 2) / b4;
|
||||||
}
|
}
|
||||||
@ -240,9 +240,9 @@ static int _read_up(const bmp180_t *dev, int32_t *output)
|
|||||||
|
|
||||||
static int _compute_b5(const bmp180_t *dev, int32_t ut, int32_t *output)
|
static int _compute_b5(const bmp180_t *dev, int32_t ut, int32_t *output)
|
||||||
{
|
{
|
||||||
int32_t x1, x2;
|
int32_t x1 = 0, x2 = 0;
|
||||||
x1 = (ut - dev->calibration.ac6) * dev->calibration.ac5 >> 15;
|
x1 = (((int32_t)ut - (int32_t)dev->calibration.ac6) * (int32_t)dev->calibration.ac5) >> 15;
|
||||||
x2 = (dev->calibration.mc << 11) / (x1 + dev->calibration.md);
|
x2 = ((int32_t)dev->calibration.mc << 11) / (x1 + dev->calibration.md);
|
||||||
|
|
||||||
*output = x1 + x2;
|
*output = x1 + x2;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user