diff options
author | Tristan Honscheid <honscheid@google.com> | 2021-11-04 16:57:54 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-09 21:29:49 +0000 |
commit | c5b31809cb024e89f51555943d34197ceb1640f1 (patch) | |
tree | 240eaed46671786edeef49780d9b1a67ef6c69a7 /zephyr/test | |
parent | 998bd68a7d018e4b610805e1b365eedecc425bbf (diff) | |
download | chrome-ec-c5b31809cb024e89f51555943d34197ceb1640f1.tar.gz |
zephyr: bmi160: Test interrupt handler and bug fix
Test the interrupt handler in the BMI160 driver. Also, correct an error
from an earlier CL (3229647) where I moved the BMI260 event flag in to
BMI160 driver's header.
BRANCH=None
BUG=b:184856157
TEST=zmake -D configure --test test-drivers
Signed-off-by: Tristan Honscheid <honscheid@google.com>
Change-Id: Icb08d9e1142066ba0ef22b9633895e60e6b40e90
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262878
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'zephyr/test')
-rw-r--r-- | zephyr/test/drivers/src/bmi160.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/zephyr/test/drivers/src/bmi160.c b/zephyr/test/drivers/src/bmi160.c index 8678e34093..dca9d5bf30 100644 --- a/zephyr/test/drivers/src/bmi160.c +++ b/zephyr/test/drivers/src/bmi160.c @@ -1989,6 +1989,30 @@ static void test_bmi_temp_sensor(void) EC_ERROR_NOT_POWERED, ret); } +static void test_bmi_interrupt_handler(void) +{ + /* The accelerometer interrupt handler simply sets an event flag for the + * motion sensing task. Make sure that flag starts cleared, fire the + * interrupt, and ensure the flag is set. + */ + + uint32_t *mask; + + mask = task_get_event_bitmap(TASK_ID_MOTIONSENSE); + zassert_true(mask != NULL, + "Got a null pointer when getting event bitmap."); + zassert_true((*mask & CONFIG_ACCELGYRO_BMI160_INT_EVENT) == 0, + "Event flag is set before firing interrupt"); + + bmi160_interrupt(0); + + mask = task_get_event_bitmap(TASK_ID_MOTIONSENSE); + zassert_true(mask != NULL, + "Got a null pointer when getting event bitmap."); + zassert_true(*mask & CONFIG_ACCELGYRO_BMI160_INT_EVENT, + "Event flag is not set after firing interrupt"); +} + void test_suite_bmi160(void) { ztest_test_suite(bmi160, @@ -2015,6 +2039,7 @@ void test_suite_bmi160(void) ztest_user_unit_test(test_bmi_set_offset_invalid_type), ztest_user_unit_test( test_bmi_perform_calib_invalid_type), - ztest_user_unit_test(test_bmi_temp_sensor)); + ztest_user_unit_test(test_bmi_temp_sensor), + ztest_user_unit_test(test_bmi_interrupt_handler)); ztest_run_test_suite(bmi160); } |