summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-04-21 01:37:22 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-22 16:56:22 +0000
commitdfd6ea85f7837dbffbf3826364c438caba9e9d9e (patch)
tree7978880957407635919235fcdfadd633b394f609
parent20b5af2676fa9d2b1123970c1119a9a9080f3271 (diff)
downloadchrome-ec-dfd6ea85f7837dbffbf3826364c438caba9e9d9e.tar.gz
zephyr: driver: bmi160: Add interrupt handler using devicetree
Add the interrupt handler using the same model used in the bmi260. BRANCH=none BUG=b:185966444 TEST=zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I7aa3bcade8c3bc0fe526d44f8223bab8760cf279 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2842714 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--driver/accelgyro_bmi160.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index 611ac7d9cc..daa47965d8 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -28,6 +28,23 @@
#define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ## args)
#define CPRINTS(format, args...) cprints(CC_ACCEL, format, ## args)
+#if defined(CONFIG_ZEPHYR) && defined(CONFIG_ACCEL_INTERRUPTS)
+/* Get the motion sensor ID of the BMI160 sensor that generates the interrupt.
+ * The interrupt is converted to the event and transferred to motion sense task
+ * that actually handles the interrupt.
+ *
+ * Here we use an alias (bmi160_int) to get the motion sensor ID. This alias
+ * MUST be defined for this driver to work.
+ * aliases {
+ * bmi160-int = &base_accel;
+ * };
+ */
+#if DT_NODE_EXISTS(DT_ALIAS(bmi160_int))
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(SENSOR_ID(DT_ALIAS(bmi160_int)))
+#endif
+#endif
+
STATIC_IF(CONFIG_BMI_ORIENTATION_SENSOR) void irq_set_orientation(
struct motion_sensor_t *s,
int interrupt);