Browse Source

Merge remote-tracking branch 'upstream/main' into underglow/state-persistence

xmkb
Nick 4 years ago
parent
commit
18d21b0362
  1. 4
      .clang-format
  2. 4
      .github/workflows/build.yml
  3. 25
      .github/workflows/clang-format-lint.yml
  4. 70
      .github/workflows/test.yml
  5. 1
      .gitignore
  6. 11
      AUTHORS
  7. 28
      app/CMakeLists.txt
  8. 44
      app/Kconfig
  9. 7
      app/boards/arm/dz60rgb/CMakeLists.txt
  10. 6
      app/boards/arm/dz60rgb/Kconfig.board
  11. 14
      app/boards/arm/dz60rgb/Kconfig.defconfig
  12. 7
      app/boards/arm/dz60rgb/board.cmake
  13. 88
      app/boards/arm/dz60rgb/dz60rgb_rev1.dts
  14. 25
      app/boards/arm/dz60rgb/dz60rgb_rev1.keymap
  15. 19
      app/boards/arm/dz60rgb/dz60rgb_rev1.yaml
  16. 27
      app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig
  17. 67
      app/boards/arm/dz60rgb/pinmux.c
  18. 5
      app/boards/arm/nrfmicro/Kconfig
  19. 2
      app/boards/arm/nrfmicro/Kconfig.board
  20. 9
      app/boards/arm/nrfmicro/Kconfig.defconfig
  21. 2
      app/boards/arm/nrfmicro/arduino_pro_micro_pins.dtsi
  22. 2
      app/boards/arm/nrfmicro/arduino_pro_micro_pins_flipped.dtsi
  23. 2
      app/boards/arm/nrfmicro/nrfmicro_11.dts
  24. 2
      app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts
  25. 2
      app/boards/arm/nrfmicro/nrfmicro_13.dts
  26. 13
      app/boards/arm/nrfmicro/pinmux.c
  27. 2
      app/boards/arm/planck/Kconfig.board
  28. 2
      app/boards/arm/planck/Kconfig.defconfig
  29. 6
      app/boards/arm/planck/pinmux.c
  30. 3
      app/boards/arm/planck/planck_rev6_defconfig
  31. 6
      app/boards/arm/proton_c/pinmux.c
  32. 3
      app/boards/native_posix.conf
  33. 73
      app/boards/native_posix.overlay
  34. 5
      app/boards/shields/corne/corne.keymap
  35. 1
      app/boards/shields/corne/corne_left.conf
  36. 1
      app/boards/shields/corne/corne_right.conf
  37. 16
      app/boards/shields/iris/Kconfig.defconfig
  38. 8
      app/boards/shields/iris/Kconfig.shield
  39. 0
      app/boards/shields/iris/iris.conf
  40. 51
      app/boards/shields/iris/iris.dtsi
  41. 60
      app/boards/shields/iris/iris.keymap
  42. 2
      app/boards/shields/iris/iris_left.conf
  43. 22
      app/boards/shields/iris/iris_left.overlay
  44. 2
      app/boards/shields/iris/iris_right.conf
  45. 26
      app/boards/shields/iris/iris_right.overlay
  46. 1
      app/boards/shields/kyria/kyria_left.conf
  47. 1
      app/boards/shields/kyria/kyria_right.conf
  48. 4
      app/boards/shields/lily58/lily58.conf
  49. 15
      app/boards/shields/lily58/lily58.dtsi
  50. 11
      app/boards/shields/lily58/lily58.keymap
  51. 5
      app/boards/shields/lily58/lily58_left.conf
  52. 6
      app/boards/shields/lily58/lily58_left.overlay
  53. 1
      app/boards/shields/lily58/lily58_right.conf
  54. 2
      app/boards/shields/lily58/lily58_right.overlay
  55. 9
      app/boards/shields/qaz/Kconfig.defconfig
  56. 5
      app/boards/shields/qaz/Kconfig.shield
  57. 58
      app/boards/shields/qaz/qaz.keymap
  58. 53
      app/boards/shields/qaz/qaz.overlay
  59. 10
      app/boards/shields/romac/Kconfig.defconfig
  60. 5
      app/boards/shields/romac/Kconfig.shield
  61. 0
      app/boards/shields/romac/romac.conf
  62. 47
      app/boards/shields/romac/romac.keymap
  63. 40
      app/boards/shields/romac/romac.overlay
  64. 10
      app/boards/shields/settings_reset/Kconfig.defconfig
  65. 5
      app/boards/shields/settings_reset/Kconfig.shield
  66. 1
      app/boards/shields/settings_reset/settings_reset.conf
  67. 22
      app/boards/shields/settings_reset/settings_reset.keymap
  68. 24
      app/boards/shields/settings_reset/settings_reset.overlay
  69. 54
      app/boards/shields/sofle/Kconfig.defconfig
  70. 8
      app/boards/shields/sofle/Kconfig.shield
  71. 9
      app/boards/shields/sofle/sofle.conf
  72. 93
      app/boards/shields/sofle/sofle.dtsi
  73. 64
      app/boards/shields/sofle/sofle.keymap
  74. 5
      app/boards/shields/sofle/sofle_left.conf
  75. 26
      app/boards/shields/sofle/sofle_left.overlay
  76. 5
      app/boards/shields/sofle/sofle_right.conf
  77. 30
      app/boards/shields/sofle/sofle_right.overlay
  78. 22
      app/boards/shields/splitreus62/Kconfig.defconfig
  79. 8
      app/boards/shields/splitreus62/Kconfig.shield
  80. 0
      app/boards/shields/splitreus62/splitreus62.conf
  81. 50
      app/boards/shields/splitreus62/splitreus62.dtsi
  82. 31
      app/boards/shields/splitreus62/splitreus62.keymap
  83. 2
      app/boards/shields/splitreus62/splitreus62_left.conf
  84. 18
      app/boards/shields/splitreus62/splitreus62_left.overlay
  85. 2
      app/boards/shields/splitreus62/splitreus62_right.conf
  86. 22
      app/boards/shields/splitreus62/splitreus62_right.overlay
  87. 1
      app/cmake/zmk_config.cmake
  88. 51
      app/drivers/zephyr/ec11.c
  89. 5
      app/drivers/zephyr/ec11.h
  90. 72
      app/drivers/zephyr/ec11_trigger.c
  91. 137
      app/drivers/zephyr/kscan_gpio_direct.c
  92. 208
      app/drivers/zephyr/kscan_gpio_matrix.c
  93. 2
      app/dts/behaviors.dtsi
  94. 9
      app/dts/behaviors/bluetooth.dtsi
  95. 12
      app/dts/behaviors/layer_tap.dtsi
  96. 5
      app/dts/behaviors/mod_tap.dtsi
  97. 9
      app/dts/behaviors/reset.dtsi
  98. 4
      app/dts/behaviors/toggle_layer.dtsi
  99. 8
      app/dts/bindings/behaviors/zmk,behavior-bluetooth.yaml
  100. 23
      app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml
  101. Some files were not shown because too many files have changed in this diff Show More

4
.clang-format

@ -0,0 +1,4 @@
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
SortIncludes: false

4
.github/workflows/build.yml

@ -16,6 +16,8 @@ jobs:
- kyria_right - kyria_right
- lily58_left - lily58_left
- lily58_right - lily58_right
- romac
- settings_reset
include: include:
- board: proton_c - board: proton_c
shield: clueboard_california shield: clueboard_california
@ -25,6 +27,8 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache west modules - name: Cache west modules
timeout-minutes: 2
continue-on-error: true
uses: actions/cache@v2 uses: actions/cache@v2
env: env:
cache-name: cache-zephyr-modules cache-name: cache-zephyr-modules

25
.github/workflows/clang-format-lint.yml

@ -0,0 +1,25 @@
name: clang-format-lint
on:
push:
paths:
- "app/boards/**/*.c"
- "app/include/**/*.h"
- "app/src/**"
pull_request:
paths:
- "app/boards/**/*.c"
- "app/include/**/*.h"
- "app/src/**"
jobs:
build:
runs-on: ubuntu-latest
name: clang-format lint
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.9
with:
source: "./app"
extensions: "h,c"

70
.github/workflows/test.yml

@ -0,0 +1,70 @@
on:
push:
paths:
- "app/tests/**"
- "app/src/**"
pull_request:
paths:
- "app/tests/**"
- "app/src/**"
name: Test
jobs:
integration_test:
runs-on: ubuntu-latest
name: Integration Tests
steps:
# To use this repository's private action,
# you must check out the repository
- name: Checkout
uses: actions/checkout@v2
- name: Cache west modules
timeout-minutes: 2
continue-on-error: true
uses: actions/cache@v2
env:
cache-name: cache-zephyr-modules
with:
path: |
modules/
tools/
zephyr/
bootloader/
key: 2-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('app/west.yml') }}
restore-keys: |
2-${{ runner.os }}-build-${{ env.cache-name }}-
2-${{ runner.os }}-build-
2-${{ runner.os }}-
- name: West Init
uses: "docker://zmkfirmware/zephyr-west-action-arm:latest"
id: west-init
with:
args: 'init "-l app"'
- name: West Update
uses: "docker://zmkfirmware/zephyr-west-action-arm:latest"
id: west-update
with:
args: "update"
- name: West Config Zephyr Base
uses: "docker://zmkfirmware/zephyr-west-action-arm:latest"
id: west-config
with:
args: 'config "--global zephyr.base-prefer configfile"'
- name: West Zephyr Export
uses: "docker://zmkfirmware/zephyr-west-action-arm:latest"
id: west-zephyr-export
with:
args: "zephyr-export"
- name: Test All
uses: "docker://zmkfirmware/zephyr-west-action-arm:latest"
id: west-build
with:
entrypoint: /bin/bash
args: '-c "cd app && ./run-test.sh all"'
- name: Archive Build
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: "log-files"
path: app/build/**/*.log

1
.gitignore vendored

@ -4,3 +4,4 @@
/tools /tools
/zephyr /zephyr
/build /build
*.DS_Store

11
AUTHORS

@ -0,0 +1,11 @@
# The ZMK Project consists of many contributors. This file includes individuals
# who have contributed significant changes to the project. To be added to here,
# please submit a PR to the project repo.
Peter Johanson (@petejohanson)
Innovaker (@innovaker)
Nick Winans (@Nicell)
Okke Formsma (@okke-formsma)
Cody McGinnis (@BrainWart)
Kurtis Lew (@kurtis-lew)
Richard Jones (@bmcgavin)
Kevin Chen (@chenkevinh)

28
app/CMakeLists.txt

@ -1,4 +1,3 @@
# Find Zephyr. This also loads Zephyr's build system.
cmake_minimum_required(VERSION 3.13.1) cmake_minimum_required(VERSION 3.13.1)
set(CONFIG_APPLICATION_DEFINED_SYSCALL true) set(CONFIG_APPLICATION_DEFINED_SYSCALL true)
@ -15,6 +14,7 @@ list(APPEND SYSCALL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/drivers/zephyr)
include(cmake/zmk_config.cmake) include(cmake/zmk_config.cmake)
# Find Zephyr. This also loads Zephyr's build system.
find_package(Zephyr REQUIRED HINTS ../zephyr) find_package(Zephyr REQUIRED HINTS ../zephyr)
project(zmk) project(zmk)
@ -25,26 +25,30 @@ zephyr_linker_sources(RODATA include/linker/zmk-events.ld)
target_include_directories(app PRIVATE include) target_include_directories(app PRIVATE include)
target_sources(app PRIVATE src/kscan.c) target_sources(app PRIVATE src/kscan.c)
target_sources(app PRIVATE src/matrix_transform.c) target_sources(app PRIVATE src/matrix_transform.c)
target_sources(app PRIVATE src/keymap.c)
target_sources(app PRIVATE src/hid.c) target_sources(app PRIVATE src/hid.c)
target_sources(app PRIVATE src/sensors.c) target_sources(app PRIVATE src/sensors.c)
target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c) target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c)
target_sources(app PRIVATE src/event_manager.c) target_sources(app PRIVATE src/event_manager.c)
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble_unpair_combo.c)
target_sources(app PRIVATE src/events/position_state_changed.c) target_sources(app PRIVATE src/events/position_state_changed.c)
target_sources(app PRIVATE src/events/keycode_state_changed.c) target_sources(app PRIVATE src/events/keycode_state_changed.c)
target_sources(app PRIVATE src/events/modifiers_state_changed.c) target_sources(app PRIVATE src/events/modifiers_state_changed.c)
target_sources(app PRIVATE src/events/sensor_event.c) target_sources(app PRIVATE src/events/sensor_event.c)
target_sources(app PRIVATE src/behaviors/behavior_key_press.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/events/ble_active_profile_changed.c)
target_sources(app PRIVATE src/behaviors/behavior_reset.c) if (NOT CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL)
target_sources(app PRIVATE src/behaviors/behavior_mod_tap.c) target_sources(app PRIVATE src/behaviors/behavior_key_press.c)
target_sources(app PRIVATE src/behaviors/behavior_momentary_layer.c) target_sources(app PRIVATE src/behaviors/behavior_reset.c)
target_sources(app PRIVATE src/behaviors/behavior_toggle_layer.c) target_sources(app PRIVATE src/behaviors/behavior_hold_tap.c)
target_sources(app PRIVATE src/behaviors/behavior_transparent.c) target_sources(app PRIVATE src/behaviors/behavior_momentary_layer.c)
target_sources(app PRIVATE src/behaviors/behavior_none.c) target_sources(app PRIVATE src/behaviors/behavior_toggle_layer.c)
target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) target_sources(app PRIVATE src/behaviors/behavior_transparent.c)
target_sources(app PRIVATE src/behaviors/behavior_none.c)
target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c)
target_sources(app PRIVATE src/keymap.c)
endif()
target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c)
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/behaviors/behavior_bt.c)
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble.c)
target_sources_ifdef(CONFIG_ZMK_BLE_UNPAIR_COMBO app PRIVATE src/ble_unpair_combo.c)
target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split_listener.c) target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split_listener.c)
target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split/bluetooth/service.c) target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split/bluetooth/service.c)
target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL app PRIVATE src/split/bluetooth/central.c) target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL app PRIVATE src/split/bluetooth/central.c)
@ -57,3 +61,5 @@ target_sources(app PRIVATE src/endpoints.c)
target_sources(app PRIVATE src/hid_listener.c) target_sources(app PRIVATE src/hid_listener.c)
target_sources_ifdef(CONFIG_SETTINGS app PRIVATE src/settings.c) target_sources_ifdef(CONFIG_SETTINGS app PRIVATE src/settings.c)
target_sources(app PRIVATE src/main.c) target_sources(app PRIVATE src/main.c)
zephyr_cc_option(-Wfatal-errors)

