Skip to content

Commit

Permalink
feat(boards): Add KBDfans Tofu65 2.0 board
Browse files Browse the repository at this point in the history
* Initial commit of Tofu65 2.0 board

---------

Co-authored-by: Pete Johanson <peter@peterjohanson.com>
  • Loading branch information
digver and petejohanson authored May 18, 2023
1 parent b1ca919 commit 89d71ed
Show file tree
Hide file tree
Showing 7 changed files with 288 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/boards/arm/kbdfans_tofu65/Kconfig.board
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions app/boards/arm/kbdfans_tofu65/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -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
125 changes: 125 additions & 0 deletions app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright (c) 2023 The ZMK Contributors
* SPDX-License-Identifier: MIT
*/

/dts-v1/;

#include <rpi_pico/rp2040.dtsi>
#include <dt-bindings/zmk/matrix_transform.h>

/ {

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";
};

97 changes: 97 additions & 0 deletions app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright (c) 2023 The ZMK Contributors
// SPDX-License-Identifier: MIT

#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>

#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 &lt 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
>;
};
};
};
15 changes: 15 additions & 0 deletions app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.zmk.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2_defconfig
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 89d71ed

Please sign in to comment.