mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-12 19:04:59 +00:00
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 <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291990 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
0b79533f88
commit
179d5d3c83
@@ -400,9 +400,10 @@ static int set_data_rate(const struct motion_sensor_t *s,
|
||||
}
|
||||
break;
|
||||
case MOTIONSENSE_TYPE_MAG:
|
||||
if (reg_val > BMI160_ODR_800HZ) {
|
||||
reg_val = BMI160_ODR_800HZ;
|
||||
normalized_rate = 800000;
|
||||
/* We use the regular preset we can go about 100Hz */
|
||||
if (reg_val > BMI160_ODR_100HZ) {
|
||||
reg_val = BMI160_ODR_100HZ;
|
||||
normalized_rate = 100000;
|
||||
} else if (reg_val < BMI160_ODR_0_78HZ) {
|
||||
reg_val = BMI160_ODR_0_78HZ;
|
||||
normalized_rate = 780;
|
||||
|
||||
@@ -172,6 +172,8 @@ enum fifo_header {
|
||||
/* odr = 100 / (1 << (8 - reg)) ,within limit */
|
||||
#define BMI160_ODR_0_78HZ 0x01
|
||||
#define BMI160_ODR_25HZ 0x06
|
||||
#define BMI160_ODR_50HZ 0x07
|
||||
#define BMI160_ODR_100HZ 0x08
|
||||
#define BMI160_ODR_800HZ 0x0b
|
||||
#define BMI160_ODR_1600HZ 0x0c
|
||||
#define BMI160_ODR_3200HZ 0x0d
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -34,8 +34,20 @@
|
||||
|
||||
#define BMM150_INT_CTRL 0x4d
|
||||
|
||||
/* Hidden registers for RHALL calculation */
|
||||
#define BMM150_REPXY 0x51
|
||||
#define BMM150_LOW_POWER_nXY 3
|
||||
#define BMM150_REGULAR_nXY 9
|
||||
#define BMM150_ENHANCED_nXY 15
|
||||
#define BMM150_HIGH_ACCURACY_nXY 47
|
||||
#define BMM150_REPZ 0x52
|
||||
#define BMM150_LOW_POWER_nZ 3
|
||||
#define BMM150_REGULAR_nZ 15
|
||||
#define BMM150_ENHANCED_nZ 27
|
||||
#define BMM150_HIGH_ACCURACY_nZ 83
|
||||
|
||||
#define BMM150_REP(_preset, _axis) CONCAT4(BMM150_, _preset, _n, _axis)
|
||||
|
||||
/* Hidden registers for RHALL calculation */
|
||||
#define BMM150_REGA_DIG_X1 0x5d
|
||||
#define BMM150_REGA_DIG_Y1 0x5e
|
||||
#define BMM150_REGA_DIG_Z4_LSB 0x62
|
||||
|
||||
Reference in New Issue
Block a user