From 0c71c4748699f5f2cb1423ffc07d4c852d04b3fc Mon Sep 17 00:00:00 2001 From: Mathew King Date: Thu, 18 Apr 2019 15:28:58 -0600 Subject: motion sense: Calculate loop time based on sensor needs Currently the motion sense loop bases its sleep time based on the fastest active sensor. This method has several flaws: 1. It does not take into account any task switching overhead 2. With a mix of interrupt driven and forced sensors the sleep time gets recalculated every time there is an interrupt causing the loop to oversleep 3. If multiple sensors do not have rates that are in sync the timing of the slower sensor will be off. For example if there was a sensor running at 50 Hz and one running at 20 Hz the slower sensor would end up being sampled at about 16 Hz instead of 20 Hz This change calculates an ideal read time for every forced mode sensor and calculates the sleep time based on the nearest read time. Every time a sensor is read the next read time is calculated based on the ideal read time not the actual read time so that reading does not drift because of system load or other overhead. BUG=b:129159505 TEST=Ran sensor CTS tests on arcada, without this change the magnetometer was failing 50 Hz tests at about 38 Hz with 30% jitter with this change in place 50 Hz was spot on with about 10% jitter BRANCH=none Change-Id: Ia4fccb083713b490518d45e7398eb3be3b957eae Signed-off-by: Mathew King Reviewed-on: https://chromium-review.googlesource.com/1574786 Reviewed-by: Jett Rink --- test/motion_common.h | 1 - 1 file changed, 1 deletion(-) (limited to 'test/motion_common.h') diff --git a/test/motion_common.h b/test/motion_common.h index 3adb9f24e5..45d856d9ef 100644 --- a/test/motion_common.h +++ b/test/motion_common.h @@ -24,7 +24,6 @@ #define TEST_LID_SAMPLE_SIZE (2 * 3) extern enum chipset_state_mask sensor_active; -extern unsigned int motion_interval; extern struct motion_sensor_t motion_sensors[]; extern const unsigned int motion_sensor_count; -- cgit v1.2.1