44
app/Kconfig

@ -37,20 +37,15 @@ menuconfig ZMK_BLE
select BT select BT
select BT_SMP select BT_SMP
select BT_SMP_SC_PAIR_ONLY select BT_SMP_SC_PAIR_ONLY
select BT_SMP_APP_PAIRING_ACCEPT
select BT_PERIPHERAL select BT_PERIPHERAL
select BT_GATT_DIS select BT_GATT_DIS
select BT_GATT_BAS select BT_GATT_BAS
select SETTINGS
select BT_SETTINGS select BT_SETTINGS
select SETTINGS
if ZMK_BLE if ZMK_BLE
config ZMK_BLE_UNPAIR_COMBO
bool "Enable BT unpair combo"
help
Adds a magic key combo that can be held on startup to remove all paired devices
default n
config ZMK_BLE_INIT_PRIORITY config ZMK_BLE_INIT_PRIORITY
int "Init Priority" int "Init Priority"
default 50 default 50
@ -58,6 +53,10 @@ config ZMK_BLE_INIT_PRIORITY
config SYSTEM_WORKQUEUE_STACK_SIZE config SYSTEM_WORKQUEUE_STACK_SIZE
default 2048 default 2048
config ZMK_BLE_CLEAR_BONDS_ON_START
bool "Configuration that clears all bond information from the keyboard on startup."
default n
# HID GATT notifications sent this way are *not* picked up by Linux, and possibly others. # HID GATT notifications sent this way are *not* picked up by Linux, and possibly others.
config BT_GATT_NOTIFY_MULTIPLE config BT_GATT_NOTIFY_MULTIPLE
default n default n
@ -107,28 +106,20 @@ config ZMK_SPLIT_BLE_ROLE_CENTRAL
select BT_CENTRAL select BT_CENTRAL
select BT_GATT_CLIENT select BT_GATT_CLIENT
if ZMK_SPLIT_BLE_ROLE_CENTRAL
config BT_MAX_CONN
default 5
config BT_MAX_PAIRED
# Bump this everywhere once we support switching active connections!
default 2
endif
config ZMK_SPLIT_BLE_ROLE_PERIPHERAL config ZMK_SPLIT_BLE_ROLE_PERIPHERAL
bool "Peripheral" bool "Peripheral"
select BT_KEYS_OVERWRITE_OLDEST
if ZMK_SPLIT_BLE_ROLE_PERIPHERAL if ZMK_SPLIT_BLE_ROLE_PERIPHERAL
config ZMK_USB config ZMK_USB
default n default n
config BT_MAX_PAIRED
default 1
config BT_MAX_CONN config BT_MAX_CONN
default 5 default 1
config BT_GAP_AUTO_UPDATE_CONN_PARAMS config BT_GAP_AUTO_UPDATE_CONN_PARAMS
default n default n
@ -141,8 +132,17 @@ endif
endif endif
endmenu if ZMK_BLE && (!ZMK_SPLIT_BLE || ZMK_SPLIT_BLE_ROLE_CENTRAL)
config BT_MAX_CONN
default 6
config BT_MAX_PAIRED
default 5
endif
endmenu
config ZMK_KSCAN_MOCK_DRIVER config ZMK_KSCAN_MOCK_DRIVER
bool "Enable mock kscan driver to simulate key presses" bool "Enable mock kscan driver to simulate key presses"
@ -227,6 +227,10 @@ source "subsys/logging/Kconfig.template.log_config"
rsource "boards/Kconfig" rsource "boards/Kconfig"
rsource "boards/shields/*/Kconfig.defconfig" rsource "boards/shields/*/Kconfig.defconfig"
rsource "boards/shields/*/Kconfig.shield"
osource "$(ZMK_CONFIG)/boards/shields/*/Kconfig.defconfig"
osource "$(ZMK_CONFIG)/boards/shields/*/Kconfig.shield"
source "Kconfig.zephyr" source "Kconfig.zephyr"

7
app/boards/arm/dz60rgb/CMakeLists.txt

@ -0,0 +1,7 @@
# SPDX-License-Identifier: MIT
if(CONFIG_PINMUX)
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
endif()

6
app/boards/arm/dz60rgb/Kconfig.board

@ -0,0 +1,6 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
config BOARD_DZ60RGB_REV1
bool "DZ60RGB Keyboard"
depends on SOC_STM32F303XC

14
app/boards/arm/dz60rgb/Kconfig.defconfig

@ -0,0 +1,14 @@
# DZ60RGB keyboard configuration
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
if BOARD_DZ60RGB_REV1
config ZMK_KEYBOARD_NAME
default "DZ60RGB Rev 1"
config ZMK_USB
default y
endif # BOARD_DZ60RGB_REV1

7
app/boards/arm/dz60rgb/board.cmake

@ -0,0 +1,7 @@
# SPDX-License-Identifier: MIT
board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse")
board_runner_args(jlink "--device=STM32F303CC" "--speed=4000")
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)

88
app/boards/arm/dz60rgb/dz60rgb_rev1.dts

@ -0,0 +1,88 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
/dts-v1/;
#include <st/f3/stm32f303Xc.dtsi>
#include <dt-bindings/zmk/matrix-transform.h>
/ {
model = "DZ60RGB, Rev 1";
compatible = "dz60rgb,rev1", "st,stm32f303";
chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zmk,kscan = &kscan0;
zmk,matrix_transform = &default_transform;
};
default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <14>;
rows = <5>;
map = <
RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(0,12) RC(0,13)
RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13)
RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,13)
RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) RC(3,13)
RC(4,0) RC(4,1) RC(4,2) RC(4,5) RC(4,8) RC(4,9) RC(4,10) RC(4,11) RC(4,13)
>;
};
kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
row-gpios
= <&gpioa 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&gpiob 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&gpiob 11 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&gpiob 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&gpiob 12 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
col-gpios
= <&gpioa 6 GPIO_ACTIVE_HIGH>
, <&gpioa 7 GPIO_ACTIVE_HIGH>
, <&gpiob 0 GPIO_ACTIVE_HIGH>
, <&gpiob 13 GPIO_ACTIVE_HIGH>
, <&gpiob 15 GPIO_ACTIVE_HIGH>
, <&gpioa 8 GPIO_ACTIVE_HIGH>
, <&gpioa 15 GPIO_ACTIVE_HIGH>
, <&gpiob 3 GPIO_ACTIVE_HIGH>
, <&gpiob 4 GPIO_ACTIVE_HIGH>
, <&gpiob 5 GPIO_ACTIVE_HIGH>
, <&gpiob 8 GPIO_ACTIVE_HIGH>
, <&gpiob 9 GPIO_ACTIVE_HIGH>
, <&gpioc 13 GPIO_ACTIVE_HIGH>
, <&gpioc 14 GPIO_ACTIVE_HIGH>
;
};
};
&usb {
status = "okay";
};
&flash0 {
/*
* For more information, see:
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
/* Set 6Kb of storage at the end of the 256Kb of flash */
storage_partition: partition@3e800 {
label = "storage";
reg = <0x0003e800 0x00001800>;
};
};
};

25
app/boards/arm/dz60rgb/dz60rgb_rev1.keymap

@ -0,0 +1,25 @@
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
// ------------------------------------------------------------------------------------------
// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BKSP |
// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | "|" |
// | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER |
// | SHIFT | Z | X | C | V | B | N | M | , | . | SHIFT(/) | ^ | DEL |
// | CTL | WIN | ALT | SPACE | ALT | MO(1) | <- | v | -> |
// ------------------------------------------------------------------------------------------
bindings = <
&kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS &kp EQL &kp BKSP
&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH
&kp CLCK &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT &kp RET
&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &mt MOD_RSFT FSLH &kp UARW &kp DEL
&kp LCTL &kp LGUI &kp LALT &kp SPC &kp RALT &mo 1 &kp LARW &kp DARW &kp RARW
>;
};
};
};

19
app/boards/arm/dz60rgb/dz60rgb_rev1.yaml

@ -0,0 +1,19 @@
identifier: DZ60RGB_rev1
name: DZ60RGBREV1
type: keyboard
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 40
supported:
- gpio
- i2c
- counter
- spi
- usb_device
- lsm303dlhc
- nvs
- can
- kscan

27
app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig

@ -0,0 +1,27 @@
# SPDX-License-Identifier: MIT
CONFIG_SOC_SERIES_STM32F3X=y
CONFIG_SOC_STM32F303XC=y
# 72MHz system clock
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000
# enable pinmux
CONFIG_PINMUX=y
# enable GPIO
CONFIG_GPIO=y
# clock configuration
CONFIG_CLOCK_CONTROL=y
# Clock configuration for Cube Clock control driver
CONFIG_CLOCK_STM32_HSE_CLOCK=8000000
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# use HSE as PLL input
CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
# produce 72MHz clock at PLL output
CONFIG_CLOCK_STM32_PLL_PREDIV=1
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
CONFIG_CLOCK_STM32_APB1_PRESCALER=2
CONFIG_CLOCK_STM32_APB2_PRESCALER=1

67
app/boards/arm/dz60rgb/pinmux.c

@ -0,0 +1,67 @@
/*
* Copyright (c) 2017 I-SENSE group of ICCS
*
* SPDX-License-Identifier: MIT
*/
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <drivers/pinmux.h>
#include <sys/sys_io.h>
#include <pinmux/stm32/pinmux_stm32.h>
/* pin assignments for STM32F3DISCOVERY board */
static const struct pin_config pinconf[] = {
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay) && CONFIG_SERIAL
{STM32_PIN_PC4, STM32F3_PINMUX_FUNC_PC4_USART1_TX},
{STM32_PIN_PC5, STM32F3_PINMUX_FUNC_PC5_USART1_RX},
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart2), okay) && CONFIG_SERIAL
{STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA3, STM32F3_PINMUX_FUNC_PA3_USART2_RX},
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C
{STM32_PIN_PB6, STM32F3_PINMUX_FUNC_PB6_I2C1_SCL},
{STM32_PIN_PB7, STM32F3_PINMUX_FUNC_PB7_I2C1_SDA},
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c2), okay) && CONFIG_I2C
{STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_I2C2_SCL},
{STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_I2C2_SDA},
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI
#ifdef CONFIG_SPI_STM32_USE_HW_SS
{STM32_PIN_PA4, STM32F3_PINMUX_FUNC_PA4_SPI1_NSS},
#endif /* CONFIG_SPI_STM32_USE_HW_SS */
{STM32_PIN_PA5, STM32F3_PINMUX_FUNC_PA5_SPI1_SCK},
{STM32_PIN_PA6, STM32F3_PINMUX_FUNC_PA6_SPI1_MISO},
{STM32_PIN_PA7, STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI},
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi2), okay) && CONFIG_SPI
#ifdef CONFIG_SPI_STM32_USE_HW_SS
{STM32_PIN_PB12, STM32F3_PINMUX_FUNC_PB12_SPI2_NSS},
#endif /* CONFIG_SPI_STM32_USE_HW_SS */
{STM32_PIN_PB13, STM32F3_PINMUX_FUNC_PB13_SPI2_SCK},
{STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO},
{STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI},
#endif
#ifdef CONFIG_USB_DC_STM32
{STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM},
{STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP},
#endif /* CONFIG_USB_DC_STM32 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(can1), okay) && CONFIG_CAN
{STM32_PIN_PD0, STM32F3_PINMUX_FUNC_PD0_CAN1_RX},
{STM32_PIN_PD1, STM32F3_PINMUX_FUNC_PD1_CAN1_TX},
#endif
};
static int pinmux_stm32_init(struct device *port) {
ARG_UNUSED(port);
stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));
return 0;
}
SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);

5
app/boards/arm/nrfmicro/Kconfig

@ -3,3 +3,8 @@ config BOARD_ENABLE_DCDC
select SOC_DCDC_NRF52X select SOC_DCDC_NRF52X
default y default y
depends on (BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13) depends on (BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13)
config BOARD_NRFMICRO_CHARGER
bool "Enable battery charger"
default y
depends on (BOARD_NRFMICRO_13)

2
app/boards/arm/nrfmicro/Kconfig.board

@ -1,6 +1,6 @@
# nrfmicro board configuration # nrfmicro board configuration
# Copyright (c) 2020 Okke Formsma, joric # Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
config BOARD_NRFMICRO_11 config BOARD_NRFMICRO_11

9
app/boards/arm/nrfmicro/Kconfig.defconfig

@ -1,6 +1,6 @@
# Electronut Labs Papyr board configuration # Electronut Labs Papyr board configuration
# Copyright (c) 2020 Okke Formsma, joric # Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
if BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13 if BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13
@ -30,4 +30,11 @@ config ZMK_USB
config PINMUX config PINMUX
default y default y
if BOARD_NRFMICRO_13
config BOARD_NRFMICRO_CHARGER
default y
endif # BOARD_NRFMICRO_13
endif # BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13 endif # BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13

2
app/boards/arm/nrfmicro/arduino_pro_micro_pins.dtsi

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Okke Formsma, joric * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */

2
app/boards/arm/nrfmicro/arduino_pro_micro_pins_flipped.dtsi

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Okke Formsma, joric * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */

2
app/boards/arm/nrfmicro/nrfmicro_11.dts

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Okke Formsma, joric * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */

2
app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Okke Formsma, joric * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */

2
app/boards/arm/nrfmicro/nrfmicro_13.dts

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Okke Formsma, joric * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */

