summaryrefslogtreecommitdiff
path: root/common/mag_cal.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2020-02-01 23:37:56 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-04 03:16:07 +0000
commitd60a962c3a4907d2f18c236015aef7b989e1d384 (patch)
tree93c8fd42c648378a2e623e489225669e033efbf1 /common/mag_cal.c
parentae9aea55280abdf2febb362cd9af7be656614eb2 (diff)
downloadchrome-ec-d60a962c3a4907d2f18c236015aef7b989e1d384.tar.gz
common: mag_cal: Re-add bias inversion
Sensors add offset to raw value. kaza_compute calculate the bias (the hard iron) and it has to be remove from the raw value. Invert the vector in magnetometer calibration code. Fixes: 994af4a65fa7e ("common: mag_cal: update magnetometer to leverage kasa") BUG=b:144027014 BRANCH=none TEST=Check that after successful online calibration, value reported to the host are closer to 0 than before calibration. Change-Id: I6cfd711c82287b1c877912e85d84d2725b063cb2 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2034675 Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'common/mag_cal.c')
-rw-r--r--common/mag_cal.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/common/mag_cal.c b/common/mag_cal.c
index 1dc40e34db..f7b1945933 100644
--- a/common/mag_cal.c
+++ b/common/mag_cal.c
@@ -132,9 +132,9 @@ int mag_cal_update(struct mag_cal_t *moc, const intv3_t v)
/* 4. Kasa sphere fitting */
kasa_compute(&moc->kasa_fit, bias, &radius);
if (radius > MIN_FIT_MAG && radius < MAX_FIT_MAG) {
- moc->bias[X] = FP_TO_INT(bias[X]);
- moc->bias[Y] = FP_TO_INT(bias[Y]);
- moc->bias[Z] = FP_TO_INT(bias[Z]);
+ moc->bias[X] = -FP_TO_INT(bias[X]);
+ moc->bias[Y] = -FP_TO_INT(bias[Y]);
+ moc->bias[Z] = -FP_TO_INT(bias[Z]);
moc->radius = radius;