diff options
author | Sheng-Liang Song <ssl@chromium.org> | 2014-08-13 14:17:07 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-08-26 03:05:55 +0000 |
commit | 7d40063d46aa9a8b6146355ee9be9db775af7f0d (patch) | |
tree | aed9ecdc51ff99d1dcb9b259e6727577986d2be6 /common/math_util.c | |
parent | c598e1ac06c4ceddf28399081ed669eaaa533ae9 (diff) | |
download | chrome-ec-7d40063d46aa9a8b6146355ee9be9db775af7f0d.tar.gz |
samus: added gyro support for lsm6ds0
Changed motion_sense task to assume sensors are unpowered in G3
and re-initialize sensors every time coming out of G3.
Added EC command line test utils as well.
Fixed some bug during unit tests.
BUG=chrome-os-partner:27313,27320
BRANCH=ToT
TEST=Verified on Samus.
Tested with accel EC CLIs
accelread, accelrange, accelrate, accelres
Tested accelcalib, a ACCEL calibration util, and it succeeded.
Tested sysfs interface:
cd /sys/bus/iio/devices/iio:device1
cat in_accel_*_gyro_raw
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Change-Id: I5752b00c03e1942c790ea4f28610fda83fa2dcbc
Reviewed-on: https://chromium-review.googlesource.com/211484
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common/math_util.c')
-rw-r--r-- | common/math_util.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/common/math_util.c b/common/math_util.c index 7487019c44..56acec16dc 100644 --- a/common/math_util.c +++ b/common/math_util.c @@ -84,18 +84,30 @@ float cosine_of_angle_diff(const vector_3_t v1, const vector_3_t v2) return (float)dotproduct / (denominator); } -void rotate(const vector_3_t v, const matrix_3x3_t (* const R), - vector_3_t *res) +/* + * rotate a vector v + * - support input v and output res are the same vector + */ +void rotate(const vector_3_t v, const matrix_3x3_t R, + vector_3_t res) { - (*res)[0] = v[0] * (*R)[0][0] + - v[1] * (*R)[1][0] + - v[2] * (*R)[2][0]; - (*res)[1] = v[0] * (*R)[0][1] + - v[1] * (*R)[1][1] + - v[2] * (*R)[2][1]; - (*res)[2] = v[0] * (*R)[0][2] + - v[1] * (*R)[1][2] + - v[2] * (*R)[2][2]; + vector_3_t t; + + /* copy input v to temp vector t */ + t[0] = v[0]; + t[1] = v[1]; + t[2] = v[2]; + + /* start rotate */ + res[0] = t[0] * R[0][0] + + t[1] * R[1][0] + + t[2] * R[2][0]; + res[1] = t[0] * R[0][1] + + t[1] * R[1][1] + + t[2] * R[2][1]; + res[2] = t[0] * R[0][2] + + t[1] * R[1][2] + + t[2] * R[2][2]; } #ifdef CONFIG_ACCEL_CALIBRATE |