summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2015-08-06 11:21:34 -0700
committerAseda Aboagye <aaboagye@google.com>2015-08-07 19:58:18 -0700
commit3a659c1fedb3536a6f04b80b65ff18df6ddb653f (patch)
treeec05d59a317dbf71cfa06a28e7affecb6d44b879
parenta7bf7b9564bf952a229d1cb4bcef5b65be777c93 (diff)
downloadchrome-ec-3a659c1fedb3536a6f04b80b65ff18df6ddb653f.tar.gz
motion_sense: Reduce condition for lid angle calc.
The motion sense task was checking to see that every single motion sensor was ready (active, initialized, and reading), before performing the lid angle calculations. This amount of checking is unnecessary. This commit reduces the condition to only check if the sensors required for lid angle calculation are ready. BUG=chrome-os-partner:36132 BRANCH=None TEST=Build and flash on samus. Verify that the lid still works. TEST=make -j buildall tests Change-Id: Ibaa5cc8358cdcc6023a50aed247fce2e599fef58 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/291301 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/motion_sense.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 465674fb56..cad99aa633 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -411,8 +411,12 @@ void motion_sense_task(void)
int i, ret, wait_us, fifo_flush_needed = 0;
timestamp_t ts_begin_task, ts_end_task;
uint32_t event = 0;
- int rd_cnt;
+ uint16_t ready_status;
struct motion_sensor_t *sensor;
+#ifdef CONFIG_LID_ANGLE
+ const uint16_t lid_angle_sensors = ((1 << CONFIG_LID_ANGLE_SENSOR_BASE)|
+ (1 << CONFIG_LID_ANGLE_SENSOR_LID));
+#endif
#ifdef CONFIG_ACCEL_FIFO
timestamp_t ts_last_int;
#endif
@@ -431,7 +435,7 @@ void motion_sense_task(void)
#endif
do {
ts_begin_task = get_time();
- rd_cnt = 0;
+ ready_status = 0;
for (i = 0; i < motion_sensor_count; ++i) {
sensor = &motion_sensors[i];
@@ -450,7 +454,7 @@ void motion_sense_task(void)
&fifo_flush_needed);
if (ret != EC_SUCCESS)
continue;
- rd_cnt++;
+ ready_status |= (1 << i);
mutex_lock(&g_sensor_mutex);
memcpy(sensor->xyz, sensor->raw_xyz,
sizeof(sensor->xyz));
@@ -464,12 +468,11 @@ void motion_sense_task(void)
#endif
#ifdef CONFIG_LID_ANGLE
/*
- * TODO (crosbug.com/p/36132): Checking for ALL sensors on is
- * overkill. It should just check for ACCEL in BASE and ACCEL
- * in LID, since those are the only ones needed for the lid
- * calculation.
+ * Check to see that the sensors required for lid angle
+ * calculation are ready.
*/
- if (rd_cnt == motion_sensor_count)
+ ready_status &= lid_angle_sensors;
+ if (ready_status == lid_angle_sensors)
motion_lid_calc();
#endif
#ifdef CONFIG_CMD_ACCEL_INFO