diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0aee5d7f..288a2dee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,6 +57,7 @@ jobs: - tidbit cmake-args: [""] include: + - board: bdn9_rev2 - board: dz60rgb_rev1 - board: nrf52840_m2 shield: m60 diff --git a/app/boards/arm/bdn9/Kconfig.board b/app/boards/arm/bdn9/Kconfig.board new file mode 100644 index 00000000..a67e9a51 --- /dev/null +++ b/app/boards/arm/bdn9/Kconfig.board @@ -0,0 +1,8 @@ +# keeb.io BDN9 board configuration + +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config BOARD_BDN9 + bool "BDN9 rev2" + depends on SOC_STM32F072XB diff --git a/app/boards/arm/bdn9/Kconfig.defconfig b/app/boards/arm/bdn9/Kconfig.defconfig new file mode 100644 index 00000000..9af7ca4c --- /dev/null +++ b/app/boards/arm/bdn9/Kconfig.defconfig @@ -0,0 +1,17 @@ +# keeb.io BDN9 board configuration + +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +if BOARD_BDN9 + +config BOARD + default "bdn9_rev2" + +config ZMK_KEYBOARD_NAME + default "BDN9 Rev2" + +config ZMK_USB + default y + +endif # BOARD_BDN9 diff --git a/app/boards/arm/bdn9/README.md b/app/boards/arm/bdn9/README.md new file mode 100644 index 00000000..7b4ef441 --- /dev/null +++ b/app/boards/arm/bdn9/README.md @@ -0,0 +1,37 @@ +# Building ZMK for the BDN9 + +Some general notes/commands for building standard BDN9 layouts from the assembly documentation. + +## Standard Build + +``` +west build -p -d build/bdn9 --board bdn9_rev2 +``` + +## Encoder Notes + +If you built your BDN9 with encoders, you'll need to change the following in your local BDN9 config or add them to the end of the file. + +``` +CONFIG_EC11=y +CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y +``` + +Then, you'll want to uncomment the necessary encoder lines in your `bdn9_rev2.keymap`: + +``` +&sensors { + status = "okay"; + sensors = <&left_encoder &mid_encoder &right_encoder>; +}; + +&left_encoder { status = "okay"; }; +&mid_encoder { status = "okay"; }; +&right_encoder { status = "okay"; }; +``` + +And then add the correct `sensor-bindings` array to each keymap layer, e.g.: + +``` +sensor-bindings = <&inc_dec_kp PG_UP PG_DN &inc_dec_kp M_VOLU M_VOLD &inc_dec_kp C_PREV C_NEXT>; +``` diff --git a/app/boards/arm/bdn9/bdn9_rev2.dts b/app/boards/arm/bdn9/bdn9_rev2.dts new file mode 100644 index 00000000..43854a16 --- /dev/null +++ b/app/boards/arm/bdn9/bdn9_rev2.dts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; +#include + +/ { + model = "Keeb.io BDN9 rev2"; + compatible = "keebio,bdn9", "st,stm32f072"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zmk,kscan = &kscan; + /* TODO: Enable once the GPIO bitbanging driver supports STM32 + zmk,underglow = &led_strip; + */ + }; + + kscan: kscan { + compatible = "zmk,kscan-gpio-direct"; + label = "KSCAN"; + + input-gpios + = <&gpiob 12 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpioa 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiof 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiof 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + ; + }; + + /* + led_strip: ws2812 { + compatible = "worldsemi,ws2812-gpio"; + label = "WS2812"; + + in-gpios = <&gpiob 15 0>; + + chain-length = <9>; + }; + */ + + left_encoder: encoder_left { + compatible = "alps,ec11"; + label = "LEFT_ENCODER"; + a-gpios = <&gpioa 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&gpioa 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + mid_encoder: encoder_mid { + compatible = "alps,ec11"; + label = "MID_ENCODER"; + a-gpios = <&gpioa 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&gpioa 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + right_encoder: encoder_right { + compatible = "alps,ec11"; + label = "RIGHT_ENCODER"; + a-gpios = <&gpioa 15 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&gpiob 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + + sensors: sensors { + compatible = "zmk,keymap-sensors"; + status = "disabled"; + sensors = <>; + }; +}; + +&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/bdn9/bdn9_rev2.keymap b/app/boards/arm/bdn9/bdn9_rev2.keymap new file mode 100644 index 00000000..50c273c7 --- /dev/null +++ b/app/boards/arm/bdn9/bdn9_rev2.keymap @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include + +/* Uncomment and keep whatever encoders are on your BDN9 +&sensors { + status = "okay"; + sensors = <&left_encoder &mid_encoder &right_encoder>; +}; +*/ + +// Uncomment each encoder installed on your BDN9 +// &left_encoder { status = "okay"; }; +// &mid_encoder { status = "okay"; }; +// &right_encoder { status = "okay"; }; + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < + &kp HOME &kp K_PP &kp END + &kp PG_UP &kp UP &kp PG_DN + &kp LEFT &kp DOWN &kp RIGHT + >; + /* Uncomment and add necessary bindings. This examples is for one encoder + sensor-bindings = <&inc_dec_kp PG_UP PG_DN>; + */ + }; + }; +}; + diff --git a/app/boards/arm/bdn9/bdn9_rev2.yaml b/app/boards/arm/bdn9/bdn9_rev2.yaml new file mode 100644 index 00000000..bbae8833 --- /dev/null +++ b/app/boards/arm/bdn9/bdn9_rev2.yaml @@ -0,0 +1,14 @@ +identifier: bdn9 +name: keeb.io BDN9 +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +ram: 40 +supported: + - encoders + - switches + - underglow + - per_key diff --git a/app/boards/arm/bdn9/bdn9_rev2_defconfig b/app/boards/arm/bdn9/bdn9_rev2_defconfig new file mode 100644 index 00000000..139cf853 --- /dev/null +++ b/app/boards/arm/bdn9/bdn9_rev2_defconfig @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: MIT + +CONFIG_SOC_SERIES_STM32F0X=y +CONFIG_SOC_STM32F072XB=y +# 72MHz system clock +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000 + +# Floating Point Options +CONFIG_FPU=y + +# enable GPIO +CONFIG_GPIO=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 72MHz clock at PLL output +CONFIG_CLOCK_STM32_PLL_PREDIV=1 +CONFIG_CLOCK_STM32_PLL_MULTIPLIER=12 +CONFIG_CLOCK_STM32_AHB_PRESCALER=1 +CONFIG_CLOCK_STM32_APB1_PRESCALER=2 +CONFIG_CLOCK_STM32_APB2_PRESCALER=1 diff --git a/app/boards/arm/bdn9/board.cmake b/app/boards/arm/bdn9/board.cmake new file mode 100644 index 00000000..4f430e12 --- /dev/null +++ b/app/boards/arm/bdn9/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/docs/docs/hardware.md b/docs/docs/hardware.md index 406b9ad8..89761c42 100644 --- a/docs/docs/hardware.md +++ b/docs/docs/hardware.md @@ -19,6 +19,7 @@ That being said, there are currently only a few specific [boards](/docs/faq#what - [nrfMicro](https://github.com/joric/nrfmicro) (`nrfmicro_13`, `nrfmicro_11`, `nrfmicro_11_flipped`) - [BlueMicro840](https://store.jpconstantineau.com/#/group/bluemicro) (`bluemicro840_v1`) - [QMK Proton-C](https://qmk.fm/proton-c/) (`proton_c`) +- [BDN9 Rev2](https://keeb.io/products/bdn9-rev-2-3x3-9-key-macropad-rotary-encoder-and-rgb) (`bdn9_rev2`) ## Keyboard Shields