From 15d1ea544b02599aa5c1eed61d80092716411f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 6 Mar 2021 00:04:41 +0000 Subject: [PATCH] drivers: sensor: bmi160: Fix bug where undersampling is not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #32774 Bit position BIT(7) is 1000 0000 in binary which is actually the bit positon 128. BIT(7) can be used as a mask, but we need to define the position specifically as the integer 7. Signed-off-by: Guðni Már Gilbert --- drivers/sensor/bmi160/bmi160.c | 2 +- drivers/sensor/bmi160/bmi160.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/sensor/bmi160/bmi160.c b/drivers/sensor/bmi160/bmi160.c index 57e0705c455..4ca0ed9c6db 100644 --- a/drivers/sensor/bmi160/bmi160.c +++ b/drivers/sensor/bmi160/bmi160.c @@ -222,7 +222,7 @@ static int bmi160_pmu_set(const struct device *dev, /* set the undersampling flag for accelerometer */ return bmi160_reg_field_update(dev, BMI160_REG_ACC_CONF, - BMI160_ACC_CONF_US, BMI160_ACC_CONF_US, + BMI160_ACC_CONF_US_POS, BMI160_ACC_CONF_US_MASK, pmu_sts->acc != BMI160_PMU_NORMAL); } diff --git a/drivers/sensor/bmi160/bmi160.h b/drivers/sensor/bmi160/bmi160.h index 532c41c0cef..01fb035f452 100644 --- a/drivers/sensor/bmi160/bmi160.h +++ b/drivers/sensor/bmi160/bmi160.h @@ -180,7 +180,8 @@ #define BMI160_ACC_CONF_ODR_MASK 0xF #define BMI160_ACC_CONF_BWP_POS 4 #define BMI160_ACC_CONF_BWP_MASK (0x7 << 4) -#define BMI160_ACC_CONF_US BIT(7) +#define BMI160_ACC_CONF_US_POS 7 +#define BMI160_ACC_CONF_US_MASK BIT(7) /* BMI160_REG_GYRO_CONF */ #define BMI160_GYR_CONF_ODR_POS 0