Skip to content

Commit ead1cfb

Browse files
Derek Valleroykartben
authored andcommitted
drivers: sensors: lsm6dsv16x: Fix bug in decoder
The lsm6dsv16x driver is using an incorrect value for the index into the acceleration range. This results in using the wrong range. The issue was found to be a bug in a MACRO in lsm6dsv16x_decoder.h that was used to find the index in the acceleration range. The MACRO was improperly counting zeros from the leading edge, instead of the trailing edge. Signed-off-by: Derek Valleroy <[email protected]>
1 parent f3ddb06 commit ead1cfb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/sensor/st/lsm6dsv16x/lsm6dsv16x_decoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* This macro converts the Accelerometer full-scale range value (which should be a power of 2) to
1717
* an index value used by the decoder. Note: this index is not the same as the RAW register value.
1818
*/
19-
#define LSM6DSV16X_ACCEL_FS_VAL_TO_FS_IDX(x) (__builtin_clz(x) - 1)
19+
#define LSM6DSV16X_ACCEL_FS_VAL_TO_FS_IDX(x) (__builtin_ctz(x) - 1)
2020

2121
struct lsm6dsv16x_decoder_header {
2222
uint64_t timestamp;

0 commit comments

Comments
 (0)