summaryrefslogtreecommitdiff
path: root/board/arcada_ish
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-03-08 10:01:29 -0700
committerJett Rink <jettrink@chromium.org>2019-03-18 22:18:49 +0000
commit53d08058ce107f0529c45f910d84e9d5de5620e6 (patch)
treef209c6da08aec0a6941d23f34955c9528c77f90f /board/arcada_ish
parent6c022cf36fb039f6edcf3c22d0a1a0ea9e4f0fae (diff)
downloadchrome-ec-53d08058ce107f0529c45f910d84e9d5de5620e6.tar.gz
arcada_ish: add base lis2dh accel sensor
Add base accelerometer to arcada_ish image. Lid angle detection using base and lid accel sensors in EC is still pending. With draft CLs, I successfully calibrated this sensor and calculated lid angle successfully using the AccelerometersLidAngleTest factory test in the AP. BRANCH=none BUG=b:122281217 TEST=sensors is calibratable with normal factory calibration process and usable for lid angle calculation using factory tests. Change-Id: I1c512cd4016d75c5bfece12475787189a99e6ee0 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1512133 Reviewed-by: Mathew King <mathewk@chromium.org>
Diffstat (limited to 'board/arcada_ish')
-rw-r--r--board/arcada_ish/board.c49
-rw-r--r--board/arcada_ish/board.h12
2 files changed, 56 insertions, 5 deletions
diff --git a/board/arcada_ish/board.c b/board/arcada_ish/board.c
index 6ab110e03f..d8fd2f24d2 100644
--- a/board/arcada_ish/board.c
+++ b/board/arcada_ish/board.c
@@ -5,8 +5,9 @@
/* Arcada ISH board-specific configuration */
-#include "accelgyro_lsm6dsm.h"
#include "console.h"
+#include "driver/accel_lis2dh.h"
+#include "driver/accelgyro_lsm6dsm.h"
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
@@ -29,8 +30,18 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* Sensor config */
static struct mutex g_lid_mutex;
+static struct mutex g_base_mutex;
+
/* sensor private data */
static struct lsm6dsm_data lsm6dsm_a_data;
+static struct stprivate_data g_lis2dh_data;
+
+/* Matrix to rotate lid sensor into standard reference frame */
+const mat33_fp_t lid_rot_ref = {
+ { FLOAT_TO_FP(-1), 0, 0},
+ { 0, FLOAT_TO_FP(-1), 0},
+ { 0, 0, FLOAT_TO_FP(1)}
+};
/* Drivers */
struct motion_sensor_t motion_sensors[] = {
@@ -46,7 +57,7 @@ struct motion_sensor_t motion_sensors[] = {
MOTIONSENSE_TYPE_ACCEL),
.port = I2C_PORT_SENSOR,
.addr = LSM6DSM_ADDR1,
- .rot_standard_ref = NULL, /* TODO rotate correctly */
+ .rot_standard_ref = &lid_rot_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
.max_frequency = LSM6DSM_ODR_MAX_VAL,
@@ -54,7 +65,10 @@ struct motion_sensor_t motion_sensors[] = {
/* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S0] = {
.odr = 13000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
+ },
+ /* Sensor on for lid angle detection */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 13000 | ROUND_UP_FLAG,
},
},
},
@@ -76,6 +90,35 @@ struct motion_sensor_t motion_sensors[] = {
.min_frequency = LSM6DSM_ODR_MIN_VAL,
.max_frequency = LSM6DSM_ODR_MAX_VAL,
},
+
+ [BASE_ACCEL] = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_LNG2DM,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &lis2dh_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_lis2dh_data,
+ .port = I2C_PORT_SENSOR,
+ .addr = LNG2DM_ADDR0,
+ .rot_standard_ref = NULL, /* Identity matrix */
+ /* We only use 2g because its resolution is only 8-bits */
+ .default_range = 2, /* g */
+ .min_frequency = LIS2DH_ODR_MIN_VAL,
+ .max_frequency = LIS2DH_ODR_MAX_VAL,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ /* Sensor on for lid angle detection */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ },
+ },
+
/* TODO(b/122281217): Add remain sensors */
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
diff --git a/board/arcada_ish/board.h b/board/arcada_ish/board.h
index fbc8ad1c8a..fe5e82777a 100644
--- a/board/arcada_ish/board.h
+++ b/board/arcada_ish/board.h
@@ -31,11 +31,14 @@
#define CONFIG_I2C
#define CONFIG_I2C_MASTER
-#define CONFIG_ACCELGYRO_LSM6DSM /* For LSM6DS3 */
+#define CONFIG_ACCEL_LNG2DM /* Base sensor: LNG2DM (uses LIS2DH driver) */
+#define CONFIG_ACCELGYRO_LSM6DSM /* Lid sensor: LSM6DS3 (uses LSM6DSM driver) */
#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_LSM6DSM_INT_EVENT TASK_EVENT_CUSTOM(1 << 2)
@@ -83,10 +86,15 @@
#include "gpio_signal.h"
#include "registers.h"
-/* Motion sensors */
+/* Motion sensors
+ *
+ * Note: Since we aren't using LPC memory map to transmit sensor data, the
+ * order of this enum does not need to be accel, accel, gyro
+ */
enum sensor_id {
LID_ACCEL,
LID_GYRO,
+ BASE_ACCEL,
/* TODO(b/122281217): Add remain sensors */
SENSOR_COUNT
};