Skip to content

Commit

Permalink
drivers/sensor/st: ism330dhcx: fix gyro range setting
Browse files Browse the repository at this point in the history
Fix ism330dhcx_gyro_fs_map[] and ism330dhcx_gyro_fs_sens[] arrays
initialization in order to be able to correctly convert from dps
to register raw value through the array index.

Fix: #72617

Signed-off-by: Armando Visconti <[email protected]>
  • Loading branch information
avisconti authored and aescolar committed Jul 4, 2024
1 parent 50ad2e0 commit cd7119d
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions drivers/sensor/st/ism330dhcx/ism330dhcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,30 @@ static int ism330dhcx_accel_range_to_fs_val(int32_t range)
return -EINVAL;
}

static const uint16_t ism330dhcx_gyro_fs_map[] = {250, 500, 1000, 2000, 125};
static const uint16_t ism330dhcx_gyro_fs_sens[] = {2, 4, 8, 16, 1};
/*
* Following arrays are initialized in order to mimic
* the ism330dhcx_fs_g_t enum:
*
* typedef enum
* {
* ISM330DHCX_125dps = 2,
* ISM330DHCX_250dps = 0,
* ISM330DHCX_500dps = 4,
* ISM330DHCX_1000dps = 8,
* ISM330DHCX_2000dps = 12,
* ISM330DHCX_4000dps = 1,
* } ism330dhcx_fs_g_t;
*/
static const uint16_t ism330dhcx_gyro_fs_map[] = {
250, 4000, 125, 0, 500,
0, 0, 0, 1000,
0, 0, 0, 2000
};
static const uint16_t ism330dhcx_gyro_fs_sens[] = {
2, 32, 1, 0, 4,
0, 0, 0, 8,
0, 0, 0, 16
};

static int ism330dhcx_gyro_range_to_fs_val(int32_t range)
{
Expand Down

0 comments on commit cd7119d

Please sign in to comment.