summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2018-02-15 11:51:29 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-19 19:21:19 -0700
commit88613a3aa27b6845faf6917c2c9ef950b974f51a (patch)
tree205d7b040278677cd1ce823de665a753ac6baff5
parent47f344713e3792b5b75ccd8d8d0f3797208e2de7 (diff)
downloadchrome-ec-88613a3aa27b6845faf6917c2c9ef950b974f51a.tar.gz
driver: accel_lis2dh: Fix interface
Add support in ectool, expose min/max ODR. BUG=b:73546254 BRANCH=master TEST=compile Change-Id: Ib09c06e17d7d73aaab91680672de4d5267299c7f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/924405 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/accel_lis2dh.c4
-rw-r--r--driver/accel_lis2dh.h4
-rw-r--r--include/ec_commands.h1
-rw-r--r--util/ectool.c3
4 files changed, 10 insertions, 2 deletions
diff --git a/driver/accel_lis2dh.c b/driver/accel_lis2dh.c
index e937205755..a02b1df1b0 100644
--- a/driver/accel_lis2dh.c
+++ b/driver/accel_lis2dh.c
@@ -129,10 +129,10 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
/* Adjust rounded value */
if (reg_val > LIS2DH_ODR_400HZ_VAL) {
reg_val = LIS2DH_ODR_400HZ_VAL;
- normalized_rate = 400000;
+ normalized_rate = LIS2DH_ODR_MAX_VAL;
} else if (reg_val < LIS2DH_ODR_1HZ_VAL) {
reg_val = LIS2DH_ODR_1HZ_VAL;
- normalized_rate = 1000;
+ normalized_rate = LIS2DH_ODR_MIN_VAL;
}
/*
diff --git a/driver/accel_lis2dh.h b/driver/accel_lis2dh.h
index 3b87ffff8b..48e5bb4fab 100644
--- a/driver/accel_lis2dh.h
+++ b/driver/accel_lis2dh.h
@@ -99,6 +99,10 @@ enum lis2dh_odr {
LIS2DH_ODR_LIST_NUM
};
+/* Absolute maximum rate for sensor */
+#define LIS2DH_ODR_MIN_VAL 1000
+#define LIS2DH_ODR_MAX_VAL 400000
+
/* Return ODR reg value based on data rate set */
#define LIS2DH_ODR_TO_REG(_odr) \
(_odr <= 1000) ? LIS2DH_ODR_1HZ_VAL : \
diff --git a/include/ec_commands.h b/include/ec_commands.h
index bc654209f0..fdbcf3dcf9 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -2275,6 +2275,7 @@ enum motionsensor_chip {
MOTIONSENSE_CHIP_OPT3001 = 10,
MOTIONSENSE_CHIP_BH1730 = 11,
MOTIONSENSE_CHIP_GPIO = 12,
+ MOTIONSENSE_CHIP_LIS2DH = 13,
};
/* List of orientation positions */
diff --git a/util/ectool.c b/util/ectool.c
index 36b68c93c2..eaeee132a5 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -3985,6 +3985,9 @@ static int cmd_motionsense(int argc, char **argv)
case MOTIONSENSE_CHIP_GPIO:
printf("gpio\n");
break;
+ case MOTIONSENSE_CHIP_LIS2DH:
+ printf("lis2dh\n");
+ break;
default:
printf("unknown\n");
}