Browse Source

Rename kscan direct wired driver polling kscan flag in preparationfor addition of new matrix driver flag that enables polling.

xmkb
Jason Chestnut 4 years ago
parent
commit
53425aa3c4
  1. 4
      app/drivers/zephyr/Kconfig
  2. 16
      app/drivers/zephyr/kscan_gpio_direct.c

4
app/drivers/zephyr/Kconfig

@ -5,11 +5,11 @@ config ZMK_KSCAN_GPIO_DRIVER @@ -5,11 +5,11 @@ config ZMK_KSCAN_GPIO_DRIVER
if ZMK_KSCAN_GPIO_DRIVER
config ZMK_KSCAN_GPIO_POLLING
config ZMK_KSCAN_MATRIX_POLLING
bool "Poll for key event triggers instead of using interrupts"
default n
config ZMK_KSCAN_GPIO_MATRIX_POLLING
config ZMK_KSCAN_DIRECT_POLLING
bool "Poll for key event triggers instead of using interrupts on matrix boards."
default n

16
app/drivers/zephyr/kscan_gpio_direct.c

@ -33,9 +33,9 @@ struct kscan_gpio_config { @@ -33,9 +33,9 @@ struct kscan_gpio_config {
};
struct kscan_gpio_data {
#if defined(CONFIG_ZMK_KSCAN_GPIO_POLLING)
#if defined(ZMK_KSCAN_DIRECT_POLLING)
struct k_timer poll_timer;
#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */
#endif /* defined(ZMK_KSCAN_DIRECT_POLLING) */
kscan_callback_t callback;
union work_reference work;
struct device *dev;
@ -53,7 +53,7 @@ static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct devi @@ -53,7 +53,7 @@ static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct devi
return cfg->inputs;
}
#if !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING)
#if !defined(ZMK_KSCAN_DIRECT_POLLING)
struct kscan_gpio_irq_callback {
union work_reference *work;
@ -101,7 +101,7 @@ static void kscan_gpio_irq_callback_handler(struct device *dev, struct gpio_call @@ -101,7 +101,7 @@ static void kscan_gpio_irq_callback_handler(struct device *dev, struct gpio_call
}
}
#else /* !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */
#else /* !defined(ZMK_KSCAN_DIRECT_POLLING) */
static void kscan_gpio_timer_handler(struct k_timer *timer) {
struct kscan_gpio_data *data = CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer);
@ -120,7 +120,7 @@ static int kscan_gpio_direct_disable(struct device *dev) { @@ -120,7 +120,7 @@ static int kscan_gpio_direct_disable(struct device *dev) {
return 0;
}
#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */
#endif /* defined(ZMK_KSCAN_DIRECT_POLLING) */
static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) {
struct kscan_gpio_data *data = dev->driver_data;
@ -173,7 +173,7 @@ static const struct kscan_driver_api gpio_driver_api = { @@ -173,7 +173,7 @@ static const struct kscan_driver_api gpio_driver_api = {
#define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios)
#define GPIO_INST_INIT(n) \
COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, \
COND_CODE_0(ZMK_KSCAN_DIRECT_POLLING, \
(static struct kscan_gpio_irq_callback irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \
static struct kscan_gpio_data kscan_gpio_data_##n = { \
.inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \
@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = { @@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = {
return err; \
} \
COND_CODE_0( \
CONFIG_ZMK_KSCAN_GPIO_POLLING, \
ZMK_KSCAN_DIRECT_POLLING, \
(irq_callbacks_##n[i].work = &data->work; \
irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \
gpio_init_callback(&irq_callbacks_##n[i].callback, \
@ -208,7 +208,7 @@ static const struct kscan_driver_api gpio_driver_api = { @@ -208,7 +208,7 @@ static const struct kscan_driver_api gpio_driver_api = {
()) \
} \
data->dev = dev; \
COND_CODE_1(CONFIG_ZMK_KSCAN_GPIO_POLLING, \
COND_CODE_1(ZMK_KSCAN_DIRECT_POLLING, \
(k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \
if (cfg->debounce_period > 0) { \
k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \

Loading…
Cancel
Save