mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
driver: bm160: fix ODR_TO_REG macros
Were not working when ODR > 100Hz. BRANCH=smaug TEST=Check by setting iio:deviceX/frequency from user space. BUG=chrome-os-partner:39900 Change-Id: I1795e4faf85039133da6bb38ae3b415e5fde236e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/284612 Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
08414a6da2
commit
ee44cbd583
@@ -106,8 +106,12 @@
|
||||
#define BMI160_ODR_1600HZ 0x0c
|
||||
#define BMI160_ODR_3200HZ 0x0d
|
||||
|
||||
#define BMI160_REG_TO_ODR(_regval) (100000 / (1 << (8 - (_regval))))
|
||||
#define BMI160_ODR_TO_REG(_odr) (__builtin_clz(100000 / (_odr)) - 23)
|
||||
#define BMI160_REG_TO_ODR(_regval) \
|
||||
((_regval) < 8 ? 100000 / (1 << (8 - (_regval))) : \
|
||||
100000 * (1 << ((_regval) - 8)))
|
||||
#define BMI160_ODR_TO_REG(_odr) \
|
||||
((_odr) < 100000 ? (__builtin_clz(100000 / (_odr)) - 23) : \
|
||||
(39 - __builtin_clz((_odr) / 100000)))
|
||||
|
||||
#define BMI160_CONF_REG(_sensor) (0x40 + 2 * (_sensor))
|
||||
#define BMI160_RANGE_REG(_sensor) (0x41 + 2 * (_sensor))
|
||||
@@ -283,6 +287,6 @@ enum bmi160_running_mode {
|
||||
#define BMI160_FLAG_SEC_I2C_ENABLED (1 << 0)
|
||||
struct bmi160_drv_data_t {
|
||||
struct motion_data_t saved_data[3];
|
||||
uint8_t flags;
|
||||
uint8_t flags;
|
||||
};
|
||||
#endif /* __CROS_EC_ACCELGYRO_BMI160_H */
|
||||
|
||||
Reference in New Issue
Block a user