ISM330DHCX driver: wrong FS bitmask for gyroscope calculated #72617
Labels
area: Sensors
Sensors
bug
The issue is a bug, or the PR is fixing a bug
priority: low
Low impact/importance bug
Describe the bug
The driver for the ism330dhcx incorrectly calculates the bitmap for the fs bits in the CTRL2_G register. The driver uses the ST hal to set the values, but hands over an incorrect bitmask leading to wrong configuration.
HAL values for given FS: https://github.com/zephyrproject-rtos/hal_st/blob/b77157f6bc4395e398d90ab02a7d2cbc01ab2ce7/sensor/stmemsc/ism330dhcx_STdC/driver/ism330dhcx_reg.h#L2894
Zephyr driver logic for getting the value from the devicetree: https://github.com/zephyrproject-rtos/zephyr/blob/be682e22e166c33a67c1db0755f8ca20c37b6576/drivers/sensor/st/ism330dhcx/ism330dhcx.c#L70C2-L70C17
in my opinion, the lines in the zephyr driver should be
In addition the devicetree binding should be adapted to allow a FS value of 4000 (dps).
For convenience, here is a screenshot from the datasheet:
And the link to how the ST HAL parses this value: https://github.com/zephyrproject-rtos/hal_st/blob/b77157f6bc4395e398d90ab02a7d2cbc01ab2ce7/sensor/stmemsc/ism330dhcx_STdC/driver/ism330dhcx_reg.h#L357
To Reproduce
Not applicable
Expected behavior
The devicetree full-scale property for gyroscope to be correctly applied.
Impact
Unintended FS selection and wrong gyroscope readings, since raw to dps conversion is intended sensitivity but not the actual one.
The text was updated successfully, but these errors were encountered: