Merge branch 'main' into rgb-momentary-eff

This commit is contained in:
ReFil 2024-07-16 10:13:26 +01:00
commit 2b334a7318
146 changed files with 2603 additions and 564 deletions

View file

@ -12,6 +12,12 @@ on:
schedule: schedule:
- cron: "22 4 * * *" - cron: "22 4 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true
permissions: {}
jobs: jobs:
build: build:
if: ${{ always() }} if: ${{ always() }}
@ -25,6 +31,8 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
persist-credentials: false
- name: Cache west modules - name: Cache west modules
uses: actions/cache@v4 uses: actions/cache@v4
env: env:
@ -131,7 +139,7 @@ jobs:
throw new Error('Failed to build one or more configurations'); throw new Error('Failed to build one or more configurations');
} }
compile-matrix: compile-matrix:
if: ${{ always() }} if: ${{ !cancelled() }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [core-coverage, board-changes, nightly] needs: [core-coverage, board-changes, nightly]
outputs: outputs:
@ -179,6 +187,8 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js - name: Use Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
@ -284,7 +294,7 @@ jobs:
}); });
}))).flat(); }))).flat();
nightly: nightly:
if: ${{ github.event_name == 'schedule' }} if: ${{ github.event_name == 'schedule' && github.repository_owner == 'zmkfirmware' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: get-grouped-hardware needs: get-grouped-hardware
outputs: outputs:
@ -335,6 +345,8 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js - name: Use Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
@ -413,7 +425,11 @@ jobs:
board-changes: ${{ steps.board-changes.outputs.result }} board-changes: ${{ steps.board-changes.outputs.result }}
core-changes: ${{ steps.core-changes.outputs.result }} core-changes: ${{ steps.core-changes.outputs.result }}
steps: steps:
- uses: tj-actions/changed-files@v42 - name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: tj-actions/changed-files@v44
id: changed-files id: changed-files
with: with:
json: true json: true

View file

@ -11,6 +11,10 @@ project(zmk)
zephyr_linker_sources(SECTIONS include/linker/zmk-behaviors.ld) zephyr_linker_sources(SECTIONS include/linker/zmk-behaviors.ld)
zephyr_linker_sources(RODATA include/linker/zmk-events.ld) zephyr_linker_sources(RODATA include/linker/zmk-events.ld)
if(CONFIG_ZMK_BEHAVIOR_LOCAL_IDS)
zephyr_linker_sources(DATA_SECTIONS include/linker/zmk-behavior-local-id-map.ld)
endif()
zephyr_syscall_header(${APPLICATION_SOURCE_DIR}/include/drivers/behavior.h) zephyr_syscall_header(${APPLICATION_SOURCE_DIR}/include/drivers/behavior.h)
zephyr_syscall_header(${APPLICATION_SOURCE_DIR}/include/drivers/ext_power.h) zephyr_syscall_header(${APPLICATION_SOURCE_DIR}/include/drivers/ext_power.h)
@ -20,9 +24,9 @@ target_include_directories(app PRIVATE include)
target_sources(app PRIVATE src/stdlib.c) target_sources(app PRIVATE src/stdlib.c)
target_sources(app PRIVATE src/activity.c) target_sources(app PRIVATE src/activity.c)
target_sources(app PRIVATE src/behavior.c) target_sources(app PRIVATE src/behavior.c)
target_sources(app PRIVATE src/kscan.c)
target_sources_ifdef(CONFIG_ZMK_KSCAN_SIDEBAND_BEHAVIORS app PRIVATE src/kscan_sideband_behaviors.c) target_sources_ifdef(CONFIG_ZMK_KSCAN_SIDEBAND_BEHAVIORS app PRIVATE src/kscan_sideband_behaviors.c)
target_sources(app PRIVATE src/matrix_transform.c) target_sources(app PRIVATE src/matrix_transform.c)
target_sources(app PRIVATE src/physical_layouts.c)
target_sources(app PRIVATE src/sensors.c) target_sources(app PRIVATE src/sensors.c)
target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/wpm.c) target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/wpm.c)
target_sources(app PRIVATE src/event_manager.c) target_sources(app PRIVATE src/event_manager.c)

View file

@ -113,6 +113,12 @@ config ZMK_HID_INDICATORS
Enable HID indicators, used for detecting state of Caps/Scroll/Num Lock, Enable HID indicators, used for detecting state of Caps/Scroll/Num Lock,
Kata, and Compose. Kata, and Compose.
config ZMK_HID_SEPARATE_MOD_RELEASE_REPORT
bool "Release Modifiers Separately"
help
Send a separate release event for the modifiers, to make sure the release
of the modifier doesn't get recognized before the actual key's release event.
menu "Output Types" menu "Output Types"
config ZMK_USB config ZMK_USB
@ -490,7 +496,11 @@ if USB_DEVICE_STACK
config ZMK_USB_INIT_PRIORITY config ZMK_USB_INIT_PRIORITY
int "USB Init Priority" int "USB Init Priority"
default 50 default 94
config ZMK_USB_HID_INIT_PRIORITY
int "USB HID Init Priority"
default 95
#USB #USB
endif endif

View file

@ -1,6 +1,45 @@
# Copyright (c) 2023 The ZMK Contributors # Copyright (c) 2023 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
config ZMK_BEHAVIOR_METADATA
bool "Metadata"
help
Enabling this option adds APIs for documenting and fetching
metadata describing a behaviors name, and supported parameters.
config ZMK_BEHAVIOR_LOCAL_IDS
bool "Local IDs"
if ZMK_BEHAVIOR_LOCAL_IDS
config ZMK_BEHAVIOR_LOCAL_IDS_IN_BINDINGS
bool "Track in behavior bindings"
choice ZMK_BEHAVIOR_LOCAL_ID_TYPE
prompt "Local ID Type"
config ZMK_BEHAVIOR_LOCAL_ID_TYPE_SETTINGS_TABLE
bool "Settings Table"
depends on SETTINGS
select ZMK_BEHAVIOR_LOCAL_IDS_IN_BINDINGS
help
Use persistent entries in the settings subsystem to identify
behaviors by local ID, which uses the device name to generate
a new settings entry tying a presistant local ID to that name.
This guarantees stable, colllision-free local IDs at the expense
of settings storage used.
config ZMK_BEHAVIOR_LOCAL_ID_TYPE_CRC16
bool "CRC16 Hash"
help
Use the CRC16-ANSI hash of behavior device names to generate
stable behavior local IDs. This saves on settings storage at
the expense of (highly unlikely) risk of collisions.
endchoice
endif
config ZMK_BEHAVIOR_KEY_TOGGLE config ZMK_BEHAVIOR_KEY_TOGGLE
bool bool
default y default y

View file

@ -4,6 +4,4 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include "usb_console.dtsi"
&xiao_serial { status = "disabled"; }; &xiao_serial { status = "disabled"; };

View file

@ -4,6 +4,4 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include "usb_console.dtsi"
&pro_micro_serial { status = "disabled"; }; &pro_micro_serial { status = "disabled"; };

View file

@ -4,6 +4,4 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include "usb_console.dtsi"
&xiao_serial { status = "disabled"; }; &xiao_serial { status = "disabled"; };

View file

