From e42590a049f256953ba7edfa4d7cd7f8280731b9 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Mon, 13 Sep 2021 22:18:58 -0400 Subject: [PATCH] feat(board): Add Ferris 0.2 boards * Onboard stm32f072 with mcp23018 IO expander. * No underglow support yet. * Miryoku inspired default layout. --- app/boards/arm/ferris/Kconfig.board | 8 ++ app/boards/arm/ferris/Kconfig.defconfig | 23 +++ app/boards/arm/ferris/README.md | 16 +++ app/boards/arm/ferris/board.cmake | 7 + app/boards/arm/ferris/ferris_rev02.dts | 139 +++++++++++++++++++ app/boards/arm/ferris/ferris_rev02.keymap | 79 +++++++++++ app/boards/arm/ferris/ferris_rev02.yaml | 12 ++ app/boards/arm/ferris/ferris_rev02.zmk.yml | 10 ++ app/boards/arm/ferris/ferris_rev02_defconfig | 43 ++++++ 9 files changed, 337 insertions(+) create mode 100644 app/boards/arm/ferris/Kconfig.board create mode 100644 app/boards/arm/ferris/Kconfig.defconfig create mode 100644 app/boards/arm/ferris/README.md create mode 100644 app/boards/arm/ferris/board.cmake create mode 100644 app/boards/arm/ferris/ferris_rev02.dts create mode 100644 app/boards/arm/ferris/ferris_rev02.keymap create mode 100644 app/boards/arm/ferris/ferris_rev02.yaml create mode 100644 app/boards/arm/ferris/ferris_rev02.zmk.yml create mode 100644 app/boards/arm/ferris/ferris_rev02_defconfig diff --git a/app/boards/arm/ferris/Kconfig.board b/app/boards/arm/ferris/Kconfig.board new file mode 100644 index 00000000..ad96271a --- /dev/null +++ b/app/boards/arm/ferris/Kconfig.board @@ -0,0 +1,8 @@ +# Ferris board configuration + +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config BOARD_FERRIS + bool "Ferris rev 0.2" + depends on SOC_STM32F072XB diff --git a/app/boards/arm/ferris/Kconfig.defconfig b/app/boards/arm/ferris/Kconfig.defconfig new file mode 100644 index 00000000..23bc8a1e --- /dev/null +++ b/app/boards/arm/ferris/Kconfig.defconfig @@ -0,0 +1,23 @@ +# Ferris board configuration + +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if BOARD_FERRIS + +config BOARD + default "ferris_rev02" + +config ZMK_KEYBOARD_NAME + default "Ferris rev 0.2" + +config ZMK_USB + default y + +config ZMK_KSCAN_MATRIX_POLLING + default y + +config ZMK_KSCAN_COMPOSITE_DRIVER + default y + +endif # BOARD_FERRIS diff --git a/app/boards/arm/ferris/README.md b/app/boards/arm/ferris/README.md new file mode 100644 index 00000000..2793c6fa --- /dev/null +++ b/app/boards/arm/ferris/README.md @@ -0,0 +1,16 @@ +# Building ZMK for the Ferris 0.2 + + +## Standard Build + +``` +west build -p -d build/ferris --board ferris_rev02 +``` + +## Flashing + +`west` can be used to flash the board directly. Press the reset button once, and run: + +``` +west flash -d build/ferris +``` diff --git a/app/boards/arm/ferris/board.cmake b/app/boards/arm/ferris/board.cmake new file mode 100644 index 00000000..4f430e12 --- /dev/null +++ b/app/boards/arm/ferris/board.cmake @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT + +board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse") +board_runner_args(jlink "--device=STM32F072CB" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/dfu-util.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/app/boards/arm/ferris/ferris_rev02.dts b/app/boards/arm/ferris/ferris_rev02.dts new file mode 100644 index 00000000..848760fa --- /dev/null +++ b/app/boards/arm/ferris/ferris_rev02.dts @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; +#include +#include + +#include + +/ { + model = "Ferris rev0.2"; + compatible = "ferris,rev02", "st,stm32f072"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zmk,kscan = &kscan; + zmk,matrix_transform = &transform; + /* TODO: Enable once we support the IC for underglow + zmk,underglow = &led_strip; + */ + }; + + transform: transform { + compatible = "zmk,matrix-transform"; + rows = <4>; + columns = <10>; + + 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(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(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(3,3) RC(3,4) RC(3,5) RC(3,6) + >; + }; + + kscan: kscan { + compatible = "zmk,kscan-composite"; + label = "KSCAN"; + rows = <4>; + columns = <10>; + + left { + kscan = <&kscan_left>; + }; + + right { + kscan = <&kscan_right>; + column-offset = <5>; + }; + }; + + kscan_left: kscan_left { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN_LEFT"; + + diode-direction = "col2row"; + + col-gpios + = <&gpiob 8 (GPIO_ACTIVE_HIGH)> + , <&gpiob 4 (GPIO_ACTIVE_HIGH)> + , <&gpiob 3 (GPIO_ACTIVE_HIGH)> + , <&gpioa 15 (GPIO_ACTIVE_HIGH)> + , <&gpioa 14 (GPIO_ACTIVE_HIGH)> + ; + row-gpios + = <&gpiob 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpiob 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpiob 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpioa 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; + + kscan_right: kscan_right { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN_RIGHT"; + + diode-direction = "row2col"; + + col-gpios + = <&right_io 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&right_io 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&right_io 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&right_io 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&right_io 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + ; + row-gpios + = <&right_io 8 (GPIO_ACTIVE_LOW)> + , <&right_io 9 (GPIO_ACTIVE_LOW)> + , <&right_io 10 (GPIO_ACTIVE_LOW)> + , <&right_io 11 (GPIO_ACTIVE_LOW)> + ; + }; +}; + +&i2c2 { + pinctrl-0 = <&i2c2_scl_pb10 &i2c2_sda_pb11>; + status = "okay"; + clock-frequency = ; + + right_io: mcp23017@20 { + compatible = "microchip,mcp23017"; + status = "okay"; + gpio-controller; + reg = <0x20>; + label = "RIGHT_IO"; + #gpio-cells = <2>; + ngpios = <16>; + }; +}; + +&usb { + status = "okay"; +}; + +&rtc { + status = "okay"; +}; + +&flash0 { + /* + * For more information, see: + * http: //docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions + */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* Set 6Kb of storage at the end of the 128Kb of flash */ + storage_partition: partition@3e800 { + label = "storage"; + reg = <0x0001e800 0x00001800>; + }; + }; +}; diff --git a/app/boards/arm/ferris/ferris_rev02.keymap b/app/boards/arm/ferris/ferris_rev02.keymap new file mode 100644 index 00000000..18fad423 --- /dev/null +++ b/app/boards/arm/ferris/ferris_rev02.keymap @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +#define NAV_L 1 +#define OTHER_L 2 +#define NUM_L 3 +#define SYM_L 4 + +// Using layer taps on thumbs, having quick tap as well helps w/ repeating space/backspace +< { quick_tap_ms = <200>; }; + +/ { + behaviors { + hm: homerow_mods { + compatible = "zmk,behavior-hold-tap"; + label = "homerow mods"; + #binding-cells = <2>; + tapping_term_ms = <200>; + flavor = "tap-preferred"; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < + &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P + &hm LGUI A &hm LALT S &hm LCTRL D &hm LSHFT F &kp G &kp H &hm RSHFT J &hm RCTRL K &hm LALT L &hm LGUI QUOT + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH + < NAV_L TAB &kp ENTER < NUM_L SPACE < SYM_L BKSP + >; + }; + + nav_layer { + bindings = < + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + &trans &trans &trans &trans &trans &trans &kp LARW &kp DARW &kp UARW &kp RARW + &trans &trans &trans &trans &trans &trans &kp HOME &kp PG_DN &kp PG_UP &kp END + &trans &trans &kp ESC &kp DEL + >; + }; + + other_layer { + bindings = < + &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 HOME &trans &trans &trans + &trans &trans &trans &trans + >; + }; + + num_layer { + bindings = < + &kp LBKT &kp N7 &kp N8 &kp N9 &kp RBKT &trans &trans &trans &trans &trans + &kp SEMI &kp N4 &kp N5 &kp N6 &kp EQUAL &trans &trans &trans &trans &trans + &kp GRAVE &kp N1 &kp N2 &kp N3 &kp BSLH &trans &trans &trans &trans &trans + &kp N0 &kp MINUS &trans &trans + >; + }; + + sym_layer { + bindings = < + &kp LBRC &kp LS(N7) &kp LS(N8) &kp LS(N9) &kp RBRC &trans &trans &trans &trans &trans + &kp COLON &kp LS(N4) &kp LS(N5) &kp LS(N6) &kp PLUS &trans &trans &trans &trans &trans + &kp TILDE &kp LS(N1) &kp LS(N2) &kp LS(N3) &kp LS(BSLH) &trans &trans &trans &trans &trans + &kp LS(N0) &kp UNDER &trans &trans + >; + }; + }; +}; diff --git a/app/boards/arm/ferris/ferris_rev02.yaml b/app/boards/arm/ferris/ferris_rev02.yaml new file mode 100644 index 00000000..f4cbdcaf --- /dev/null +++ b/app/boards/arm/ferris/ferris_rev02.yaml @@ -0,0 +1,12 @@ +identifier: ferris_rev02 +name: Ferris 0.2 +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +ram: 40 +supported: + - switches + - underglow diff --git a/app/boards/arm/ferris/ferris_rev02.zmk.yml b/app/boards/arm/ferris/ferris_rev02.zmk.yml new file mode 100644 index 00000000..da3a7f53 --- /dev/null +++ b/app/boards/arm/ferris/ferris_rev02.zmk.yml @@ -0,0 +1,10 @@ +file_format: "1" +id: ferris_rev02 +name: Ferris 0.2 +type: board +arch: arm +features: + - keys +outputs: + - usb +url: https://github.com/pierrechevalier83/ferris/tree/main/0.2 diff --git a/app/boards/arm/ferris/ferris_rev02_defconfig b/app/boards/arm/ferris/ferris_rev02_defconfig new file mode 100644 index 00000000..99c0b329 --- /dev/null +++ b/app/boards/arm/ferris/ferris_rev02_defconfig @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: MIT + +CONFIG_BOARD_FERRIS=y +CONFIG_SOC_SERIES_STM32F0X=y +CONFIG_SOC_STM32F072XB=y +# 48MHz system clock +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000 + +# enable PINMUX +CONFIG_PINMUX=y + +# enable GPIO +CONFIG_GPIO=y + +# Enable i2c +CONFIG_I2C=y + +# ZMK Settings +CONFIG_ZMK_USB=y +CONFIG_ZMK_KSCAN_GPIO_DRIVER=y +CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER=y +CONFIG_ZMK_KSCAN_MATRIX_POLLING=y +CONFIG_USB_SELF_POWERED=n + +# Enable IO multiplexer +CONFIG_GPIO_MCP23017=y + +# Needed to reduce this to size that will fit on F072 +CONFIG_HEAP_MEM_POOL_SIZE=1024 + +# clock configuration +CONFIG_CLOCK_CONTROL=y + +# Clock configuration for Cube Clock control driver +CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y +# use HSI as PLL input +CONFIG_CLOCK_STM32_PLL_SRC_HSI=y +# produce 48MHz clock at PLL output +# CONFIG_CLOCK_STM32_PLL_PREDIV=1 +CONFIG_CLOCK_STM32_PLL_MULTIPLIER=6 +CONFIG_CLOCK_STM32_AHB_PRESCALER=1 +CONFIG_CLOCK_STM32_APB1_PRESCALER=1 +# CONFIG_CLOCK_STM32_APB2_PRESCALER=1