13
app/boards/arm/nrfmicro/pinmux.c

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Okke Formsma, joric * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
@ -11,21 +11,24 @@
#include <sys/sys_io.h> #include <sys/sys_io.h>
#include <devicetree.h> #include <devicetree.h>
static int pinmux_nrfmicro_init(struct device *port) static int pinmux_nrfmicro_init(struct device *port) {
{
ARG_UNUSED(port); ARG_UNUSED(port);
struct device *p1 = device_get_binding("GPIO_1"); struct device *p1 = device_get_binding("GPIO_1");
#if defined(BOARD_NRFMICRO_13) #if CONFIG_BOARD_NRFMICRO_13
struct device *p0 = device_get_binding("GPIO_0"); struct device *p0 = device_get_binding("GPIO_0");
// enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1)
gpio_pin_configure(p1, 9, GPIO_OUTPUT); gpio_pin_configure(p1, 9, GPIO_OUTPUT);
gpio_pin_set(p1, 9, 0); gpio_pin_set(p1, 9, 0);
// enable charger (nRFMicro 1.3 only) #if CONFIG_BOARD_NRFMICRO_CHARGER
gpio_pin_configure(p0, 5, GPIO_OUTPUT); gpio_pin_configure(p0, 5, GPIO_OUTPUT);
gpio_pin_set(p0, 5, 0); gpio_pin_set(p0, 5, 0);
#else
gpio_pin_configure(p0, 5, GPIO_INPUT);
#endif
#else #else
// enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1)
gpio_pin_configure(p1, 9, GPIO_OUTPUT); gpio_pin_configure(p1, 9, GPIO_OUTPUT);

2
app/boards/arm/planck/Kconfig.board

@ -1,6 +1,6 @@
# Planck V6 board configuration # Planck V6 board configuration
# Copyright (c) 2020 Peter Johanson # Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
config BOARD_PLANCK_REV6 config BOARD_PLANCK_REV6

2
app/boards/arm/planck/Kconfig.defconfig

@ -1,6 +1,6 @@
# Planck keyboard configuration # Planck keyboard configuration
# Copyright (c) 2020 Peter Johanson # Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
if BOARD_PLANCK_REV6 if BOARD_PLANCK_REV6

6
app/boards/arm/planck/pinmux.c

@ -56,8 +56,7 @@ static const struct pin_config pinconf[] = {
#endif /* CONFIG_CAN_1 */ #endif /* CONFIG_CAN_1 */
}; };
static int pinmux_stm32_init(struct device *port) static int pinmux_stm32_init(struct device *port) {
{
ARG_UNUSED(port); ARG_UNUSED(port);
stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));
@ -65,5 +64,4 @@ static int pinmux_stm32_init(struct device *port)
return 0; return 0;
} }
SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);

3
app/boards/arm/planck/planck_rev6_defconfig

@ -20,9 +20,6 @@ CONFIG_CLOCK_STM32_HSE_CLOCK=8000000
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# use HSE as PLL input # use HSE as PLL input
CONFIG_CLOCK_STM32_PLL_SRC_HSE=y CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
# however, the board does not have an external oscillator, so just use
# the 8MHz clock signal coming from integrated STLink
CONFIG_CLOCK_STM32_HSE_BYPASS=y
# produce 72MHz clock at PLL output # produce 72MHz clock at PLL output
CONFIG_CLOCK_STM32_PLL_PREDIV=1 CONFIG_CLOCK_STM32_PLL_PREDIV=1
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9 CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9

6
app/boards/arm/proton_c/pinmux.c

@ -56,8 +56,7 @@ static const struct pin_config pinconf[] = {
#endif #endif
}; };
static int pinmux_stm32_init(struct device *port) static int pinmux_stm32_init(struct device *port) {
{
ARG_UNUSED(port); ARG_UNUSED(port);
stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));
@ -65,5 +64,4 @@ static int pinmux_stm32_init(struct device *port)
return 0; return 0;
} }
SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);

3
app/boards/native_posix.conf

@ -1,9 +1,8 @@
CONFIG_KSCAN=n CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=n CONFIG_GPIO=n
CONFIG_ZMK_BLE=n CONFIG_ZMK_BLE=n
CONFIG_LOG=y CONFIG_LOG=y
CONFIG_KSCAN_LOG_LEVEL_DBG=y CONFIG_LOG_BACKEND_SHOW_COLOR=n
CONFIG_ZMK_LOG_LEVEL_DBG=y CONFIG_ZMK_LOG_LEVEL_DBG=y

73
app/boards/native_posix.overlay

@ -1,79 +1,18 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi> #include <behaviors.dtsi>
#include <zmk/kscan-mock.h> #include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/kscan-mock.h>
/ { / {
chosen { chosen {
zmk,kscan = &kscan0; zmk,kscan = &kscan;
zmk,keymap = &keymap0;
};
kscan0: kscan_0 {
compatible = "zmk,kscan-composite";
label = "KSCAN_COMP";
rows = <2>;
columns = <4>;
left: left {
kscan = <&left_hand>;
};
right: right {
kscan = <&right_hand>;
column-offset = <2>;
};
};
left_hand: kscan_1 {
compatible = "zmk,kscan-mock";
label = "KSCAN_LEFT";
rows = <2>;
columns = <2>;
events = <ZMK_MOCK_PRESS(0,1,300) ZMK_MOCK_PRESS(0,0,300) ZMK_MOCK_RELEASE(0,0,300) ZMK_MOCK_RELEASE(0,1,300)>;
// events = <ZMK_MOCK_PRESS(0,0,800) ZMK_MOCK_RELEASE(0,0,800) ZMK_MOCK_PRESS(0,1,800) ZMK_MOCK_RELEASE(0,1,800)>;
}; };
right_hand: kscan_2 { kscan: kscan {
compatible = "zmk,kscan-mock"; compatible = "zmk,kscan-mock";
label = "KSCAN_RIGHT"; label = "KSCAN_MOCK";
rows = <2>; rows = <2>;
columns = <2>; columns = <2>;
events = <ZMK_MOCK_PRESS(1,1,800) ZMK_MOCK_RELEASE(1,1,100) ZMK_MOCK_PRESS(0,1,800) ZMK_MOCK_RELEASE(0,1,100)>; exit-after;
};
keymap0: keymap {
compatible = "zmk,keymap";
label ="Default keymap";
layers = <&default &lower &raise>;
};
layers {
compatible = "zmk,layers";
default: layer_0 {
label = "DEFAULT";
bindings = <
&kp B &mo 1 &kp C &kp E
&kp D &kp G &kp F &kp Q>;
};
lower: layer_1 {
label = "LOWER";
bindings = <
&cp M_NEXT &trans &kp O &kp Q
&kp L &kp J &kp P &kp K>;
};
raise: layer_2 {
label = "RAISE";
bindings = <
&kp W &kp U &kp I &kp N
&kp X &kp M &kp C &kp B>;
};
}; };
}; };

5
app/boards/shields/corne/corne.keymap

@ -1,5 +1,6 @@
#include <behaviors.dtsi> #include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h> #include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
/ { / {
keymap { keymap {
@ -21,12 +22,12 @@
lower_layer { lower_layer {
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
// | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP | // | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP |
// | CTRL | | | | | | | LFT | DWN | UP | RGT | | | // | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | LFT | DWN | UP | RGT | | |
// | SHFT | | | | | | | | | | | | | // | SHFT | | | | | | | | | | | | |
// | GUI | | SPC | | ENT | | ALT | // | GUI | | SPC | | ENT | | ALT |
bindings = < bindings = <
&kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp BKSP &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp BKSP
&kp LCTL &trans &trans &trans &trans &trans &kp LARW &kp DARW &kp UARW &kp RARW &trans &trans &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LARW &kp DARW &kp UARW &kp RARW &trans &trans
&kp LSFT &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp LSFT &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&kp LGUI &trans &kp SPC &kp RET &trans &kp RALT &kp LGUI &trans &kp SPC &kp RET &trans &kp RALT
>; >;

1
app/boards/shields/corne/corne_left.conf

@ -1,3 +1,2 @@
CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
CONFIG_ZMK_BLE_UNPAIR_COMBO=y

1
app/boards/shields/corne/corne_right.conf

@ -1,3 +1,2 @@
CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
CONFIG_ZMK_BLE_UNPAIR_COMBO=y

16
app/boards/shields/iris/Kconfig.defconfig

@ -0,0 +1,16 @@
# Copyright (c) 2020 Pete Johanson, Kurtis Lew
# SPDX-License-Identifier: MIT
if SHIELD_IRIS_LEFT
config ZMK_KEYBOARD_NAME
default "Iris Left"
endif
if SHIELD_IRIS_RIGHT
config ZMK_KEYBOARD_NAME
default "Iris Right"
endif

8
app/boards/shields/iris/Kconfig.shield

@ -0,0 +1,8 @@
# Copyright (c) 2020 Pete Johanson, Kurtis Lew
# SPDX-License-Identifier: MIT
config SHIELD_IRIS_LEFT
def_bool $(shields_list_contains,iris_left)
config SHIELD_IRIS_RIGHT
def_bool $(shields_list_contains,iris_right)

0
app/boards/shields/iris/iris.conf

51
app/boards/shields/iris/iris.dtsi

@ -0,0 +1,51 @@
/*
* Copyright (c) 2020 Pete Johanson, Kurtis Lew
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix-transform.h>
/ {
chosen {
zmk,kscan = &kscan0;
zmk,matrix_transform = &default_transform;
};
default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <16>;
rows = <4>;
// | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 |
// | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 |
// | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 |
// | SW24 | SW23 | SW22 | SW21 | SW20 | SW19 | SW25 | | SW25 | SW19 | SW20 | SW21 | SW22 | SW23 | SW24 |
// | SW29 | SW28 | SW27 | SW26 | | SW26 | SW27 | SW28 | SW29 |
map = <
RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11)
RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11)
RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11)
RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,2) RC(4,9) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11)
RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(4,8)
>;
};
kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
row-gpios
= <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
};
};

60
app/boards/shields/iris/iris.keymap

@ -0,0 +1,60 @@
# Copyright (c) 2020 Pete Johanson, Kurtis Lew
# SPDX-License-Identifier: MIT
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
// ------------------------------------------------------------------------------------------------------------
// | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | ` |
// | TAB | Q | W | E | R | T | | Y | U | I | O | P | - |
// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' |
// | SHIFT | Z | X | C | V | B | "[" | | "]" | N | M | , | . | / | SHIFT |
// | GUI | LOWER| SPACE | | ENTER | RAISE| ALT |
bindings = <
&kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp GRAV
&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp MINUS
&kp LCTL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT
&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp LBKT &kp RBKT &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT
&kp LGUI &mo 1 &kp SPC &kp RET &mo 2 &kp RALT
>;
};
lower_layer {
// ------------------------------------------------------------------------------------------------------------
// | BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | |
// | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 |
// | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ |
// | | | | | | | | | | | _ | + | { | } | "|" |
// | | | | | | | |
bindings = <
&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans &trans &trans &trans &trans &trans
&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12
&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD
&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE
&trans &trans &trans &trans &trans &trans
>;
};
raise_layer {
// ------------------------------------------------------------------------------------------------------------
// | | | | | | | | | | | | | |
// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
// | F1 | F2 | F3 | F4 | F5 | F6 | | | <- | ^ | v | -> | |
// | F7 | F8 | F9 | F10 | F11 | F12 | | | | + | - | = | [ | ] | \ |
// | | | | | | | |
bindings = <
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &trans
&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &trans &kp LARW &kp DARW &kp UARW &kp RARW &trans
&kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &trans &kp KPLS &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH
&trans &trans &trans &trans &trans &trans
>;
};
};
};

2
app/boards/shields/iris/iris_left.conf

@ -0,0 +1,2 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y

22
app/boards/shields/iris/iris_left.overlay

@ -0,0 +1,22 @@
/*
* Copyright (c) 2020 Pete Johanson, Kurtis Lew
*
* SPDX-License-Identifier: MIT
*/
#include "iris.dtsi"
&kscan0 {
col-gpios
= <&pro_micro_a 1 GPIO_ACTIVE_HIGH>
, <&pro_micro_a 0 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 15 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 14 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 16 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 10 GPIO_ACTIVE_HIGH>
;
};
&bt_unpair_combo {
key-positions = <0 42>;
};

2
app/boards/shields/iris/iris_right.conf

@ -0,0 +1,2 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y

26
app/boards/shields/iris/iris_right.overlay

@ -0,0 +1,26 @@
/*
* Copyright (c) 2020 Pete Johanson, Kurtis Lew
*
* SPDX-License-Identifier: MIT
*/
#include "iris.dtsi"
&default_transform {
col-offset = <6>;
};
&kscan0 {
col-gpios
= <&pro_micro_d 10 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 16 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 14 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 15 GPIO_ACTIVE_HIGH>
, <&pro_micro_a 0 GPIO_ACTIVE_HIGH>
, <&pro_micro_a 1 GPIO_ACTIVE_HIGH>
;
};
&bt_unpair_combo {
key-positions = <11 43>;
};

1
app/boards/shields/kyria/kyria_left.conf

@ -1,3 +1,2 @@
CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
CONFIG_ZMK_BLE_UNPAIR_COMBO=y

1
app/boards/shields/kyria/kyria_right.conf

@ -1,3 +1,2 @@
CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
CONFIG_ZMK_BLE_UNPAIR_COMBO=y

4
app/boards/shields/lily58/lily58.conf

@ -1,2 +1,6 @@
# Uncomment to enable encoder
# CONFIG_EC11=y
# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y
# Uncomment the following line to enable the Lily58 OLED Display # Uncomment the following line to enable the Lily58 OLED Display
# CONFIG_ZMK_DISPLAY=y # CONFIG_ZMK_DISPLAY=y

15
app/boards/shields/lily58/lily58.dtsi

@ -15,7 +15,7 @@
default_transform: keymap_transform_0 { default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform"; compatible = "zmk,matrix-transform";
columns = <16>; columns = <16>;
rows = <4>; rows = <5>;
// | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | // | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 |
// | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | // | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 |
// | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | // | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 |
@ -45,6 +45,19 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7)
}; };
left_encoder: encoder_left {
compatible = "alps,ec11";
label = "LEFT_ENCODER";
a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
resolution = <4>;
};
sensors {
compatible = "zmk,keymap-sensors";
sensors = <&left_encoder>;
};
bt_unpair_combo: bt_unpair_combo { bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo"; compatible = "zmk,bt-unpair-combo";
}; };

11
app/boards/shields/lily58/lily58.keymap

@ -1,5 +1,6 @@
#include <behaviors.dtsi> #include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h> #include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
/ { / {
keymap { keymap {
@ -19,22 +20,26 @@
&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp LBKT &kp RBKT &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT &kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp LBKT &kp RBKT &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT
&kp LALT &kp LGUI &mo 1 &kp SPC &kp RET &mo 2 &kp BKSP &kp RGUI &kp LALT &kp LGUI &mo 1 &kp SPC &kp RET &mo 2 &kp BKSP &kp RGUI
>; >;
sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>;
}; };
lower_layer { lower_layer {
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
// | | | | | | | | | | | | | | // | BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | |
// | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | // | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 |
// | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ | // | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ |
// | | | | | | | | | | | _ | + | { | } | "|" | // | | | | | | | | | | | _ | + | { | } | "|" |
// | | | | | | | | | | // | | | | | | | | | |
bindings = < bindings = <
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans &trans &trans &trans &trans &trans
&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12
&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD &kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD
&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
>; >;
sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>;
}; };
raise_layer { raise_layer {
@ -51,6 +56,8 @@
&kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &trans &kp KPLS &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &trans &kp KPLS &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
>; >;
sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>;
}; };
}; };
}; };

5
app/boards/shields/lily58/lily58_left.conf

@ -1,3 +1,6 @@
# Uncomment to enable encoder
# CONFIG_EC11=y
# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y
CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
CONFIG_ZMK_BLE_UNPAIR_COMBO=y

6
app/boards/shields/lily58/lily58_left.overlay

@ -17,6 +17,10 @@
; ;
}; };
&left_encoder {
status = "okay";
};
&bt_unpair_combo { &bt_unpair_combo {
key-positions = <0 42>; key-positions = <0 53>;
}; };

