drivers: sensor: bmi160: Fix bug where undersampling is not set

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 <gudni.m.g@gmail.com>
This commit is contained in:
Guðni Már Gilbert 2021-03-06 00:04:41 +00:00 committed by Carles Cufí
commit 15d1ea544b
2 changed files with 3 additions and 2 deletions

View file

@ -222,7 +222,7 @@ static int bmi160_pmu_set(const struct device *dev,
/* set the undersampling flag for accelerometer */ /* set the undersampling flag for accelerometer */
return bmi160_reg_field_update(dev, BMI160_REG_ACC_CONF, 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); pmu_sts->acc != BMI160_PMU_NORMAL);
} }

View file

@ -180,7 +180,8 @@
#define BMI160_ACC_CONF_ODR_MASK 0xF #define BMI160_ACC_CONF_ODR_MASK 0xF
#define BMI160_ACC_CONF_BWP_POS 4 #define BMI160_ACC_CONF_BWP_POS 4
#define BMI160_ACC_CONF_BWP_MASK (0x7 << 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 */ /* BMI160_REG_GYRO_CONF */
#define BMI160_GYR_CONF_ODR_POS 0 #define BMI160_GYR_CONF_ODR_POS 0