diff options
author | Pete Johanson <peter@peterjohanson.com> | 2020-07-17 22:43:19 -0400 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2020-07-19 22:11:17 -0400 |
commit | 893b99d907b85109c8cf8b00f381f36939f5ae3c (patch) | |
tree | 0c2997894375eeddc4c6409ffa43587a736acf45 /app/src | |
parent | f6110a632d0ddbc0a9ebd7bfd4997366f95facfd (diff) |
Initial en11 exploration.
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/drivers/sensors/en11/CMakeLists.txt | 6 | ||||
-rw-r--r-- | app/src/drivers/sensors/en11/Kconfig | 52 | ||||
-rw-r--r-- | app/src/main.c | 24 |
3 files changed, 82 insertions, 0 deletions
diff --git a/app/src/drivers/sensors/en11/CMakeLists.txt b/app/src/drivers/sensors/en11/CMakeLists.txt new file mode 100644 index 0000000..4c538ca --- /dev/null +++ b/app/src/drivers/sensors/en11/CMakeLists.txt @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +zephyr_library() + +zephyr_library_sources_ifdef(CONFIG_EN11 en11.c) +zephyr_library_sources_ifdef(CONFIG_EN11_TRIGGER en11_trigger.c) diff --git a/app/src/drivers/sensors/en11/Kconfig b/app/src/drivers/sensors/en11/Kconfig new file mode 100644 index 0000000..84fec95 --- /dev/null +++ b/app/src/drivers/sensors/en11/Kconfig @@ -0,0 +1,52 @@ +# EN11 incremental encoder sensor configuration options + +# Copyright (c) 2020 Peter Johanson +# SPDX-License-Identifier: MIT + +menuconfig EN11 + bool "EN11 Incremental Encoder Sensor" + depends on GPIO + help + Enable driver for EN11 incremental encoder sensors. + +if EN11 + +choice + prompt "Trigger mode" + default EN11_TRIGGER_NONE + help + Specify the type of triggering to be used by the driver. + +config EN11_TRIGGER_NONE + bool "No trigger" + +config EN11_TRIGGER_GLOBAL_THREAD + bool "Use global thread" + depends on GPIO + select EN11_TRIGGER + +config EN11_TRIGGER_OWN_THREAD + bool "Use own thread" + depends on GPIO + select EN11_TRIGGER + +endchoice + +config EN11_TRIGGER + bool + +config EN11_THREAD_PRIORITY + int "Thread priority" + depends on EN11_TRIGGER_OWN_THREAD + default 10 + help + Priority of thread used by the driver to handle interrupts. + +config EN11_THREAD_STACK_SIZE + int "Thread stack size" + depends on EN11_TRIGGER_OWN_THREAD + default 1024 + help + Stack size of thread used by the driver to handle interrupts. + +endif # EN11 diff --git a/app/src/main.c b/app/src/main.c index 92ecc8b..f42c7c4 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -8,6 +8,7 @@ #include <device.h> #include <devicetree.h> #include <settings/settings.h> +#include <drivers/sensor.h> #include <logging/log.h> LOG_MODULE_REGISTER(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -18,6 +19,27 @@ LOG_MODULE_REGISTER(zmk, CONFIG_ZMK_LOG_LEVEL); #define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID) +static struct sensor_trigger trigger; + +void encoder_change(struct device *dev, struct sensor_trigger *trigger) +{ + LOG_DBG(""); +} + +void init_sensor() +{ + struct device *dev = device_get_binding("Rotary Encoder"); + if (!dev) { + LOG_DBG("NO ENCODER!"); + return; + } + + trigger.type = SENSOR_TRIG_DATA_READY; + trigger.chan = SENSOR_CHAN_ROTATION; + + sensor_trigger_set(dev, &trigger, encoder_change); +} + void main(void) { printk("Welcome to ZMK!\n"); @@ -31,4 +53,6 @@ void main(void) #ifdef CONFIG_SETTINGS settings_load(); #endif + + init_sensor(); } |