diff options
27 files changed, 519 insertions, 15 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11b9f39..7b2aa0c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,9 @@ jobs: build: runs-on: ubuntu-latest name: Build Test + strategy: + matrix: + board: [proton_c, nice_nano] steps: # To use this repository's private action, # you must check out the repository @@ -27,27 +30,33 @@ jobs: ${{ runner.os }}-build- ${{ runner.os }}- - name: West Init - uses: 'docker://zmkfirmware/zephyr-west-action-arm:latest' + 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' + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" id: west-update with: - args: 'update' + args: "update" - name: West Config Zephyr Base - uses: 'docker://zmkfirmware/zephyr-west-action-arm:latest' + 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' + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" id: west-zephyr-export with: - args: 'zephyr-export' + args: "zephyr-export" - name: West Build - uses: 'docker://zmkfirmware/zephyr-west-action-arm:latest' + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" id: west-build with: - args: 'build "-s app -b proton_c -- -DSHIELD=petejohanson_proton_handwire"' + args: 'build "-s app -b ${{ matrix.board }} -- -DSHIELD=petejohanson_proton_handwire"' + - name: Archive Build + uses: actions/upload-artifact@v2 + if: ${{ matrix.board == 'nice_nano' }} + with: + name: "${{ matrix.board }}-zmk-uf2" + path: build/zephyr/zmk.uf2 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..096a82c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "*.overlay": "dts" + } +} diff --git a/app/boards/arm/nice_nano/CMakeLists.txt b/app/boards/arm/nice_nano/CMakeLists.txt new file mode 100644 index 0000000..00952c3 --- /dev/null +++ b/app/boards/arm/nice_nano/CMakeLists.txt @@ -0,0 +1,8 @@ +set_property(GLOBAL APPEND PROPERTY extra_post_build_commands + COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py + -c + -b 0x26000 + -f 0xADA52840 + -o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2 + ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin +) diff --git a/app/boards/arm/nice_nano/Kconfig.board b/app/boards/arm/nice_nano/Kconfig.board new file mode 100644 index 0000000..60ee58b --- /dev/null +++ b/app/boards/arm/nice_nano/Kconfig.board @@ -0,0 +1,8 @@ +# nice!nano board configuration + +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +config BOARD_NICE_NANO + bool "nice!nano" + depends on SOC_NRF52840_QIAA diff --git a/app/boards/arm/nice_nano/Kconfig.defconfig b/app/boards/arm/nice_nano/Kconfig.defconfig new file mode 100644 index 0000000..2c122ae --- /dev/null +++ b/app/boards/arm/nice_nano/Kconfig.defconfig @@ -0,0 +1,27 @@ +# Electronut Labs Papyr board configuration + +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +if BOARD_NICE_NANO + +config BOARD + default "nice_nano" + +if USB + +config USB_NRFX + default y + +config USB_DEVICE_STACK + default y + +endif # USB + +config BT_CTLR + default BT + +config ZMK_BLE + default y + +endif # BOARD_NICE_NANO diff --git a/app/boards/arm/nice_nano/arduino_pro_micro_pins.dtsi b/app/boards/arm/nice_nano/arduino_pro_micro_pins.dtsi new file mode 100644 index 0000000..f11dcdd --- /dev/null +++ b/app/boards/arm/nice_nano/arduino_pro_micro_pins.dtsi @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +/ { + pro_micro_pins: connector { + compatible = "arduino-pro-micro"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = + <1 0 &gpio0 6 0>, /* D1 */ + <0 0 &gpio0 8 0>, /* D0 */ + <2 0 &gpio0 17 0>, /* D2 */ + <3 0 &gpio0 20 0>, /* D3 */ + <4 0 &gpio0 22 0>, /* D4/A6 */ + <5 0 &gpio0 24 0>, /* D5 */ + <6 0 &gpio1 0 0>, /* D6/A7 */ + <7 0 &gpio0 11 0>, /* D7 */ + <8 0 &gpio1 4 0>, /* D8/A8 */ + <9 0 &gpio1 6 0>, /* D9/A9 */ + <10 0 &gpio0 9 0>, /* D10/A10 */ + <16 0 &gpio0 10 0>, /* D16 */ + <14 0 &gpio1 11 0>, /* D14 */ + <15 0 &gpio1 13 0>, /* D15 */ + <18 0 &gpio1 15 0>, /* A0 */ + <19 0 &gpio0 2 0>, /* A1 */ + <20 0 &gpio0 29 0>, /* A2 */ + <21 0 &gpio0 31 0>; /* A3 */ + }; +}; + +pro_micro_i2c: &i2c1 {}; +pro_micro_spi: &spi1 {}; +pro_micro_serial: &uart1 {}; diff --git a/app/boards/arm/nice_nano/board.cmake b/app/boards/arm/nice_nano/board.cmake new file mode 100644 index 0000000..12a1d93 --- /dev/null +++ b/app/boards/arm/nice_nano/board.cmake @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset") +include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake) +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts new file mode 100644 index 0000000..21b60d3 --- /dev/null +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; +#include <nordic/nrf52840_qiaa.dtsi> +#include "arduino_pro_micro_pins.dtsi" + +/ { + model = "nice!nano"; + compatible = "nice,nano"; + + chosen { + zephyr,code-partition = &code_partition; + //zephyr,bt-mon-uart = &uart0; + //zephyr,bt-c2h-uart = &uart0; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds { + compatible = "gpio-leds"; + blue_led: led_0 { + gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; + label = "Blue LED"; + }; + }; + +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&uart0 { + compatible = "nordic,nrf-uart"; + current-speed = <115200>; + tx-pin = <6>; + rx-pin = <8>; +}; + +&i2c0 { + compatible = "nordic,nrf-twi"; + sda-pin = <17>; + scl-pin = <20>; +}; + +/* TODO: Needs testing */ +&spi0 { + compatible = "nordic,nrf-spi"; + /* Cannot be used together with i2c0. */ + /* status = "okay"; */ + sck-pin = <45>; + mosi-pin = <10>; + miso-pin = <43>; +}; + +&flash0 { + /* + * For more information, see: + * http://docs.zephyrproject.org/latest/devices/dts/flash_partitions.html + */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "adafruit_boot"; + reg = <0x000000000 0x0000C000>; + }; + code_partition: partition@26000 { + label = "code_partition"; + reg = <0x00026000 0x0002e000>; + }; + + /* + * The flash starting at 0x000f8000 and ending at + * 0x000fffff is reserved for use by the application. + */ + + /* + * Storage partition will be used by FCB/LittleFS/NVS + * if enabled. + */ + storage_partition: partition@f8000 { + label = "storage"; + reg = <0x000f8000 0x00008000>; + }; + }; +}; diff --git a/app/boards/arm/nice_nano/nice_nano.yaml b/app/boards/arm/nice_nano/nice_nano.yaml new file mode 100644 index 0000000..1c36732 --- /dev/null +++ b/app/boards/arm/nice_nano/nice_nano.yaml @@ -0,0 +1,15 @@ +identifier: nice_nano +name: nice!nano +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - usb_device + - ble + - ieee802154 + - pwm + - watchdog diff --git a/app/boards/arm/nice_nano/nice_nano_defconfig b/app/boards/arm/nice_nano/nice_nano_defconfig new file mode 100644 index 0000000..f9be0ee --- /dev/null +++ b/app/boards/arm/nice_nano/nice_nano_defconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: MIT + +CONFIG_SOC_SERIES_NRF52X=y +CONFIG_SOC_NRF52840_QIAA=y +CONFIG_BOARD_NICE_NANO=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# enable GPIO +CONFIG_GPIO=y + +CONFIG_USE_DT_CODE_PARTITION=y diff --git a/app/boards/arm/proton_c/Kconfig.defconfig b/app/boards/arm/proton_c/Kconfig.defconfig index b9c907b..78ccbab 100644 --- a/app/boards/arm/proton_c/Kconfig.defconfig +++ b/app/boards/arm/proton_c/Kconfig.defconfig @@ -8,4 +8,7 @@ if BOARD_QMK_PROTON_C config BOARD default "proton_c" +config ZMK_USB + default y + endif # BOARD_QMK_PROTON_C diff --git a/app/boards/arm/proton_c/arduino_pro_micro_pins.dtsi b/app/boards/arm/proton_c/arduino_pro_micro_pins.dtsi index f794dec..d1b050a 100644 --- a/app/boards/arm/proton_c/arduino_pro_micro_pins.dtsi +++ b/app/boards/arm/proton_c/arduino_pro_micro_pins.dtsi @@ -11,6 +11,7 @@ gpio-map-mask = <0xffffffff 0xffffffc0>; gpio-map-pass-thru = <0 0x3f>; gpio-map = + /* Down the front left side */ <1 0 &gpioa 9 0>, /* D1 */ <0 0 &gpioa 10 0>, /* D0 */ <2 0 &gpiob 7 0>, /* D2 */ @@ -21,6 +22,8 @@ <7 0 &gpiob 2 0>, /* D7 */ <8 0 &gpiob 1 0>, /* D8/A8 */ <9 0 &gpiob 0 0>, /* D9/A9 */ + + /* Back up the front right side */ <10 0 &gpiob 9 0>, /* D10/A10 */ <16 0 &gpiob 15 0>, /* D16 */ <14 0 &gpiob 14 0>, /* D14 */ diff --git a/app/boards/shields/kyria/Kconfig.defconfig b/app/boards/shields/kyria/Kconfig.defconfig new file mode 100644 index 0000000..0bd3562 --- /dev/null +++ b/app/boards/shields/kyria/Kconfig.defconfig @@ -0,0 +1,7 @@ + +if SHIELD_KYRIA + +config ZMK_KEYBOARD_NAME + default "Kyria" + +endif diff --git a/app/boards/shields/kyria/Kconfig.shield b/app/boards/shields/kyria/Kconfig.shield new file mode 100644 index 0000000..598fc81 --- /dev/null +++ b/app/boards/shields/kyria/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +config SHIELD_KYRIA + def_bool $(shields_list_contains,kyria) diff --git a/app/boards/shields/kyria/keymaps/default/include/keymap.h b/app/boards/shields/kyria/keymaps/default/include/keymap.h new file mode 100644 index 0000000..01cd9e5 --- /dev/null +++ b/app/boards/shields/kyria/keymaps/default/include/keymap.h @@ -0,0 +1,5 @@ + +#include <dt-bindings/zmk/keys.h> + +#define CC_RAIS ZC_CSTM(1) +#define CC_LOWR ZC_CSTM(2)
\ No newline at end of file diff --git a/app/boards/shields/kyria/keymaps/default/keymap.c b/app/boards/shields/kyria/keymaps/default/keymap.c new file mode 100644 index 0000000..067cd08 --- /dev/null +++ b/app/boards/shields/kyria/keymaps/default/keymap.c @@ -0,0 +1,34 @@ + +#include <zmk/keys.h> +#include <zmk/keymap.h> +#include <keymap.h> + +bool zmk_handle_key_user(struct zmk_key_event *key_event) +{ + switch (key_event->key) + { + case CC_LOWR: + if (key_event->pressed) + { + zmk_keymap_layer_activate(1); + } + else + { + zmk_keymap_layer_deactivate(1); + } + + return false; + case CC_RAIS: + if (key_event->pressed) + { + zmk_keymap_layer_activate(2); + } + else + { + zmk_keymap_layer_deactivate(2); + } + return false; + } + + return true; +}; diff --git a/app/boards/shields/kyria/keymaps/default/keymap.overlay b/app/boards/shields/kyria/keymaps/default/keymap.overlay new file mode 100644 index 0000000..303c675 --- /dev/null +++ b/app/boards/shields/kyria/keymaps/default/keymap.overlay @@ -0,0 +1,63 @@ +#include <dt-bindings/zmk/keys.h> +#include <dt-bindings/zmk/matrix-transform.h> +#include <keymap.h> + +/ { + chosen { + zmk,keymap = &keymap0; + }; + + keymap0: keymap { + compatible = "zmk,keymap"; + label ="Default Kyria Keymap"; + layers = <&default>; + transform = <&default_transform>; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; +// | MX6 | MX5 | MX4 | MX3 | MX2 | MX1 | | MX1 | MX2 | MX3 | MX4 | MX5 | MX6 | +// | MX12 | MX11 | MX10 | MX9 | MX8 | MX7 | | MX7 | MX8 | MX9 | MX10 | MX11 | MX12 | +// | MX20 | MX19 | MX18 | MX17 | MX16 | MX15 | MX14 | MX13 | | MX13 | MX14 | MX15 | MX16 | MX17 | MX18 | MX19 | MX20 | +// | MX25 | MX24 | MX23 | MX22 | MX21 | | MX21 | MX22 | MX23 | MX24 | MX25 | + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,10) RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,15) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,10) RC(1,11) RC(1,12) RC(1,13) RC(1,14) RC(1,15) +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,12) RC(2,13) RC(2,14) RC(2,15) + 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,12) + >; + }; + +// | MX5 | MX4 | MX3 | MX2 | MX1 | | MX1 | MX2 | MX3 | MX4 | MX5 | +// | MX11 | MX10 | MX9 | MX8 | MX7 | | MX7 | MX8 | MX9 | MX10 | MX11 | +// | MX19 | MX18 | MX17 | MX16 | MX15 | MX14 | MX13 | | MX13 | MX14 | MX15 | MX16 | MX17 | MX18 | MX19 | +// | MX25 | MX24 | MX23 | MX22 | MX21 | | MX21 | MX22 | MX23 | MX24 | MX25 | + five_column_transform: keymap_transform_1 { + compatible = "zmk,matrix-transform"; + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) 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,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,12) RC(2,13) + 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) + >; + }; + + layers { + compatible = "zmk,layers"; + + default: layer_0 { + label = "DEFAULT"; +// --------------------------------------------------------------------------------------------------------------------------------- +// | ESC | Q | W | E | R | T | | Y | U | I | O | P | "|" | +// | <- | A | S | D | F | G | | H | J | K | L | ; | ' | +// | SHIFT | Z | X | C | V | B | L SHIFT | L SHIFT | | L SHIFT | L SHIFT | N | M | , | . | / | - | +// | GUI | DEL | RET | SPACE | ESC | | RET | SPACE | TAB | BSPC | R-ALT | + keys = < + KC_ESC KC_Q KC_W KC_E KC_R KC_T KC_Y KC_U KC_I KC_O KC_P KC_PIPE + KC_BKSP KC_A KC_S KC_D KC_F KC_G KC_H KC_J KC_K KC_L KC_SCLN KC_QUOT + KC_LSFT KC_Z KC_X KC_C KC_V KC_B KC_LSFT KC_LSFT KC_LSFT KC_LSFT KC_N KC_M KC_CMMA KC_DOT KC_BSLH KC_MIN + KC_LGUI KC_DEL KC_RET KC_SPC KC_ESC KC_RET KC_SPC KC_TAB KC_BKSP KC_RALT + >; + }; + }; +}; diff --git a/app/boards/shields/kyria/kyria.conf b/app/boards/shields/kyria/kyria.conf new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/boards/shields/kyria/kyria.conf diff --git a/app/boards/shields/kyria/kyria.overlay b/app/boards/shields/kyria/kyria.overlay new file mode 100644 index 0000000..af4e591 --- /dev/null +++ b/app/boards/shields/kyria/kyria.overlay @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +/ { + chosen { + zmk,kscan = &kscan0; + }; + + kscan0: kscan_comp { + compatible = "zmk,kscan-composite"; + + label = "KSCAN_COMP"; + rows = <4>; + columns = <16>; + + left { + kscan = <&kscan_left>; + }; + + right { + kscan = <&kscan_right>; + // TODO: Actually put this in the kscan driver, so it can report + // HID events directly to host if plugged in directly. + column-offset = <8>; + }; + }; + + kscan_left: kscan_left { + compatible = "gpio-kscan"; + label = "KSCAN_LEFT"; + + diode-direction = "row2col"; + row-gpios = <&pro_micro_pins 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + + col-gpios = <&pro_micro_pins 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 18 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 19 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 20 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 21 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + kscan_right: kscan_right { + compatible = "gpio-kscan"; + label = "KSCAN_RIGHT"; + + diode-direction = "row2col"; + row-gpios = <&pro_micro_pins 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + + col-gpios = <&pro_micro_pins 21 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 20 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 19 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 18 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&pro_micro_pins 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + // TODO: Encoder node(s) + // TODO: OLED node + // TODO: RGB node(s) +}; + diff --git a/app/dts/bindings/zmk,keymap.yaml b/app/dts/bindings/zmk,keymap.yaml index 8c56f93..b9517a3 100644 --- a/app/dts/bindings/zmk,keymap.yaml +++ b/app/dts/bindings/zmk,keymap.yaml @@ -4,6 +4,10 @@ description: | compatible: "zmk,keymap" properties: + transform: + type: phandle + required: false + label: type: string required: true diff --git a/app/dts/bindings/zmk,matrix-transform.yaml b/app/dts/bindings/zmk,matrix-transform.yaml new file mode 100644 index 0000000..453da9d --- /dev/null +++ b/app/dts/bindings/zmk,matrix-transform.yaml @@ -0,0 +1,9 @@ +description: | + Defines a mapping from keymap logical positions to matrix physical positions + +compatible: "zmk,matrix-transform" + +properties: + map: + type: array + required: true diff --git a/app/include/dt-bindings/zmk/matrix-transform.h b/app/include/dt-bindings/zmk/matrix-transform.h new file mode 100644 index 0000000..4fd3e6c --- /dev/null +++ b/app/include/dt-bindings/zmk/matrix-transform.h @@ -0,0 +1,5 @@ + +#define KT_ROW(item) (item >> 8) +#define KT_COL(item) (item & 0xFF) + +#define RC(row, col) (((row) << 8) + (col))
\ No newline at end of file diff --git a/app/prj.conf b/app/prj.conf index c4d6d35..f5b2d4a 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -1,2 +1,3 @@ # CONFIG_LOG=y # CONFIG_ZMK_LOG_LEVEL_DBG=y +CONFIG_KERNEL_BIN_NAME="zmk" diff --git a/app/src/keymap.c b/app/src/keymap.c index 569a2cc..1cb705e 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -2,10 +2,57 @@ #include <logging/log.h> LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include <zmk/keymap.h> +#include <dt-bindings/zmk/matrix-transform.h> +#include <sys/util.h> static u32_t zmk_keymap_layer_state = 0; static u8_t zmk_keymap_layer_default = 0; +#if DT_NODE_HAS_PROP(ZMK_KEYMAP_NODE, transform) +#define ZMK_KEYMAP_TRANSFORM_NODE DT_PHANDLE(ZMK_KEYMAP_NODE, transform) +#define ZMK_KEYMAP_LEN DT_PROP_LEN(ZMK_KEYMAP_TRANSFORM_NODE, map) + +#define _TRANSFORM_ENTRY(i, l) \ + [(KT_ROW(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i)) * ZMK_MATRIX_COLS) + KT_COL(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i))] = DT_PROP_BY_IDX(DT_PHANDLE_BY_IDX(ZMK_KEYMAP_NODE, layers, l), keys, i), + +#define TRANSFORMED_LAYER(idx) \ + { UTIL_LISTIFY(ZMK_KEYMAP_LEN, _TRANSFORM_ENTRY, idx) } + +static zmk_key zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_MATRIX_ROWS * ZMK_MATRIX_COLS] = { +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 0) + TRANSFORMED_LAYER(0), +#endif +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 1) + TRANSFORMED_LAYER(1), +#endif +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 2) + TRANSFORMED_LAYER(2), +#endif +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 3) + TRANSFORMED_LAYER(3), +#endif +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 4) + TRANSFORMED_LAYER(4), +#endif +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 5) + TRANSFORMED_LAYER(5), +#endif +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 6) + TRANSFORMED_LAYER(6), +#endif +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 7) + TRANSFORMED_LAYER(7), +#endif +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 8) + TRANSFORMED_LAYER(8), +#endif +#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 9) + TRANSFORMED_LAYER(9), +#endif +}; + +#else + static zmk_key zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_MATRIX_ROWS * ZMK_MATRIX_COLS] = { #if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 0) DT_PROP_BY_PHANDLE_IDX(ZMK_KEYMAP_NODE, layers, 0, keys), @@ -33,6 +80,8 @@ static zmk_key zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_MATRIX_ROWS * ZMK_MATRIX_CO #endif }; +#endif + #define SET_LAYER_STATE(layer, state) \ if (layer >= 32) \ { \ diff --git a/app/west.yml b/app/west.yml index c0a557d..3784d97 100644 --- a/app/west.yml +++ b/app/west.yml @@ -4,10 +4,12 @@ manifest: url-base: https://github.com/zephyrproject-rtos - name: petejohanson url-base: https://github.com/petejohanson + - name: microsoft + url-base: https://github.com/microsoft projects: - name: zephyr remote: petejohanson - revision: kconfig/external-sheilds-shields-as-list-fix + revision: zmk-v2.3.0-with-fixes import: # TODO: Rename once upstream offers option like `exclude` or `denylist` name-blacklist: @@ -19,5 +21,8 @@ manifest: - hal_microchip - hal_nxp - hal_openisa + - name: uf2 + remote: microsoft + path: tools/uf2 self: path: zmk diff --git a/docs/docs/dev-posix-board.md b/docs/docs/dev-posix-board.md index e804ca8..dc33ea0 100644 --- a/docs/docs/dev-posix-board.md +++ b/docs/docs/dev-posix-board.md @@ -8,6 +8,19 @@ be helpful to build and run the firmware on your local workstation, with generated virtual press/release events flowing into the handler functions. +## Prerequisites + +In order to build targetting the `native_posix` board, you need to setup your system +with a compiler that can target 32-bit POSIX. + +On Debian, you can do this with: + +``` +apt install -y gcc-multilib +``` + +## Building + To do this, you can build ZMK targetting the `native_posix` board. diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index 6f26182..5741766 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -36,9 +36,9 @@ With the latest package information, you can now install the base dependencies: ```bash sudo apt install -y \ - git \ - wget \ - autoconf \ + git \ + wget \ + autoconf \ automake \ build-essential \ ccache \ @@ -46,11 +46,10 @@ sudo apt install -y \ dfu-util \ g++ \ gcc \ - gcc-multilib \ libtool \ make \ - ninja-build \ - cmake \ + ninja-build \ + cmake \ python3-dev \ python3-pip \ python3-setuptools \ |