1
app/boards/shields/lily58/lily58_right.conf

@ -1,3 +1,2 @@
CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
CONFIG_ZMK_BLE_UNPAIR_COMBO=y

2
app/boards/shields/lily58/lily58_right.overlay

@ -22,5 +22,5 @@
}; };
&bt_unpair_combo { &bt_unpair_combo {
key-positions = <11 43>; key-positions = <11 54>;
}; };

9
app/boards/shields/qaz/Kconfig.defconfig

@ -0,0 +1,9 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
if SHIELD_QAZ
config ZMK_KEYBOARD_NAME
default "QAZ"
endif

5
app/boards/shields/qaz/Kconfig.shield

@ -0,0 +1,5 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
config SHIELD_QAZ
def_bool $(shields_list_contains,qaz)

58
app/boards/shields/qaz/qaz.keymap

@ -0,0 +1,58 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
#define DEFAULT 0
#define NUM_SYM 1
#define NAV 2
/ {
behaviors {
hm: homerow_mods {
compatible = "zmk,behavior-hold-tap";
label = "homerow mods";
#binding-cells = <2>;
tapping_term_ms = <225>;
flavor = "tap-preferred";
bindings = <&kp>, <&kp>;
};
};
};
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P
&hm LGUI A &hm LALT S &hm LCTL D &hm LSFT F &kp G &kp H &hm RSFT J &hm RCTL K &hm RALT L &hm RGUI RET
&kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT
&kp LSFT &kp LGUI &kp LALT &lt NAV RET &lt NUM_SYM SPC &kp COLN &kp QUOT &kp FSLH
>;
};
num_sym {
bindings = <
&kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0
&trans &trans &trans &trans &trans &trans &trans &trans &kp EQL &kp MINUS
&kp DEL &none &none &none &none &none &none &none &kp DOT
&bootloader &reset &none &trans &trans &kp RET &trans &kp FSLH
>;
};
nav {
bindings = <
&bt BT_CLR &bt BT_NXT &bt BT_PRV &none &none &none &none &kp UARW &none &kp BKSP
&trans &trans &trans &trans &none &none &kp LARW &kp DARW &kp RARW &none
&none &none &none &none &none &none &none &none &none
&none &none &none &trans &trans &kp RET &trans &kp FSLH
>;
};
};
};

53
app/boards/shields/qaz/qaz.overlay

@ -0,0 +1,53 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix-transform.h>
/ {
chosen {
zmk,kscan = &kscan0;
zmk,matrix_transform = &default_transform;
};
default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <7>;
rows = <6>;
map = <
RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(4,0) RC(4,1) RC(4,2)
RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(5,0) RC(5,1) RC(5,2)
RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(4,3) RC(5,3)
RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(4,4)
>;
};
kscan0: kscan_0 {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
col-gpios
= <&pro_micro_d 8 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 1 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 0 GPIO_ACTIVE_HIGH>
, <&pro_micro_a 2 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 9 GPIO_ACTIVE_HIGH>
, <&pro_micro_a 1 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 6 GPIO_ACTIVE_HIGH>
;
row-gpios
= <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};
};

10
app/boards/shields/romac/Kconfig.defconfig

@ -0,0 +1,10 @@
# Copyright (c) 2020 Pete Johanson, Richard Jones
# SPDX-License-Identifier: MIT
if SHIELD_ROMAC
config ZMK_KEYBOARD_NAME
default "RoMac"
endif

5
app/boards/shields/romac/Kconfig.shield

@ -0,0 +1,5 @@
# Copyright (c) 2020 Pete Johanson, Richard Jones
# SPDX-License-Identifier: MIT
config SHIELD_ROMAC
def_bool $(shields_list_contains,romac)

0
app/boards/shields/romac/romac.conf

47
app/boards/shields/romac/romac.keymap

@ -0,0 +1,47 @@
/*
* Copyright (c) 2020 Pete Johanson, Richard Jones
*
* SPDX-License-Identifier: MIT
*/
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
// -------------------
// | 7 | 8 | 9 |
// | 4 | 5 | 6 |
// | 1 | 2 | 3 |
// | MO(1) | 0 | . |
// ----------------------
bindings = <
&kp NUM_7 &kp NUM_8 &kp NUM_9
&kp NUM_4 &kp NUM_5 &kp NUM_6
&kp NUM_1 &kp NUM_2 &kp NUM_3
&mo 1 &kp NUM_0 &kp DOT
>;
};
nav_layer {
// -----------------------
// | BTNXT | HOME | PGUP |
// | BTPRV | END | PGDN |
// | BTCLR | _ | _ |
// | _ | _ | RET |
// -----------------------
bindings = <
&bt BT_NXT &kp HOME &kp PGUP
&bt BT_PRV &kp END &kp PGDN
&bt BT_CLR &trans &trans
&trans &trans &kp RET
>;
};
};
};

40
app/boards/shields/romac/romac.overlay

@ -0,0 +1,40 @@
/*
* Copyright (c) 2020 Pete Johanson, Richard Jones
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix-transform.h>
/ {
chosen {
zmk,kscan = &kscan0;
};
kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
row-gpios
= <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
col-gpios
= <&pro_micro_a 0 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 15 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 14 GPIO_ACTIVE_HIGH>
;
};
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
key-positions = <0 11>;
};
};

10
app/boards/shields/settings_reset/Kconfig.defconfig

@ -0,0 +1,10 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
if SHIELD_SETTINGS_RESET
config ZMK_KEYBOARD_NAME
default "SETTINGS RESET"
endif

5
app/boards/shields/settings_reset/Kconfig.shield

@ -0,0 +1,5 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
config SHIELD_SETTINGS_RESET
def_bool $(shields_list_contains,settings_reset)

1
app/boards/shields/settings_reset/settings_reset.conf

@ -0,0 +1 @@
CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START=y

22
app/boards/shields/settings_reset/settings_reset.keymap

@ -0,0 +1,22 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&reset
>;
};
};
};

24
app/boards/shields/settings_reset/settings_reset.overlay

@ -0,0 +1,24 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix-transform.h>
/ {
chosen {
zmk,kscan = &kscan0;
};
kscan0: kscan {
compatible = "zmk,kscan-gpio-direct";
label = "KSCAN";
input-gpios
= <&pro_micro_d 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
;
};
};

54
app/boards/shields/sofle/Kconfig.defconfig

@ -0,0 +1,54 @@
# Copyright (c) 2020 Ryan Cross
# SPDX-License-Identifier: MIT
if SHIELD_SOFLE_LEFT
config ZMK_KEYBOARD_NAME
default "Sofle Left"
endif
if SHIELD_SOFLE_RIGHT
config ZMK_KEYBOARD_NAME
default "Sofle Right"
endif
if SHIELD_SOFLE_LEFT || SHIELD_SOFLE_RIGHT
if ZMK_DISPLAY
config I2C
default y
config SSD1306
default y
config SSD1306_REVERSE_MODE
default y
endif # ZMK_DISPLAY
if LVGL
config LVGL_HOR_RES
default 128
config LVGL_VER_RES
default 32
config LVGL_VDB_SIZE
default 64
config LVGL_DPI
default 148
config LVGL_BITS_PER_PIXEL
default 1
choice LVGL_COLOR_DEPTH
default LVGL_COLOR_DEPTH_1
endchoice
endif # LVGL
endif

8
app/boards/shields/sofle/Kconfig.shield

@ -0,0 +1,8 @@
# Copyright (c) 2020 Ryan Cross
# SPDX-License-Identifier: MIT
config SHIELD_SOFLE_LEFT
def_bool $(shields_list_contains,sofle_left)
config SHIELD_SOFLE_RIGHT
def_bool $(shields_list_contains,sofle_right)

9
app/boards/shields/sofle/sofle.conf

@ -0,0 +1,9 @@
# Copyright (c) 2020 Ryan Cross
# SPDX-License-Identifier: MIT
# Uncomment the following line to enable the Sofle OLED Display
# CONFIG_ZMK_DISPLAY=y
# Uncomment these two lines to add support for encoders
# CONFIG_EC11=y
# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y

93
app/boards/shields/sofle/sofle.dtsi

@ -0,0 +1,93 @@
/*
* Copyright (c) 2020 Pete Johanson, Ryan Cross
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix-transform.h>
/ {
chosen {
zmk,kscan = &kscan0;
zmk,matrix_transform = &default_transform;
};
default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <16>;
rows = <4>;
// | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 |
// | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 |
// | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 |
// | SW24 | SW23 | SW22 | SW21 | SW20 | SW19 | SW25 | | SW25 | SW19 | SW20 | SW21 | SW22 | SW23 | SW24 |
// | SW30 | SW29 | SW28 | SW27 | SW26 | | SW26 | SW27 | SW28 | SW29 | SW30 |
map = <
RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11)
RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11)
RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11)
RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11)
RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11)
>;
};
kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
row-gpios
= <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};
left_encoder: encoder_left {
compatible = "alps,ec11";
label = "LEFT_ENCODER";
a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
resolution = <4>;
status = "disabled";
};
right_encoder: encoder_right {
compatible = "alps,ec11";
label = "RIGHT_ENCODER";
a-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
resolution = <4>;
status = "disabled";
};
sensors {
compatible = "zmk,keymap-sensors";
sensors = <&left_encoder &right_encoder>;
};
bt_unpair_combo: bt_unpair_combo {
compatible = "zmk,bt-unpair-combo";
};
};
&pro_micro_i2c {
status = "okay";
ssd1306@3c {
compatible = "solomon,ssd1306fb";
reg = <0x3c>;
label = "DISPLAY";
width = <128>;
height = <32>;
segment-offset = <0>;
page-offset = <0>;
display-offset = <0>;
multiplex-ratio = <31>;
segment-remap;
com-invdir;
com-sequential;
prechargep = <0x22>;
};
};

64
app/boards/shields/sofle/sofle.keymap

@ -0,0 +1,64 @@
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
// ------------------------------------------------------------------------------------------------------------
// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
// | ESC | Q | W | E | R | T | | Y | U | I | O | P | BKSPC |
// | TAB | A | S | D | F | G | | H | J | K | L | ; | ' |
// | SHIFT | Z | X | C | V | B | MUTE | | | N | M | , | . | / | SHIFT |
// | GUI | ALT | CTRL | LOWER| ENTER | | SPACE | RAISE| CTRL | ALT | GUI |
bindings = <
&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &none
&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BKSP
&kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT
&kp LSFT &kp Z &kp X &kp C &kp V &kp B &cp M_MUTE &none &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT
&kp LGUI &kp LALT &kp LCTL &mo 1 &kp RET &kp SPC &mo 2 &kp RCTL &kp RALT &kp RGUI
>;
sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>;
};
lower_layer {
// TODO: Some binds are waiting for shifted keycode support.
// ------------------------------------------------------------------------------------------------------------
// | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 |
// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | F12 |
// | | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | |
// | | = | - | + | { | } | | | | [ | ] | ; | : | \ | |
// | | | | | | | | | | | |
bindings = <
&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11
&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp F12
&trans &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp PIPE
&trans &kp EQL &kp MINUS &kp KPLS &kp LCUR &kp RCUR &trans &trans &kp LBKT &kp RBKT &kp SCLN &kp COLN &kp BSLH &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
>;
sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>;
};
raise_layer {
// ------------------------------------------------------------------------------------------------------------
// |BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | |
// | | INS | PSCR | GUI | | | | PGUP | | ^ | | | |
// | | ALT | CTRL | SHIFT | | CAPS | | PGDN | <- | v | -> | DEL | BKSPC |
// | | UNDO | CUT | COPY | PASTE | | | | | | | | | | |
// | | | | | | | | | | | |
bindings = <
&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans &trans &trans &trans &trans &trans
&trans &kp INS &kp PRSC &kp GUI &trans &trans &kp PGUP &trans &kp UARW &trans &kp NUM_0 &trans
&trans &kp LALT &kp LCTL &kp LSFT &trans &kp CLCK &kp PGDN &kp LARW &kp DARW &kp RARW &kp DEL &kp BKSP
&trans &kp UNDO &kp CUT &kp COPY &kp PSTE &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
>;
sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>;
};
};
};

5
app/boards/shields/sofle/sofle_left.conf

@ -0,0 +1,5 @@
# Copyright (c) 2020 Ryan Cross
# SPDX-License-Identifier: MIT
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y

26
app/boards/shields/sofle/sofle_left.overlay

@ -0,0 +1,26 @@
/*
* Copyright (c) 2020 Ryan Cross
*
* SPDX-License-Identifier: MIT
*/
#include "sofle.dtsi"
&kscan0 {
col-gpios
= <&pro_micro_a 1 GPIO_ACTIVE_HIGH>
, <&pro_micro_a 0 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 15 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 14 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 16 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 10 GPIO_ACTIVE_HIGH>
;
};
&left_encoder {
status = "okay";
};
&bt_unpair_combo {
key-positions = <0 54>;
};

