zmk_mf68/app/drivers/zephyr/ec11.h

60 lines
1.1 KiB
C
Raw Normal View History

2020-07-18 12:43:19 +10:00
/*
* Copyright (c) 2020 The ZMK Contributors
2020-07-18 12:43:19 +10:00
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <device.h>
#include <drivers/gpio.h>
#include <sys/util.h>
struct ec11_config {
2020-07-18 12:43:19 +10:00
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;
2020-07-18 12:43:19 +10:00
};
struct ec11_data {
2020-07-18 12:43:19 +10:00
struct device *a;
struct device *b;
u8_t ab_state;
2020-07-21 12:47:50 +10:00
s8_t pulses;
s8_t ticks;
s8_t delta;
2020-07-18 12:43:19 +10:00
#ifdef CONFIG_EC11_TRIGGER
2020-07-18 12:43:19 +10:00
struct gpio_callback a_gpio_cb;
struct gpio_callback b_gpio_cb;
struct device *dev;
sensor_trigger_handler_t handler;
2020-07-22 16:13:52 +10:00
const struct sensor_trigger *trigger;
2020-07-18 12:43:19 +10:00
#if defined(CONFIG_EC11_TRIGGER_OWN_THREAD)
K_THREAD_STACK_MEMBER(thread_stack, CONFIG_EC11_THREAD_STACK_SIZE);
2020-07-18 12:43:19 +10:00
struct k_sem gpio_sem;
struct k_thread thread;
#elif defined(CONFIG_EC11_TRIGGER_GLOBAL_THREAD)
2020-07-18 12:43:19 +10:00
struct k_work work;
#endif
#endif /* CONFIG_EC11_TRIGGER */
2020-07-18 12:43:19 +10:00
};
#ifdef CONFIG_EC11_TRIGGER
2020-07-18 12:43:19 +10:00
int ec11_trigger_set(struct device *dev,
2020-07-18 12:43:19 +10:00
const struct sensor_trigger *trig,
sensor_trigger_handler_t handler);
int ec11_init_interrupt(struct device *dev);
2020-07-18 12:43:19 +10:00
#endif