From 89d71ed2c2c1af78c166a96dc65658e4f39743ab Mon Sep 17 00:00:00 2001 From: digger vermont Date: Thu, 18 May 2023 19:47:36 -0400 Subject: [PATCH] feat(boards): Add KBDfans Tofu65 2.0 board * Initial commit of Tofu65 2.0 board --------- Co-authored-by: Pete Johanson --- app/boards/arm/kbdfans_tofu65/Kconfig.board | 6 + .../arm/kbdfans_tofu65/Kconfig.defconfig | 15 +++ .../arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts | 125 ++++++++++++++++++ .../kbdfans_tofu65/kbdfans_tofu65_v2.keymap | 97 ++++++++++++++ .../arm/kbdfans_tofu65/kbdfans_tofu65_v2.yaml | 15 +++ .../kbdfans_tofu65/kbdfans_tofu65_v2.zmk.yml | 10 ++ .../kbdfans_tofu65_v2_defconfig | 20 +++ 7 files changed, 288 insertions(+) create mode 100644 app/boards/arm/kbdfans_tofu65/Kconfig.board create mode 100644 app/boards/arm/kbdfans_tofu65/Kconfig.defconfig create mode 100644 app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts create mode 100644 app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.keymap create mode 100644 app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.yaml create mode 100644 app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.zmk.yml create mode 100644 app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2_defconfig diff --git a/app/boards/arm/kbdfans_tofu65/Kconfig.board b/app/boards/arm/kbdfans_tofu65/Kconfig.board new file mode 100644 index 00000000000..954166b715f --- /dev/null +++ b/app/boards/arm/kbdfans_tofu65/Kconfig.board @@ -0,0 +1,6 @@ +# Copyright (c) 2023 The ZMK Contributors +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_KBDFANS_TOFU65_V2 + bool "KBDfans Tofu65 2.0" + depends on SOC_RP2040 diff --git a/app/boards/arm/kbdfans_tofu65/Kconfig.defconfig b/app/boards/arm/kbdfans_tofu65/Kconfig.defconfig new file mode 100644 index 00000000000..993d51423b5 --- /dev/null +++ b/app/boards/arm/kbdfans_tofu65/Kconfig.defconfig @@ -0,0 +1,15 @@ +# Copyright (c) 2023 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if BOARD_KBDFANS_TOFU65_V2 + +config ZMK_KEYBOARD_NAME + default "kbdfans tofu65" + +config RP2_FLASH_W25Q080 + default y + +config ZMK_USB + default y + +endif # BOARD_KBDFANS_TOFU65_V2 diff --git a/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts new file mode 100644 index 00000000000..261ffbf4850 --- /dev/null +++ b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2023 The ZMK Contributors + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; + +#include +#include + +/ { + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,console = &cdc_acm_uart; + zephyr,shell-uart = &cdc_acm_uart; + zephyr,code-partition = &code_partition; + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + xtal_clk: xtal-clk { + compatible = "fixed-clock"; + clock-frequency = <12000000>; + #clock-cells = <0>; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <15>; + rows = <5>; + +// ------- Switch Matrix ---------- +// +// Column 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | +// ========================================================================================== +// Row 0 || S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | S8 | S9 | S10 | S11 | S12 | S13 | S14 | +// Row 1 || S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | S8 | S9 | S10 | S11 | S12 | S13 | S14 | +// Row 2 || S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | S8 | S9 | S10 | S11 | S12 | | S13 | +// Row 3 || S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | S8 | S9 | S10 | S11 | | S12 | S13 | +// Row 4 || S0 | S1 | S2 | | | | S3 | | S4 | S5 | S6 | | S7 | S8 | S9 | +// ----------------------------------------------------------------------------------- +// + 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(0,14) +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(1,14) +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,14) +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(3,14) +RC(4,0) RC(4,1) RC(4,2) RC(4,6) RC(4,8) RC(4,9) RC(4,10) RC(4,12) RC(4,13) RC(4,14) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&gpio0 29 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 28 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 27 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 26 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 22 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + col-gpios + = <&gpio0 25 GPIO_ACTIVE_HIGH> + , <&gpio0 24 GPIO_ACTIVE_HIGH> + , <&gpio0 23 GPIO_ACTIVE_HIGH> + , <&gpio0 1 GPIO_ACTIVE_HIGH> + , <&gpio0 7 GPIO_ACTIVE_HIGH> + , <&gpio0 21 GPIO_ACTIVE_HIGH> + , <&gpio0 20 GPIO_ACTIVE_HIGH> + , <&gpio0 19 GPIO_ACTIVE_HIGH> + , <&gpio0 18 GPIO_ACTIVE_HIGH> + , <&gpio0 17 GPIO_ACTIVE_HIGH> + , <&gpio0 16 GPIO_ACTIVE_HIGH> + , <&gpio0 15 GPIO_ACTIVE_HIGH> + , <&gpio0 14 GPIO_ACTIVE_HIGH> + , <&gpio0 13 GPIO_ACTIVE_HIGH> + , <&gpio0 12 GPIO_ACTIVE_HIGH> + ; + }; +}; + +&flash0 { + reg = <0x10000000 DT_SIZE_M(16)>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* Reserved memory for the second stage bootloader */ + second_stage_bootloader: partition@0 { + label = "second_stage_bootloader"; + reg = <0x00000000 0x100>; + read-only; + }; + + /* + * Usable flash. Starts at 0x100, after the bootloader. The partition + * size is 16MB minus the 0x100 bytes taken by the bootloader. + */ + code_partition: partition@100 { + label = "code"; + reg = <0x100 (DT_SIZE_M(16) - 0x100)>; + read-only; + }; + }; +}; + + +&usbd { + status = "okay"; + cdc_acm_uart: cdc_acm_uart { + compatible = "zephyr,cdc-acm-uart"; + }; +}; + + +&gpio0 { + status = "okay"; +}; + diff --git a/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.keymap b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.keymap new file mode 100644 index 00000000000..7eca7919a4a --- /dev/null +++ b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.keymap @@ -0,0 +1,97 @@ +// Copyright (c) 2023 The ZMK Contributors +// SPDX-License-Identifier: MIT + +#include +#include + +#define BASE 0 +#define FUNC 1 + +// +// ---------- Tofu65 2.0 key switch positions ---------- +// +// ------------------------------------------------------------------------------------------------- +// | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | +// ------------------------------------------------------------------------------------------------- +// | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 24 | 26 | 27 | 28 | 29 | +// ------------------------------------------------------------------------------------------------- +// | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | +// ------------------------------------------------------------------------------------------------- +// | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | +// ------------------------------------------------------------------------------------------------- +// | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | +// ------------------------------------------------------------------------------------------------- +// + + +/ { + combos { + compatible = "zmk,combos"; + + // BACKSPACE + LCTRL + LALT = &sys_reset + combo_bootloader { + timeout-ms = <100>; + key-positions = <13 58 60>; + bindings = <&sys_reset>; + }; + + // RETURN + LCTRL + LALT = &bootloader + combo_sys_reset { + timeout-ms = <100>; + key-positions = <42 58 60>; + bindings = <&bootloader>; + }; + }; + + + keymap { + compatible = "zmk,keymap"; + + base { + +// --------- Default QWERTY Layout --------- +// Layer 0 BASE +// ------------------------------------------------------------------------------------------------- +// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BSPC | HME | +// ------------------------------------------------------------------------------------------------- +// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | PGU | +// ------------------------------------------------------------------------------------------------- +// | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | PGD | +// ------------------------------------------------------------------------------------------------- +// | LSHIFT | Z | X | C | V | B | N | M | , | . | / | RSHFT | ↑ | END | +// ------------------------------------------------------------------------------------------------- +// | LCTL | LGUI | LALT | SPACE | RALT | RGUI | RCTL | <- | ↓ | -> | +// ------------------------------------------------------------------------------------------------- + bindings = < +&kp ESC &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp EQUAL &kp BSPC &kp HOME +&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 PG_UP +&kp CLCK &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT &kp ENTER &kp PG_DN +&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RSHFT &kp UP &kp END +&kp LCTRL &kp LGUI &kp LALT &kp SPACE &kp RALT < FUNC K_APP &kp RCTRL &kp LEFT &kp DOWN &kp RIGHT + >; + }; + + func { +// --------- Default QWERTY Layout --------- +// Layer 1 FUNC +// --------------------------------------------------------------------------------------------------- +// | ESC | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DEL | HME | +// --------------------------------------------------------------------------------------------------- +// | --- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | scroll lock | pause | --- | PGU | +// --------------------------------------------------------------------------------------------------- +// | CAPS | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | --- | PGD | +// --------------------------------------------------------------------------------------------------- +// | LSHIFT | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | ----- | VOL UP | MUTE | +// --------------------------------------------------------------------------------------------------- +// | ---- | ---- | ---- | ---- | -- | MO 1 | -- | PREV | VOL DN | NEXT | +// --------------------------------------------------------------------------------------------------- + bindings = < +&kp GRAVE &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 DEL &trans +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp SLCK &kp PAUSE_BREAK &trans &trans +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp C_VOL_UP &kp C_MUTE +&trans &trans &trans &trans &trans &trans &trans &kp C_PREV &kp C_VOL_DN &kp C_NEXT + >; + }; + }; +}; diff --git a/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.yaml b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.yaml new file mode 100644 index 00000000000..e1089766da2 --- /dev/null +++ b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.yaml @@ -0,0 +1,15 @@ +identifier: kbdfans_tofu65_v2 +name: KBDfans Tofu65 2.0 +type: mcu +arch: arm +flash: 16384 +ram: 264 +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - gpio + - usb_device + - hwinfo + - pwm diff --git a/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.zmk.yml b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.zmk.yml new file mode 100644 index 00000000000..382e7dd3603 --- /dev/null +++ b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.zmk.yml @@ -0,0 +1,10 @@ +file_format: "1" +id: kbdfans_tofu65_v2 +name: KBDfans Tofu65 2.0 +type: board +arch: arm +features: + - keys +outputs: + - usb +url: https://kbdfans.com/collections/tofu65-2-0/products/tofu65-2-0 diff --git a/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2_defconfig b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2_defconfig new file mode 100644 index 00000000000..cf546683452 --- /dev/null +++ b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2_defconfig @@ -0,0 +1,20 @@ +# Copyright (c) 2023 The ZMK Contributors +# SPDX-License-Identifier: MIT + +CONFIG_SOC_SERIES_RP2XXX=y +CONFIG_SOC_RP2040=y +CONFIG_BOARD_KBDFANS_TOFU65_V2=y + +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=125000000 + +# Enable USB CDC ACM logging for debugging +# CONFIG_ZMK_USB_LOGGING=y + +# Enable reset by default +CONFIG_RESET=y + +# Code partition needed to target the correct flash range +CONFIG_USE_DT_CODE_PARTITION=y + +# Output UF2 by default, native bootloader supports it. +CONFIG_BUILD_OUTPUT_UF2=y