5
app/boards/shields/sofle/sofle_right.conf

@ -0,0 +1,5 @@
# Copyright (c) 2020 Ryan Cross
# SPDX-License-Identifier: MIT
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y

30
app/boards/shields/sofle/sofle_right.overlay

@ -0,0 +1,30 @@
/*
* Copyright (c) 2020 Ryan Cross
*
* SPDX-License-Identifier: MIT
*/
#include "sofle.dtsi"
&default_transform {
col-offset = <6>;
};
&kscan0 {
col-gpios
= <&pro_micro_d 10 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 16 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 14 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 15 GPIO_ACTIVE_HIGH>
, <&pro_micro_a 0 GPIO_ACTIVE_HIGH>
, <&pro_micro_a 1 GPIO_ACTIVE_HIGH>
;
};
&right_encoder {
status = "okay";
};
&bt_unpair_combo {
key-positions = <11 55>;
};

22
app/boards/shields/splitreus62/Kconfig.defconfig

@ -0,0 +1,22 @@
#Copyright (c) 2020 Derek Schmell
#SPDX-License-Identifier: MIT
if SHIELD_SPLITREUS62_LEFT
config ZMK_KEYBOARD_NAME
default "Splitreus62 Left"
endif
if SHIELD_SPLITREUS62_RIGHT
config ZMK_KEYBOARD_NAME
default "Splitreus62 Right"
endif
if SHIELD_SPLITREUS62_LEFT || SHIELD_SPLITREUS62_RIGHT
endif

8
app/boards/shields/splitreus62/Kconfig.shield

@ -0,0 +1,8 @@
# Copyright (c) 2020 Derek Schmell
# SPDX-License-Identifier: MIT
config SHIELD_SPLITREUS62_LEFT
def_bool $(shields_list_contains,splitreus62_left)
config SHIELD_SPLITREUS62_RIGHT
def_bool $(shields_list_contains,splitreus62_right)

0
app/boards/shields/splitreus62/splitreus62.conf

50
app/boards/shields/splitreus62/splitreus62.dtsi

@ -0,0 +1,50 @@
/*
* Copyright (c) 2020 Derek Schmell
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix-transform.h>
/ {
chosen {
zmk,kscan = &kscan0;
zmk,matrix_transform = &default_transform;
};
default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <12>;
rows = <6>;
// | SW0 | SW5 | SW10 | SW15 | SW20 | SW25 | SW25 | SW20 | SW15 | SW10 | SW5 | SW1 |
// | SW1 | SW6 | SW11 | SW16 | SW21 | SW26 | SW26 | SW21 | SW16 | SW11 | SW6 | SW2 |
// | SW2 | SW7 | SW12 | SW17 | SW22 | SW27 | SW27 | SW22 | SW17 | SW12 | SW7 | SW3 |
// | SW3 | SW8 | SW13 | SW18 | SW23 | SW28 | SW28 | SW23 | SW18 | SW13 | SW8 | SW4 |
// | SW4 | SW9 | SW14 | SW19 | SW24 | SW29 | SW29 | SW24 | SW19 | SW14 | SW9 | SW5 |
// SW30 | SW30
map = <
RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11)
RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11)
RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11)
RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11)
RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11)
RC(5,5) RC(5,6)
>;
};
kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "row2col";
row-gpios
= <&pro_micro_d 1 GPIO_ACTIVE_HIGH >
, <&pro_micro_d 0 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 2 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 4 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 5 GPIO_ACTIVE_HIGH>
, <&pro_micro_d 6 GPIO_ACTIVE_HIGH>
;
};
};

31
app/boards/shields/splitreus62/splitreus62.keymap

@ -0,0 +1,31 @@
/*
* Copyright (c) 2020 Derek Schmell
*
* SPDX-License-Identifier: MIT
*/
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
// ------------------------------------------------------------------------------------------------------------
// | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - |
// | TAB | Q | W | E | R | T | | Y | U | I | O | P | \ |
// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' |
// | SHIFT | Z | X | C | V | B | | N | M | , | . | / | SHIFT |
// | LCTL | LGUI | LALT | GRAV | | EQL | DEL | BKSP| | RET | SPC | LBKT | RBKT | LBKT | HOME | END |
bindings = <
&kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS
&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSLH
&kp LCTL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT
&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT
&kp LCTL &kp LGUI &kp LALT &kp GRAV &kp EQL &kp DEL &kp SPC &kp LBKT &kp RBKT &kp MINUS &kp HOME &kp END
&kp BKSP &kp RET
>;
};
};
};

2
app/boards/shields/splitreus62/splitreus62_left.conf

@ -0,0 +1,2 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y

18
app/boards/shields/splitreus62/splitreus62_left.overlay

@ -0,0 +1,18 @@
/*
* Copyright (c) 2020 Derek Schmell
*
* SPDX-License-Identifier: MIT
*/
#include "splitreus62.dtsi"
&kscan0 {
col-gpios
= <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};

2
app/boards/shields/splitreus62/splitreus62_right.conf

@ -0,0 +1,2 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y

22
app/boards/shields/splitreus62/splitreus62_right.overlay

@ -0,0 +1,22 @@
/*
* Copyright (c) 2020 Derek Schmell
*
* SPDX-License-Identifier: MIT
*/
#include "splitreus62.dtsi"
&default_transform {
col-offset = <6>;
};
&kscan0 {
col-gpios
= <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};

1
app/cmake/zmk_config.cmake

@ -44,6 +44,7 @@ endif()
set(CACHED_ZMK_CONFIG ${ZMK_CONFIG} CACHE STRING "Selected user ZMK config") set(CACHED_ZMK_CONFIG ${ZMK_CONFIG} CACHE STRING "Selected user ZMK config")
if (ZMK_CONFIG) if (ZMK_CONFIG)
set(ENV{ZMK_CONFIG} "${ZMK_CONFIG}")
if(EXISTS ${ZMK_CONFIG}/boards) if(EXISTS ${ZMK_CONFIG}/boards)
message(STATUS "Adding ZMK config directory as board root: ${ZMK_CONFIG}") message(STATUS "Adding ZMK config directory as board root: ${ZMK_CONFIG}")
list(APPEND BOARD_ROOT ${ZMK_CONFIG}) list(APPEND BOARD_ROOT ${ZMK_CONFIG})

