Skip to content

Commit 8b50c76

Browse files
korneldulebaChromeos LUCI
authored andcommitted
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 <[email protected]> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4379149 Reviewed-by: Gwendal Grignou <[email protected]>
1 parent 26d7d64 commit 8b50c76

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

driver/accel_lis2dw12.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
360360
* But lis2dw12 needs switch low power mode according to odr value.
361361
*/
362362
if (!IS_ENABLED(CONFIG_ACCEL_LIS2DWL)) {
363-
if (reg_val > LIS2DW12_ODR_200HZ_VAL)
363+
if (reg_val >= LIS2DW12_ODR_50HZ_VAL)
364364
ret = lis2dw12_set_power_mode(s, LIS2DW12_HIGH_PERF, 0);
365365
else
366366
ret = lis2dw12_set_power_mode(
@@ -392,7 +392,7 @@ static int get_rms_noise(const struct motion_sensor_t *s)
392392
rate = INT_TO_FP(st_get_data_rate(s) / 1000);
393393

394394
/*
395-
* LIS2DW12: 90ug/sqrt(Hz) when ODR is over 200Hz
395+
* LIS2DW12: 90ug/sqrt(Hz) when ODR is over 50Hz
396396
* When lower, we are in power mode 2, so the noise density does not
397397
* depend on frequency and the RMS at +/-2g is 2.4mg.
398398
*
@@ -401,7 +401,7 @@ static int get_rms_noise(const struct motion_sensor_t *s)
401401
*/
402402

403403
if (!IS_ENABLED(CONFIG_ACCEL_LIS2DWL)) {
404-
if (rate < INT_TO_FP(200))
404+
if (rate < INT_TO_FP(50))
405405
return 2400;
406406
noise_density_ug = INT_TO_FP(90);
407407
} else {

zephyr/test/drivers/default/src/lis2dw12.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ ZTEST(lis2dw12, test_lis2dw12_set_rate)
337337
test_params[i].expected_reg_val, odr_bits,
338338
LIS2DW12_ODR_MAX_VAL);
339339

340-
/* Check if high performance mode was enabled if rate >
341-
* 200,000mHz
340+
/* Check if high performance mode was enabled if rate >=
341+
* 50,000mHz
342342
*/
343343

344344
uint8_t mode_bits = lis2dw12_emul_peek_mode(emul);
345345
uint8_t lpmode_bits = lis2dw12_emul_peek_lpmode(emul);
346346

347-
if (odr_bits > LIS2DW12_ODR_200HZ_VAL) {
347+
if (odr_bits >= LIS2DW12_ODR_50HZ_VAL) {
348348
/* High performance mode, LP mode immaterial */
349349
zassert_equal(mode_bits, LIS2DW12_HIGH_PERF,
350350
"MODE[1:0] should be 0x%x, but got 0x%x",

0 commit comments

Comments
 (0)