Skip to content

Commit 38e81e3

Browse files
valkjsaaaMaureenHelm
authored andcommitted
drivers: sensor: lsm6dsl: Fix lsm6dsl gyroscope full range setting
Bug 1: Fix lsm6dsl_gyro_set_fs_raw does not clear FS125 to register when setting the full range to be other values. Bug 2: Fix lsm6dsl_gyro_channel_get does not use the current gyro_sensitivity when getting data from the gyroscope. Signed-off-by: Jackie Yang <[email protected]>
1 parent 5dbc069 commit 38e81e3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/sensor/lsm6dsl/lsm6dsl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ static int lsm6dsl_gyro_set_fs_raw(const struct device *dev, uint8_t fs)
141141
if (fs == GYRO_FULLSCALE_125) {
142142
if (data->hw_tf->update_reg(dev,
143143
LSM6DSL_REG_CTRL2_G,
144-
LSM6DSL_MASK_CTRL2_FS125,
144+
LSM6DSL_MASK_CTRL2_FS125 | LSM6DSL_MASK_CTRL2_G_FS_G,
145145
1 << LSM6DSL_SHIFT_CTRL2_FS125) < 0) {
146146
return -EIO;
147147
}
148148
} else {
149149
if (data->hw_tf->update_reg(dev,
150150
LSM6DSL_REG_CTRL2_G,
151-
LSM6DSL_MASK_CTRL2_G_FS_G,
151+
LSM6DSL_MASK_CTRL2_FS125 | LSM6DSL_MASK_CTRL2_G_FS_G,
152152
fs << LSM6DSL_SHIFT_CTRL2_G_FS_G) < 0) {
153153
return -EIO;
154154
}
@@ -558,7 +558,7 @@ static int lsm6dsl_gyro_channel_get(enum sensor_channel chan,
558558
struct lsm6dsl_data *data)
559559
{
560560
return lsm6dsl_gyro_get_channel(chan, val, data,
561-
LSM6DSL_DEFAULT_GYRO_SENSITIVITY);
561+
data->gyro_sensitivity);
562562
}
563563

564564
#if defined(CONFIG_LSM6DSL_ENABLE_TEMP)

0 commit comments

Comments
 (0)