diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2018-01-24 08:28:03 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-03-19 19:21:21 -0700 |
commit | 94f5413159518e798800ca41916c02af00a6e2c8 (patch) | |
tree | 76424bc8dcd3938da10fccec08e8038f0bb51547 /driver/accel_lis2dh.h | |
parent | b87bea3289d8ea050f0b482972f6e04ecb8823b1 (diff) | |
download | chrome-ec-94f5413159518e798800ca41916c02af00a6e2c8.tar.gz |
driver: lis2dh: fix gain units
Accelerometer reports accelerating in mg. Fix gain to that full range
(2g, 4g or 8g) returns 2<<15.
BUG=b:73546254
BRANCH=master
TEST=compile
Change-Id: I2873a641985fa800709a2d30b031c2b6e3fcb39e
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/924407
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/accel_lis2dh.h')
-rw-r--r-- | driver/accel_lis2dh.h | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/driver/accel_lis2dh.h b/driver/accel_lis2dh.h index 48e5bb4fab..4a01cc995c 100644 --- a/driver/accel_lis2dh.h +++ b/driver/accel_lis2dh.h @@ -122,37 +122,8 @@ enum lis2dh_odr { /* Full scale range Mask register */ #define LIS2DH_FS_MASK 0x30 -/* Acc FS value */ -enum lis2dh_fs { - LIS2DH_FS_2G_VAL = 0x00, - LIS2DH_FS_4G_VAL, - LIS2DH_FS_8G_VAL, - LIS2DH_FS_16G_VAL, - LIS2DH_FS_LIST_NUM -}; - /* FS reg value from Full Scale */ -#define LIS2DH_FS_TO_REG(_fs) \ - (31 - __builtin_clz(_fs) - 1) - -/* Full Scale range real value normalized to sensor capabilities */ -#define LIS2DH_FS_TO_NORMALIZE(_fs) \ - (1 << (31 - __builtin_clz(_fs))) - -/* Acc Gain value */ -#define LIS2DH_FS_2G_GAIN 4 -#define LIS2DH_FS_4G_GAIN 8 -#define LIS2DH_FS_8G_GAIN 16 -#define LIS2DH_FS_16G_GAIN 48 - -/* Return Gain from Full Scale range - * TODO: This work only for 2, 4 and 8 G full scale */ -#define LIS2DH_FS_TO_GAIN(_fs) \ - (LIS2DH_FS_2G_GAIN << (30 - __builtin_clz(_fs))) - -/* Return Full Scale Range from normalized gain */ -#define LIS2DH_GAIN_TO_FS(_gain) \ - (1 << (30 - __builtin_clz(_gain))) +#define LIS2DH_FS_TO_REG(_fs) (__fls(_fs) - 1) /* Sensor resolution in number of bits * This sensor has variable precision (8/10/12 bits) depending Power Mode |