Skip to content

Commit

Permalink
feat(boards): Add initial Ferris 0.2 board definition.
Browse files Browse the repository at this point in the history
* Onboard stm32f072, mcp23017 expander.
* Underglow not yet supported.
* Keymap is Miryoku inspired, but for less thumbs
  • Loading branch information
petejohanson committed Feb 4, 2021
1 parent f22fed5 commit ee6e2e1
Show file tree
Hide file tree
Showing 11 changed files with 372 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
include:
- board: bdn9_rev2
- board: dz60rgb_rev1
- board: ferris_rev02
- board: nrf52840_m2
shield: m60
- board: planck_rev6
Expand Down
7 changes: 7 additions & 0 deletions app/boards/arm/ferris/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0

if(CONFIG_PINMUX)
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
endif()
8 changes: 8 additions & 0 deletions app/boards/arm/ferris/Kconfig.board
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions app/boards/arm/ferris/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions app/boards/arm/ferris/README.md
Original file line number Diff line number Diff line change
@@ -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
```
7 changes: 7 additions & 0 deletions app/boards/arm/ferris/board.cmake
Original file line number Diff line number Diff line change
@@ -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)
137 changes: 137 additions & 0 deletions app/boards/arm/ferris/ferris_rev02.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

/dts-v1/;
#include <st/f0/stm32f072Xb.dtsi>

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

/ {
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 {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;

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>;
};
};
};
79 changes: 79 additions & 0 deletions app/boards/arm/ferris/ferris_rev02.keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

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

#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
&lt { 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
&lt NAV_L TAB &kp ENTER &lt NUM_L SPACE &lt 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
>;
};
};
};
12 changes: 12 additions & 0 deletions app/boards/arm/ferris/ferris_rev02.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
identifier: ferris_rev02
name: Ferris 0.2
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 40
supported:
- switches
- underglow
42 changes: 42 additions & 0 deletions app/boards/arm/ferris/ferris_rev02_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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

# 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
40 changes: 40 additions & 0 deletions app/boards/arm/ferris/pinmux.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2017 Clage GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <kernel.h>
#include <device.h>
#include <init.h>
#include <drivers/pinmux.h>
#include <sys/sys_io.h>
#include "pinmux/pinmux.h"

#include <pinmux/stm32/pinmux_stm32.h>

/* pin assignments for STM32F072B-DISCO board */
static const struct pin_config pinconf[] = {
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay) && CONFIG_SERIAL
{STM32_PIN_PB6, STM32F0_PINMUX_FUNC_PB6_USART1_TX},
{STM32_PIN_PB7, STM32F0_PINMUX_FUNC_PB7_USART1_RX},
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C
{STM32_PIN_PB8, STM32F0_PINMUX_FUNC_PB8_I2C1_SCL},
{STM32_PIN_PB9, STM32F0_PINMUX_FUNC_PB9_I2C1_SDA},
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c2), okay) && CONFIG_I2C
{STM32_PIN_PB10, STM32F0_PINMUX_FUNC_PB10_I2C2_SCL},
{STM32_PIN_PB11, STM32F0_PINMUX_FUNC_PB11_I2C2_SDA},
#endif
};

static int pinmux_stm32_init(const struct device *port) {
ARG_UNUSED(port);

stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));

return 0;
}

SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);

0 comments on commit ee6e2e1

Please sign in to comment.