@ -21,7 +21,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,kscan = &kscan0; zmk,kscan = &kscan0;
zmk,backlight = &backlight; zmk,backlight = &backlight;
zmk,battery = &vbatt; zmk,battery = &vbatt;
@ -90,11 +89,8 @@
status = "okay"; status = "okay";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&flash0 { &flash0 {

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -16,7 +16,6 @@
chosen { chosen {
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,kscan = &kscan; zmk,kscan = &kscan;
zmk,underglow = &led_strip; zmk,underglow = &led_strip;
}; };
@ -106,13 +105,10 @@
apb1-prescaler = <1>; apb1-prescaler = <1>;
}; };
&usb { zephyr_udc0: &usb {
status = "okay"; status = "okay";
pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
pinctrl-names = "default"; pinctrl-names = "default";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&rtc { &rtc {

View file

@ -17,7 +17,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
}; };
@ -82,11 +81,8 @@
pinctrl-names = "default", "sleep"; pinctrl-names = "default", "sleep";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -16,7 +16,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
zmk,kscan = &kscan0; zmk,kscan = &kscan0;
zmk,matrix-transform = &default_transform; zmk,matrix-transform = &default_transform;
@ -70,11 +69,8 @@
status = "okay"; status = "okay";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -142,7 +142,7 @@
status = "okay"; status = "okay";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
}; };

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -20,7 +20,6 @@
zephyr,flash = &flash0; zephyr,flash = &flash0;
zmk,kscan = &kscan0; zmk,kscan = &kscan0;
zmk,display = &epd; zmk,display = &epd;
zephyr,console = &cdc_acm_uart;
zmk,matrix-transform = &default_transform; zmk,matrix-transform = &default_transform;
}; };
@ -76,11 +75,8 @@
status = "okay"; status = "okay";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&flash0 { &flash0 {

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -16,7 +16,6 @@
chosen { chosen {
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,kscan = &kscan0; zmk,kscan = &kscan0;
zmk,matrix-transform = &default_transform; zmk,matrix-transform = &default_transform;
}; };
@ -65,11 +64,8 @@ RC(4,0) RC(4,1) RC(4,2) RC(4,5) RC(
}; };
&usb { zephyr_udc0: &usb {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&flash0 { &flash0 {

View file

@ -17,7 +17,6 @@
chosen { chosen {
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,kscan = &kscan; zmk,kscan = &kscan;
zmk,matrix-transform = &transform; zmk,matrix-transform = &transform;
/* TODO: Enable once we support the IC for underglow /* TODO: Enable once we support the IC for underglow
@ -110,14 +109,11 @@
}; };
}; };
&usb { zephyr_udc0: &usb {
status = "okay"; status = "okay";
pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
pinctrl-names = "default"; pinctrl-names = "default";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&clk_hsi { &clk_hsi {

View file

@ -15,7 +15,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
}; };
default_transform: keymap_transform_0 { default_transform: keymap_transform_0 {
@ -59,11 +58,8 @@
status = "okay"; status = "okay";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&flash0 { &flash0 {

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -13,8 +13,6 @@
chosen { chosen {
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zephyr,shell-uart = &cdc_acm_uart;
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zmk,kscan = &kscan0; zmk,kscan = &kscan0;
zmk,matrix-transform = &default_transform; zmk,matrix-transform = &default_transform;
@ -108,11 +106,8 @@ RC(4,0) RC(4,1) RC(4,2) RC(4,6) RC(4,8) RC(4,9)
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -17,7 +17,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
}; };
@ -81,11 +80,8 @@
pinctrl-names = "default", "sleep"; pinctrl-names = "default", "sleep";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -20,7 +20,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
zmk,kscan = &kscan0; zmk,kscan = &kscan0;
zmk,matrix-transform = &default_transform; zmk,matrix-transform = &default_transform;
@ -129,11 +128,8 @@ RC(4,0) RC(4,1) RC(4,2) RC(4,5) R
}; };
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&flash0 { &flash0 {

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -16,7 +16,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
}; };
leds { leds {
@ -65,11 +64,8 @@
pinctrl-names = "default", "sleep"; pinctrl-names = "default", "sleep";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -15,7 +15,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
}; };
@ -57,12 +56,9 @@
status = "okay"; status = "okay";
}; };
&usbd { zephyr_udc0: &usbd {
compatible = "nordic,nrf-usbd"; compatible = "nordic,nrf-usbd";
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -17,7 +17,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
}; };
leds { leds {
@ -69,11 +68,8 @@
pinctrl-names = "default", "sleep"; pinctrl-names = "default", "sleep";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -17,7 +17,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
}; };
leds { leds {
@ -69,11 +68,8 @@
pinctrl-names = "default", "sleep"; pinctrl-names = "default", "sleep";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -17,7 +17,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
}; };
@ -81,11 +80,8 @@
pinctrl-names = "default", "sleep"; pinctrl-names = "default", "sleep";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -17,7 +17,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
}; };
@ -81,11 +80,8 @@
pinctrl-names = "default", "sleep"; pinctrl-names = "default", "sleep";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -18,7 +18,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
}; };
@ -83,11 +82,8 @@
pinctrl-names = "default", "sleep"; pinctrl-names = "default", "sleep";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -16,7 +16,6 @@
chosen { chosen {
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,kscan = &kscan0; zmk,kscan = &kscan0;
zmk,matrix-transform = &layout_grid_transform; zmk,matrix-transform = &layout_grid_transform;
}; };
@ -96,13 +95,10 @@ layout_2x2u_transform:
}; };
}; };
&usb { zephyr_udc0: &usb {
pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
pinctrl-names = "default"; pinctrl-names = "default";
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&clk_hse { &clk_hse {

View file

@ -17,7 +17,6 @@
chosen { chosen {
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,kscan = &kscan0; zmk,kscan = &kscan0;
zmk,matrix-transform = &layout_grid_transform; zmk,matrix-transform = &layout_grid_transform;
}; };
@ -90,13 +89,10 @@
}; };
}; };
&usb { zephyr_udc0: &usb {
pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
pinctrl-names = "default"; pinctrl-names = "default";
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&clk_hse { &clk_hse {

View file

@ -16,7 +16,6 @@
chosen { chosen {
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart0;
}; };
aliases { aliases {
@ -66,13 +65,10 @@
apb2-prescaler = <1>; apb2-prescaler = <1>;
}; };
&usb { zephyr_udc0: &usb {
pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
pinctrl-names = "default"; pinctrl-names = "default";
status = "okay"; status = "okay";
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&rtc { &rtc {

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -17,7 +17,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
}; };
@ -72,11 +71,8 @@
pinctrl-names = "default", "sleep"; pinctrl-names = "default", "sleep";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };

View file

@ -0,0 +1,9 @@
#
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
# Suppresses duplicate unit-address warning at build time for power, clock, acl and flash-controller
# https://docs.zephyrproject.org/latest/build/dts/intro-input-output.html
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -16,7 +16,6 @@
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
zmk,kscan = &kscan0; zmk,kscan = &kscan0;
zmk,matrix-transform = &default_transform; zmk,matrix-transform = &default_transform;
@ -93,11 +92,8 @@
status = "okay"; status = "okay";
}; };
&usbd { zephyr_udc0: &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
}; };
&flash0 { &flash0 {

View file

@ -4,6 +4,4 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include "usb_console.dtsi"
&pro_micro_serial { status = "disabled"; }; &pro_micro_serial { status = "disabled"; };

View file

@ -1,8 +0,0 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include "usb_console.dtsi"

View file

@ -1,18 +0,0 @@
/*
* Copyright (c) 2022 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
/ {
chosen {
zephyr,console = &cdc_acm_uart;
};
};
&usb0 {
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
};

View file

@ -7,7 +7,6 @@
/ { / {
chosen { chosen {
zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
}; };
@ -24,12 +23,6 @@
status = "okay"; status = "okay";
}; };
&usbd {
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
};
&qspi { &qspi {
status = "okay"; status = "okay";
pinctrl-0 = <&qspi_default>; pinctrl-0 = <&qspi_default>;

View file

@ -2,3 +2,10 @@ CONFIG_CONSOLE=n
CONFIG_SERIAL=n CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n CONFIG_UART_CONSOLE=n
CONFIG_ZMK_USB=y CONFIG_ZMK_USB=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_NVS=y
CONFIG_SETTINGS_NVS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y

View file

@ -4,6 +4,19 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include "usb_console.dtsi"
&xiao_serial { status = "disabled"; }; &xiao_serial { status = "disabled"; };
&code_partition {
reg = <0x100 (DT_SIZE_M(2) - 0x100 - DT_SIZE_K(512))>;
};
&flash0 {
reg = <0x10000000 DT_SIZE_M(2)>;
partitions {
storage_partition: partition@180000 {
reg = <0x180000 DT_SIZE_K(512)>;
read-only;
};
};
};

View file

@ -40,10 +40,8 @@ nice_view_spi: &arduino_spi {
/ { / {
chosen { chosen {
zmk,kscan = &kscan_matrix;
zmk,backlight = &backlight; zmk,backlight = &backlight;
zmk,underglow = &led_strip; zmk,underglow = &led_strip;
zmk,matrix-transform = &matrix_transform;
}; };
// Commented out until we add more powerful power domain support // Commented out until we add more powerful power domain support
@ -109,7 +107,6 @@ nice_view_spi: &arduino_spi {
kscan_direct: kscan_direct { kscan_direct: kscan_direct {
compatible = "zmk,kscan-gpio-direct"; compatible = "zmk,kscan-gpio-direct";
wakeup-source; wakeup-source;
status = "disabled";
input-gpios input-gpios
= <&arduino_header 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> = <&arduino_header 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>

View file

@ -13,13 +13,9 @@
// Uncomment the following lines if using the "Direct Wire" jumper to switch the matrix to a direct wire. // Uncomment the following lines if using the "Direct Wire" jumper to switch the matrix to a direct wire.
// &kscan_direct { status = "okay"; };
// &kscan_matrix { status = "disabled"; };
// / { // / {
// chosen { // chosen {
// zmk,matrix-transform = &direct_matrix_transform; // zmk,physical-layout = &direct_physical_layout;
// zmk,kscan = &kscan_direct;
// }; // };
// }; // };

View file

@ -7,13 +7,15 @@
#include "zmk_uno.dtsi" #include "zmk_uno.dtsi"
#include <behaviors.dtsi> #include <behaviors.dtsi>
#include <physical_layouts.dtsi>
#include <dt-bindings/zmk/bt.h> #include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/outputs.h> #include <dt-bindings/zmk/outputs.h>
/ { / {
chosen { chosen {
zmk,matrix-transform = &matrix_transform; zmk,physical-layout = &matrix_physical_layout;
}; };
sensors: sensors { sensors: sensors {
compatible = "zmk,keymap-sensors"; compatible = "zmk,keymap-sensors";
sensors = <&encoder>; sensors = <&encoder>;
@ -38,6 +40,8 @@
endpoint_sideband_behaviors { endpoint_sideband_behaviors {
compatible = "zmk,kscan-sideband-behaviors"; compatible = "zmk,kscan-sideband-behaviors";
auto-enable;
kscan = <&kscan_sp3t_toggle>; kscan = <&kscan_sp3t_toggle>;
first_toggle_sideband: first_toggle_sideband { first_toggle_sideband: first_toggle_sideband {
@ -56,4 +60,35 @@
}; };
}; };
matrix_physical_layout: matrix_physical_layout {
compatible = "zmk,physical-layout";
display-name = "Matrix Layout";
kscan = <&kscan_matrix>;
transform = <&matrix_transform>;
keys
= <&key_physical_attrs 100 100 0 0 0 0 0>
, <&key_physical_attrs 100 100 100 0 0 0 0>
, <&key_physical_attrs 100 100 0 100 0 0 0>
, <&key_physical_attrs 100 100 100 100 0 0 0>
;
};
direct_physical_layout: direct_physical_layout {
compatible = "zmk,physical-layout";
display-name = "Direct Wire Layout";
kscan = <&kscan_direct>;
transform = <&direct_matrix_transform>;
keys
= <&key_physical_attrs 100 100 0 0 0 0 0>
, <&key_physical_attrs 100 100 100 0 0 0 0>
, <&key_physical_attrs 100 100 0 100 0 0 0>
, <&key_physical_attrs 100 100 100 100 0 0 0>
;
};
}; };

View file

@ -6,13 +6,15 @@
#include "zmk_uno.dtsi" #include "zmk_uno.dtsi"
#include <physical_layouts.dtsi>
left_encoder: &encoder { left_encoder: &encoder {
status = "disabled"; status = "disabled";
}; };
/ { / {
chosen { chosen {
zmk,matrix-transform = &split_matrix_transform; zmk,physical-layout = &matrix_physical_layout;
}; };
split_matrix_transform: split_matrix_transform { split_matrix_transform: split_matrix_transform {
@ -31,18 +33,57 @@
split_direct_matrix_transform: split_direct_matrix_transform { split_direct_matrix_transform: split_direct_matrix_transform {
compatible = "zmk,matrix-transform"; compatible = "zmk,matrix-transform";
rows = <3>; rows = <2>;
columns = <4>; columns = <4>;
map = < map = <
RC(0,0) RC(0,1) RC(0,0) RC(0,1)
RC(0,2) RC(0,3) RC(0,2) RC(0,3)
RC(2,0) RC(2,1) RC(1,0) RC(1,1)
RC(2,2) RC(2,3) RC(1,2) RC(1,3)
>; >;
}; };
matrix_physical_layout: matrix_physical_layout {
compatible = "zmk,physical-layout";
display-name = "Matrix Layout";
kscan = <&kscan_matrix>;
transform = <&split_matrix_transform>;
keys
= <&key_physical_attrs 100 100 0 0 0 0 0>
, <&key_physical_attrs 100 100 100 0 0 0 0>
, <&key_physical_attrs 100 100 0 100 0 0 0>
, <&key_physical_attrs 100 100 100 100 0 0 0>
, <&key_physical_attrs 100 100 0 200 0 0 0>
, <&key_physical_attrs 100 100 100 200 0 0 0>
, <&key_physical_attrs 100 100 0 300 0 0 0>
, <&key_physical_attrs 100 100 100 300 0 0 0>
;
};
direct_physical_layout: direct_physical_layout {
compatible = "zmk,physical-layout";
display-name = "Direct Wire Layout";
kscan = <&kscan_direct>;
transform = <&split_direct_matrix_transform>;
keys
= <&key_physical_attrs 100 100 0 0 0 0 0>
, <&key_physical_attrs 100 100 100 0 0 0 0>
, <&key_physical_attrs 100 100 0 100 0 0 0>
, <&key_physical_attrs 100 100 100 100 0 0 0>
, <&key_physical_attrs 100 100 0 200 0 0 0>
, <&key_physical_attrs 100 100 100 200 0 0 0>
, <&key_physical_attrs 100 100 0 300 0 0 0>
, <&key_physical_attrs 100 100 100 300 0 0 0>
;
};
right_encoder: right_encoder { right_encoder: right_encoder {
steps = <80>; steps = <80>;
status = "disabled"; status = "disabled";

View file

@ -14,14 +14,9 @@
// Uncomment the following lines if using the "Direct Wire" jumper to switch the matrix to a direct wire. // Uncomment the following lines if using the "Direct Wire" jumper to switch the matrix to a direct wire.
// &kscan_direct { status = "okay"; };
// &kscan_matrix { status = "disabled"; };
// / { // / {
// chosen { // chosen {
// zmk,matrix-transform = &split_direct_matrix_transform; // zmk,physical-layout = &direct_physical_layout;
// zmk,kscan = &kscan_direct;
// }; // };
// }; // };

View file

@ -11,7 +11,7 @@
}; };
&split_direct_matrix_transform { &split_direct_matrix_transform {
row-offset = <2>; row-offset = <1>;
}; };
&right_encoder { &right_encoder {

View file

@ -4,6 +4,4 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include "usb_console.dtsi"
&pro_micro_serial { status = "disabled"; }; &pro_micro_serial { status = "disabled"; };

View file

@ -1,19 +0,0 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
/ {
chosen {
zephyr,console = &cdc_acm_uart;
};
};
&usbd {
cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart";
};
};

View file

@ -22,6 +22,13 @@ include:
shield: kyria_left shield: kyria_left
cmake-args: "-DCONFIG_ZMK_DISPLAY=y" cmake-args: "-DCONFIG_ZMK_DISPLAY=y"
nickname: "display" nickname: "display"
- board: nice_nano_v2
shield: kyria_left
cmake-args: "-DCONFIG_ZMK_MOUSE=y"
nickname: "mouse"
- board: sparkfun_pro_micro_rp2040
shield: reviung41
cmake-args: "-DSNIPPET='zmk-usb-logging'"
- board: nice_nano_v2 - board: nice_nano_v2
shield: kyria_right shield: kyria_right
cmake-args: "-DCONFIG_ZMK_DISPLAY=y" cmake-args: "-DCONFIG_ZMK_DISPLAY=y"

View file

@ -10,6 +10,7 @@
/omit-if-no-ref/ bl: bcklight { /omit-if-no-ref/ bl: bcklight {
compatible = "zmk,behavior-backlight"; compatible = "zmk,behavior-backlight";
#binding-cells = <2>; #binding-cells = <2>;
display-name = "Backlight";
}; };
}; };
}; };

View file

@ -9,6 +9,7 @@
/omit-if-no-ref/ bt: bluetooth { /omit-if-no-ref/ bt: bluetooth {
compatible = "zmk,behavior-bluetooth"; compatible = "zmk,behavior-bluetooth";
#binding-cells = <2>; #binding-cells = <2>;
display-name = "Bluetooth";
}; };
}; };
}; };

View file

@ -12,6 +12,7 @@
compatible = "zmk,behavior-caps-word"; compatible = "zmk,behavior-caps-word";
#binding-cells = <0>; #binding-cells = <0>;
continue-list = <UNDERSCORE BACKSPACE DELETE>; continue-list = <UNDERSCORE BACKSPACE DELETE>;
display-name = "Caps Word";
}; };
}; };
}; };

View file

@ -10,6 +10,7 @@
ext_power: extpower { ext_power: extpower {
compatible = "zmk,behavior-ext-power"; compatible = "zmk,behavior-ext-power";
#binding-cells = <1>; #binding-cells = <1>;
display-name = "External Power";
}; };
}; };
}; };

View file

@ -13,6 +13,7 @@
#binding-cells = <0>; #binding-cells = <0>;
bindings = <&kp ESC>, <&kp GRAVE>; bindings = <&kp ESC>, <&kp GRAVE>;
mods = <(MOD_LGUI|MOD_LSFT|MOD_RGUI|MOD_RSFT)>; mods = <(MOD_LGUI|MOD_LSFT|MOD_RGUI|MOD_RSFT)>;
display-name = "Grave/Escape";
}; };
}; };
}; };

View file

@ -10,6 +10,7 @@
/omit-if-no-ref/ cp: kp: key_press { /omit-if-no-ref/ cp: kp: key_press {
compatible = "zmk,behavior-key-press"; compatible = "zmk,behavior-key-press";
#binding-cells = <1>; #binding-cells = <1>;
display-name = "Key Press";
}; };
}; };
}; };

View file

@ -12,6 +12,7 @@
compatible = "zmk,behavior-key-repeat"; compatible = "zmk,behavior-key-repeat";
#binding-cells = <0>; #binding-cells = <0>;
usage-pages = <HID_USAGE_KEY>; usage-pages = <HID_USAGE_KEY>;
display-name = "Key Repeat";
}; };
}; };
}; };

View file

@ -9,6 +9,7 @@
/omit-if-no-ref/ kt: key_toggle { /omit-if-no-ref/ kt: key_toggle {
compatible = "zmk,behavior-key-toggle"; compatible = "zmk,behavior-key-toggle";
#binding-cells = <1>; #binding-cells = <1>;
display-name = "Key Toggle";
}; };
}; };
}; };

View file

@ -12,6 +12,7 @@
flavor = "tap-preferred"; flavor = "tap-preferred";
tapping-term-ms = <200>; tapping-term-ms = <200>;
bindings = <&mo>, <&kp>; bindings = <&mo>, <&kp>;
display-name = "Layer-Tap";
}; };
}; };
}; };

View file

@ -12,6 +12,7 @@
flavor = "hold-preferred"; flavor = "hold-preferred";
tapping-term-ms = <200>; tapping-term-ms = <200>;
bindings = <&kp>, <&kp>; bindings = <&kp>, <&kp>;
display-name = "Mod-Tap";
}; };
}; };
}; };

View file

@ -9,6 +9,7 @@
/omit-if-no-ref/ mo: momentary_layer { /omit-if-no-ref/ mo: momentary_layer {
compatible = "zmk,behavior-momentary-layer"; compatible = "zmk,behavior-momentary-layer";
#binding-cells = <1>; #binding-cells = <1>;
display-name = "Momentary Layer";
}; };
}; };
}; };

View file

@ -9,6 +9,7 @@
/omit-if-no-ref/ none: none { /omit-if-no-ref/ none: none {
compatible = "zmk,behavior-none"; compatible = "zmk,behavior-none";
#binding-cells = <0>; #binding-cells = <0>;
display-name = "None";
}; };
}; };
}; };

View file

@ -9,6 +9,7 @@
/omit-if-no-ref/ out: outputs { /omit-if-no-ref/ out: outputs {
compatible = "zmk,behavior-outputs"; compatible = "zmk,behavior-outputs";
#binding-cells = <1>; #binding-cells = <1>;
display-name = "Output Selection";
}; };
}; };
}; };

View file

@ -12,6 +12,7 @@
sys_reset: sysreset { sys_reset: sysreset {
compatible = "zmk,behavior-reset"; compatible = "zmk,behavior-reset";
#binding-cells = <0>; #binding-cells = <0>;
display-name = "Reset";
}; };
// Behavior can be invoked on peripherals, so name must be <= 8 characters. // Behavior can be invoked on peripherals, so name must be <= 8 characters.
@ -19,6 +20,7 @@
compatible = "zmk,behavior-reset"; compatible = "zmk,behavior-reset";
type = <RST_UF2>; type = <RST_UF2>;
#binding-cells = <0>; #binding-cells = <0>;
display-name = "Bootloader";
}; };
}; };
}; };

View file

@ -10,6 +10,7 @@
rgb_ug: rgb_ug { rgb_ug: rgb_ug {
compatible = "zmk,behavior-rgb-underglow"; compatible = "zmk,behavior-rgb-underglow";
#binding-cells = <2>; #binding-cells = <2>;
display-name = "Underglow";
}; };
}; };
}; };

View file

@ -12,6 +12,7 @@
release-after-ms = <1000>; release-after-ms = <1000>;
bindings = <&kp>; bindings = <&kp>;
ignore-modifiers; ignore-modifiers;
display-name = "Sticky Key";
}; };
/omit-if-no-ref/ sl: sticky_layer { /omit-if-no-ref/ sl: sticky_layer {
compatible = "zmk,behavior-sticky-key"; compatible = "zmk,behavior-sticky-key";
@ -19,6 +20,7 @@
release-after-ms = <1000>; release-after-ms = <1000>;
bindings = <&mo>; bindings = <&mo>;
quick-release; quick-release;
display-name = "Sticky Layer";
}; };
}; };

View file

@ -9,6 +9,7 @@
/omit-if-no-ref/ to: to_layer { /omit-if-no-ref/ to: to_layer {
compatible = "zmk,behavior-to-layer"; compatible = "zmk,behavior-to-layer";
#binding-cells = <1>; #binding-cells = <1>;
display-name = "To Layer";
}; };
}; };
}; };

View file

@ -9,6 +9,7 @@
/omit-if-no-ref/ tog: toggle_layer { /omit-if-no-ref/ tog: toggle_layer {
compatible = "zmk,behavior-toggle-layer"; compatible = "zmk,behavior-toggle-layer";
#binding-cells = <1>; #binding-cells = <1>;
display-name = "Toggle Layer";
}; };
}; };
}; };

View file

@ -9,6 +9,7 @@
/omit-if-no-ref/ trans: transparent { /omit-if-no-ref/ trans: transparent {
compatible = "zmk,behavior-transparent"; compatible = "zmk,behavior-transparent";
#binding-cells = <0>; #binding-cells = <0>;
display-name = "Transparent";
}; };
}; };
}; };

View file

@ -0,0 +1,6 @@
# Copyright (c) 2024 The ZMK Contributors
# SPDX-License-Identifier: MIT
properties:
display-name:
type: string

View file

@ -1,6 +1,8 @@
# Copyright (c) 2020 The ZMK Contributors # Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
include: behavior-metadata.yaml
properties: properties:
label: label:
type: string type: string

View file

@ -1,6 +1,8 @@
# Copyright (c) 2020 The ZMK Contributors # Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
include: behavior-metadata.yaml
properties: properties:
label: label:
type: string type: string

View file

@ -1,6 +1,8 @@
# Copyright (c) 2020 The ZMK Contributors # Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
include: behavior-metadata.yaml
properties: properties:
label: label:
type: string type: string

View file

@ -11,6 +11,9 @@ compatible: "zmk,kscan-sideband-behaviors"
include: kscan.yaml include: kscan.yaml
properties: properties:
auto-enable:
type: boolean
kscan: kscan:
type: phandle type: phandle
required: true required: true

View file

@ -0,0 +1,24 @@
#
# Copyright (c) 2024 The ZMK Contributors
#
# SPDX-License-Identifier: MIT
description: |
The physical attributes of a key, including size, location, and rotation
compatible: "zmk,key-physical-attrs"
properties:
"#key-cells":
type: int
required: true
const: 7
key-cells:
- width
- height
- x
- y
- r
- rx
- ry

View file

@ -0,0 +1,23 @@
#
# Copyright (c) 2024 The ZMK Contributors
#
# SPDX-License-Identifier: MIT
description: |
Describes how to correlate equivalent keys between layouts that don't have the exact same X,Y location.
compatible: "zmk,physical-layout-position-map"
properties:
complete:
type: boolean
description: If the mapping complete describes the key mapping, and no position based mapping should be used.
child-binding:
properties:
physical-layout:
type: phandle
description: The physical layout that corresponds to this mapping entry.
positions:
type: array
description: Array of key positions that match the same array entry in the other sibling nodes.

View file

@ -0,0 +1,26 @@
#
# Copyright (c) 2024 The ZMK Contributors
#
# SPDX-License-Identifier: MIT
description: |
Describe the physical layout of a keyboard, including deps like the transform and kscan
that are needed for that layout to work.
compatible: "zmk,physical-layout"
properties:
display-name:
type: string
required: true
description: The name of this layout to display in the UI
transform:
type: phandle
required: true
description: The matrix transform to use along with this layout.
kscan:
type: phandle
description: The kscan to use along with this layout. The `zmk,kscan` chosen will be used as a fallback if this property is omitted.
keys:
type: phandle-array
description: Array of key physical attributes.

View file

@ -0,0 +1,13 @@
/*
* Copyright (c) 2024 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
/ {
key_physical_attrs: key_physical_attrs {
compatible = "zmk,key-physical-attrs";
#key-cells = <7>;
};
};

View file

@ -23,6 +23,39 @@
* (Internal use only.) * (Internal use only.)
*/ */
struct behavior_parameter_value_metadata {
char *display_name;
union {
uint32_t value;
struct {
int32_t min;
int32_t max;
} range;
};
enum {
BEHAVIOR_PARAMETER_VALUE_TYPE_NIL = 0,
BEHAVIOR_PARAMETER_VALUE_TYPE_VALUE = 1,
BEHAVIOR_PARAMETER_VALUE_TYPE_RANGE = 2,
BEHAVIOR_PARAMETER_VALUE_TYPE_HID_USAGE = 3,
BEHAVIOR_PARAMETER_VALUE_TYPE_LAYER_ID = 4,
} type;
};
struct behavior_parameter_metadata_set {
size_t param1_values_len;
const struct behavior_parameter_value_metadata *param1_values;
size_t param2_values_len;
const struct behavior_parameter_value_metadata *param2_values;
};
struct behavior_parameter_metadata {
size_t sets_len;
const struct behavior_parameter_metadata_set *sets;
};
enum behavior_sensor_binding_process_mode { enum behavior_sensor_binding_process_mode {
BEHAVIOR_SENSOR_BINDING_PROCESS_MODE_TRIGGER, BEHAVIOR_SENSOR_BINDING_PROCESS_MODE_TRIGGER,
BEHAVIOR_SENSOR_BINDING_PROCESS_MODE_DISCARD, BEHAVIOR_SENSOR_BINDING_PROCESS_MODE_DISCARD,
@ -37,6 +70,10 @@ typedef int (*behavior_sensor_keymap_binding_accept_data_callback_t)(
struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event, struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event,
const struct zmk_sensor_config *sensor_config, size_t channel_data_size, const struct zmk_sensor_config *sensor_config, size_t channel_data_size,
const struct zmk_sensor_channel_data channel_data[channel_data_size]); const struct zmk_sensor_channel_data channel_data[channel_data_size]);
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
typedef int (*behavior_get_parameter_metadata_t)(
const struct device *behavior, struct behavior_parameter_metadata *param_metadata);
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
enum behavior_locality { enum behavior_locality {
BEHAVIOR_LOCALITY_CENTRAL, BEHAVIOR_LOCALITY_CENTRAL,
@ -51,23 +88,71 @@ __subsystem struct behavior_driver_api {
behavior_keymap_binding_callback_t binding_released; behavior_keymap_binding_callback_t binding_released;
behavior_sensor_keymap_binding_accept_data_callback_t sensor_binding_accept_data; behavior_sensor_keymap_binding_accept_data_callback_t sensor_binding_accept_data;
behavior_sensor_keymap_binding_process_callback_t sensor_binding_process; behavior_sensor_keymap_binding_process_callback_t sensor_binding_process;
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
behavior_get_parameter_metadata_t get_parameter_metadata;
const struct behavior_parameter_metadata *parameter_metadata;
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
}; };
/** /**
* @endcond * @endcond
*/ */
struct zmk_behavior_metadata {
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
const char *display_name;
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
};
struct zmk_behavior_ref { struct zmk_behavior_ref {
const struct device *device; const struct device *device;
const struct zmk_behavior_metadata metadata;
}; };
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_LOCAL_IDS)
struct zmk_behavior_local_id_map {
const struct device *device;
zmk_behavior_local_id_t local_id;
};
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_LOCAL_IDS)
#define ZMK_BEHAVIOR_REF_DT_NAME(node_id) _CONCAT(zmk_behavior_, DEVICE_DT_NAME_GET(node_id))
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
#define ZMK_BEHAVIOR_METADATA_INITIALIZER(node_id) \
{ .display_name = DT_PROP_OR(node_id, display_name, DEVICE_DT_NAME(node_id)), }
#else
#define ZMK_BEHAVIOR_METADATA_INITIALIZER(node_id) \
{}
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
#define ZMK_BEHAVIOR_REF_INITIALIZER(node_id, _dev) \
{ .device = _dev, .metadata = ZMK_BEHAVIOR_METADATA_INITIALIZER(node_id), }
#define ZMK_BEHAVIOR_LOCAL_ID_MAP_INITIALIZER(node_id, _dev) \
{ .device = _dev, }
#define ZMK_BEHAVIOR_REF_DEFINE(name, node_id, _dev) \
static const STRUCT_SECTION_ITERABLE(zmk_behavior_ref, name) = \
ZMK_BEHAVIOR_REF_INITIALIZER(node_id, _dev); \
COND_CODE_1(IS_ENABLED(CONFIG_ZMK_BEHAVIOR_LOCAL_IDS), \
(static const STRUCT_SECTION_ITERABLE(zmk_behavior_local_id_map, \
_CONCAT(_zmk_behavior_local_id_map, name)) = \
ZMK_BEHAVIOR_LOCAL_ID_MAP_INITIALIZER(node_id, _dev)), \
());
#define ZMK_BEHAVIOR_REF_DT_DEFINE(node_id) \
ZMK_BEHAVIOR_REF_DEFINE(ZMK_BEHAVIOR_REF_DT_NAME(node_id), node_id, DEVICE_DT_GET(node_id))
/** /**
* Registers @p node_id as a behavior. * Registers @p node_id as a behavior.
*/ */
#define BEHAVIOR_DEFINE(node_id) \ #define BEHAVIOR_DEFINE(node_id) ZMK_BEHAVIOR_REF_DT_DEFINE(node_id)
static const STRUCT_SECTION_ITERABLE(zmk_behavior_ref, \
_CONCAT(zmk_behavior_, DEVICE_DT_NAME_GET(node_id))) = { \
.device = DEVICE_DT_GET(node_id), \
}
/** /**
* @brief Like DEVICE_DT_DEFINE(), but also registers the device as a behavior. * @brief Like DEVICE_DT_DEFINE(), but also registers the device as a behavior.
@ -89,6 +174,52 @@ struct zmk_behavior_ref {
DEVICE_DT_INST_DEFINE(inst, __VA_ARGS__); \ DEVICE_DT_INST_DEFINE(inst, __VA_ARGS__); \
BEHAVIOR_DEFINE(DT_DRV_INST(inst)) BEHAVIOR_DEFINE(DT_DRV_INST(inst))
/**
* @brief Validate a given behavior binding is valid, including parameter validation
* if the metadata feature is enablued.
*
* @param binding The behavior binding to validate.
*
* @retval 0 if the passed in binding is valid.
* @retval -ENODEV if the binding references a non-existant behavior.
* @retval -EINVAL if parameters are not valid for the behavior metadata.
*/
int zmk_behavior_validate_binding(const struct zmk_behavior_binding *binding);
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
int zmk_behavior_get_empty_param_metadata(const struct device *dev,
struct behavior_parameter_metadata *metadata);
/**
* @brief Validate a given behavior parameters match the behavior metadata.
*
* @param metadata The behavior metadata to validate against
* @param param1 The first parameter value
* @param param2 The second parameter value
*
* @retval 0 if the passed in parameters are valid.
* @retval -ENODEV if metadata is NULL.
* @retval -EINVAL if parameters are not valid for the metadata.
*/
int zmk_behavior_check_params_match_metadata(const struct behavior_parameter_metadata *metadata,
uint32_t param1, uint32_t param2);
/**
* @brief Validate a given behavior parameter matches the behavior metadata parameter values.
*
* @param values The values to validate against
* @param values_len How many values to check
* @param param The value to check.
*
* @retval 0 if the passed in parameter is valid.
* @retval -ENODEV if values is NULL.
* @retval -EINVAL if parameter is not valid for the value metadata.
*/
int zmk_behavior_validate_param_values(const struct behavior_parameter_value_metadata *values,
size_t values_len, uint32_t param);
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
/** /**
* Syscall wrapper for zmk_behavior_get_binding(). * Syscall wrapper for zmk_behavior_get_binding().
* *
@ -120,6 +251,40 @@ static inline int z_impl_behavior_keymap_binding_convert_central_state_dependent
return api->binding_convert_central_state_dependent_params(binding, event); return api->binding_convert_central_state_dependent_params(binding, event);
} }
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
/**
* @brief Determine where the behavior should be run
* @param behavior Pointer to the device structure for the driver instance.
*
* @retval Zero if successful.
* @retval Negative errno code if failure.
*/
__syscall int behavior_get_parameter_metadata(const struct device *behavior,
struct behavior_parameter_metadata *param_metadata);
static inline int
z_impl_behavior_get_parameter_metadata(const struct device *behavior,
struct behavior_parameter_metadata *param_metadata) {
if (behavior == NULL || param_metadata == NULL) {
return -EINVAL;
}
const struct behavior_driver_api *api = (const struct behavior_driver_api *)behavior->api;
if (api->get_parameter_metadata) {
return api->get_parameter_metadata(behavior, param_metadata);
} else if (api->parameter_metadata) {
*param_metadata = *api->parameter_metadata;
} else {
return -ENODEV;
}
return 0;
}
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
/** /**
* @brief Determine where the behavior should be run * @brief Determine where the behavior should be run
* @param behavior Pointer to the device structure for the driver instance. * @param behavior Pointer to the device structure for the driver instance.

View file

@ -0,0 +1,9 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <zephyr/linker/linker-defs.h>
ITERABLE_SECTION_RAM(zmk_behavior_local_id_map, 4)

View file

@ -11,8 +11,13 @@
#define ZMK_BEHAVIOR_OPAQUE 0 #define ZMK_BEHAVIOR_OPAQUE 0
#define ZMK_BEHAVIOR_TRANSPARENT 1 #define ZMK_BEHAVIOR_TRANSPARENT 1
typedef uint16_t zmk_behavior_local_id_t;
struct zmk_behavior_binding { struct zmk_behavior_binding {
char *behavior_dev; #if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_LOCAL_IDS_IN_BINDINGS)
zmk_behavior_local_id_t local_id;
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_LOCAL_IDS_IN_BINDINGS)
const char *behavior_dev;
uint32_t param1; uint32_t param1;
uint32_t param2; uint32_t param2;
}; };
@ -36,3 +41,23 @@ struct zmk_behavior_binding_event {
* unrelated node which shares the same name as a behavior. * unrelated node which shares the same name as a behavior.
*/ */
const struct device *zmk_behavior_get_binding(const char *name); const struct device *zmk_behavior_get_binding(const char *name);
/**
* @brief Get a local ID for a behavior from its @p name field.
*
* @param name Behavior name to search for.
*
* @retval The local ID value that can be used to reference the behavior later, across reboots.
* @retval UINT16_MAX if the behavior is not found or its initialization function failed.
*/
zmk_behavior_local_id_t zmk_behavior_get_local_id(const char *name);
/**
* @brief Get a behavior name for a behavior from its @p local_id .
*
* @param local_id Behavior local ID used to search for the behavior
*
* @retval The name of the behavior that is associated with that local ID.
* @retval NULL if the behavior is not found or its initialization function failed.
*/
const char *zmk_behavior_find_behavior_name_from_local_id(zmk_behavior_local_id_t local_id);

View file

@ -29,7 +29,10 @@ int zmk_ble_prof_disconnect(uint8_t index);
int zmk_ble_active_profile_index(void); int zmk_ble_active_profile_index(void);
int zmk_ble_profile_index(const bt_addr_le_t *addr); int zmk_ble_profile_index(const bt_addr_le_t *addr);
bt_addr_le_t *zmk_ble_active_profile_addr(void); bt_addr_le_t *zmk_ble_active_profile_addr(void);
struct bt_conn *zmk_ble_active_profile_conn(void);
bool zmk_ble_active_profile_is_open(void); bool zmk_ble_active_profile_is_open(void);
bool zmk_ble_active_profile_is_connected(void); bool zmk_ble_active_profile_is_connected(void);
char *zmk_ble_active_profile_name(void); char *zmk_ble_active_profile_name(void);

View file

@ -64,6 +64,7 @@ struct zmk_event_subscription {
#define ZMK_LISTENER(mod, cb) const struct zmk_listener zmk_listener_##mod = {.callback = cb}; #define ZMK_LISTENER(mod, cb) const struct zmk_listener zmk_listener_##mod = {.callback = cb};
#define ZMK_SUBSCRIPTION(mod, ev_type) \ #define ZMK_SUBSCRIPTION(mod, ev_type) \
extern const struct zmk_listener zmk_listener_##mod; \
const Z_DECL_ALIGN(struct zmk_event_subscription) \ const Z_DECL_ALIGN(struct zmk_event_subscription) \
_CONCAT(_CONCAT(zmk_event_sub_, mod), ev_type) __used \ _CONCAT(_CONCAT(zmk_event_sub_, mod), ev_type) __used \
__attribute__((__section__(".event_subscription"))) = { \ __attribute__((__section__(".event_subscription"))) = { \

View file

@ -1,11 +0,0 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <zephyr/device.h>
int zmk_kscan_init(const struct device *dev);

View file

@ -9,15 +9,25 @@
#include <zephyr/devicetree.h> #include <zephyr/devicetree.h>
#define ZMK_MATRIX_NODE_ID DT_CHOSEN(zmk_kscan) #define ZMK_MATRIX_NODE_ID DT_CHOSEN(zmk_kscan)
#define ZMK_MATRIX_HAS_TRANSFORM DT_HAS_CHOSEN(zmk_matrix_transform)
#if DT_HAS_CHOSEN(zmk_matrix_transform) #if DT_HAS_COMPAT_STATUS_OKAY(zmk_physical_layout)
#if ZMK_MATRIX_HAS_TRANSFORM
#error "To use physical layouts, remove the chosen `zmk,matrix-transform` value."
#endif
#define ZMK_PHYSICAL_LAYOUT_BYTE_ARRAY(node_id) \
uint8_t _CONCAT(prop_, node_id)[DT_PROP_LEN(DT_PHANDLE(node_id, transform), map)];
#define ZMK_KEYMAP_LEN \
sizeof(union {DT_FOREACH_STATUS_OKAY(zmk_physical_layout, ZMK_PHYSICAL_LAYOUT_BYTE_ARRAY)})
#elif ZMK_MATRIX_HAS_TRANSFORM
#define ZMK_KEYMAP_TRANSFORM_NODE DT_CHOSEN(zmk_matrix_transform) #define ZMK_KEYMAP_TRANSFORM_NODE DT_CHOSEN(zmk_matrix_transform)
#define ZMK_KEYMAP_LEN DT_PROP_LEN(ZMK_KEYMAP_TRANSFORM_NODE, map) #define ZMK_KEYMAP_LEN DT_PROP_LEN(ZMK_KEYMAP_TRANSFORM_NODE, map)
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, rows)
#define ZMK_MATRIX_COLS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, columns)
#else /* DT_HAS_CHOSEN(zmk_matrix_transform) */ #else /* DT_HAS_CHOSEN(zmk_matrix_transform) */
#if DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID, row_gpios) #if DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID, row_gpios)

View file

@ -6,4 +6,16 @@
#pragma once #pragma once
int32_t zmk_matrix_transform_row_column_to_position(uint32_t row, uint32_t column); #include <zephyr/sys/util.h>
typedef const struct zmk_matrix_transform *zmk_matrix_transform_t;
#define ZMK_MATRIX_TRANSFORM_DEFAULT_EXTERN() \
extern const struct zmk_matrix_transform zmk_matrix_transform_default
#define ZMK_MATRIX_TRANSFORM_EXTERN(node_id) \
extern const struct zmk_matrix_transform _CONCAT(zmk_matrix_transform_, node_id)
#define ZMK_MATRIX_TRANSFORM_T_FOR_NODE(node_id) &_CONCAT(zmk_matrix_transform_, node_id)
int32_t zmk_matrix_transform_row_column_to_position(zmk_matrix_transform_t mt, uint32_t row,
uint32_t column);

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2024 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <zephyr/kernel.h>
#include <zmk/matrix_transform.h>
struct zmk_key_physical_attrs {
int16_t width;
int16_t height;
int16_t x;
int16_t y;
int16_t rx;
int16_t ry;
int16_t r;
};
struct zmk_physical_layout {
const char *display_name;
zmk_matrix_transform_t matrix_transform;
const struct device *kscan;
const struct zmk_key_physical_attrs *keys;
size_t keys_len;
};
#define ZMK_PHYS_LAYOUTS_FOREACH(_ref) STRUCT_SECTION_FOREACH(zmk_physical_layout, _ref)
size_t zmk_physical_layouts_get_list(struct zmk_physical_layout const *const **phys_layouts);
int zmk_physical_layouts_select(uint8_t index);
int zmk_physical_layouts_get_selected(void);
int zmk_physical_layouts_check_unsaved_selection(void);
int zmk_physical_layouts_save_selected(void);
int zmk_physical_layouts_revert_selected(void);
int zmk_physical_layouts_get_position_map(uint8_t source, uint8_t dest, uint32_t *map);

View file

@ -12,6 +12,7 @@
#include <zephyr/drivers/kscan.h> #include <zephyr/drivers/kscan.h>
#include <zephyr/kernel.h> #include <zephyr/kernel.h>
#include <zephyr/logging/log.h> #include <zephyr/logging/log.h>
#include <zephyr/pm/device.h>
#include <zephyr/sys/__assert.h> #include <zephyr/sys/__assert.h>
#include <zephyr/sys/util.h> #include <zephyr/sys/util.h>
@ -167,6 +168,21 @@ static int kscan_charlieplex_set_all_outputs(const struct device *dev, const int
return 0; return 0;
} }
static int kscan_charlieplex_disconnect_all(const struct device *dev) {
const struct kscan_charlieplex_config *config = dev->config;
for (int i = 0; i < config->cells.len; i++) {
const struct gpio_dt_spec *gpio = &config->cells.gpios[i];
int err = gpio_pin_configure_dt(gpio, GPIO_DISCONNECTED);
if (err) {
LOG_ERR("Unable to configure pin %u on %s for input", gpio->pin, gpio->port->name);
return err;
}
}
return 0;
}
static int kscan_charlieplex_interrupt_configure(const struct device *dev, static int kscan_charlieplex_interrupt_configure(const struct device *dev,
const gpio_flags_t flags) { const gpio_flags_t flags) {
const struct kscan_charlieplex_config *config = dev->config; const struct kscan_charlieplex_config *config = dev->config;
@ -359,11 +375,7 @@ static int kscan_charlieplex_init_interrupt(const struct device *dev) {
return err; return err;
} }
static int kscan_charlieplex_init(const struct device *dev) { static void kscan_charlieplex_setup_pins(const struct device *dev) {
struct kscan_charlieplex_data *data = dev->data;
data->dev = dev;
kscan_charlieplex_init_inputs(dev); kscan_charlieplex_init_inputs(dev);
kscan_charlieplex_set_all_outputs(dev, 0); kscan_charlieplex_set_all_outputs(dev, 0);
@ -371,7 +383,46 @@ static int kscan_charlieplex_init(const struct device *dev) {
if (config->use_interrupt) { if (config->use_interrupt) {
kscan_charlieplex_init_interrupt(dev); kscan_charlieplex_init_interrupt(dev);
} }
}
#if IS_ENABLED(CONFIG_PM_DEVICE)
static int kscan_charlieplex_pm_action(const struct device *dev, enum pm_device_action action) {
switch (action) {
case PM_DEVICE_ACTION_SUSPEND:
kscan_charlieplex_interrupt_configure(dev, GPIO_INT_DISABLE);
kscan_charlieplex_disconnect_all(dev);
return kscan_charlieplex_disable(dev);
case PM_DEVICE_ACTION_RESUME:
kscan_charlieplex_setup_pins(dev);
return kscan_charlieplex_enable(dev);
default:
return -ENOTSUP;
}
}
#endif // IS_ENABLED(CONFIG_PM_DEVICE)
static int kscan_charlieplex_init(const struct device *dev) {
struct kscan_charlieplex_data *data = dev->data;
data->dev = dev;
k_work_init_delayable(&data->work, kscan_charlieplex_work_handler); k_work_init_delayable(&data->work, kscan_charlieplex_work_handler);
#if IS_ENABLED(CONFIG_PM_DEVICE)
pm_device_init_suspended(dev);
#if IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)
pm_device_runtime_enable(dev);
#endif
#else
kscan_charlieplex_setup_pins(dev);
#endif
return 0; return 0;
} }
@ -406,8 +457,10 @@ static const struct kscan_driver_api kscan_charlieplex_api = {
COND_THIS_INTERRUPT(n, (.use_interrupt = INST_INTR_DEFINED(n), )) \ COND_THIS_INTERRUPT(n, (.use_interrupt = INST_INTR_DEFINED(n), )) \
COND_THIS_INTERRUPT(n, (.interrupt = KSCAN_INTR_CFG_INIT(n), ))}; \ COND_THIS_INTERRUPT(n, (.interrupt = KSCAN_INTR_CFG_INIT(n), ))}; \
\ \
DEVICE_DT_INST_DEFINE(n, &kscan_charlieplex_init, NULL, &kscan_charlieplex_data_##n, \ PM_DEVICE_DT_INST_DEFINE(n, kscan_charlieplex_pm_action); \
&kscan_charlieplex_config_##n, POST_KERNEL, CONFIG_KSCAN_INIT_PRIORITY, \ \
&kscan_charlieplex_api); DEVICE_DT_INST_DEFINE(n, &kscan_charlieplex_init, PM_DEVICE_DT_INST_GET(n), \
&kscan_charlieplex_data_##n, &kscan_charlieplex_config_##n, POST_KERNEL, \
CONFIG_KSCAN_INIT_PRIORITY, &kscan_charlieplex_api);
DT_INST_FOREACH_STATUS_OKAY(KSCAN_CHARLIEPLEX_INIT); DT_INST_FOREACH_STATUS_OKAY(KSCAN_CHARLIEPLEX_INIT);

View file

@ -294,6 +294,24 @@ static int kscan_direct_init_input_inst(const struct device *dev, const struct g
return 0; return 0;
} }
#if IS_ENABLED(CONFIG_PM_DEVICE)
static int kscan_direct_disconnect_inputs(const struct device *dev) {
const struct kscan_direct_data *data = dev->data;
for (int i = 0; i < data->inputs.len; i++) {
const struct gpio_dt_spec *gpio = &data->inputs.gpios[i].spec;
int err = gpio_pin_configure_dt(gpio, GPIO_DISCONNECTED);
if (err) {
return err;
}
}
return 0;
}
#endif // IS_ENABLED(CONFIG_PM_DEVICE)
static int kscan_direct_init_inputs(const struct device *dev) { static int kscan_direct_init_inputs(const struct device *dev) {
const struct kscan_direct_data *data = dev->data; const struct kscan_direct_data *data = dev->data;
const struct kscan_direct_config *config = dev->config; const struct kscan_direct_config *config = dev->config;
@ -317,9 +335,20 @@ static int kscan_direct_init(const struct device *dev) {
// Sort inputs by port so we can read each port just once per scan. // Sort inputs by port so we can read each port just once per scan.
kscan_gpio_list_sort_by_port(&data->inputs); kscan_gpio_list_sort_by_port(&data->inputs);
k_work_init_delayable(&data->work, kscan_direct_work_handler);
#if IS_ENABLED(CONFIG_PM_DEVICE)
pm_device_init_suspended(dev);
#if IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)
pm_device_runtime_enable(dev);
#endif
#else
kscan_direct_init_inputs(dev); kscan_direct_init_inputs(dev);
k_work_init_delayable(&data->work, kscan_direct_work_handler); #endif
return 0; return 0;
} }
@ -329,8 +358,10 @@ static int kscan_direct_init(const struct device *dev) {
static int kscan_direct_pm_action(const struct device *dev, enum pm_device_action action) { static int kscan_direct_pm_action(const struct device *dev, enum pm_device_action action) {
switch (action) { switch (action) {
case PM_DEVICE_ACTION_SUSPEND: case PM_DEVICE_ACTION_SUSPEND:
kscan_direct_disconnect_inputs(dev);
return kscan_direct_disable(dev); return kscan_direct_disable(dev);
case PM_DEVICE_ACTION_RESUME: case PM_DEVICE_ACTION_RESUME:
kscan_direct_init_inputs(dev);
return kscan_direct_enable(dev); return kscan_direct_enable(dev);
default: default:
return -ENOTSUP; return -ENOTSUP;

View file

@ -405,6 +405,44 @@ static int kscan_matrix_init_outputs(const struct device *dev) {
return 0; return 0;
} }
#if IS_ENABLED(CONFIG_PM_DEVICE)
static int kscan_matrix_disconnect_inputs(const struct device *dev) {
const struct kscan_matrix_data *data = dev->data;
for (int i = 0; i < data->inputs.len; i++) {
const struct gpio_dt_spec *gpio = &data->inputs.gpios[i].spec;
int err = gpio_pin_configure_dt(gpio, GPIO_DISCONNECTED);
if (err) {
return err;
}
}
return 0;
}
static int kscan_matrix_disconnect_outputs(const struct device *dev) {
const struct kscan_matrix_config *config = dev->config;
for (int i = 0; i < config->outputs.len; i++) {
const struct gpio_dt_spec *gpio = &config->outputs.gpios[i].spec;
int err = gpio_pin_configure_dt(gpio, GPIO_DISCONNECTED);
if (err) {
return err;
}
}
return 0;
}
#endif // IS_ENABLED(CONFIG_PM_DEVICE)
static void kscan_matrix_setup_pins(const struct device *dev) {
kscan_matrix_init_inputs(dev);
kscan_matrix_init_outputs(dev);
kscan_matrix_set_all_outputs(dev, 0);
}
static int kscan_matrix_init(const struct device *dev) { static int kscan_matrix_init(const struct device *dev) {
struct kscan_matrix_data *data = dev->data; struct kscan_matrix_data *data = dev->data;
@ -413,12 +451,19 @@ static int kscan_matrix_init(const struct device *dev) {
// Sort inputs by port so we can read each port just once per scan. // Sort inputs by port so we can read each port just once per scan.
kscan_gpio_list_sort_by_port(&data->inputs); kscan_gpio_list_sort_by_port(&data->inputs);
kscan_matrix_init_inputs(dev);
kscan_matrix_init_outputs(dev);
kscan_matrix_set_all_outputs(dev, 0);
k_work_init_delayable(&data->work, kscan_matrix_work_handler); k_work_init_delayable(&data->work, kscan_matrix_work_handler);
#if IS_ENABLED(CONFIG_PM_DEVICE)
pm_device_init_suspended(dev);
#if IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)
pm_device_runtime_enable(dev);
#endif
#else
kscan_matrix_setup_pins(dev);
#endif
return 0; return 0;
} }
@ -427,8 +472,12 @@ static int kscan_matrix_init(const struct device *dev) {
static int kscan_matrix_pm_action(const struct device *dev, enum pm_device_action action) { static int kscan_matrix_pm_action(const struct device *dev, enum pm_device_action action) {
switch (action) { switch (action) {
case PM_DEVICE_ACTION_SUSPEND: case PM_DEVICE_ACTION_SUSPEND:
kscan_matrix_disconnect_inputs(dev);
kscan_matrix_disconnect_outputs(dev);
return kscan_matrix_disable(dev); return kscan_matrix_disable(dev);
case PM_DEVICE_ACTION_RESUME: case PM_DEVICE_ACTION_RESUME:
kscan_matrix_setup_pins(dev);
return kscan_matrix_enable(dev); return kscan_matrix_enable(dev);
default: default:
return -ENOTSUP; return -ENOTSUP;

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