refactor: Move drivers into properly module.
* Align our driver module layout to properly match Zephyr conventions, allowing proper CMake setup to amend the library for each type of driver.
This commit is contained in:
parent
eaeea4bdfa
commit
690bc1bb44
55 changed files with 53 additions and 39 deletions
|
@ -8,7 +8,7 @@ list(APPEND DTS_ROOT ${CMAKE_SOURCE_DIR}/drivers/zephyr)
|
||||||
set(ZephyrBuildConfiguration_ROOT ${CMAKE_SOURCE_DIR}/cmake)
|
set(ZephyrBuildConfiguration_ROOT ${CMAKE_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
list(APPEND ZEPHYR_EXTRA_MODULES
|
list(APPEND ZEPHYR_EXTRA_MODULES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers
|
${CMAKE_CURRENT_SOURCE_DIR}/module
|
||||||
)
|
)
|
||||||
|
|
||||||
# Find Zephyr. This also loads Zephyr's build system.
|
# Find Zephyr. This also loads Zephyr's build system.
|
||||||
|
|
10
app/Kconfig
10
app/Kconfig
|
@ -403,14 +403,18 @@ endif
|
||||||
#Initialization Priorities
|
#Initialization Priorities
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "KSCAN Settings"
|
menuconfig ZMK_KSCAN
|
||||||
|
bool "ZMK KScan Integration"
|
||||||
|
default y
|
||||||
|
select KSCAN
|
||||||
|
|
||||||
|
if ZMK_KSCAN
|
||||||
|
|
||||||
config ZMK_KSCAN_EVENT_QUEUE_SIZE
|
config ZMK_KSCAN_EVENT_QUEUE_SIZE
|
||||||
int "Size of the event queue for KSCAN events to buffer events"
|
int "Size of the event queue for KSCAN events to buffer events"
|
||||||
default 4
|
default 4
|
||||||
|
|
||||||
#KSCAN Settings
|
endif # ZMK_KSCAN
|
||||||
endmenu
|
|
||||||
|
|
||||||
menu "Logging"
|
menu "Logging"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
# Copyright (c) 2020 The ZMK Contributors
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
add_subdirectory_ifdef(CONFIG_ZMK_DRIVERS_GPIO gpio)
|
|
||||||
add_subdirectory(kscan)
|
|
||||||
add_subdirectory(sensor)
|
|
||||||
add_subdirectory(display)
|
|
|
@ -1,4 +0,0 @@
|
||||||
# Copyright (c) 2021 The ZMK Contributors
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
zephyr_sources_ifdef(CONFIG_IL0323 il0323.c)
|
|
|
@ -1,9 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2020 The ZMK Contributors
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#warning "kscan-mock.h has been deprecated and superseded by kscan_mock.h"
|
|
||||||
|
|
||||||
#include "kscan_mock.h"
|
|
3
app/module/CMakeLists.txt
Normal file
3
app/module/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
zephyr_include_directories(include)
|
||||||
|
|
||||||
|
add_subdirectory(drivers)
|
2
app/module/Kconfig
Normal file
2
app/module/Kconfig
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
rsource "drivers/Kconfig"
|
7
app/module/drivers/CMakeLists.txt
Normal file
7
app/module/drivers/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Copyright (c) 2020 The ZMK Contributors
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
add_subdirectory_ifdef(CONFIG_GPIO gpio)
|
||||||
|
add_subdirectory_ifdef(CONFIG_KSCAN kscan)
|
||||||
|
add_subdirectory_ifdef(CONFIG_SENSOR sensor)
|
||||||
|
add_subdirectory_ifdef(CONFIG_DISPLAY display)
|
6
app/module/drivers/display/CMakeLists.txt
Normal file
6
app/module/drivers/display/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Copyright (c) 2021 The ZMK Contributors
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
zephyr_library_amend()
|
||||||
|
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_IL0323 il0323.c)
|
|
@ -1,4 +1,8 @@
|
||||||
# Copyright (c) 2021 The ZMK Contributors
|
# Copyright (c) 2021 The ZMK Contributors
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
if DISPLAY
|
||||||
|
|
||||||
rsource "Kconfig.il0323"
|
rsource "Kconfig.il0323"
|
||||||
|
|
||||||
|
endif # DISPLAY
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright (c) 2022 The ZMK Contributors
|
# Copyright (c) 2022 The ZMK Contributors
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
zephyr_library_named(zmk__drivers__gpio)
|
zephyr_library_amend()
|
||||||
zephyr_library_include_directories(${CMAKE_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
zephyr_library_sources_ifdef(CONFIG_GPIO_595 gpio_595.c)
|
zephyr_library_sources_ifdef(CONFIG_GPIO_595 gpio_595.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_GPIO_MAX7318 gpio_max7318.c)
|
zephyr_library_sources_ifdef(CONFIG_GPIO_MAX7318 gpio_max7318.c)
|
|
@ -1,5 +1,7 @@
|
||||||
menuconfig ZMK_DRIVERS_GPIO
|
|
||||||
bool "GPIO"
|
if GPIO
|
||||||
|
|
||||||
rsource "Kconfig.max7318"
|
rsource "Kconfig.max7318"
|
||||||
rsource "Kconfig.595"
|
rsource "Kconfig.595"
|
||||||
|
|
||||||
|
endif # GPIO
|
|
@ -10,7 +10,6 @@ menuconfig GPIO_595
|
||||||
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_GPIO_595))
|
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_GPIO_595))
|
||||||
depends on SPI
|
depends on SPI
|
||||||
select HAS_DTS_GPIO
|
select HAS_DTS_GPIO
|
||||||
select ZMK_DRIVERS_GPIO
|
|
||||||
help
|
help
|
||||||
Enable driver for 595 shift register chip using SPI.
|
Enable driver for 595 shift register chip using SPI.
|
||||||
|
|
|
@ -10,7 +10,6 @@ menuconfig GPIO_MAX7318
|
||||||
default $(dt_compat_enabled,$(DT_COMPAT_MAXIM_MAX7318))
|
default $(dt_compat_enabled,$(DT_COMPAT_MAXIM_MAX7318))
|
||||||
depends on I2C
|
depends on I2C
|
||||||
select HAS_DTS_GPIO
|
select HAS_DTS_GPIO
|
||||||
select ZMK_DRIVERS_GPIO
|
|
||||||
help
|
help
|
||||||
Enable driver for MAX7318 I2C-based GPIO chip.
|
Enable driver for MAX7318 I2C-based GPIO chip.
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright (c) 2020 The ZMK Contributors
|
# Copyright (c) 2020 The ZMK Contributors
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
zephyr_library_named(zmk__drivers__kscan)
|
zephyr_library_amend()
|
||||||
zephyr_library_include_directories(${CMAKE_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER debounce.c)
|
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER debounce.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER kscan_gpio.c)
|
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER kscan_gpio.c)
|
|
@ -7,6 +7,8 @@ DT_COMPAT_ZMK_KSCAN_GPIO_DIRECT := zmk,kscan-gpio-direct
|
||||||
DT_COMPAT_ZMK_KSCAN_GPIO_MATRIX := zmk,kscan-gpio-matrix
|
DT_COMPAT_ZMK_KSCAN_GPIO_MATRIX := zmk,kscan-gpio-matrix
|
||||||
DT_COMPAT_ZMK_KSCAN_MOCK := zmk,kscan-mock
|
DT_COMPAT_ZMK_KSCAN_MOCK := zmk,kscan-mock
|
||||||
|
|
||||||
|
if KSCAN
|
||||||
|
|
||||||
config ZMK_KSCAN_COMPOSITE_DRIVER
|
config ZMK_KSCAN_COMPOSITE_DRIVER
|
||||||
bool
|
bool
|
||||||
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_COMPOSITE))
|
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_COMPOSITE))
|
||||||
|
@ -87,8 +89,10 @@ config ZMK_KSCAN_DEBOUNCE_RELEASE_MS
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config ZMK_KSCAN_INIT_PRIORITY
|
# config ZMK_KSCAN_INIT_PRIORITY
|
||||||
int "Keyboard scan driver init priority"
|
# int "Keyboard scan driver init priority"
|
||||||
default 40
|
# default 40
|
||||||
help
|
# help
|
||||||
Keyboard scan device driver initialization priority.
|
# Keyboard scan device driver initialization priority.
|
||||||
|
|
||||||
|
endif # KSCAN
|
|
@ -1,5 +1,9 @@
|
||||||
# Copyright (c) 2020 The ZMK Contributors
|
# Copyright (c) 2020 The ZMK Contributors
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
if SENSOR
|
||||||
|
|
||||||
rsource "battery/Kconfig"
|
rsource "battery/Kconfig"
|
||||||
rsource "ec11/Kconfig"
|
rsource "ec11/Kconfig"
|
||||||
|
|
||||||
|
endif # SENSOR
|
|
@ -1,3 +1,5 @@
|
||||||
build:
|
build:
|
||||||
cmake: .
|
cmake: .
|
||||||
kconfig: Kconfig
|
kconfig: Kconfig
|
||||||
|
settings:
|
||||||
|
dts_root: .
|
Loading…
Add table
Reference in a new issue