summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKornel Dulęba <korneld@google.com>2023-03-28 13:50:05 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-26 08:06:11 +0000
commitfaa22b40be5c0e0c2ace3080cd4ec1942a8eb08e (patch)
tree74d54215f024cca70e3db9bc20a55e456dad4bc7
parent1f908510a9c58a53685aafe33565f283b236ca43 (diff)
downloadchrome-ec-faa22b40be5c0e0c2ace3080cd4ec1942a8eb08e.tar.gz
accel_list2dw12: Set high perf mode for ODR >= 50z
Until recently we're used it only as lid accel, where no significant precision is required. However in Winterhold we want to use it for body detection. In order to reduce the noise and make it usable for that purpose we need to set it into "high performance" power mode. ODR is used to recognize the sensor purpose. For lid accel it's set to 12.5Hz, assume that if it's at least 50Hz the high performance is wanted. BUG=b:262680246 BRANCH=none TEST=Set ODR to 50Hz, verify high performance mode is on Change-Id: I8c4decc93d2f2cfcc074cf2399f5cb582eb72696 Signed-off-by: Kornel Dulęba <korneld@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4379149 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> (cherry picked from commit 8b50c762dc2df4d14e7aff4838e2490419be7913) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4465588 Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
-rw-r--r--driver/accel_lis2dw12.c6
-rw-r--r--zephyr/test/drivers/default/src/lis2dw12.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/driver/accel_lis2dw12.c b/driver/accel_lis2dw12.c
index f3f3ae8537..d8c47251de 100644
--- a/driver/accel_lis2dw12.c
+++ b/driver/accel_lis2dw12.c
@@ -357,7 +357,7 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
* But lis2dw12 needs switch low power mode according to odr value.
*/
if (!IS_ENABLED(CONFIG_ACCEL_LIS2DWL)) {
- if (reg_val > LIS2DW12_ODR_200HZ_VAL)
+ if (reg_val >= LIS2DW12_ODR_50HZ_VAL)
ret = lis2dw12_set_power_mode(s, LIS2DW12_HIGH_PERF, 0);
else
ret = lis2dw12_set_power_mode(
@@ -389,7 +389,7 @@ static int get_rms_noise(const struct motion_sensor_t *s)
rate = INT_TO_FP(st_get_data_rate(s) / 1000);
/*
- * LIS2DW12: 90ug/sqrt(Hz) when ODR is over 200Hz
+ * LIS2DW12: 90ug/sqrt(Hz) when ODR is over 50Hz
* When lower, we are in power mode 2, so the noise density does not
* depend on frequency and the RMS at +/-2g is 2.4mg.
*
@@ -398,7 +398,7 @@ static int get_rms_noise(const struct motion_sensor_t *s)
*/
if (!IS_ENABLED(CONFIG_ACCEL_LIS2DWL)) {
- if (rate < INT_TO_FP(200))
+ if (rate < INT_TO_FP(50))
return 2400;
noise_density_ug = INT_TO_FP(90);
} else {
diff --git a/zephyr/test/drivers/default/src/lis2dw12.c b/zephyr/test/drivers/default/src/lis2dw12.c
index 4cacf725ba..e7609300a0 100644
--- a/zephyr/test/drivers/default/src/lis2dw12.c
+++ b/zephyr/test/drivers/default/src/lis2dw12.c
@@ -337,14 +337,14 @@ ZTEST(lis2dw12, test_lis2dw12_set_rate)
test_params[i].expected_reg_val, odr_bits,
LIS2DW12_ODR_MAX_VAL);
- /* Check if high performance mode was enabled if rate >
- * 200,000mHz
+ /* Check if high performance mode was enabled if rate >=
+ * 50,000mHz
*/
uint8_t mode_bits = lis2dw12_emul_peek_mode(emul);
uint8_t lpmode_bits = lis2dw12_emul_peek_lpmode(emul);
- if (odr_bits > LIS2DW12_ODR_200HZ_VAL) {
+ if (odr_bits >= LIS2DW12_ODR_50HZ_VAL) {
/* High performance mode, LP mode immaterial */
zassert_equal(mode_bits, LIS2DW12_HIGH_PERF,
"MODE[1:0] should be 0x%x, but got 0x%x",