summaryrefslogtreecommitdiff
path: root/driver/mag_bmm150.h
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-07-12 22:26:33 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-07-22 23:50:31 +0000
commit709676bfe1dacc42395d7ba658fcc23455e6d7a0 (patch)
treeb3436d6c3d9dc620eac18d4935ef0778fb5ccf0c /driver/mag_bmm150.h
parentd286fbd7f8a0b94a5d3a022a4cfc679f9f76a357 (diff)
downloadchrome-ec-709676bfe1dacc42395d7ba658fcc23455e6d7a0.tar.gz
driver: bmm150 measurement compensation
Using Bosh reference document, compensate X,Y,Z axis based on internal registers and R HALL values. Change compass unites to 1/16 uT per LSB. Reference: https://github.com/suribi/Thunder-Kernel/blob/master/mediatek/custom/common/kernel/magnetometer/bmm150/bmm150.c BRANCH=smaug TEST=Check compass value in user space. BUG=chrome-os-partner:39900 Change-Id: I0c480521771ef6004ac6e5182cc1d27e82c5bc7c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/285020 Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'driver/mag_bmm150.h')
-rw-r--r--driver/mag_bmm150.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/driver/mag_bmm150.h b/driver/mag_bmm150.h
index 27ca5aebb6..6ae8e679b9 100644
--- a/driver/mag_bmm150.h
+++ b/driver/mag_bmm150.h
@@ -34,4 +34,58 @@
#define BMM150_INT_CTRL 0x4d
+/* Hidden registers for RHALL calculation */
+
+#define BMM150_REGA_DIG_X1 0x5d
+#define BMM150_REGA_DIG_Y1 0x5e
+#define BMM150_REGA_DIG_Z4_LSB 0x62
+#define BMM150_REGA_DIG_Z4_MSB 0x63
+#define BMM150_REGA_DIG_X2 0x64
+#define BMM150_REGA_DIG_Y2 0x65
+#define BMM150_REGA_DIG_Z2_LSB 0x68
+#define BMM150_REGA_DIG_Z2_MSB 0x69
+#define BMM150_REGA_DIG_Z1_LSB 0x6a
+#define BMM150_REGA_DIG_Z1_MSB 0x6b
+#define BMM150_REGA_DIG_XYZ1_LSB 0x6c
+#define BMM150_REGA_DIG_XYZ1_MSB 0x6d
+#define BMM150_REGA_DIG_Z3_LSB 0x6e
+#define BMM150_REGA_DIG_Z3_MSB 0x6f
+#define BMM150_REGA_DIG_XY2 0x70
+#define BMM150_REGA_DIG_XY1 0x71
+
+/* Overflow */
+
+#define BMM150_FLIP_OVERFLOW_ADCVAL (-4096)
+#define BMM150_HALL_OVERFLOW_ADCVAL (-16384)
+#define BMM150_OVERFLOW_OUTPUT (0x8000)
+
+
+struct bmm150_comp_registers {
+ /* Local copy of the compensation registers. */
+ int8_t dig1[2];
+ int8_t dig2[2];
+
+ uint16_t dig_z1;
+ int16_t dig_z2;
+ int16_t dig_z3;
+ int16_t dig_z4;
+
+ uint8_t dig_xy1;
+ int8_t dig_xy2;
+
+ uint16_t dig_xyz1;
+};
+
+#define BMM150_COMP_REG(_s) \
+ (&BMI160_GET_DATA(_s)->comp_regs)
+
+/* Specific initialization of BMM150 when behing BMI160 */
+int bmm150_init(const struct motion_sensor_t *s);
+
+/* Command to normalize and apply temperature compensation */
+void bmm150_normalize(const struct motion_sensor_t *s,
+ vector_3_t v,
+ uint8_t *data);
+
+
#endif /* __CROS_EC_MAG_BMM150_H */