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 | |
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>
-rw-r--r-- | board/arcada_ish/board.c | 21 | ||||
-rw-r--r-- | board/arcada_ish/board.h | 14 |
2 files changed, 30 insertions, 5 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. */ diff --git a/board/arcada_ish/board.h b/board/arcada_ish/board.h index 4dc4f89abb..26592923fc 100644 --- a/board/arcada_ish/board.h +++ b/board/arcada_ish/board.h @@ -25,14 +25,20 @@ #define CONFIG_I2C #define CONFIG_I2C_MASTER -#define CONFIG_ACCEL_LNG2DM /* Base sensor: LNG2DM (uses LIS2DH driver) */ -#define CONFIG_ACCELGYRO_LSM6DSM /* Lid sensor: LSM6DS3 (uses LSM6DSM driver) */ +#define CONFIG_ACCEL_LNG2DM /* Base sensor: LNG2DM + * (uses LIS2DH driver) + */ +#define CONFIG_ACCELGYRO_LSM6DSM /* Lid sensor: LSM6DS3 + * (uses LSM6DSM driver) + */ +#define CONFIG_MAG_LIS2MDL /* Lid sensor: LIS2DML */ +#define CONFIG_MAG_CALIBRATE #define CONFIG_ACCEL_INTERRUPTS #define CONFIG_ACCEL_FIFO 256 #define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3) /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << BASE_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(BASE_ACCEL) | BIT(LID_MAG)) #define CONFIG_ACCEL_LSM6DSM_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL) @@ -106,7 +112,7 @@ enum sensor_id { LID_ACCEL, LID_GYRO, BASE_ACCEL, - /* TODO(b/122281217): Add remain sensors */ + LID_MAG, SENSOR_COUNT }; |