Skip to content

Commit c9f8b8b

Browse files
str4t0mnashif
authored andcommitted
drivers: sensor: shtcx: fix val2 calculation
The calculation of the sensor val2 did not correctly take the sign into account. Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
1 parent ecf2cb5 commit c9f8b8b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/sensor/shtcx/shtcx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void shtcx_temperature_from_raw(uint16_t raw, struct sensor_value *val)
5353
tmp = (int32_t)raw * 175U - (45 << 16);
5454
val->val1 = tmp / 0x10000;
5555
/* x * 1.000.000 / 65.536 == x * 15625 / 2^10 */
56-
val->val2 = ((tmp % 0x10000) * 15625U) / 1024;
56+
val->val2 = ((tmp % 0x10000) * 15625) / 1024;
5757
}
5858

5959
/* val = 100 * sample / (2^16) */

0 commit comments

Comments
 (0)