summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2019-05-30 12:02:10 -0600
committerCommit Bot <commit-bot@chromium.org>2019-06-05 18:50:20 +0000
commit01fd86385bdcf633db0acd91b5f60733097a84a3 (patch)
treecd142bbb9941fbaf30ff8bb969c74433c1199488 /test
parente36f5ff57b2456c61f868af7be3f6929b28f1bf3 (diff)
downloadchrome-ec-01fd86385bdcf633db0acd91b5f60733097a84a3.tar.gz
common: motion_sense: Require CONFIG_MOTION_SENSOR_MAX_COUNT
This changes requires all boards to define the maximum number of sensors they support. This will allow us to later create static arrays with the appropriate length. BUG=chromium:966506 BRANCH=None TEST=make buildall Change-Id: I5a2fa8f0fdcaef69065dfd4c2bfea4e3f371e986 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637414 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/motion_common.c4
-rw-r--r--test/motion_lid.c118
-rw-r--r--test/test_config.h11
3 files changed, 71 insertions, 62 deletions
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)