summaryrefslogtreecommitdiff
path: root/include/vec3.h
diff options
context:
space:
mode:
authorYilun Lin <yllin@google.com>2018-10-04 10:19:57 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-10-04 12:55:53 -0700
commit315aaca9467f49bc432ef5f2de9c0e3bb56f0251 (patch)
tree3ea739aca1db340e93b9daee7958d5afc5c9f31f /include/vec3.h
parentece03ab4d09b157c5e6f3c4fe0446678c0d8684b (diff)
downloadchrome-ec-315aaca9467f49bc432ef5f2de9c0e3bb56f0251.tar.gz
mag_cal: Support fixed-point calculation.
Modified from floating point version. This includes changes to vec3, vec4, mat33, mat44, and mag_cal. Now fixed-point type (fp_*) functions is a function wrapper for both fixed-point and floating point version operations: * define CONFIG_FPU to use floating version mag_cal * undef CONFIG_FPU to use fixed-point version mag_cal Also, add tests for both float and fp types operations. TEST=define CONFIG_FPU; flash on reef; See ARC++ magnetmeter app moving. TEST=undef CONFIG_FPU; flash on reef; See ARC++ magnetmeter app moving. TEST=make runtests -j TEST=make buildalltests -j BUG=b:113364863 BRANCH=None Change-Id: Ie695945acb666912babb2a603e09c602a0624d44 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1260704 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'include/vec3.h')
-rw-r--r--include/vec3.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/include/vec3.h b/include/vec3.h
index 367956b2a1..39514157dd 100644
--- a/include/vec3.h
+++ b/include/vec3.h
@@ -7,11 +7,13 @@
#ifndef __CROS_EC_VEC_3_H
#define __CROS_EC_VEC_3_H
-typedef float floatv3_t[3];
+#include "math_util.h"
-void floatv3_scalar_mul(floatv3_t v, float c);
-float floatv3_dot(const floatv3_t v, const floatv3_t w);
-float floatv3_norm_squared(const floatv3_t v);
-float floatv3_norm(const floatv3_t v);
+typedef float floatv3_t[3];
+typedef fp_t fpv3_t[3];
+void fpv3_scalar_mul(fpv3_t v, fp_t c);
+fp_t fpv3_dot(const fpv3_t v, const fpv3_t w);
+fp_t fpv3_norm_squared(const fpv3_t v);
+fp_t fpv3_norm(const fpv3_t v);
#endif /* __CROS_EC_VEC_3_H */