51
app/drivers/zephyr/ec11.c

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Peter Johanson * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
@ -18,16 +18,15 @@
LOG_MODULE_REGISTER(EC11, CONFIG_SENSOR_LOG_LEVEL); LOG_MODULE_REGISTER(EC11, CONFIG_SENSOR_LOG_LEVEL);
static int ec11_get_ab_state(struct device *dev) static int ec11_get_ab_state(struct device *dev) {
{
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
const struct ec11_config *drv_cfg = dev->config_info; const struct ec11_config *drv_cfg = dev->config_info;
return (gpio_pin_get(drv_data->a, drv_cfg->a_pin) << 1) | gpio_pin_get(drv_data->b, drv_cfg->b_pin); return (gpio_pin_get(drv_data->a, drv_cfg->a_pin) << 1) |
gpio_pin_get(drv_data->b, drv_cfg->b_pin);
} }
static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) {
{
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
const struct ec11_config *drv_cfg = dev->config_info; const struct ec11_config *drv_cfg = dev->config_info;
u8_t val; u8_t val;
@ -39,11 +38,17 @@ static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan)
LOG_DBG("prev: %d, new: %d", drv_data->ab_state, val); LOG_DBG("prev: %d, new: %d", drv_data->ab_state, val);
switch(val | (drv_data->ab_state << 2)) { switch (val | (drv_data->ab_state << 2)) {
case 0b0010: case 0b0100: case 0b1101: case 0b1011: case 0b0010:
case 0b0100:
case 0b1101:
case 0b1011:
delta = -1; delta = -1;
break; break;
case 0b0001: case 0b0111: case 0b1110: case 0b1000: case 0b0001:
case 0b0111:
case 0b1110:
case 0b1000:
delta = 1; delta = 1;
break; break;
default: default:
@ -63,10 +68,8 @@ static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan)
return 0; return 0;
} }
static int ec11_channel_get(struct device *dev, static int ec11_channel_get(struct device *dev, enum sensor_channel chan,
enum sensor_channel chan, struct sensor_value *val) {
struct sensor_value *val)
{
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
if (chan != SENSOR_CHAN_ROTATION) { if (chan != SENSOR_CHAN_ROTATION) {
@ -87,12 +90,12 @@ static const struct sensor_driver_api ec11_driver_api = {
.channel_get = ec11_channel_get, .channel_get = ec11_channel_get,
}; };
int ec11_init(struct device *dev) int ec11_init(struct device *dev) {
{
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
const struct ec11_config *drv_cfg = dev->config_info; const struct ec11_config *drv_cfg = dev->config_info;
LOG_DBG("A: %s %d B: %s %d resolution %d", drv_cfg->a_label, drv_cfg->a_pin, drv_cfg->b_label, drv_cfg->b_pin, drv_cfg->resolution); LOG_DBG("A: %s %d B: %s %d resolution %d", drv_cfg->a_label, drv_cfg->a_pin, drv_cfg->b_label,
drv_cfg->b_pin, drv_cfg->resolution);
drv_data->a = device_get_binding(drv_cfg->a_label); drv_data->a = device_get_binding(drv_cfg->a_label);
if (drv_data->a == NULL) { if (drv_data->a == NULL) {
@ -106,22 +109,16 @@ int ec11_init(struct device *dev)
return -EINVAL; return -EINVAL;
} }
if (gpio_pin_configure(drv_data->a, drv_cfg->a_pin, if (gpio_pin_configure(drv_data->a, drv_cfg->a_pin, drv_cfg->a_flags | GPIO_INPUT)) {
drv_cfg->a_flags
| GPIO_INPUT)) {
LOG_DBG("Failed to configure A pin"); LOG_DBG("Failed to configure A pin");
return -EIO; return -EIO;
} }
if (gpio_pin_configure(drv_data->b, drv_cfg->b_pin, if (gpio_pin_configure(drv_data->b, drv_cfg->b_pin, drv_cfg->b_flags | GPIO_INPUT)) {
drv_cfg->b_flags
| GPIO_INPUT)) {
LOG_DBG("Failed to configure B pin"); LOG_DBG("Failed to configure B pin");
return -EIO; return -EIO;
} }
#ifdef CONFIG_EC11_TRIGGER #ifdef CONFIG_EC11_TRIGGER
if (ec11_init_interrupt(dev) < 0) { if (ec11_init_interrupt(dev) < 0) {
LOG_DBG("Failed to initialize interrupt!"); LOG_DBG("Failed to initialize interrupt!");
@ -145,9 +142,7 @@ int ec11_init(struct device *dev)
.b_flags = DT_INST_GPIO_FLAGS(n, b_gpios), \ .b_flags = DT_INST_GPIO_FLAGS(n, b_gpios), \
COND_CODE_0(DT_INST_NODE_HAS_PROP(n, resolution), (1), (DT_INST_PROP(n, resolution))), \ COND_CODE_0(DT_INST_NODE_HAS_PROP(n, resolution), (1), (DT_INST_PROP(n, resolution))), \
}; \ }; \
DEVICE_AND_API_INIT(ec11, DT_INST_LABEL(n), ec11_init, \ DEVICE_AND_API_INIT(ec11, DT_INST_LABEL(n), ec11_init, &ec11_data_##n, &ec11_cfg_##n, \
&ec11_data_##n, \ POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &ec11_driver_api);
&ec11_cfg_##n, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, \
&ec11_driver_api);
DT_INST_FOREACH_STATUS_OKAY(EC11_INST) DT_INST_FOREACH_STATUS_OKAY(EC11_INST)

5
app/drivers/zephyr/ec11.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Peter Johanson * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
@ -51,8 +51,7 @@ struct ec11_data {
#ifdef CONFIG_EC11_TRIGGER #ifdef CONFIG_EC11_TRIGGER
int ec11_trigger_set(struct device *dev, int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig,
const struct sensor_trigger *trig,
sensor_trigger_handler_t handler); sensor_trigger_handler_t handler);
int ec11_init_interrupt(struct device *dev); int ec11_init_interrupt(struct device *dev);

72
app/drivers/zephyr/ec11_trigger.c

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016 Intel Corporation * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
@ -19,36 +19,25 @@ extern struct ec11_data ec11_driver;
#include <logging/log.h> #include <logging/log.h>
LOG_MODULE_DECLARE(EC11, CONFIG_SENSOR_LOG_LEVEL); LOG_MODULE_DECLARE(EC11, CONFIG_SENSOR_LOG_LEVEL);
static inline void setup_int(struct device *dev, static inline void setup_int(struct device *dev, bool enable) {
bool enable)
{
struct ec11_data *data = dev->driver_data; struct ec11_data *data = dev->driver_data;
const struct ec11_config *cfg = dev->config_info; const struct ec11_config *cfg = dev->config_info;
LOG_DBG("enabled %s", (enable ? "true" : "false")); LOG_DBG("enabled %s", (enable ? "true" : "false"));
if (gpio_pin_interrupt_configure(data->a, if (gpio_pin_interrupt_configure(data->a, cfg->a_pin,
cfg->a_pin, enable ? GPIO_INT_EDGE_BOTH : GPIO_INT_DISABLE)) {
enable
? GPIO_INT_EDGE_BOTH
: GPIO_INT_DISABLE)) {
LOG_WRN("Unable to set A pin GPIO interrupt"); LOG_WRN("Unable to set A pin GPIO interrupt");
} }
if (gpio_pin_interrupt_configure(data->b, if (gpio_pin_interrupt_configure(data->b, cfg->b_pin,
cfg->b_pin, enable ? GPIO_INT_EDGE_BOTH : GPIO_INT_DISABLE)) {
enable
? GPIO_INT_EDGE_BOTH
: GPIO_INT_DISABLE)) {
LOG_WRN("Unable to set A pin GPIO interrupt"); LOG_WRN("Unable to set A pin GPIO interrupt");
} }
} }
static void ec11_a_gpio_callback(struct device *dev, static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, u32_t pins) {
struct gpio_callback *cb, u32_t pins) struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, a_gpio_cb);
{
struct ec11_data *drv_data =
CONTAINER_OF(cb, struct ec11_data, a_gpio_cb);
LOG_DBG(""); LOG_DBG("");
@ -61,11 +50,8 @@ static void ec11_a_gpio_callback(struct device *dev,
#endif #endif
} }
static void ec11_b_gpio_callback(struct device *dev, static void ec11_b_gpio_callback(struct device *dev, struct gpio_callback *cb, u32_t pins) {
struct gpio_callback *cb, u32_t pins) struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, b_gpio_cb);
{
struct ec11_data *drv_data =
CONTAINER_OF(cb, struct ec11_data, b_gpio_cb);
LOG_DBG(""); LOG_DBG("");
@ -78,8 +64,7 @@ static void ec11_b_gpio_callback(struct device *dev,
#endif #endif
} }
static void ec11_thread_cb(void *arg) static void ec11_thread_cb(void *arg) {
{
struct device *dev = arg; struct device *dev = arg;
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
@ -89,8 +74,7 @@ static void ec11_thread_cb(void *arg)
} }
#ifdef CONFIG_EC11_TRIGGER_OWN_THREAD #ifdef CONFIG_EC11_TRIGGER_OWN_THREAD
static void ec11_thread(int dev_ptr, int unused) static void ec11_thread(int dev_ptr, int unused) {
{
struct device *dev = INT_TO_POINTER(dev_ptr); struct device *dev = INT_TO_POINTER(dev_ptr);
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
@ -104,10 +88,8 @@ static void ec11_thread(int dev_ptr, int unused)
#endif #endif
#ifdef CONFIG_EC11_TRIGGER_GLOBAL_THREAD #ifdef CONFIG_EC11_TRIGGER_GLOBAL_THREAD
static void ec11_work_cb(struct k_work *work) static void ec11_work_cb(struct k_work *work) {
{ struct ec11_data *drv_data = CONTAINER_OF(work, struct ec11_data, work);
struct ec11_data *drv_data =
CONTAINER_OF(work, struct ec11_data, work);
LOG_DBG(""); LOG_DBG("");
@ -115,10 +97,8 @@ static void ec11_work_cb(struct k_work *work)
} }
#endif #endif
int ec11_trigger_set(struct device *dev, int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig,
const struct sensor_trigger *trig, sensor_trigger_handler_t handler) {
sensor_trigger_handler_t handler)
{
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
setup_int(dev, false); setup_int(dev, false);
@ -133,27 +113,21 @@ int ec11_trigger_set(struct device *dev,
return 0; return 0;
} }
int ec11_init_interrupt(struct device *dev) int ec11_init_interrupt(struct device *dev) {
{
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
const struct ec11_config *drv_cfg = dev->config_info; const struct ec11_config *drv_cfg = dev->config_info;
drv_data->dev = dev; drv_data->dev = dev;
/* setup gpio interrupt */ /* setup gpio interrupt */
gpio_init_callback(&drv_data->a_gpio_cb, ec11_a_gpio_callback, BIT(drv_cfg->a_pin));
gpio_init_callback(&drv_data->a_gpio_cb,
ec11_a_gpio_callback,
BIT(drv_cfg->a_pin));
if (gpio_add_callback(drv_data->a, &drv_data->a_gpio_cb) < 0) { if (gpio_add_callback(drv_data->a, &drv_data->a_gpio_cb) < 0) {
LOG_DBG("Failed to set A callback!"); LOG_DBG("Failed to set A callback!");
return -EIO; return -EIO;
} }
gpio_init_callback(&drv_data->b_gpio_cb, gpio_init_callback(&drv_data->b_gpio_cb, ec11_b_gpio_callback, BIT(drv_cfg->b_pin));
ec11_b_gpio_callback,
BIT(drv_cfg->b_pin));
if (gpio_add_callback(drv_data->b, &drv_data->b_gpio_cb) < 0) { if (gpio_add_callback(drv_data->b, &drv_data->b_gpio_cb) < 0) {
LOG_DBG("Failed to set B callback!"); LOG_DBG("Failed to set B callback!");
@ -163,11 +137,9 @@ int ec11_init_interrupt(struct device *dev)
#if defined(CONFIG_EC11_TRIGGER_OWN_THREAD) #if defined(CONFIG_EC11_TRIGGER_OWN_THREAD)
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX); k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
k_thread_create(&drv_data->thread, drv_data->thread_stack, k_thread_create(&drv_data->thread, drv_data->thread_stack, CONFIG_EC11_THREAD_STACK_SIZE,
CONFIG_EC11_THREAD_STACK_SIZE, (k_thread_entry_t)ec11_thread, dev, 0, NULL,
(k_thread_entry_t)ec11_thread, dev, K_PRIO_COOP(CONFIG_EC11_THREAD_PRIORITY), 0, K_NO_WAIT);
0, NULL, K_PRIO_COOP(CONFIG_EC11_THREAD_PRIORITY),
0, K_NO_WAIT);
#elif defined(CONFIG_EC11_TRIGGER_GLOBAL_THREAD) #elif defined(CONFIG_EC11_TRIGGER_GLOBAL_THREAD)
k_work_init(&drv_data->work, ec11_work_cb); k_work_init(&drv_data->work, ec11_work_cb);
#endif #endif

137
app/drivers/zephyr/kscan_gpio_direct.c

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Peter Johanson <peter@peterjohanson.com> * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
@ -15,8 +15,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
struct kscan_gpio_item_config struct kscan_gpio_item_config {
{
char *label; char *label;
gpio_pin_t pin; gpio_pin_t pin;
gpio_flags_t flags; gpio_flags_t flags;
@ -27,15 +26,13 @@ union work_reference {
struct k_work direct; struct k_work direct;
}; };
struct kscan_gpio_config struct kscan_gpio_config {
{
u8_t num_of_inputs; u8_t num_of_inputs;
u8_t debounce_period; u8_t debounce_period;
struct kscan_gpio_item_config inputs[]; struct kscan_gpio_item_config inputs[];
}; };
struct kscan_gpio_data struct kscan_gpio_data {
{
#if defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) #if defined(CONFIG_ZMK_KSCAN_GPIO_POLLING)
struct k_timer poll_timer; struct k_timer poll_timer;
#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ #endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */
@ -46,42 +43,36 @@ struct kscan_gpio_data
struct device *inputs[]; struct device *inputs[];
}; };
static struct device **kscan_gpio_input_devices(struct device *dev) static struct device **kscan_gpio_input_devices(struct device *dev) {
{
struct kscan_gpio_data *data = dev->driver_data; struct kscan_gpio_data *data = dev->driver_data;
return data->inputs; return data->inputs;
} }
static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct device *dev) static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct device *dev) {
{
const struct kscan_gpio_config *cfg = dev->config_info; const struct kscan_gpio_config *cfg = dev->config_info;
return cfg->inputs; return cfg->inputs;
} }
#if !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) #if !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING)
struct kscan_gpio_irq_callback struct kscan_gpio_irq_callback {
{
union work_reference *work; union work_reference *work;
u8_t debounce_period; u8_t debounce_period;
struct gpio_callback callback; struct gpio_callback callback;
}; };
static int kscan_gpio_config_interrupts(struct device *dev, gpio_flags_t flags) static int kscan_gpio_config_interrupts(struct device *dev, gpio_flags_t flags) {
{
const struct kscan_gpio_config *cfg = dev->config_info; const struct kscan_gpio_config *cfg = dev->config_info;
struct device **devices = kscan_gpio_input_devices(dev); struct device **devices = kscan_gpio_input_devices(dev);
const struct kscan_gpio_item_config *configs = kscan_gpio_input_configs(dev); const struct kscan_gpio_item_config *configs = kscan_gpio_input_configs(dev);
for (int i = 0; i < cfg->num_of_inputs; i++) for (int i = 0; i < cfg->num_of_inputs; i++) {
{
struct device *dev = devices[i]; struct device *dev = devices[i];
const struct kscan_gpio_item_config *cfg = &configs[i]; const struct kscan_gpio_item_config *cfg = &configs[i];
int err = gpio_pin_interrupt_configure(dev, cfg->pin, flags); int err = gpio_pin_interrupt_configure(dev, cfg->pin, flags);
if (err) if (err) {
{
LOG_ERR("Unable to enable matrix GPIO interrupt"); LOG_ERR("Unable to enable matrix GPIO interrupt");
return err; return err;
} }
@ -90,20 +81,15 @@ static int kscan_gpio_config_interrupts(struct device *dev, gpio_flags_t flags)
return 0; return 0;
} }
static int kscan_gpio_direct_enable(struct device *dev) static int kscan_gpio_direct_enable(struct device *dev) {
{ return kscan_gpio_config_interrupts(dev, GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH);
return kscan_gpio_config_interrupts(dev,
GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH);
} }
static int kscan_gpio_direct_disable(struct device *dev) static int kscan_gpio_direct_disable(struct device *dev) {
{ return kscan_gpio_config_interrupts(dev, GPIO_INT_DISABLE);
return kscan_gpio_config_interrupts(dev,
GPIO_INT_DISABLE);
} }
static void kscan_gpio_irq_callback_handler(struct device *dev, static void kscan_gpio_irq_callback_handler(struct device *dev, struct gpio_callback *cb,
struct gpio_callback *cb, gpio_port_pins_t pin) gpio_port_pins_t pin) {
{
struct kscan_gpio_irq_callback *data = struct kscan_gpio_irq_callback *data =
CONTAINER_OF(cb, struct kscan_gpio_irq_callback, callback); CONTAINER_OF(cb, struct kscan_gpio_irq_callback, callback);
@ -117,22 +103,18 @@ static void kscan_gpio_irq_callback_handler(struct device *dev,
#else /* !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ #else /* !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */
static void kscan_gpio_timer_handler(struct k_timer *timer) static void kscan_gpio_timer_handler(struct k_timer *timer) {
{ struct kscan_gpio_data *data = CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer);
struct kscan_gpio_data *data =
CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer);
k_work_submit(&data->work.direct); k_work_submit(&data->work.direct);
} }
static int kscan_gpio_direct_enable(struct device *dev) static int kscan_gpio_direct_enable(struct device *dev) {
{
struct kscan_gpio_data *data = dev->driver_data; struct kscan_gpio_data *data = dev->driver_data;
k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10));
return 0; return 0;
} }
static int kscan_gpio_direct_disable(struct device *dev) static int kscan_gpio_direct_disable(struct device *dev) {
{
struct kscan_gpio_data *data = dev->driver_data; struct kscan_gpio_data *data = dev->driver_data;
k_timer_stop(&data->poll_timer); k_timer_stop(&data->poll_timer);
return 0; return 0;
@ -140,36 +122,29 @@ static int kscan_gpio_direct_disable(struct device *dev)
#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ #endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */
static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) {
{
struct kscan_gpio_data *data = dev->driver_data; struct kscan_gpio_data *data = dev->driver_data;
if (!callback) if (!callback) {
{
return -EINVAL; return -EINVAL;
} }
data->callback = callback; data->callback = callback;
return 0; return 0;
} }
static int kscan_gpio_read(struct device *dev) static int kscan_gpio_read(struct device *dev) {
{
struct kscan_gpio_data *data = dev->driver_data; struct kscan_gpio_data *data = dev->driver_data;
const struct kscan_gpio_config *cfg = dev->config_info; const struct kscan_gpio_config *cfg = dev->config_info;
u32_t read_state = data->pin_state; u32_t read_state = data->pin_state;
LOG_DBG("Scanning the pins for updated state"); for (int i = 0; i < cfg->num_of_inputs; i++) {
for (int i = 0; i < cfg->num_of_inputs; i++)
{
struct device *in_dev = kscan_gpio_input_devices(dev)[i]; struct device *in_dev = kscan_gpio_input_devices(dev)[i];
const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs(dev)[i]; const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs(dev)[i];
WRITE_BIT(read_state, i, gpio_pin_get(in_dev, in_cfg->pin) > 0); WRITE_BIT(read_state, i, gpio_pin_get(in_dev, in_cfg->pin) > 0);
} }
for (int i = 0; i < cfg->num_of_inputs; i++) for (int i = 0; i < cfg->num_of_inputs; i++) {
{ bool prev_pressed = BIT(i) & data->pin_state;
bool pressed = BIT(i) & read_state; bool pressed = BIT(i) & read_state;
if (pressed != (BIT(i) & data->pin_state)) if (pressed != prev_pressed) {
{ LOG_DBG("Sending event at %d,%d state %s", 0, i, (pressed ? "on" : "off"));
LOG_DBG("Sending event at %d,%d state %s",
0, i, (pressed ? "on" : "off"));
WRITE_BIT(data->pin_state, i, pressed); WRITE_BIT(data->pin_state, i, pressed);
data->callback(dev, 0, i, pressed); data->callback(dev, 0, i, pressed);
} }
@ -177,10 +152,8 @@ static int kscan_gpio_read(struct device *dev)
return 0; return 0;
} }
static void kscan_gpio_work_handler(struct k_work *work) static void kscan_gpio_work_handler(struct k_work *work) {
{ struct kscan_gpio_data *data = CONTAINER_OF(work, struct kscan_gpio_data, work);
struct kscan_gpio_data *data =
CONTAINER_OF(work, struct kscan_gpio_data, work);
kscan_gpio_read(data->dev); kscan_gpio_read(data->dev);
} }
@ -190,7 +163,7 @@ static const struct kscan_driver_api gpio_driver_api = {
.disable_callback = kscan_gpio_direct_disable, .disable_callback = kscan_gpio_direct_disable,
}; };
#define KSCAN_DIRECT_INPUT_ITEM(i,n) \ #define KSCAN_DIRECT_INPUT_ITEM(i, n) \
{ \ { \
.label = DT_INST_GPIO_LABEL_BY_IDX(n, input_gpios, i), \ .label = DT_INST_GPIO_LABEL_BY_IDX(n, input_gpios, i), \
.pin = DT_INST_GPIO_PIN_BY_IDX(n, input_gpios, i), \ .pin = DT_INST_GPIO_PIN_BY_IDX(n, input_gpios, i), \
@ -200,47 +173,43 @@ static const struct kscan_driver_api gpio_driver_api = {
#define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios) #define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios)
#define GPIO_INST_INIT(n) \ #define GPIO_INST_INIT(n) \
COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, (static struct kscan_gpio_irq_callback \ COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, \
irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \ (static struct kscan_gpio_irq_callback irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \
static struct kscan_gpio_data kscan_gpio_data_##n = { \ static struct kscan_gpio_data kscan_gpio_data_##n = { \
.inputs = { [INST_INPUT_LEN(n)-1] = NULL } \ .inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \
}; \ static int kscan_gpio_init_##n(struct device *dev) { \
static int kscan_gpio_init_##n(struct device *dev) \
{ \
struct kscan_gpio_data *data = dev->driver_data; \ struct kscan_gpio_data *data = dev->driver_data; \
const struct kscan_gpio_config *cfg = dev->config_info; \ const struct kscan_gpio_config *cfg = dev->config_info; \
int err; \ int err; \
struct device **input_devices = kscan_gpio_input_devices(dev); \ struct device **input_devices = kscan_gpio_input_devices(dev); \
for (int i = 0; i < cfg->num_of_inputs; i++) \ for (int i = 0; i < cfg->num_of_inputs; i++) { \
{ \
const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs(dev)[i]; \ const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs(dev)[i]; \
input_devices[i] = device_get_binding(in_cfg->label); \ input_devices[i] = device_get_binding(in_cfg->label); \
if (!input_devices[i]) \ if (!input_devices[i]) { \
{ \
LOG_ERR("Unable to find input GPIO device"); \ LOG_ERR("Unable to find input GPIO device"); \
return -EINVAL; \ return -EINVAL; \
} \ } \
err = gpio_pin_configure(input_devices[i], in_cfg->pin, GPIO_INPUT | in_cfg->flags); \ err = gpio_pin_configure(input_devices[i], in_cfg->pin, GPIO_INPUT | in_cfg->flags); \
if (err) \ if (err) { \
{ \
LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \
return err; \ return err; \
} \ } \
COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ COND_CODE_0( \
( \ CONFIG_ZMK_KSCAN_GPIO_POLLING, \
irq_callbacks_##n[i].work = &data->work; \ (irq_callbacks_##n[i].work = &data->work; \
irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \ irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \
gpio_init_callback(&irq_callbacks_##n[i].callback, kscan_gpio_irq_callback_handler, BIT(in_cfg->pin)); \ gpio_init_callback(&irq_callbacks_##n[i].callback, \
kscan_gpio_irq_callback_handler, BIT(in_cfg->pin)); \
err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \
if (err) \ if (err) { \
{ \
LOG_ERR("Error adding the callback to the column device"); \ LOG_ERR("Error adding the callback to the column device"); \
return err; \ return err; \
} \ }), \
), ()) \ ()) \
} \ } \
data->dev = dev; \ data->dev = dev; \
COND_CODE_1(CONFIG_ZMK_KSCAN_GPIO_POLLING, (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ( )) \ COND_CODE_1(CONFIG_ZMK_KSCAN_GPIO_POLLING, \
(k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \
if (cfg->debounce_period > 0) { \ if (cfg->debounce_period > 0) { \
k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \ k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \
} else { \ } else { \
@ -249,14 +218,12 @@ static const struct kscan_driver_api gpio_driver_api = {
return 0; \ return 0; \
} \ } \
static const struct kscan_gpio_config kscan_gpio_config_##n = { \ static const struct kscan_gpio_config kscan_gpio_config_##n = { \
.inputs = { UTIL_LISTIFY(INST_INPUT_LEN(n), KSCAN_DIRECT_INPUT_ITEM, n) }, \ .inputs = {UTIL_LISTIFY(INST_INPUT_LEN(n), KSCAN_DIRECT_INPUT_ITEM, n)}, \
.num_of_inputs = INST_INPUT_LEN(n), \ .num_of_inputs = INST_INPUT_LEN(n), \
.debounce_period = DT_INST_PROP(n, debounce_period) \ .debounce_period = DT_INST_PROP(n, debounce_period)}; \
}; \
DEVICE_AND_API_INIT(kscan_gpio_##n, DT_INST_LABEL(n), kscan_gpio_init_##n, \ DEVICE_AND_API_INIT(kscan_gpio_##n, DT_INST_LABEL(n), kscan_gpio_init_##n, \
&kscan_gpio_data_##n, &kscan_gpio_config_##n, \ &kscan_gpio_data_##n, &kscan_gpio_config_##n, POST_KERNEL, \
POST_KERNEL, CONFIG_ZMK_KSCAN_INIT_PRIORITY, \ CONFIG_ZMK_KSCAN_INIT_PRIORITY, &gpio_driver_api);
&gpio_driver_api);
DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT) DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT)

208
app/drivers/zephyr/kscan_gpio_matrix.c

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020 Peter Johanson <peter@peterjohanson.com> * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
@ -15,14 +15,12 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
struct kscan_gpio_item_config struct kscan_gpio_item_config {
{
char *label; char *label;
gpio_pin_t pin; gpio_pin_t pin;
gpio_flags_t flags; gpio_flags_t flags;
}; };
#define _KSCAN_GPIO_ITEM_CFG_INIT(n, prop, idx) \ #define _KSCAN_GPIO_ITEM_CFG_INIT(n, prop, idx) \
{ \ { \
.label = DT_INST_GPIO_LABEL_BY_IDX(n, prop, idx), \ .label = DT_INST_GPIO_LABEL_BY_IDX(n, prop, idx), \
@ -34,18 +32,15 @@ struct kscan_gpio_item_config
#define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx) #define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx)
static int kscan_gpio_config_interrupts(struct device **devices, static int kscan_gpio_config_interrupts(struct device **devices,
const struct kscan_gpio_item_config *configs, const struct kscan_gpio_item_config *configs, size_t len,
size_t len, gpio_flags_t flags) gpio_flags_t flags) {
{ for (int i = 0; i < len; i++) {
for (int i = 0; i < len; i++)
{
struct device *dev = devices[i]; struct device *dev = devices[i];
const struct kscan_gpio_item_config *cfg = &configs[i]; const struct kscan_gpio_item_config *cfg = &configs[i];
int err = gpio_pin_interrupt_configure(dev, cfg->pin, flags); int err = gpio_pin_interrupt_configure(dev, cfg->pin, flags);
if (err) if (err) {
{
LOG_ERR("Unable to enable matrix GPIO interrupt"); LOG_ERR("Unable to enable matrix GPIO interrupt");
return err; return err;
} }
@ -55,24 +50,24 @@ static int kscan_gpio_config_interrupts(struct device **devices,
} }
#define INST_MATRIX_ROWS(n) DT_INST_PROP_LEN(n, row_gpios) #define INST_MATRIX_ROWS(n) DT_INST_PROP_LEN(n, row_gpios)
#define INST_MATRIX_COLS(n) DT_INST_PROP_LEN(n, col_gpios) #define INST_MATRIX_COLS(n) DT_INST_PROP_LEN(n, col_gpios)
#define INST_OUTPUT_LEN(n) COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (INST_MATRIX_ROWS(n)), (INST_MATRIX_COLS(n))) #define INST_OUTPUT_LEN(n) \
#define INST_INPUT_LEN(n) COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (INST_MATRIX_COLS(n)), (INST_MATRIX_ROWS(n))) COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (INST_MATRIX_ROWS(n)), \
(INST_MATRIX_COLS(n)))
#define INST_INPUT_LEN(n) \
COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (INST_MATRIX_COLS(n)), \
(INST_MATRIX_ROWS(n)))
#define GPIO_INST_INIT(n) \ #define GPIO_INST_INIT(n) \
struct kscan_gpio_irq_callback_##n \ struct kscan_gpio_irq_callback_##n { \
{ \
struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \
struct gpio_callback callback; \ struct gpio_callback callback; \
}; \ }; \
static struct kscan_gpio_irq_callback_##n \ static struct kscan_gpio_irq_callback_##n irq_callbacks_##n[INST_INPUT_LEN(n)]; \
irq_callbacks_##n[INST_INPUT_LEN(n)]; \ struct kscan_gpio_config_##n { \
struct kscan_gpio_config_##n \
{ \
struct kscan_gpio_item_config rows[INST_MATRIX_ROWS(n)]; \ struct kscan_gpio_item_config rows[INST_MATRIX_ROWS(n)]; \
struct kscan_gpio_item_config cols[INST_MATRIX_COLS(n)]; \ struct kscan_gpio_item_config cols[INST_MATRIX_COLS(n)]; \
}; \ }; \
struct kscan_gpio_data_##n \ struct kscan_gpio_data_##n { \
{ \
kscan_callback_t callback; \ kscan_callback_t callback; \
struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \
bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \
@ -80,51 +75,53 @@ static int kscan_gpio_config_interrupts(struct device **devices,
struct device *cols[INST_MATRIX_COLS(n)]; \ struct device *cols[INST_MATRIX_COLS(n)]; \
struct device *dev; \ struct device *dev; \
}; \ }; \
static struct device **kscan_gpio_input_devices_##n(struct device *dev) \ static struct device **kscan_gpio_input_devices_##n(struct device *dev) { \
{ \
struct kscan_gpio_data_##n *data = dev->driver_data; \ struct kscan_gpio_data_##n *data = dev->driver_data; \
return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->cols), (data->rows))); \ return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->cols), \
(data->rows))); \
} \ } \
static const struct kscan_gpio_item_config *kscan_gpio_input_configs_##n(struct device *dev) \ static const struct kscan_gpio_item_config *kscan_gpio_input_configs_##n(struct device *dev) { \
{ \
const struct kscan_gpio_config_##n *cfg = dev->config_info; \ const struct kscan_gpio_config_##n *cfg = dev->config_info; \
return ((COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->cols), (cfg->rows)))); \ return (( \
COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->cols), (cfg->rows)))); \
} \ } \
static struct device **kscan_gpio_output_devices_##n(struct device *dev) \ static struct device **kscan_gpio_output_devices_##n(struct device *dev) { \
{ \
struct kscan_gpio_data_##n *data = dev->driver_data; \ struct kscan_gpio_data_##n *data = dev->driver_data; \
return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->rows), (data->cols))); \ return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->rows), \
(data->cols))); \
} \ } \
static const struct kscan_gpio_item_config *kscan_gpio_output_configs_##n(struct device *dev) \ static const struct kscan_gpio_item_config *kscan_gpio_output_configs_##n( \
{ \ struct device *dev) { \
const struct kscan_gpio_config_##n *cfg = dev->config_info; \ const struct kscan_gpio_config_##n *cfg = dev->config_info; \
return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ return ( \
COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \
} \ } \
static int kscan_gpio_enable_interrupts_##n(struct device *dev) \ static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \
{ \ return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \
return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \
GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \
} \ } \
static int kscan_gpio_disable_interrupts_##n(struct device *dev) \ static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \
{ \ return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \
return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \
GPIO_INT_DISABLE); \ GPIO_INT_DISABLE); \
} \ } \
static void kscan_gpio_set_output_state_##n(struct device *dev, int value) \ static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \
{ \ for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \
for (int i = 0; i < INST_OUTPUT_LEN(n); i++) \
{ \
struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \
const struct kscan_gpio_item_config *cfg = &kscan_gpio_output_configs_##n(dev)[i]; \ const struct kscan_gpio_item_config *cfg = &kscan_gpio_output_configs_##n(dev)[i]; \
gpio_pin_set(in_dev, cfg->pin, value); \ gpio_pin_set(in_dev, cfg->pin, value); \
} \ } \
} \ } \
static void kscan_gpio_set_matrix_state_##n(bool state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)], u32_t input_index, u32_t output_index, bool value) \ static void kscan_gpio_set_matrix_state_##n( \
{ \ bool state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)], u32_t input_index, \
state[COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (output_index), (input_index))][COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (input_index), (output_index))] = value; \ u32_t output_index, bool value) { \
state[COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (output_index), \
(input_index))] \
[COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (input_index), \
(output_index))] = value; \
} \ } \
static int kscan_gpio_read_##n(struct device *dev) \ static int kscan_gpio_read_##n(struct device *dev) { \
{ \
bool submit_follow_up_read = false; \ bool submit_follow_up_read = false; \
struct kscan_gpio_data_##n *data = dev->driver_data; \ struct kscan_gpio_data_##n *data = dev->driver_data; \
static bool read_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ static bool read_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \
@ -133,16 +130,16 @@ static int kscan_gpio_config_interrupts(struct device **devices,
/* to get pressed state for each matrix cell. */ \ /* to get pressed state for each matrix cell. */ \
kscan_gpio_disable_interrupts_##n(dev); \ kscan_gpio_disable_interrupts_##n(dev); \
kscan_gpio_set_output_state_##n(dev, 0); \ kscan_gpio_set_output_state_##n(dev, 0); \
for (int o = 0; o < INST_OUTPUT_LEN(n); o++) \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \
{ \
struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \
const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \ const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \
gpio_pin_set(out_dev, out_cfg->pin, 1); \ gpio_pin_set(out_dev, out_cfg->pin, 1); \
for (int i = 0; i < INST_INPUT_LEN(n); i++) \ for (int i = 0; i < INST_INPUT_LEN(n); i++) { \
{ \
struct device *in_dev = kscan_gpio_input_devices_##n(dev)[i]; \ struct device *in_dev = kscan_gpio_input_devices_##n(dev)[i]; \
const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs_##n(dev)[i]; \ const struct kscan_gpio_item_config *in_cfg = \
kscan_gpio_set_matrix_state_##n(read_state, i, o, gpio_pin_get(in_dev, in_cfg->pin) > 0); \ &kscan_gpio_input_configs_##n(dev)[i]; \
kscan_gpio_set_matrix_state_##n(read_state, i, o, \
gpio_pin_get(in_dev, in_cfg->pin) > 0); \
} \ } \
gpio_pin_set(out_dev, out_cfg->pin, 0); \ gpio_pin_set(out_dev, out_cfg->pin, 0); \
} \ } \
@ -150,116 +147,102 @@ static int kscan_gpio_config_interrupts(struct device **devices,
/* so we can trigger interrupts again for future press/release */ \ /* so we can trigger interrupts again for future press/release */ \
kscan_gpio_set_output_state_##n(dev, 1); \ kscan_gpio_set_output_state_##n(dev, 1); \
kscan_gpio_enable_interrupts_##n(dev); \ kscan_gpio_enable_interrupts_##n(dev); \
for (int r = 0; r < INST_MATRIX_ROWS(n); r++) \ for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \
{ \ for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \
for (int c = 0; c < INST_MATRIX_COLS(n); c++) \
{ \
bool pressed = read_state[r][c]; \ bool pressed = read_state[r][c]; \
/* Follow up reads needed because further interrupts won't fire on already tripped input GPIO pins */ \ /* Follow up reads needed because further interrupts won't fire on already tripped \
* input GPIO pins */ \
submit_follow_up_read = (submit_follow_up_read || pressed); \ submit_follow_up_read = (submit_follow_up_read || pressed); \
if (pressed != data->matrix_state[r][c]) \ if (pressed != data->matrix_state[r][c]) { \
{ \ LOG_DBG("Sending event at %d,%d state %s", r, c, (pressed ? "on" : "off")); \
LOG_DBG("Sending event at %d,%d state %s", \
r, c, (pressed ? "on" : "off")); \
data->matrix_state[r][c] = pressed; \ data->matrix_state[r][c] = pressed; \
data->callback(dev, r, c, pressed); \ data->callback(dev, r, c, pressed); \
} \ } \
} \ } \
} \ } \
if (submit_follow_up_read) { \ if (submit_follow_up_read) { \
COND_CODE_0(DT_INST_PROP(n, debounce_period), \ COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(&data->work); }), ({ \
({ k_work_submit(&data->work); }), \
({ \
k_delayed_work_cancel(&data->work); \ k_delayed_work_cancel(&data->work); \
k_delayed_work_submit(&data->work, K_MSEC(5)); })) \ k_delayed_work_submit(&data->work, K_MSEC(5)); \
})) \
} \ } \
return 0; \ return 0; \
} \ } \
static void kscan_gpio_work_handler_##n(struct k_work *work) \ static void kscan_gpio_work_handler_##n(struct k_work *work) { \
{ \ struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \
struct kscan_gpio_data_##n *data = \
CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \
kscan_gpio_read_##n(data->dev); \ kscan_gpio_read_##n(data->dev); \
} \ } \
static void kscan_gpio_irq_callback_handler_##n(struct device *dev, \ static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \
struct gpio_callback *cb, gpio_port_pins_t pin) \ gpio_port_pins_t pin) { \
{ \
struct kscan_gpio_irq_callback_##n *data = \ struct kscan_gpio_irq_callback_##n *data = \
CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \
COND_CODE_0(DT_INST_PROP(n, debounce_period), \ COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \
({ k_work_submit(data->work); }), \
({ \
k_delayed_work_cancel(data->work); \ k_delayed_work_cancel(data->work); \
k_delayed_work_submit(data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); })) \ k_delayed_work_submit(data->work, \
K_MSEC(DT_INST_PROP(n, debounce_period))); \
})) \
} \ } \
static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \ static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \
.rows = { [INST_MATRIX_ROWS(n)-1] = NULL}, \ .rows = {[INST_MATRIX_ROWS(n) - 1] = NULL}, .cols = {[INST_MATRIX_COLS(n) - 1] = NULL}}; \
.cols = { [INST_MATRIX_COLS(n)-1] = NULL }\ static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) { \
}; \
static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) \
{ \
struct kscan_gpio_data_##n *data = dev->driver_data; \ struct kscan_gpio_data_##n *data = dev->driver_data; \
if (!callback) \ if (!callback) { \
{ \
return -EINVAL; \ return -EINVAL; \
} \ } \
data->callback = callback; \ data->callback = callback; \
return 0; \ return 0; \
}; \ }; \
static int kscan_gpio_enable_##n(struct device *dev) \ static int kscan_gpio_enable_##n(struct device *dev) { \
{ \
int err = kscan_gpio_enable_interrupts_##n(dev); \ int err = kscan_gpio_enable_interrupts_##n(dev); \
if (err) { return err; } \ if (err) { \
return err; \
} \
return kscan_gpio_read_##n(dev); \ return kscan_gpio_read_##n(dev); \
}; \ }; \
static int kscan_gpio_init_##n(struct device *dev) \ static int kscan_gpio_init_##n(struct device *dev) { \
{ \
struct kscan_gpio_data_##n *data = dev->driver_data; \ struct kscan_gpio_data_##n *data = dev->driver_data; \
int err; \ int err; \
struct device **input_devices = kscan_gpio_input_devices_##n(dev); \ struct device **input_devices = kscan_gpio_input_devices_##n(dev); \
for (int i = 0; i < INST_INPUT_LEN(n); i++) \ for (int i = 0; i < INST_INPUT_LEN(n); i++) { \
{ \
const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs_##n(dev)[i]; \ const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs_##n(dev)[i]; \
input_devices[i] = device_get_binding(in_cfg->label); \ input_devices[i] = device_get_binding(in_cfg->label); \
if (!input_devices[i]) \ if (!input_devices[i]) { \
{ \
LOG_ERR("Unable to find input GPIO device"); \ LOG_ERR("Unable to find input GPIO device"); \
return -EINVAL; \ return -EINVAL; \
} \ } \
err = gpio_pin_configure(input_devices[i], in_cfg->pin, GPIO_INPUT | in_cfg->flags); \ err = gpio_pin_configure(input_devices[i], in_cfg->pin, GPIO_INPUT | in_cfg->flags); \
if (err) \ if (err) { \
{ \
LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \
return err; \ return err; \
} \ } \
irq_callbacks_##n[i].work = &data->work; \ irq_callbacks_##n[i].work = &data->work; \
gpio_init_callback(&irq_callbacks_##n[i].callback, kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \ gpio_init_callback(&irq_callbacks_##n[i].callback, \
kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \
err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \
if (err) \ if (err) { \
{ \
LOG_ERR("Error adding the callback to the column device"); \ LOG_ERR("Error adding the callback to the column device"); \
return err; \ return err; \
} \ } \
} \ } \
struct device **output_devices = kscan_gpio_output_devices_##n(dev); \ struct device **output_devices = kscan_gpio_output_devices_##n(dev); \
for (int o = 0; o < INST_OUTPUT_LEN(n); o++) \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \
{ \
const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \ const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \
output_devices[o] = device_get_binding(out_cfg->label); \ output_devices[o] = device_get_binding(out_cfg->label); \
if (!output_devices[o]) \ if (!output_devices[o]) { \
{ \
LOG_ERR("Unable to find output GPIO device"); \ LOG_ERR("Unable to find output GPIO device"); \
return -EINVAL; \ return -EINVAL; \
} \ } \
err = gpio_pin_configure(output_devices[o], out_cfg->pin, GPIO_OUTPUT_ACTIVE | out_cfg->flags); \ err = gpio_pin_configure(output_devices[o], out_cfg->pin, \
if (err) \ GPIO_OUTPUT_ACTIVE | out_cfg->flags); \
{ \ if (err) { \
LOG_ERR("Unable to configure pin %d on %s for output", out_cfg->pin, out_cfg->label); \ LOG_ERR("Unable to configure pin %d on %s for output", out_cfg->pin, \
out_cfg->label); \
return err; \ return err; \
} \ } \
} \ } \
data->dev = dev; \ data->dev = dev; \
(COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))(&data->work, kscan_gpio_work_handler_##n); \ (COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))( \
&data->work, kscan_gpio_work_handler_##n); \
return 0; \ return 0; \
} \ } \
static const struct kscan_driver_api gpio_driver_api_##n = { \ static const struct kscan_driver_api gpio_driver_api_##n = { \
@ -268,13 +251,12 @@ static int kscan_gpio_config_interrupts(struct device **devices,
.disable_callback = kscan_gpio_disable_interrupts_##n, \ .disable_callback = kscan_gpio_disable_interrupts_##n, \
}; \ }; \
static const struct kscan_gpio_config_##n kscan_gpio_config_##n = { \ static const struct kscan_gpio_config_##n kscan_gpio_config_##n = { \
.rows = { UTIL_LISTIFY(INST_MATRIX_ROWS(n), _KSCAN_GPIO_ROW_CFG_INIT, n) }, \ .rows = {UTIL_LISTIFY(INST_MATRIX_ROWS(n), _KSCAN_GPIO_ROW_CFG_INIT, n)}, \
.cols = { UTIL_LISTIFY(INST_MATRIX_COLS(n), _KSCAN_GPIO_COL_CFG_INIT, n) }, \ .cols = {UTIL_LISTIFY(INST_MATRIX_COLS(n), _KSCAN_GPIO_COL_CFG_INIT, n)}, \
}; \ }; \
DEVICE_AND_API_INIT(kscan_gpio_##n, DT_INST_LABEL(n), kscan_gpio_init_##n, \ DEVICE_AND_API_INIT(kscan_gpio_##n, DT_INST_LABEL(n), kscan_gpio_init_##n, \
&kscan_gpio_data_##n, &kscan_gpio_config_##n, \ &kscan_gpio_data_##n, &kscan_gpio_config_##n, APPLICATION, \
APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY, \ CONFIG_APPLICATION_INIT_PRIORITY, &gpio_driver_api_##n);
&gpio_driver_api_##n);
DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT) DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT)

