From 8d9ae1fdf379020d4743b4f85f465e88b148ac29 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Thu, 19 Nov 2020 17:20:43 +0000 Subject: [PATCH] refactor: Align drivers with Zephyr file system conventions PR: #400 --- app/drivers/CMakeLists.txt | 5 +++ app/drivers/Kconfig | 5 +++ app/drivers/kscan/CMakeLists.txt | 8 +++++ app/drivers/kscan/Kconfig | 25 +++++++++++++++ .../{zephyr => kscan}/kscan_gpio_demux.c | 0 .../{zephyr => kscan}/kscan_gpio_direct.c | 0 .../{zephyr => kscan}/kscan_gpio_matrix.c | 0 app/drivers/sensor/CMakeLists.txt | 5 +++ app/drivers/sensor/Kconfig | 5 +++ .../battery_voltage_divider/CMakeLists.txt | 6 ++++ .../sensor/battery_voltage_divider/Kconfig | 8 +++++ .../battery_voltage_divider.c | 0 app/drivers/sensor/ec11/CMakeLists.txt | 9 ++++++ app/drivers/{zephyr => sensor/ec11}/Kconfig | 31 +------------------ app/drivers/{zephyr => sensor/ec11}/ec11.c | 0 app/drivers/{zephyr => sensor/ec11}/ec11.h | 0 .../{zephyr => sensor/ec11}/ec11_trigger.c | 0 app/drivers/zephyr/CMakeLists.txt | 14 --------- .../{ => kscan}/zmk,kscan-gpio-demux.yaml | 0 .../{ => kscan}/zmk,kscan-gpio-direct.yaml | 0 .../{ => kscan}/zmk,kscan-gpio-matrix.yaml | 0 .../dts/bindings/{ => sensor}/alps,ec11.yaml | 0 .../zmk,battery-voltage-divider.yaml | 0 app/drivers/zephyr/module.yml | 4 +-- 24 files changed, 79 insertions(+), 46 deletions(-) create mode 100644 app/drivers/CMakeLists.txt create mode 100644 app/drivers/Kconfig create mode 100644 app/drivers/kscan/CMakeLists.txt create mode 100644 app/drivers/kscan/Kconfig rename app/drivers/{zephyr => kscan}/kscan_gpio_demux.c (100%) rename app/drivers/{zephyr => kscan}/kscan_gpio_direct.c (100%) rename app/drivers/{zephyr => kscan}/kscan_gpio_matrix.c (100%) create mode 100644 app/drivers/sensor/CMakeLists.txt create mode 100644 app/drivers/sensor/Kconfig create mode 100644 app/drivers/sensor/battery_voltage_divider/CMakeLists.txt create mode 100644 app/drivers/sensor/battery_voltage_divider/Kconfig rename app/drivers/{zephyr => sensor/battery_voltage_divider}/battery_voltage_divider.c (100%) create mode 100644 app/drivers/sensor/ec11/CMakeLists.txt rename app/drivers/{zephyr => sensor/ec11}/Kconfig (57%) rename app/drivers/{zephyr => sensor/ec11}/ec11.c (100%) rename app/drivers/{zephyr => sensor/ec11}/ec11.h (100%) rename app/drivers/{zephyr => sensor/ec11}/ec11_trigger.c (100%) delete mode 100644 app/drivers/zephyr/CMakeLists.txt rename app/drivers/zephyr/dts/bindings/{ => kscan}/zmk,kscan-gpio-demux.yaml (100%) rename app/drivers/zephyr/dts/bindings/{ => kscan}/zmk,kscan-gpio-direct.yaml (100%) rename app/drivers/zephyr/dts/bindings/{ => kscan}/zmk,kscan-gpio-matrix.yaml (100%) rename app/drivers/zephyr/dts/bindings/{ => sensor}/alps,ec11.yaml (100%) rename app/drivers/zephyr/dts/bindings/{ => sensor}/zmk,battery-voltage-divider.yaml (100%) diff --git a/app/drivers/CMakeLists.txt b/app/drivers/CMakeLists.txt new file mode 100644 index 00000000..13f04f82 --- /dev/null +++ b/app/drivers/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +add_subdirectory_ifdef(CONFIG_KSCAN kscan) +add_subdirectory_ifdef(CONFIG_SENSOR sensor) \ No newline at end of file diff --git a/app/drivers/Kconfig b/app/drivers/Kconfig new file mode 100644 index 00000000..7ad76992 --- /dev/null +++ b/app/drivers/Kconfig @@ -0,0 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +rsource "kscan/Kconfig" +rsource "sensor/Kconfig" \ No newline at end of file diff --git a/app/drivers/kscan/CMakeLists.txt b/app/drivers/kscan/CMakeLists.txt new file mode 100644 index 00000000..19933aa6 --- /dev/null +++ b/app/drivers/kscan/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +zephyr_library() + +zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER kscan_gpio_matrix.c) +zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER kscan_gpio_direct.c) +zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER kscan_gpio_demux.c) \ No newline at end of file diff --git a/app/drivers/kscan/Kconfig b/app/drivers/kscan/Kconfig new file mode 100644 index 00000000..5b913f3e --- /dev/null +++ b/app/drivers/kscan/Kconfig @@ -0,0 +1,25 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config ZMK_KSCAN_GPIO_DRIVER + bool "Enable GPIO kscan driver to simulate key presses" + default y + select GPIO + +if ZMK_KSCAN_GPIO_DRIVER + +config ZMK_KSCAN_MATRIX_POLLING + bool "Poll for key event triggers instead of using interrupts on matrix boards." + default n + +config ZMK_KSCAN_DIRECT_POLLING + bool "Poll for key event triggers instead of using interrupts on direct wired boards." + default n + +endif + +config ZMK_KSCAN_INIT_PRIORITY + int "Keyboard scan driver init priority" + default 40 + help + Keyboard scan device driver initialization priority. \ No newline at end of file diff --git a/app/drivers/zephyr/kscan_gpio_demux.c b/app/drivers/kscan/kscan_gpio_demux.c similarity index 100% rename from app/drivers/zephyr/kscan_gpio_demux.c rename to app/drivers/kscan/kscan_gpio_demux.c diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/kscan/kscan_gpio_direct.c similarity index 100% rename from app/drivers/zephyr/kscan_gpio_direct.c rename to app/drivers/kscan/kscan_gpio_direct.c diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/kscan/kscan_gpio_matrix.c similarity index 100% rename from app/drivers/zephyr/kscan_gpio_matrix.c rename to app/drivers/kscan/kscan_gpio_matrix.c diff --git a/app/drivers/sensor/CMakeLists.txt b/app/drivers/sensor/CMakeLists.txt new file mode 100644 index 00000000..a4c2ba89 --- /dev/null +++ b/app/drivers/sensor/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +add_subdirectory_ifdef(CONFIG_ZMK_BATTERY_VOLTAGE_DIVIDER battery_voltage_divider) +add_subdirectory_ifdef(CONFIG_EC11 ec11) \ No newline at end of file diff --git a/app/drivers/sensor/Kconfig b/app/drivers/sensor/Kconfig new file mode 100644 index 00000000..7b6a0d08 --- /dev/null +++ b/app/drivers/sensor/Kconfig @@ -0,0 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +rsource "battery_voltage_divider/Kconfig" +rsource "ec11/Kconfig" \ No newline at end of file diff --git a/app/drivers/sensor/battery_voltage_divider/CMakeLists.txt b/app/drivers/sensor/battery_voltage_divider/CMakeLists.txt new file mode 100644 index 00000000..4b7f042c --- /dev/null +++ b/app/drivers/sensor/battery_voltage_divider/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +zephyr_library() + +zephyr_library_sources(battery_voltage_divider.c) \ No newline at end of file diff --git a/app/drivers/sensor/battery_voltage_divider/Kconfig b/app/drivers/sensor/battery_voltage_divider/Kconfig new file mode 100644 index 00000000..18c4ea3a --- /dev/null +++ b/app/drivers/sensor/battery_voltage_divider/Kconfig @@ -0,0 +1,8 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config ZMK_BATTERY_VOLTAGE_DIVIDER + bool "ZMK battery voltage divider" + select ADC + help + Enable ZMK battery voltage divider driver for battery monitoring. \ No newline at end of file diff --git a/app/drivers/zephyr/battery_voltage_divider.c b/app/drivers/sensor/battery_voltage_divider/battery_voltage_divider.c similarity index 100% rename from app/drivers/zephyr/battery_voltage_divider.c rename to app/drivers/sensor/battery_voltage_divider/battery_voltage_divider.c diff --git a/app/drivers/sensor/ec11/CMakeLists.txt b/app/drivers/sensor/ec11/CMakeLists.txt new file mode 100644 index 00000000..de291fef --- /dev/null +++ b/app/drivers/sensor/ec11/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +zephyr_include_directories(.) + +zephyr_library() + +zephyr_library_sources(ec11.c) +zephyr_library_sources_ifdef(CONFIG_EC11_TRIGGER ec11_trigger.c) \ No newline at end of file diff --git a/app/drivers/zephyr/Kconfig b/app/drivers/sensor/ec11/Kconfig similarity index 57% rename from app/drivers/zephyr/Kconfig rename to app/drivers/sensor/ec11/Kconfig index b8b2b1be..6854e530 100644 --- a/app/drivers/zephyr/Kconfig +++ b/app/drivers/sensor/ec11/Kconfig @@ -1,35 +1,6 @@ # Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT -config ZMK_KSCAN_GPIO_DRIVER - bool "Enable GPIO kscan driver to simulate key presses" - default y - select GPIO - -if ZMK_KSCAN_GPIO_DRIVER - -config ZMK_KSCAN_MATRIX_POLLING - bool "Poll for key event triggers instead of using interrupts on matrix boards." - default n - -config ZMK_KSCAN_DIRECT_POLLING - bool "Poll for key event triggers instead of using interrupts on direct wired boards." - default n - -endif - -config ZMK_KSCAN_INIT_PRIORITY - int "Keyboard scan driver init priority" - default 40 - help - Keyboard scan device driver initialization priority. - -config ZMK_BATTERY_VOLTAGE_DIVIDER - bool "ZMK battery voltage divider" - select ADC - help - Enable ZMK battery voltage divider driver for battery monitoring. - menuconfig EC11 bool "EC11 Incremental Encoder Sensor" depends on GPIO @@ -76,4 +47,4 @@ config EC11_THREAD_STACK_SIZE help Stack size of thread used by the driver to handle interrupts. -endif # EC11 +endif # EC11 \ No newline at end of file diff --git a/app/drivers/zephyr/ec11.c b/app/drivers/sensor/ec11/ec11.c similarity index 100% rename from app/drivers/zephyr/ec11.c rename to app/drivers/sensor/ec11/ec11.c diff --git a/app/drivers/zephyr/ec11.h b/app/drivers/sensor/ec11/ec11.h similarity index 100% rename from app/drivers/zephyr/ec11.h rename to app/drivers/sensor/ec11/ec11.h diff --git a/app/drivers/zephyr/ec11_trigger.c b/app/drivers/sensor/ec11/ec11_trigger.c similarity index 100% rename from app/drivers/zephyr/ec11_trigger.c rename to app/drivers/sensor/ec11/ec11_trigger.c diff --git a/app/drivers/zephyr/CMakeLists.txt b/app/drivers/zephyr/CMakeLists.txt deleted file mode 100644 index e3a192d2..00000000 --- a/app/drivers/zephyr/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -if(CONFIG_ZMK_KSCAN_GPIO_DRIVER) - zephyr_include_directories(.) - - zephyr_library() - zephyr_library_sources( - kscan_gpio_matrix.c - kscan_gpio_direct.c - kscan_gpio_demux.c - ) - - zephyr_library_sources_ifdef(CONFIG_EC11 ec11.c) - zephyr_library_sources_ifdef(CONFIG_EC11_TRIGGER ec11_trigger.c) - zephyr_library_sources_ifdef(CONFIG_ZMK_BATTERY_VOLTAGE_DIVIDER battery_voltage_divider.c) -endif() diff --git a/app/drivers/zephyr/dts/bindings/zmk,kscan-gpio-demux.yaml b/app/drivers/zephyr/dts/bindings/kscan/zmk,kscan-gpio-demux.yaml similarity index 100% rename from app/drivers/zephyr/dts/bindings/zmk,kscan-gpio-demux.yaml rename to app/drivers/zephyr/dts/bindings/kscan/zmk,kscan-gpio-demux.yaml diff --git a/app/drivers/zephyr/dts/bindings/zmk,kscan-gpio-direct.yaml b/app/drivers/zephyr/dts/bindings/kscan/zmk,kscan-gpio-direct.yaml similarity index 100% rename from app/drivers/zephyr/dts/bindings/zmk,kscan-gpio-direct.yaml rename to app/drivers/zephyr/dts/bindings/kscan/zmk,kscan-gpio-direct.yaml diff --git a/app/drivers/zephyr/dts/bindings/zmk,kscan-gpio-matrix.yaml b/app/drivers/zephyr/dts/bindings/kscan/zmk,kscan-gpio-matrix.yaml similarity index 100% rename from app/drivers/zephyr/dts/bindings/zmk,kscan-gpio-matrix.yaml rename to app/drivers/zephyr/dts/bindings/kscan/zmk,kscan-gpio-matrix.yaml diff --git a/app/drivers/zephyr/dts/bindings/alps,ec11.yaml b/app/drivers/zephyr/dts/bindings/sensor/alps,ec11.yaml similarity index 100% rename from app/drivers/zephyr/dts/bindings/alps,ec11.yaml rename to app/drivers/zephyr/dts/bindings/sensor/alps,ec11.yaml diff --git a/app/drivers/zephyr/dts/bindings/zmk,battery-voltage-divider.yaml b/app/drivers/zephyr/dts/bindings/sensor/zmk,battery-voltage-divider.yaml similarity index 100% rename from app/drivers/zephyr/dts/bindings/zmk,battery-voltage-divider.yaml rename to app/drivers/zephyr/dts/bindings/sensor/zmk,battery-voltage-divider.yaml diff --git a/app/drivers/zephyr/module.yml b/app/drivers/zephyr/module.yml index cbff6a1a..0b660594 100644 --- a/app/drivers/zephyr/module.yml +++ b/app/drivers/zephyr/module.yml @@ -1,3 +1,3 @@ build: - cmake: zephyr - kconfig: zephyr/Kconfig + cmake: . + kconfig: Kconfig