diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-11-17 13:05:58 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-11-18 13:33:27 -0800 |
commit | 420099f74976b3af1f4b24dc24b9fec461b1037b (patch) | |
tree | ed28845a84cccfd5083902c5a12b36b4bb015247 | |
parent | 192d0b4da107aa65c3e340e883034811601cbe17 (diff) | |
download | chrome-ec-420099f74976b3af1f4b24dc24b9fec461b1037b.tar.gz |
motion: Change units of ec_rate from us to ms.
To ease finer calculation of ec rate change units from
ms to us.
BRANCH=smaug
BUG=b:24367625
TEST=compile
Change-Id: I52057c8ca1b1180a64b58d1ba0af9ec53f40b026
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312984
-rw-r--r-- | board/glados/board.c | 6 | ||||
-rw-r--r-- | board/kunimitsu/board.c | 4 | ||||
-rw-r--r-- | board/lars/board.c | 4 | ||||
-rw-r--r-- | board/samus/board.c | 10 | ||||
-rw-r--r-- | board/strago/board.c | 4 | ||||
-rw-r--r-- | board/wheatley/board.c | 4 | ||||
-rw-r--r-- | common/motion_sense.c | 22 | ||||
-rw-r--r-- | include/motion_sense.h | 8 | ||||
-rw-r--r-- | test/motion_lid.c | 8 |
9 files changed, 35 insertions, 35 deletions
diff --git a/board/glados/board.c b/board/glados/board.c index 0ea36b3e1e..490d8ebb52 100644 --- a/board/glados/board.c +++ b/board/glados/board.c @@ -517,7 +517,7 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* Sensor off in S3/S5 */ [SENSOR_CONFIG_EC_S3] = { @@ -582,12 +582,12 @@ struct motion_sensor_t motion_sensors[] = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* unused */ [SENSOR_CONFIG_EC_S3] = { diff --git a/board/kunimitsu/board.c b/board/kunimitsu/board.c index 07c561715e..287e4bcd91 100644 --- a/board/kunimitsu/board.c +++ b/board/kunimitsu/board.c @@ -248,7 +248,7 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 100000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* Sensor off in S3/S5 */ [SENSOR_CONFIG_EC_S3] = { @@ -282,7 +282,7 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 100000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* Sensor off in S3/S5 */ [SENSOR_CONFIG_EC_S3] = { diff --git a/board/lars/board.c b/board/lars/board.c index c2c1c62461..bf96d2b8bb 100644 --- a/board/lars/board.c +++ b/board/lars/board.c @@ -207,7 +207,7 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 100000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* Sensor off in S3/S5 */ [SENSOR_CONFIG_EC_S3] = { @@ -241,7 +241,7 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 100000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* Sensor off in S3/S5 */ [SENSOR_CONFIG_EC_S3] = { diff --git a/board/samus/board.c b/board/samus/board.c index 83b9b58309..84cadf1042 100644 --- a/board/samus/board.c +++ b/board/samus/board.c @@ -321,16 +321,16 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 119000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* Used for double tap */ [SENSOR_CONFIG_EC_S3] = { .odr = TAP_ODR | ROUND_UP_FLAG, - .ec_rate = CONFIG_GESTURE_SAMPLING_INTERVAL_MS + .ec_rate = CONFIG_GESTURE_SAMPLING_INTERVAL_MS * MSEC, }, [SENSOR_CONFIG_EC_S5] = { .odr = TAP_ODR | ROUND_UP_FLAG, - .ec_rate = CONFIG_GESTURE_SAMPLING_INTERVAL_MS + .ec_rate = CONFIG_GESTURE_SAMPLING_INTERVAL_MS * MSEC, }, }, }, @@ -355,7 +355,7 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 100000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* unused */ [SENSOR_CONFIG_EC_S3] = { @@ -389,7 +389,7 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 119000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* unused */ [SENSOR_CONFIG_EC_S3] = { diff --git a/board/strago/board.c b/board/strago/board.c index 270882b8b0..ae4cb51ea6 100644 --- a/board/strago/board.c +++ b/board/strago/board.c @@ -236,7 +236,7 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 100000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* Sensor off in S3/S5 */ [SENSOR_CONFIG_EC_S3] = { @@ -270,7 +270,7 @@ struct motion_sensor_t motion_sensors[] = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 100000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* Sensor off in S3/S5 */ [SENSOR_CONFIG_EC_S3] = { diff --git a/board/wheatley/board.c b/board/wheatley/board.c index e63ac3b89e..d00bcc623d 100644 --- a/board/wheatley/board.c +++ b/board/wheatley/board.c @@ -535,12 +535,12 @@ struct motion_sensor_t motion_sensors[] = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100, + .ec_rate = 100 * MSEC, }, /* unused */ [SENSOR_CONFIG_EC_S3] = { diff --git a/common/motion_sense.c b/common/motion_sense.c index ded4ad4832..775de8385b 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -246,12 +246,12 @@ static int motion_sense_select_ec_rate( int rate = BASE_ODR(sensor->config[config_id].odr); /* we have to run ec at the sensor frequency rate.*/ if (rate > 0) - return 1000000 / rate; + return SECOND * 1000 / rate; else return 0; } else #endif - return sensor->config[config_id].ec_rate; + return sensor->config[config_id].ec_rate; } /* motion_sense_ec_rate @@ -275,7 +275,7 @@ static int motion_sense_ec_rate(struct motion_sensor_t *sensor) if (ec_rate_from_cfg != 0) if (ec_rate == 0 || ec_rate_from_cfg < ec_rate) ec_rate = ec_rate_from_cfg; - return ec_rate * MSEC; + return ec_rate; } /* @@ -288,7 +288,7 @@ static int motion_sense_ec_rate(struct motion_sensor_t *sensor) */ static int motion_sense_set_motion_intervals(void) { - int i, sensor_ec_rate, ec_rate = 0, ec_int_rate_ms = 0, wake_up = 0; + int i, sensor_ec_rate, ec_rate = 0, ec_int_rate = 0, wake_up = 0; struct motion_sensor_t *sensor; for (i = 0; i < motion_sensor_count; ++i) { sensor = &motion_sensors[i]; @@ -307,9 +307,9 @@ static int motion_sense_set_motion_intervals(void) sensor_ec_rate = motion_sense_select_ec_rate( sensor, SENSOR_CONFIG_AP); - if (ec_int_rate_ms == 0 || - (sensor_ec_rate && sensor_ec_rate < ec_int_rate_ms)) - ec_int_rate_ms = sensor_ec_rate; + if (ec_int_rate == 0 || + (sensor_ec_rate && sensor_ec_rate < ec_int_rate)) + ec_int_rate = sensor_ec_rate; } /* * Wake up the motion sense task: we want to sensor task to take @@ -318,10 +318,10 @@ static int motion_sense_set_motion_intervals(void) if ((motion_interval == 0 || (ec_rate > 0 && motion_interval > ec_rate)) || (motion_int_interval == 0 || - (ec_int_rate_ms > 0 && motion_int_interval > ec_int_rate_ms))) + (ec_int_rate > 0 && motion_int_interval > ec_int_rate))) wake_up = 1; motion_interval = ec_rate; - motion_int_interval = ec_int_rate_ms * MSEC; + motion_int_interval = ec_int_rate; if (wake_up) task_wake(TASK_ID_MOTIONSENSE); return motion_interval; @@ -903,8 +903,8 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args) sensor->config[SENSOR_CONFIG_AP].ec_rate = 0; else sensor->config[SENSOR_CONFIG_AP].ec_rate = - MAX(in->ec_rate.data, - motion_min_interval / MSEC); + MAX(in->ec_rate.data * MSEC, + motion_min_interval); /* Bound the new sampling rate. */ motion_sense_set_motion_intervals(); diff --git a/include/motion_sense.h b/include/motion_sense.h index 89203dd040..b16c309db7 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -49,15 +49,15 @@ struct motion_data_t { /* * data rate the sensor will measure, in mHz: 0 suspended. * MSB is used to know if we are rounding up. - * */ - unsigned odr; - /* delay between collection by EC, in ms. + */ + unsigned int odr; + /* delay between collection by EC, in us. * For non FIFO sensor, should be need 1e6/odr to * collect events. * For sensor with FIFO, can be much longer. * 0: no collection. */ - unsigned short ec_rate; + unsigned int ec_rate; }; struct motion_sensor_t { diff --git a/test/motion_lid.c b/test/motion_lid.c index 5fdd26b7fd..224b12a26b 100644 --- a/test/motion_lid.c +++ b/test/motion_lid.c @@ -26,7 +26,7 @@ extern unsigned motion_interval; * Period in us for the motion task period. * The task will read the vectors at that interval */ -#define TEST_LID_EC_RATE (10) +#define TEST_LID_EC_RATE (10 * MSEC) /* * Time in ms to wait for the task to read the vectors. @@ -186,10 +186,10 @@ static void wait_for_valid_sample(void) uint8_t *lpc_status = host_get_memmap(EC_MEMMAP_ACC_STATUS); sample = *lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK; - msleep(TEST_LID_EC_RATE); + usleep(TEST_LID_EC_RATE); task_wake(TASK_ID_MOTIONSENSE); while ((*lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK) == sample) - msleep(TEST_LID_SLEEP_RATE); + usleep(TEST_LID_SLEEP_RATE); } static int test_lid_angle(void) @@ -210,7 +210,7 @@ static int test_lid_angle(void) msleep(1000); TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S0); TEST_ASSERT(accel_get_data_rate(lid) == (119000 | ROUND_UP_FLAG)); - TEST_ASSERT(motion_interval == TEST_LID_EC_RATE * MSEC); + TEST_ASSERT(motion_interval == TEST_LID_EC_RATE); /* * Set the base accelerometer as if it were sitting flat on a desk |