From 179d5d3c833433b07530b136a55085a6d22cbeee Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Thu, 6 Aug 2015 15:42:44 -0700 Subject: bmm150: add measurement repetition To reduce noise the magnetometer measures in burst and average the data. Use "regular" presets: max frequency is limited to 100Hz. Using a more precise presets limit frequency to no more than 50Hz. BRANCH=smaug TEST=Check magnetomter still works. BUG=chrome-os-partner:39900 Change-Id: Ida6af86f6c207cc91e11378c129032f6d9e6b9ea Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/291990 Reviewed-by: Sheng-liang Song --- driver/mag_bmm150.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'driver/mag_bmm150.c') diff --git a/driver/mag_bmm150.c b/driver/mag_bmm150.c index fb2d5c7108..59ce76785e 100644 --- a/driver/mag_bmm150.c +++ b/driver/mag_bmm150.c @@ -115,6 +115,14 @@ int bmm150_init(const struct motion_sensor_t *s) BMI150_READ_16BIT_COM_REG(regs->dig_z4, BMM150_REGA_DIG_Z4_LSB); BMI150_READ_16BIT_COM_REG(regs->dig_xyz1, BMM150_REGA_DIG_XYZ1_LSB); + + /* Set the repetition in "Regular Preset" */ + raw_mag_write8(s->addr, BMM150_REPXY, 1 + 2 * BMM150_REP(REGULAR, XY)); + raw_mag_write8(s->addr, BMM150_REPZ, 1 + BMM150_REP(REGULAR, Z)); + ret = raw_mag_read8(s->addr, BMM150_REPXY, &val); + CPRINTS("repxy: 0x%02x", val); + ret = raw_mag_read8(s->addr, BMM150_REPZ, &val); + CPRINTS("repz: 0x%02x", val); /* * Set the compass forced mode, to sleep after each measure. */ -- cgit v1.2.1