You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.2 KiB
65 lines
1.2 KiB
![]()
4 years ago
|
/*
|
||
|
* Copyright (c) 2020 Peter Johanson
|
||
|
*
|
||
|
* SPDX-License-Identifier: MIT
|
||
|
*/
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include <device.h>
|
||
|
#include <drivers/gpio.h>
|
||
|
#include <sys/util.h>
|
||
|
|
||
![]()
4 years ago
|
struct ec11_config {
|
||
![]()
4 years ago
|
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;
|
||
![]()
4 years ago
|
|
||
|
const u8_t resolution;
|
||
![]()
4 years ago
|
};
|
||
|
|
||
![]()
4 years ago
|
enum ec11_pin_state {
|
||
|
EC11_A_PIN_STATE,
|
||
|
EC11_B_PIN_STATE
|
||
![]()
4 years ago
|
};
|
||
|
|
||
![]()
4 years ago
|
struct ec11_data {
|
||
![]()
4 years ago
|
struct device *a;
|
||
|
struct device *b;
|
||
|
u8_t ab_state;
|
||
![]()
4 years ago
|
s16_t pulse_state;
|
||
|
s16_t tick_state;
|
||
![]()
4 years ago
|
|
||
![]()
4 years ago
|
#ifdef CONFIG_EC11_TRIGGER
|
||
![]()
4 years ago
|
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;
|
||
|
|
||
![]()
4 years ago
|
#if defined(CONFIG_EC11_TRIGGER_OWN_THREAD)
|
||
|
K_THREAD_STACK_MEMBER(thread_stack, CONFIG_EC11_THREAD_STACK_SIZE);
|
||
![]()
4 years ago
|
struct k_sem gpio_sem;
|
||
|
struct k_thread thread;
|
||
![]()
4 years ago
|
#elif defined(CONFIG_EC11_TRIGGER_GLOBAL_THREAD)
|
||
![]()
4 years ago
|
struct k_work work;
|
||
|
#endif
|
||
|
|
||
![]()
4 years ago
|
#endif /* CONFIG_EC11_TRIGGER */
|
||
![]()
4 years ago
|
};
|
||
|
|
||
![]()
4 years ago
|
#ifdef CONFIG_EC11_TRIGGER
|
||
![]()
4 years ago
|
|
||
![]()
4 years ago
|
int ec11_trigger_set(struct device *dev,
|
||
![]()
4 years ago
|
const struct sensor_trigger *trig,
|
||
|
sensor_trigger_handler_t handler);
|
||
|
|
||
![]()
4 years ago
|
int ec11_init_interrupt(struct device *dev);
|
||
![]()
4 years ago
|
#endif
|