diff options
author | Pete Johanson <peter@peterjohanson.com> | 2020-07-20 20:54:58 -0400 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2020-07-20 20:54:58 -0400 |
commit | 109c69cbab0a417c97b20788b0fd3bcd720178f1 (patch) | |
tree | cf784baf61b03bf48cc9f021cd069debd9554e00 /app/drivers/zephyr/ec11.h | |
parent | 331bfa70521112759a4b553356a90eee8747644d (diff) |
EN11 is actually EC11, some sample work.
Diffstat (limited to 'app/drivers/zephyr/ec11.h')
-rw-r--r-- | app/drivers/zephyr/ec11.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/app/drivers/zephyr/ec11.h b/app/drivers/zephyr/ec11.h new file mode 100644 index 0000000..524af2c --- /dev/null +++ b/app/drivers/zephyr/ec11.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include <device.h> +#include <drivers/gpio.h> +#include <sys/util.h> + +struct ec11_config { + const char *a_label; + const u8_t a_pin; + const u8_t a_flags; + + const char *b_label; + const u8_t b_pin; + const u8_t b_flags; + + const u8_t resolution; +}; + +enum ec11_pin_state { + EC11_A_PIN_STATE, + EC11_B_PIN_STATE +}; + +struct ec11_data { + struct device *a; + struct device *b; + u8_t ab_state; + s16_t pulse_state; + s16_t tick_state; + +#ifdef CONFIG_EC11_TRIGGER + struct device *gpio; + struct gpio_callback a_gpio_cb; + struct gpio_callback b_gpio_cb; + struct device *dev; + + sensor_trigger_handler_t handler; + struct sensor_trigger trigger; + +#if defined(CONFIG_EC11_TRIGGER_OWN_THREAD) + K_THREAD_STACK_MEMBER(thread_stack, CONFIG_EC11_THREAD_STACK_SIZE); + struct k_sem gpio_sem; + struct k_thread thread; +#elif defined(CONFIG_EC11_TRIGGER_GLOBAL_THREAD) + struct k_work work; +#endif + +#endif /* CONFIG_EC11_TRIGGER */ +}; + +#ifdef CONFIG_EC11_TRIGGER + +int ec11_trigger_set(struct device *dev, + const struct sensor_trigger *trig, + sensor_trigger_handler_t handler); + +int ec11_init_interrupt(struct device *dev); +#endif |