diff options
author | Yuval Peress <peress@chromium.org> | 2019-03-22 11:00:39 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-24 15:52:10 -0700 |
commit | cf02f0076fbc0afbde2394fd05ce097c33aaffdb (patch) | |
tree | 273fbdbeb072cdb59c69162d06c47cb0f0540760 /board/arcada_ish/board.c | |
parent | d2ac74c21848c1cec16d5e72d28f93eb15c5d869 (diff) | |
download | chrome-ec-cf02f0076fbc0afbde2394fd05ce097c33aaffdb.tar.gz |
board: arcada_ish: add lis2mdl magnetometer
BRANCH=None
BUG=b:128619310
TEST=Validated that iio:device4 is present
TEST=Validate that cat **/iio:device4/in_magn_*_raw prints correct
values
TEST=Ran some CTS tests and verified magnetometer tests pass.
TEST=Opened an android compass app and raw magnetometer reading
app and verified that data is correct.
Change-Id: I79ff5ba8de12686d61e7701ac83689924c4de6c4
Signed-off-by: Yuval Peress <peress@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1535428
Commit-Ready: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Mathew King <mathewk@chromium.org>
Diffstat (limited to 'board/arcada_ish/board.c')
-rw-r--r-- | board/arcada_ish/board.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/board/arcada_ish/board.c b/board/arcada_ish/board.c index 22533e0d8c..0693548be1 100644 --- a/board/arcada_ish/board.c +++ b/board/arcada_ish/board.c @@ -8,6 +8,7 @@ #include "console.h" #include "driver/accel_lis2dh.h" #include "driver/accelgyro_lsm6dsm.h" +#include "driver/mag_lis2mdl.h" #include "gpio.h" #include "hooks.h" #include "host_command.h" @@ -31,11 +32,13 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* Sensor config */ static struct mutex g_lid_mutex; +static struct mutex g_lid_mag_mutex; static struct mutex g_base_mutex; /* sensor private data */ static struct lsm6dsm_data lsm6dsm_a_data; static struct stprivate_data g_lis2dh_data; +static struct lis2mdl_private_data lis2mdl_a_data; /* Matrix to rotate lid sensor into standard reference frame */ const mat33_fp_t lid_rot_ref = { @@ -120,8 +123,24 @@ struct motion_sensor_t motion_sensors[] = { }, }, - /* TODO(b/122281217): Add remain sensors */ + [LID_MAG] = { + .name = "Lid Mag", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_LIS2MDL, + .type = MOTIONSENSE_TYPE_MAG, + .location = MOTIONSENSE_LOC_LID, + .drv = &lis2mdl_drv, + .mutex = &g_lid_mag_mutex, + .drv_data = &lis2mdl_a_data, + .port = I2C_PORT_SENSOR, + .addr = LIS2MDL_ADDR, + .default_range = 1 << 11, /* 16LSB / uT, fixed */ + .rot_standard_ref = NULL, /* TODO rotate correctly */ + .min_frequency = LIS2MDL_ODR_MIN_VAL, + .max_frequency = LIS2MDL_ODR_MAX_VAL, + }, }; + const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); /* Initialize board. */ |