2
app/dts/behaviors.dtsi

@ -2,8 +2,10 @@
#include <behaviors/transparent.dtsi> #include <behaviors/transparent.dtsi>
#include <behaviors/none.dtsi> #include <behaviors/none.dtsi>
#include <behaviors/mod_tap.dtsi> #include <behaviors/mod_tap.dtsi>
#include <behaviors/layer_tap.dtsi>
#include <behaviors/momentary_layer.dtsi> #include <behaviors/momentary_layer.dtsi>
#include <behaviors/toggle_layer.dtsi> #include <behaviors/toggle_layer.dtsi>
#include <behaviors/reset.dtsi> #include <behaviors/reset.dtsi>
#include <behaviors/sensor_rotate_key_press.dtsi> #include <behaviors/sensor_rotate_key_press.dtsi>
#include <behaviors/rgb_underglow.dtsi> #include <behaviors/rgb_underglow.dtsi>
#include <behaviors/bluetooth.dtsi>

9
app/dts/behaviors/bluetooth.dtsi

@ -0,0 +1,9 @@
/ {
behaviors {
bt: behavior_bluetooth {
compatible = "zmk,behavior-bluetooth";
label = "BLUETOOTH";
#binding-cells = <2>;
};
};
};

12
app/dts/behaviors/layer_tap.dtsi

