Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New board: Ferris 0.2 #642

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
139 changes: 139 additions & 0 deletions app/boards/arm/ferris/ferris_rev02.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

/dts-v1/;
#include <st/f0/stm32f072Xb.dtsi>
#include <st/f0/stm32f072v(8-b)tx-pinctrl.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 {
pinctrl-0 = <&i2c2_scl_pb10 &i2c2_sda_pb11>;
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
10 changes: 10 additions & 0 deletions app/boards/arm/ferris/ferris_rev02.zmk.yml
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions app/boards/arm/ferris/ferris_rev02_defconfig
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion app/drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT

add_subdirectory(gpio)
add_subdirectory(kscan)
add_subdirectory(sensor)
add_subdirectory(display)
add_subdirectory(display)
3 changes: 2 additions & 1 deletion app/drivers/Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT

rsource "gpio/Kconfig"
rsource "kscan/Kconfig"
rsource "sensor/Kconfig"
rsource "display/Kconfig"
rsource "display/Kconfig"
8 changes: 8 additions & 0 deletions app/drivers/gpio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT

zephyr_library_named(zmk__drivers__gpio)
zephyr_library_include_directories(${CMAKE_SOURCE_DIR}/include)

zephyr_library_sources_ifdef(CONFIG_GPIO_MCP23017 gpio_mcp23017.c)
zephyr_library_sources_ifndef(CONFIG_GPIO_MCP23017 ${ZEPHYR_BASE}/misc/empty_file.c)
1 change: 1 addition & 0 deletions app/drivers/gpio/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rsource "Kconfig.mcp23017"
21 changes: 21 additions & 0 deletions app/drivers/gpio/Kconfig.mcp23017
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MCP23017 GPIO configuration options

# Copyright (c) 2021 Pete Johanson
# SPDX-License-Identifier: Apache-2.0

menuconfig GPIO_MCP23017
bool "MCP23017 I2C-based GPIO chip"
depends on I2C
select HAS_DTS_GPIO
help
Enable driver for MCP23017 I2C-based GPIO chip.

if GPIO_MCP23017

config GPIO_MCP23017_INIT_PRIORITY
int "Init priority"
default 75
help
Device driver initialization priority.

endif #GPIO_MCP23017
Loading