zephyr/drivers/sensor/ltrf216a
Thomas Stranger 61f065230a drivers: sensor: ltrf216a: fix overflow in conversion
The conversion of the raw sensor value overflows because
only a 32 bit multiplication is executed.
Fix the issue by promoting the raw sensor value to uint64_t before
executing the multiplication.

Analysis:
The current implementation overflows for all raw values grater
than 9544(14-bit).
But according to the datasheet the sensor has a maximum resolution of
20-bit. So Multiplying that value with 450.000 would need at least 39
bit to avoid an overflow, hence do it using 64-bit arithmetic.

Fixes CID 330657

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2024-02-13 21:14:21 +01:00
..
CMakeLists.txt
Kconfig
ltrf216a.c