Skip to content

Commit

Permalink
drivers: sensor: bmi160: Fix bug where undersampling is not set
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gudnimg authored and carlescufi committed Mar 9, 2021
1 parent 156914f commit 15d1ea5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/sensor/bmi160/bmi160.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/sensor/bmi160/bmi160.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 15d1ea5

Please sign in to comment.