summaryrefslogtreecommitdiff
path: root/driver/mag_bmm150.h
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-09-11 12:02:26 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-10-13 05:28:54 -0700
commit828b55a7358ad5ec8bc27552bfb280eb173dd453 (patch)
treeb9430d2bf624ee2b6976eed211696b50ae56decb /driver/mag_bmm150.h
parent0647f66f81de880af603a7fb70f57159519782ac (diff)
downloadchrome-ec-828b55a7358ad5ec8bc27552bfb280eb173dd453.tar.gz
common: Add magnetometer online calibration.
Code for hard iron calibration: Every seconds (or faster if enough samples), find a sphere that fit the compass data. Based on Android code. BRANCH=smaug BUG=chrome-os-partner:39900 TEST=Check hard-iron bias is removed. Works better outside. Change-Id: Iab479d5113b6560b4f01b0fd87373d2eecdb9b54 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/299583 Reviewed-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'driver/mag_bmm150.h')
-rw-r--r--driver/mag_bmm150.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/driver/mag_bmm150.h b/driver/mag_bmm150.h
index f3a0a38f50..4a6af7ee0d 100644
--- a/driver/mag_bmm150.h
+++ b/driver/mag_bmm150.h
@@ -9,6 +9,7 @@
#define __CROS_EC_MAG_BMM150_H
#include "accelgyro.h"
+#include "mag_cal.h"
#define BMM150_ADDR0 0x20
#define BMM150_ADDR1 0x22
@@ -86,13 +87,17 @@ struct bmm150_comp_registers {
int8_t dig_xy2;
uint16_t dig_xyz1;
-
- /* Factory or online calibration */
- int16_t offset[3];
};
+struct bmm150_private_data {
+ struct bmm150_comp_registers comp;
+ struct mag_cal_t cal;
+};
#define BMM150_COMP_REG(_s) \
- (&BMI160_GET_DATA(_s)->comp_regs)
+ (&BMI160_GET_DATA(_s)->compass.comp)
+
+#define BMM150_CAL(_s) \
+ (&BMI160_GET_DATA(_s)->compass.cal)
/* Specific initialization of BMM150 when behing BMI160 */
int bmm150_init(const struct motion_sensor_t *s);