@ -0,0 +1,12 @@
/ {
behaviors {
lt: behavior_layer_tap {
compatible = "zmk,behavior-hold-tap";
label = "LAYER_TAP";
#binding-cells = <2>;
flavor = "tap-preferred";
tapping_term_ms = <200>;
bindings = <&mo>, <&kp>;
};
};
};

5
app/dts/behaviors/mod_tap.dtsi

@ -1,9 +1,12 @@
/ { / {
behaviors { behaviors {
mt: behavior_mod_tap { mt: behavior_mod_tap {
compatible = "zmk,behavior-mod-tap"; compatible = "zmk,behavior-hold-tap";
label = "MOD_TAP"; label = "MOD_TAP";
#binding-cells = <2>; #binding-cells = <2>;
flavor = "hold-preferred";
tapping_term_ms = <200>;
bindings = <&kp>, <&kp>;
}; };
}; };
}; };

9
app/dts/behaviors/reset.dtsi

@ -1,3 +1,5 @@
#include <dt-bindings/zmk/reset.h>
/ { / {
behaviors { behaviors {
reset: behavior_reset { reset: behavior_reset {
@ -5,5 +7,12 @@
label = "RESET"; label = "RESET";
#binding-cells = <0>; #binding-cells = <0>;
}; };
bootloader: behavior_reset_dfu {
compatible = "zmk,behavior-reset";
label = "BOOTLOADER_RESET";
type = <RST_UF2>;
#binding-cells = <0>;
};
}; };
}; };

4
app/dts/behaviors/toggle_layer.dtsi

@ -1,10 +1,10 @@
/* /*
* Copyright (c) 2020 Cody McGinnis <brainwart@gmail.com> * Copyright (c) 2020 The ZMK Contributors
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/ { / {
behaviors { behaviors {
tog: behavior_toggle_layer { tog: behavior_toggle_layer {
compatible = "zmk,behavior-toggle-layer"; compatible = "zmk,behavior-toggle-layer";

8
app/dts/bindings/behaviors/zmk,behavior-bluetooth.yaml

@ -0,0 +1,8 @@
# Copyright (c) 2020, Peter Johanson
# SPDX-License-Identifier: MIT
description: Bluetooth Behavior
compatible: "zmk,behavior-bluetooth"
include: two_param.yaml

23
app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml

@ -0,0 +1,23 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
description: Hold or Tap behavior
compatible: "zmk,behavior-hold-tap"
include: two_param.yaml
properties:
bindings:
type: phandles
required: true
tapping_term_ms:
type: int
flavor:
type: string
required: false
default: "hold-preferred"
enum:
- "hold-preferred"
- "balanced"
- "tap-preferred"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save