summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--baseboard/grunt/baseboard.h1
-rw-r--r--baseboard/zork/baseboard.h1
-rw-r--r--board/atlas/board.h1
-rw-r--r--board/cheza/board.h1
-rw-r--r--board/coral/board.h1
-rw-r--r--board/elm/board.c79
-rw-r--r--board/elm/board.h10
-rw-r--r--board/eve/board.h1
-rw-r--r--board/glados/board.c114
-rw-r--r--board/glados/board.h11
-rw-r--r--board/kukui/board.h1
-rw-r--r--board/mchpevb1/board.c112
-rw-r--r--board/mchpevb1/board.h17
-rw-r--r--board/nami/board.h1
-rw-r--r--board/nautilus/board.h1
-rw-r--r--board/nocturne/board.h1
-rw-r--r--board/nucleo-f411re/board.h1
-rw-r--r--board/oak/board.c113
-rw-r--r--board/oak/board.h15
-rw-r--r--board/poppy/board.h1
-rw-r--r--board/rainier/board.h1
-rw-r--r--board/rammus/board.h1
-rw-r--r--board/reef/board.h1
-rw-r--r--board/reef_mchp/board.h1
-rw-r--r--board/samus/board.h11
-rw-r--r--board/scarlet/board.h1
-rw-r--r--board/strago/board.c86
-rw-r--r--board/strago/board.h10
-rw-r--r--test/motion_common.c4
-rw-r--r--test/motion_lid.c118
-rw-r--r--test/test_config.h11
31 files changed, 410 insertions, 318 deletions
diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h
index 8dc4a98c01..89345b09f9 100644
--- a/baseboard/grunt/baseboard.h
+++ b/baseboard/grunt/baseboard.h
@@ -219,6 +219,7 @@ enum sensor_id {
LID_ACCEL,
BASE_ACCEL,
BASE_GYRO,
+ SENSOR_COUNT,
};
/*
diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h
index 2320450b75..bba818aabf 100644
--- a/baseboard/zork/baseboard.h
+++ b/baseboard/zork/baseboard.h
@@ -219,6 +219,7 @@ enum sensor_id {
LID_ACCEL,
BASE_ACCEL,
BASE_GYRO,
+ SENSOR_COUNT,
};
/*
diff --git a/board/atlas/board.h b/board/atlas/board.h
index 636ff2c982..1f261144f7 100644
--- a/board/atlas/board.h
+++ b/board/atlas/board.h
@@ -207,6 +207,7 @@ enum pwm_channel {
enum sensor_id {
LID_ALS,
+ SENSOR_COUNT,
};
/* LID_ALS needs to be polled */
diff --git a/board/cheza/board.h b/board/cheza/board.h
index f9adee2690..983316e062 100644
--- a/board/cheza/board.h
+++ b/board/cheza/board.h
@@ -197,6 +197,7 @@ enum sensor_id {
LID_ACCEL = 0,
LID_GYRO,
LID_ALS,
+ SENSOR_COUNT,
};
enum pwm_channel {
diff --git a/board/coral/board.h b/board/coral/board.h
index 3a93a88e7c..f9dfb4e174 100644
--- a/board/coral/board.h
+++ b/board/coral/board.h
@@ -269,6 +269,7 @@ enum sensor_id {
LID_ACCEL,
BASE_ACCEL,
BASE_GYRO,
+ SENSOR_COUNT,
};
#define CONFIG_HOSTCMD_SKUID
diff --git a/board/elm/board.c b/board/elm/board.c
index f2d567ace7..312caa6509 100644
--- a/board/elm/board.c
+++ b/board/elm/board.c
@@ -450,50 +450,53 @@ const mat33_fp_t lid_standard_ref = {
struct kionix_accel_data g_kx022_data[2];
struct motion_sensor_t motion_sensors[] = {
- {.name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_KX022,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &kionix_accel_drv,
- .mutex = &g_kx022_mutex[0],
- .drv_data = &g_kx022_data[0],
- .addr = 1, /* SPI, device ID 0 */
- .rot_standard_ref = &base_standard_ref,
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = KX022_ACCEL_MIN_FREQ,
- .max_frequency = KX022_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
+ [BASE_ACCEL] = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_KX022,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_kx022_mutex[0],
+ .drv_data = &g_kx022_data[0],
+ .addr = 1, /* SPI, device ID 0 */
+ .rot_standard_ref = &base_standard_ref,
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = KX022_ACCEL_MIN_FREQ,
+ .max_frequency = KX022_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
},
- },
},
- {.name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_KX022,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &kionix_accel_drv,
- .mutex = &g_kx022_mutex[1],
- .drv_data = &g_kx022_data[1],
- .addr = 3, /* SPI, device ID 1 */
- .rot_standard_ref = &lid_standard_ref,
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = KX022_ACCEL_MIN_FREQ,
- .max_frequency = KX022_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
+ [LID_ACCEL] = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_KX022,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_kx022_mutex[1],
+ .drv_data = &g_kx022_data[1],
+ .addr = 3, /* SPI, device ID 1 */
+ .rot_standard_ref = &lid_standard_ref,
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = KX022_ACCEL_MIN_FREQ,
+ .max_frequency = KX022_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
},
- },
},
};
+
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
void lid_angle_peripheral_enable(int enable)
diff --git a/board/elm/board.h b/board/elm/board.h
index 8d1283244c..0de9730454 100644
--- a/board/elm/board.h
+++ b/board/elm/board.h
@@ -19,8 +19,8 @@
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
#define CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_SENSOR_BASE 0
-#define CONFIG_LID_ANGLE_SENSOR_LID 1
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
#define CONFIG_LID_ANGLE_UPDATE
#define CONFIG_ADC
@@ -215,6 +215,12 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
+enum sensor_id {
+ BASE_ACCEL,
+ LID_ACCEL,
+ SENSOR_COUNT,
+};
+
/* TODO: determine the following board specific type-C power constants */
/*
* delay to turn on the power supply max is ~16ms.
diff --git a/board/eve/board.h b/board/eve/board.h
index fce7c0de91..311cc97955 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -269,6 +269,7 @@ enum sensor_id {
BASE_GYRO,
BASE_MAG,
LID_LIGHT,
+ SENSOR_COUNT,
};
enum adc_channel {
diff --git a/board/glados/board.c b/board/glados/board.c
index e1a5c566fc..48e1acac8b 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -444,65 +444,69 @@ struct motion_sensor_t motion_sensors[] = {
* Requirement: accelerometer sensor must init before gyro sensor
* DO NOT change the order of the following table.
*/
- {.name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
- .rot_standard_ref = NULL, /* Identity matrix. */
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = BMI160_ACCEL_MIN_FREQ,
- .max_frequency = BMI160_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- },
+ [BASE_ACCEL] = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_BMI160,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi160_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_bmi160_data,
+ .port = I2C_PORT_ACCEL,
+ .addr = BMI160_ADDR0,
+ .rot_standard_ref = NULL, /* Identity matrix. */
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = BMI160_ACCEL_MIN_FREQ,
+ .max_frequency = BMI160_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ },
},
- {.name = "Base Gyro",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_GYRO,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
- .default_range = 1000, /* dps */
- .rot_standard_ref = NULL, /* Identity Matrix. */
- .min_frequency = BMI160_GYRO_MIN_FREQ,
- .max_frequency = BMI160_GYRO_MAX_FREQ,
+ [BASE_GYRO] = {
+ .name = "Base Gyro",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_BMI160,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi160_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_bmi160_data,
+ .port = I2C_PORT_ACCEL,
+ .addr = BMI160_ADDR0,
+ .default_range = 1000, /* dps */
+ .rot_standard_ref = NULL, /* Identity Matrix. */
+ .min_frequency = BMI160_GYRO_MIN_FREQ,
+ .max_frequency = BMI160_GYRO_MAX_FREQ,
},
- {.name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_KX022,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &kionix_accel_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_kx022_data,
- .port = I2C_PORT_ACCEL,
- .addr = KX022_ADDR1,
- .rot_standard_ref = NULL, /* Identity matrix. */
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = KX022_ACCEL_MIN_FREQ,
- .max_frequency = KX022_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
+ [LID_ACCEL] = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_KX022,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_kx022_data,
+ .port = I2C_PORT_ACCEL,
+ .addr = KX022_ADDR1,
+ .rot_standard_ref = NULL, /* Identity matrix. */
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = KX022_ACCEL_MIN_FREQ,
+ .max_frequency = KX022_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ },
},
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
diff --git a/board/glados/board.h b/board/glados/board.h
index 04c5450eb2..c58c2f87a7 100644
--- a/board/glados/board.h
+++ b/board/glados/board.h
@@ -50,8 +50,8 @@
#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_LED_COMMON
#define CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_SENSOR_BASE 0
-#define CONFIG_LID_ANGLE_SENSOR_LID 2
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
#define CONFIG_LID_SWITCH
#define CONFIG_LOW_POWER_IDLE
#define CONFIG_LTO
@@ -188,6 +188,13 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
+enum sensor_id {
+ BASE_ACCEL,
+ BASE_GYRO,
+ LID_ACCEL,
+ SENSOR_COUNT,
+};
+
/* Light sensors */
enum als_id {
ALS_OPT3001 = 0,
diff --git a/board/kukui/board.h b/board/kukui/board.h
index e49147a2b5..491b0ea29a 100644
--- a/board/kukui/board.h
+++ b/board/kukui/board.h
@@ -243,6 +243,7 @@ enum sensor_id {
LID_GYRO,
LID_MAG,
VSYNC,
+ SENSOR_COUNT,
};
#include "gpio_signal.h"
diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c
index 79226d7d71..ed5a661224 100644
--- a/board/mchpevb1/board.c
+++ b/board/mchpevb1/board.c
@@ -929,64 +929,68 @@ struct motion_sensor_t motion_sensors[] = {
* Requirement: accelerometer sensor must init before gyro sensor
* DO NOT change the order of the following table.
*/
- {.name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
- .rot_standard_ref = NULL, /* Identity matrix. */
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = BMI160_ACCEL_MIN_FREQ,
- .max_frequency = BMI160_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- },
+ [BASE_ACCEL] = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_BMI160,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi160_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_bmi160_data,
+ .port = CONFIG_SPI_ACCEL_PORT,
+ .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .rot_standard_ref = NULL, /* Identity matrix. */
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = BMI160_ACCEL_MIN_FREQ,
+ .max_frequency = BMI160_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ },
},
- {.name = "Base Gyro",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_GYRO,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
- .default_range = 1000, /* dps */
- .rot_standard_ref = NULL, /* Identity Matrix. */
- .min_frequency = BMI160_GYRO_MIN_FREQ,
- .max_frequency = BMI160_GYRO_MAX_FREQ,
+ [BASE_GYRO] = {
+ .name = "Base Gyro",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_BMI160,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi160_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_bmi160_data,
+ .port = CONFIG_SPI_ACCEL_PORT,
+ .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .default_range = 1000, /* dps */
+ .rot_standard_ref = NULL, /* Identity Matrix. */
+ .min_frequency = BMI160_GYRO_MIN_FREQ,
+ .max_frequency = BMI160_GYRO_MAX_FREQ,
},
#ifdef CONFIG_ACCEL_KX022
- {.name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_KX022,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &kionix_accel_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_kx022_data,
- .port = I2C_PORT_ACCEL,
- .addr = KX022_ADDR1,
- .rot_standard_ref = NULL, /* Identity matrix. */
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = KX022_ACCEL_MIN_FREQ,
- .max_frequency = KX022_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
+ [LID_ACCEL] = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_KX022,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_kx022_data,
+ .port = I2C_PORT_ACCEL,
+ .addr = KX022_ADDR1,
+ .rot_standard_ref = NULL, /* Identity matrix. */
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = KX022_ACCEL_MIN_FREQ,
+ .max_frequency = KX022_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
},
},
#endif /* #ifdef CONFIG_ACCEL_KX022 */
diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h
index 9cc28a38fd..ee6f9d92ba 100644
--- a/board/mchpevb1/board.h
+++ b/board/mchpevb1/board.h
@@ -182,9 +182,13 @@
#define CONFIG_I2C_MASTER
#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_LED_COMMON
+
+#ifdef CONFIG_ACCEL_KX022
#define CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_SENSOR_BASE 0
-#define CONFIG_LID_ANGLE_SENSOR_LID 2
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#endif /* CONFIG_ACCEL_KX022 */
+
#define CONFIG_LID_SWITCH
/*
* Enable MCHP Low Power Idle support
@@ -445,6 +449,15 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
+enum sensor_id {
+ BASE_ACCEL,
+ BASE_GYRO,
+#ifdef CONFIG_ACCEL_KX022
+ LID_ACCEL,
+#endif
+ SENSOR_COUNT,
+};
+
/* Light sensors */
enum als_id {
ALS_OPT3001 = 0,
diff --git a/board/nami/board.h b/board/nami/board.h
index 27f8358a99..61d1274c46 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -254,6 +254,7 @@ enum sensor_id {
BASE_ACCEL,
BASE_GYRO,
LID_ALS,
+ SENSOR_COUNT,
};
enum adc_channel {
diff --git a/board/nautilus/board.h b/board/nautilus/board.h
index 1d72270566..93a283c4c3 100644
--- a/board/nautilus/board.h
+++ b/board/nautilus/board.h
@@ -220,6 +220,7 @@ enum sensor_id {
LID_ACCEL = 0,
BASE_ACCEL,
BASE_GYRO,
+ SENSOR_COUNT,
};
enum adc_channel {
diff --git a/board/nocturne/board.h b/board/nocturne/board.h
index 26dab74e0a..9fe50b7fbd 100644
--- a/board/nocturne/board.h
+++ b/board/nocturne/board.h
@@ -254,6 +254,7 @@ enum sensor_id {
LID_GYRO,
LID_ALS,
VSYNC,
+ SENSOR_COUNT,
};
#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ALS)
diff --git a/board/nucleo-f411re/board.h b/board/nucleo-f411re/board.h
index 7ffa0b0f07..069e1367f2 100644
--- a/board/nucleo-f411re/board.h
+++ b/board/nucleo-f411re/board.h
@@ -68,6 +68,7 @@ enum adc_channel {
enum sensor_id {
BASE_ACCEL = 0,
BASE_GYRO,
+ SENSOR_COUNT,
};
#include "gpio_signal.h"
diff --git a/board/oak/board.c b/board/oak/board.c
index 6639202654..845eeebe10 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -623,67 +623,70 @@ struct motion_sensor_t motion_sensors[] = {
* Requirement: accelerometer sensor must init before gyro sensor
* DO NOT change the order of the following table.
*/
- {.name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = I2C_PORT_ACCEL,
- .addr = 1,
- .rot_standard_ref = &base_standard_ref,
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = BMI160_ACCEL_MIN_FREQ,
- .max_frequency = BMI160_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- },
+ [BASE_ACCEL] = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_BMI160,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi160_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_bmi160_data,
+ .port = I2C_PORT_ACCEL,
+ .addr = 1,
+ .rot_standard_ref = &base_standard_ref,
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = BMI160_ACCEL_MIN_FREQ,
+ .max_frequency = BMI160_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ },
},
- {.name = "Base Gyro",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_GYRO,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = I2C_PORT_ACCEL,
- .addr = 1,
- .default_range = 1000, /* dps */
- .rot_standard_ref = &base_standard_ref,
- .min_frequency = BMI160_GYRO_MIN_FREQ,
- .max_frequency = BMI160_GYRO_MAX_FREQ,
+ [BASE_GYRO] = {
+ .name = "Base Gyro",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_BMI160,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi160_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_bmi160_data,
+ .port = I2C_PORT_ACCEL,
+ .addr = 1,
+ .default_range = 1000, /* dps */
+ .rot_standard_ref = &base_standard_ref,
+ .min_frequency = BMI160_GYRO_MIN_FREQ,
+ .max_frequency = BMI160_GYRO_MAX_FREQ,
},
#endif
#ifdef CONFIG_ACCEL_KX022
- {.name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_KX022,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &kionix_accel_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_kx022_data,
- .port = I2C_PORT_ACCEL,
- .addr = KX022_ADDR1,
- .rot_standard_ref = NULL, /* Identity matrix. */
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = KX022_ACCEL_MIN_FREQ,
- .max_frequency = KX022_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
+ [LID_ACCEL] = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_KX022,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_kx022_data,
+ .port = I2C_PORT_ACCEL,
+ .addr = KX022_ADDR1,
+ .rot_standard_ref = NULL, /* Identity matrix. */
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = KX022_ACCEL_MIN_FREQ,
+ .max_frequency = KX022_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
},
- },
},
#endif
};
diff --git a/board/oak/board.h b/board/oak/board.h
index b84b852679..e4ae567b29 100644
--- a/board/oak/board.h
+++ b/board/oak/board.h
@@ -68,8 +68,8 @@
#else
#define CONFIG_HIBERNATE_WAKEUP_PINS (STM32_PWR_CSR_EWUP1)
#define CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_SENSOR_BASE 0
-#define CONFIG_LID_ANGLE_SENSOR_LID 2
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
#define CONFIG_LID_ANGLE_UPDATE
#endif /* BOARD_REV */
#define CONFIG_HOST_COMMAND_STATUS
@@ -208,6 +208,17 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
+enum sensor_id {
+#ifdef CONFIG_ACCELGYRO_BMI160
+ BASE_ACCEL,
+ BASE_GYRO,
+#endif
+#ifdef CONFIG_ACCEL_KX022
+ LID_ACCEL,
+#endif
+ SENSOR_COUNT,
+};
+
/* Light sensors */
enum als_id {
ALS_OPT3001 = 0,
diff --git a/board/poppy/board.h b/board/poppy/board.h
index a79216bb63..87262ca4b6 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -232,6 +232,7 @@ enum sensor_id {
LID_GYRO,
LID_MAG,
LID_ALS,
+ SENSOR_COUNT,
};
enum adc_channel {
diff --git a/board/rainier/board.h b/board/rainier/board.h
index 334d481732..4903de557d 100644
--- a/board/rainier/board.h
+++ b/board/rainier/board.h
@@ -160,6 +160,7 @@ enum sensor_id {
LID_ACCEL = 0,
LID_GYRO,
LID_BARO,
+ SENSOR_COUNT,
};
#include "gpio_signal.h"
diff --git a/board/rammus/board.h b/board/rammus/board.h
index eb6df68f75..ba4b1c9936 100644
--- a/board/rammus/board.h
+++ b/board/rammus/board.h
@@ -244,6 +244,7 @@ enum sensor_id {
LID_ACCEL = 0,
BASE_ACCEL,
BASE_GYRO,
+ SENSOR_COUNT,
};
enum adc_channel {
diff --git a/board/reef/board.h b/board/reef/board.h
index 6847d82c5b..13495970bc 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -278,6 +278,7 @@ enum sensor_id {
BASE_MAG,
BASE_BARO,
LID_ALS,
+ SENSOR_COUNT,
};
enum reef_board_version {
diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h
index 4526946070..162f863009 100644
--- a/board/reef_mchp/board.h
+++ b/board/reef_mchp/board.h
@@ -286,6 +286,7 @@ enum sensor_id {
BASE_MAG,
BASE_BARO,
LID_ALS, /* firmware-reef-9042.B doesn't have this */
+ SENSOR_COUNT,
};
enum reef_board_version {
diff --git a/board/samus/board.h b/board/samus/board.h
index 2bfb1574c8..a3a6b97448 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -173,6 +173,13 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
+enum sensor_id {
+ BASE_ACCEL,
+ LID_ACCEL,
+ BASE_GYRO,
+ SENSOR_COUNT,
+};
+
/* The number of TMP006 sensor chips on the board. */
#define TMP006_COUNT 6
@@ -213,8 +220,8 @@ void set_pp5000_in_g3(int mask, int enable);
#define CONFIG_GESTURE_TAP_MIN_INTERSTICE_T 120
#define CONFIG_GESTURE_TAP_MAX_INTERSTICE_T 500
-#define CONFIG_LID_ANGLE_SENSOR_BASE 0
-#define CONFIG_LID_ANGLE_SENSOR_LID 1
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
#endif /* !__ASSEMBLER__ */
diff --git a/board/scarlet/board.h b/board/scarlet/board.h
index 1a682b93ba..c13b45029c 100644
--- a/board/scarlet/board.h
+++ b/board/scarlet/board.h
@@ -211,6 +211,7 @@ enum sensor_id {
LID_ACCEL = 0,
LID_GYRO,
VSYNC,
+ SENSOR_COUNT,
};
#include "gpio_signal.h"
diff --git a/board/strago/board.c b/board/strago/board.c
index 7b7304e374..57dff8a71a 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -196,49 +196,51 @@ const mat33_fp_t lid_standard_ref = {
};
struct motion_sensor_t motion_sensors[] = {
- {.name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_KXCJ9,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &kionix_accel_drv,
- .mutex = &g_kxcj9_mutex[0],
- .drv_data = &g_kxcj9_data[0],
- .port = I2C_PORT_ACCEL,
- .addr = KXCJ9_ADDR1,
- .rot_standard_ref = &base_standard_ref,
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = KXCJ9_ACCEL_MIN_FREQ,
- .max_frequency = KXCJ9_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 100000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- }
+ [BASE_ACCEL] = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_KXCJ9,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_kxcj9_mutex[0],
+ .drv_data = &g_kxcj9_data[0],
+ .port = I2C_PORT_ACCEL,
+ .addr = KXCJ9_ADDR1,
+ .rot_standard_ref = &base_standard_ref,
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = KXCJ9_ACCEL_MIN_FREQ,
+ .max_frequency = KXCJ9_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 100000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ }
},
- {.name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_KXCJ9,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &kionix_accel_drv,
- .mutex = &g_kxcj9_mutex[1],
- .drv_data = &g_kxcj9_data[1],
- .port = I2C_PORT_ACCEL,
- .addr = KXCJ9_ADDR0,
- .rot_standard_ref = &lid_standard_ref,
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = KXCJ9_ACCEL_MIN_FREQ,
- .max_frequency = KXCJ9_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 100000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- },
+ [LID_ACCEL] = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_KXCJ9,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &kionix_accel_drv,
+ .mutex = &g_kxcj9_mutex[1],
+ .drv_data = &g_kxcj9_data[1],
+ .port = I2C_PORT_ACCEL,
+ .addr = KXCJ9_ADDR0,
+ .rot_standard_ref = &lid_standard_ref,
+ .default_range = 2, /* g, enough for laptop. */
+ .min_frequency = KXCJ9_ACCEL_MIN_FREQ,
+ .max_frequency = KXCJ9_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 100000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ },
},
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
diff --git a/board/strago/board.h b/board/strago/board.h
index 64721ca95f..185cf1ad92 100644
--- a/board/strago/board.h
+++ b/board/strago/board.h
@@ -89,8 +89,8 @@
#undef CONFIG_CMD_ACCELS
#undef CONFIG_CMD_ACCEL_INFO
#define CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_SENSOR_BASE 0
-#define CONFIG_LID_ANGLE_SENSOR_LID 1
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
/* Number of buttons */
#define CONFIG_VOLUME_BUTTONS
@@ -169,6 +169,12 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
+enum sensor_id {
+ BASE_ACCEL,
+ LID_ACCEL,
+ SENSOR_COUNT,
+};
+
/* Light sensors */
enum als_id {
ALS_ISL29035 = 0,
diff --git a/test/motion_common.c b/test/motion_common.c
index 2e0ebc3d91..36f9d003a0 100644
--- a/test/motion_common.c
+++ b/test/motion_common.c
@@ -60,7 +60,7 @@ const struct accelgyro_drv test_motion_sense = {
};
struct motion_sensor_t motion_sensors[] = {
- {
+ [BASE] = {
.name = "base",
.active_mask = SENSOR_ACTIVE_S0_S3_S5,
.chip = MOTIONSENSE_CHIP_LSM6DS0,
@@ -76,7 +76,7 @@ struct motion_sensor_t motion_sensors[] = {
},
},
},
- {
+ [LID] = {
.name = "lid",
.active_mask = SENSOR_ACTIVE_S0,
.chip = MOTIONSENSE_CHIP_KXCJ9,
diff --git a/test/motion_lid.c b/test/motion_lid.c
index a8e16f8cd1..8b50653585 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -90,65 +90,67 @@ const struct accelgyro_drv test_motion_sense = {
};
struct motion_sensor_t motion_sensors[] = {
- {.name = "base",
- .active_mask = SENSOR_ACTIVE_S0_S3_S5,
- .chip = MOTIONSENSE_CHIP_LSM6DS0,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &test_motion_sense,
- .rot_standard_ref = NULL,
- .default_range = MOTION_SCALING_FACTOR / ONE_G_MEASURED,
- .config = {
- /* AP: by default shutdown all sensors */
- [SENSOR_CONFIG_AP] = {
- .odr = 0,
- .ec_rate = 0,
- },
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 119000 | ROUND_UP_FLAG,
- .ec_rate = TEST_LID_EC_RATE
- },
- /* Used for double tap */
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 119000 | ROUND_UP_FLAG,
- .ec_rate = TEST_LID_EC_RATE * 100,
- },
- [SENSOR_CONFIG_EC_S5] = {
- .odr = 0,
- .ec_rate = 0,
- },
- },
+ [BASE] = {
+ .name = "base",
+ .active_mask = SENSOR_ACTIVE_S0_S3_S5,
+ .chip = MOTIONSENSE_CHIP_LSM6DS0,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &test_motion_sense,
+ .rot_standard_ref = NULL,
+ .default_range = MOTION_SCALING_FACTOR / ONE_G_MEASURED,
+ .config = {
+ /* AP: by default shutdown all sensors */
+ [SENSOR_CONFIG_AP] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 119000 | ROUND_UP_FLAG,
+ .ec_rate = TEST_LID_EC_RATE
+ },
+ /* Used for double tap */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 119000 | ROUND_UP_FLAG,
+ .ec_rate = TEST_LID_EC_RATE * 100,
+ },
+ [SENSOR_CONFIG_EC_S5] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ },
},
- {.name = "lid",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_KXCJ9,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &test_motion_sense,
- .rot_standard_ref = NULL,
- .default_range = MOTION_SCALING_FACTOR / ONE_G_MEASURED,
- .config = {
- /* AP: by default shutdown all sensors */
- [SENSOR_CONFIG_AP] = {
- .odr = 0,
- .ec_rate = 0,
- },
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 119000 | ROUND_UP_FLAG,
- .ec_rate = TEST_LID_EC_RATE,
- },
- /* Used for double tap */
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 200000 | ROUND_UP_FLAG,
- .ec_rate = TEST_LID_EC_RATE * 100,
- },
- [SENSOR_CONFIG_EC_S5] = {
- .odr = 0,
- .ec_rate = 0,
- },
- },
+ [LID] = {
+ .name = "lid",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_KXCJ9,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &test_motion_sense,
+ .rot_standard_ref = NULL,
+ .default_range = MOTION_SCALING_FACTOR / ONE_G_MEASURED,
+ .config = {
+ /* AP: by default shutdown all sensors */
+ [SENSOR_CONFIG_AP] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 119000 | ROUND_UP_FLAG,
+ .ec_rate = TEST_LID_EC_RATE,
+ },
+ /* Used for double tap */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 200000 | ROUND_UP_FLAG,
+ .ec_rate = TEST_LID_EC_RATE * 100,
+ },
+ [SENSOR_CONFIG_EC_S5] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ },
},
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
diff --git a/test/test_config.h b/test/test_config.h
index afb2350681..d3c7db1895 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -77,11 +77,18 @@
#if defined(TEST_MOTION_LID) || defined(TEST_MOTION_ANGLE) || \
defined(TEST_MOTION_ANGLE_TABLET)
+enum sensor_id {
+ BASE,
+ LID,
+ SENSOR_COUNT,
+};
+
#define CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_SENSOR_BASE 0
-#define CONFIG_LID_ANGLE_SENSOR_LID 1
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE
+#define CONFIG_LID_ANGLE_SENSOR_LID LID
#define CONFIG_TABLET_MODE
#define CONFIG_MOTION_FILL_LPC_SENSE_DATA
+
#endif
#if defined(TEST_MOTION_ANGLE)