Added nRF52840 Feather Express support, MF68 shield

This commit is contained in:
Exentio 2021-12-19 21:29:23 +01:00
parent 7b023affbd
commit 6714237027
No known key found for this signature in database
GPG key ID: 349B496CAF40884F
18 changed files with 545 additions and 0 deletions

View file

@ -0,0 +1,8 @@
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py
-c
-b 0x26000
-f 0xADA52840
-o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2
${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin
)

View file

@ -0,0 +1,10 @@
# Adafruit Feather nRF52840 Express board configuration
# Copyright (c) 2020 Tobias Svehagen
# SPDX-License-Identifier: Apache-2.0
config BOARD_ENABLE_DCDC
bool "Enable DCDC mode"
select SOC_DCDC_NRF52X
default y
depends on BOARD_ADAFRUIT_FEATHER_NRF52840

View file

@ -0,0 +1,8 @@
# Adafruit Feather nRF52840 Express board configuration
# Copyright (c) 2020 Tobias Svehagen
# SPDX-License-Identifier: Apache-2.0
config BOARD_ADAFRUIT_FEATHER_NRF52840
bool "Adafruit Feather nRF52840 Express"
depends on SOC_NRF52840_QIAA

View file

@ -0,0 +1,30 @@
# Adafruit Feather nRF52840 Express board configuration
# Copyright (c) 2021 Exentio
# SPDX-License-Identifier: MIT
if BOARD_ADAFRUIT_FEATHER_NRF52840
config BOARD
default "adafruit_feather_nrf52840"
if USB
config USB_NRFX
default y
config USB_DEVICE_STACK
default y
endif # USB
config BT_CTLR
default BT
config ZMK_BLE
default y
config ZMK_USB
default y
endif # BOARD_ADAFRUIT_FEATHER_NRF52840

View file

@ -0,0 +1,171 @@
/*
* Copyright (c) 2021 Exentio
*
* SPDX-License-Identifier: MIT
*/
/dts-v1/;
#include <nordic/nrf52840_qiaa.dtsi>
#include "feather_connector.dtsi"
/ {
model = "Adafruit Feather nRF52840 Express";
compatible = "adafruit,feather-nrf52840";
chosen {
zephyr,code-partition = &code_partition;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
};
leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio1 15 0>;
label = "D3 LED";
};
led1: led_1 {
gpios = <&gpio1 10 0>;
label = "CONN LED";
};
};
vbatt {
compatible = "zmk,battery-voltage-divider";
label = "BATTERY";
io-channels = <&adc 6>;
// copy-pasted values because idk how to calculate them
output-ohms = <2000000>;
full-ohms = <(2000000 + 806000)>;
};
buttons {
compatible = "gpio-keys";
button0: button_0 {
gpios = <&gpio1 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "User switch";
};
};
/* These aliases are provided for compatibility with samples */
aliases {
led0 = &led0;
led1 = &led1;
sw0 = &button0;
};
};
&adc {
status = "okay";
};
&gpiote {
status = "okay";
};
&gpio0 {
status = "okay";
};
&gpio1 {
status = "okay";
};
/* Free TX/RX pins from UART
&uart0 {
compatible = "nordic,nrf-uart";
current-speed = <115200>;
status = "okay";
tx-pin = <25>;
rx-pin = <24>;
};
*/
/* Free SCL/SDA pins from I2C
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <12>;
scl-pin = <11>;
};
*/
/* Free SCK, MO, and MI pins from SPI
&spi1 {
compatible = "nordic,nrf-spi";
status = "okay";
sck-pin = <14>;
mosi-pin = <13>;
miso-pin = <15>;
};
*/
/* You also probably don't need the QSPI flash
&qspi {
status = "okay";
sck-pin = <19>;
io-pins = <17>, <22>, <23>, <21>;
csn-pins = <20>;
gd25q16: gd25q16@0 {
// NOTE: Quad mode not supported as driver does not handle
// QE bit setting in SR2. Ref. GD25Q16C, Rev 3.0, p. 12.
compatible = "nordic,qspi-nor";
reg = <0>;
writeoc = "pp2o";
readoc = "read2io";
sck-frequency = <16000000>;
label = "GD25Q16";
jedec-id = [c8 40 15];
size = <16777216>;
has-dpd;
t-enter-dpd = <20000>;
t-exit-dpd = <20000>;
};
};
*/
&flash0 {
/*
* Basically the same as the Nice!Nano, the original .dts from Zephyr
* doesn't support UF2.
* For more information about the memory map, see:
* https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/hathach-memory-map
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
sd_partition: partition@0 {
label = "softdevice";
reg = <0x00000000 0x00026000>;
};
code_partition: partition@26000 {
label = "code_partition";
reg = <0x00026000 0x000c6000>;
};
/*
* The flash starting at 0x000ec000 and ending at
* 0x000f3fff is reserved for use by the application.
*/
/*
* Storage partition will be used by FCB/LittleFS/NVS
* if enabled.
*/
storage_partition: partition@ec000 {
label = "storage";
reg = <0x000ec000 0x00008000>;
};
boot_partition: partition@f4000 {
label = "adafruit_boot";
reg = <0x000f4000 0x0000c000>;
};
};
};
&usbd {
status = "okay";
};

View file

@ -0,0 +1,22 @@
identifier: adafruit_feather_nrf52840
name: Adafruit Feather nRF52840 Express
type: mcu
arch: arm
ram: 256
flash: 1024
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- adc
- pwm
- usb_device
- usb_cdc
- ble
- ieee802154
- watchdog
- counter
- feather_serial
- feather_i2c
- feather_spi

View file

@ -0,0 +1,10 @@
file_format: "1"
id: adafruit_feather_nrf52840
name: Adafruit Feather nRF52840 Express
type: board
arch: arm
outputs:
- usb
- ble
url: https://www.adafruit.com/product/4062
exposes: [feather]

View file

@ -0,0 +1,30 @@
# SPDX-License-Identifier: MIT
CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52840_QIAA=y
CONFIG_BOARD_ADAFRUIT_FEATHER_NRF52840=y
# Enable MPU
CONFIG_ARM_MPU=y
# enable GPIO
CONFIG_GPIO=y
CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_NVS=y
CONFIG_SETTINGS_NVS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
# enable uart driver
#CONFIG_SERIAL=y
# enable console
CONFIG_CONSOLE=y
#CONFIG_UART_CONSOLE=y
# additional board options
CONFIG_GPIO_AS_PINRESET=y

View file

@ -0,0 +1,5 @@
# SPDX-License-Identifier: MIT
board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset")
include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake)
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2020 Richard Osterloh <richard.osterloh@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
feather_header: connector {
compatible = "adafruit-feather-header";
#gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map = <0 0 &gpio0 4 0>, /* A0 */
<1 0 &gpio0 5 0>, /* A1 */
<2 0 &gpio0 30 0>, /* A2 */
<3 0 &gpio0 28 0>, /* A3 */
<4 0 &gpio0 2 0>, /* A4 */
<5 0 &gpio0 3 0>, /* A5 */
<6 0 &gpio0 14 0>, /* SCK */
<7 0 &gpio0 13 0>, /* MOSI */
<8 0 &gpio0 15 0>, /* MISO */
<9 0 &gpio0 24 0>, /* RXD */
<10 0 &gpio0 25 0>, /* TXD */
<11 0 &gpio0 10 0>, /* D2 (NFC2) */
<12 0 &gpio0 12 0>, /* SDA */
<13 0 &gpio0 11 0>, /* SCL */
<14 0 &gpio1 8 0>, /* D5 */
<15 0 &gpio0 7 0>, /* D6 */
<16 0 &gpio0 26 0>, /* D9 */
<17 0 &gpio0 27 0>, /* D10 */
<18 0 &gpio0 6 0>, /* D11 */
<19 0 &gpio0 8 0>, /* D12 */
<20 0 &gpio1 9 0>; /* D13 */
};
};
/* Enable UART, I2C, and/or SPI
feather_serial: &uart0 {};
feather_i2c: &i2c0 {};
feather_spi: &spi1 {};
*/

View file

@ -0,0 +1,9 @@
# Copyright (c) 2021 Exentio
# SPDX-License-Identifier: MIT
if SHIELD_MF68
config ZMK_KEYBOARD_NAME
default "MF68"
endif

View file

@ -0,0 +1,5 @@
# Copyright (c) 2021 Exentio
# SPDX-License-Identifier: MIT
config SHIELD_MF68
def_bool $(shields_list_contains,mf68)

View file

@ -0,0 +1,46 @@
# [MF68](https://www.40percent.club/2016/11/mf68-revised-pcb.html)
Replacement MagicForce 68 PCB designed by [di0ib](https://github.com/di0ib).
Hardware repo: https://github.com/di0ib/tmk_keyboard/tree/master/keyboard/mf68
This shield is made to be easily used with an Adafruit Feather nRF52840 Express, and the default pin order is optimized for that board. For use with a Pro Micro-compatible controller, comment lines 21-41 and uncomment lines 44-64 in `mf68.overlay`.
## Features
- Designed for Pro Micro boards
- PWM backlight control (with optional FDS6630A, not configured)
- Mini USB port for DIY case
## Default layout
![](mf68.png)
## Use with an Adafruit Feather nRF52840 Express
### Pinout
| Pro Micro Left | Feather Left | Feather Right | Pro Micro Right |
|----------------|--------------|---------------|-----------------|
| D3 | A2 | | RAW |
| D2 | A3 | GND* | GND |
| GND | | RST* | RESET |
| GND | | | VCC |
| D1 | A4 | D5 | F4 |
| D0 | A5 | D6 | F5 |
| D4 | SCK | D9 | F6 |
| C6 | MO | D10 | F7 |
| D7 | MI | D11 | B1 |
| E6 | RX | D12 | B3 |
| B4 | TX | D13 | B2 |
| B5 | | A0 | B6 |
### But why not a Pro Micro-compatible microcontroller?
Availability and sometimes cost. Sometimes it's hard to find them or the developers straight up stop producing them, sad but common in the mechanical keyboards community. On the other hand, the Feather nRF52840 Express is more widely available and I doubt it's gonna be discontinued anytime soon.
I was unable to use the D2 pin, and using the SDA pin caused issues.
In the board definitions, UART is disabled since the RX and TX pins are used for the matrix, same for SPI and SCK/MO/MI pins.
SCL and SDA pins are available for I2C but disabled by default, uncomment lines 84-91 in `app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840.dts` to enable.
The QSPI flash is disabled too, if needed uncomment lines 103-125 in the same file.
The space inside the MagicForce68 case is very, very limited, and physical modifications to the case, like the removal of inner support, are necessary; I also had to desolder the JST connector and remove the black holder from the SWD connector from the Feather, basically making it flat. For the same reason, forget about putting a battery inside: best case scenario it just doesn't fit, worst case scenario it gets punctured by the solder joints (which is as bad as it sounds). I'm gonna try with a 18650 battery on the outside.
If adding backlight to your board with this controller, remember that Adafruit says that it's not safe to pull 500mA from the regulator when connected to 5V (read: USB).

View file

@ -0,0 +1,2 @@
# Turn on logging, and set ZMK logging to debug output
#CONFIG_ZMK_USB_LOGGING=y

View file

@ -0,0 +1,53 @@
/*
* Copyright (c) 2021 Exentio
*
* SPDX-License-Identifier: MIT
*/
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/outputs.h>
#include <dt-bindings/zmk/ext_power.h>
/ {
keymap0: keymap {
compatible = "zmk,keymap";
// ,--------------------------------------------------------------------------------------------------------.
// |GRESC| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BKSP | |INSERT| PGUP |
// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | |DELETE| PGDN |
// | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | |
// | SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | | UP | |
// | CTRL | WIN | ALT | SPACE | ALT | FN | CTRL | | LEFT | DOWN |RIGHT |
// `--------------------------------------------------------------------------------------------------------'
default_layer {
bindings = <
&gresc &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 INS &kp PG_UP
&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 DEL &kp PG_DN
&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 RET
&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 LCTRL &kp LGUI &kp LALT &kp SPACE &kp RALT &mo 1 &kp RCTRL &kp LEFT &kp DOWN &kp RIGHT
>;
};
// ,--------------------------------------------------------------------------------------------------------.
// |GRAVE| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |BOOTLOADER| | PLAY | HOME |
// | TAB | USB | BLE | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | RESET | | PRTSC| END |
// | CAPS | BT1 | BT2 | BT3 | BT4 | --- | --- | --- | --- | --- | --- | --- | ENTER | |
// | SHIFT |EXTPW|BTCLR| --- | --- | --- | --- | --- | --- | --- | --- | SHIFT | | UP | |
// | CTRL | WIN | ALT | SPACE | ALT | FN | CTRL | | LEFT | DOWN |RIGHT |
// `--------------------------------------------------------------------------------------------------------'
fn_layer {
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 &bootloader &kp K_PP &kp HOME
&trans &out OUT_USB &out OUT_BLE &none &none &none &none &none &none &none &none &none &none &reset &kp PSCRN &kp END
&trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &none &none &none &none &none &none &none &trans
&trans &ext_power EP_TOG &bt BT_CLR &none &none &none &none &none &none &none &none &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
>;
};
};
};

View file

@ -0,0 +1,88 @@
/*
* Copyright (c) 2021 Exentio
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix_transform.h>
/ {
chosen {
zmk,kscan = &kscan0;
zmk,matrix_transform = &default_transform;
};
kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
// Adafruit Feather nRF52840 Express
row-gpios
= <&gpio0 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> /* A0 */
, <&gpio1 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> /* D13 */
, <&gpio0 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> /* D12 */
, <&gpio0 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> /* D11 */
, <&gpio0 27 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> /* D10 */
, <&gpio0 26 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> /* D9 */
, <&gpio0 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> /* D6 */
, <&gpio1 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> /* D5 */
;
col-gpios
= <&gpio0 30 GPIO_ACTIVE_HIGH> /* A2 */
, <&gpio0 28 GPIO_ACTIVE_HIGH> /* A3 */
, <&gpio0 2 GPIO_ACTIVE_HIGH> /* A4 */
, <&gpio0 3 GPIO_ACTIVE_HIGH> /* A5 */
, <&gpio0 14 GPIO_ACTIVE_HIGH> /* SCK */
, <&gpio0 13 GPIO_ACTIVE_HIGH> /* MOSI */
, <&gpio0 15 GPIO_ACTIVE_HIGH> /* MISO */
, <&gpio0 24 GPIO_ACTIVE_HIGH> /* RXD */
, <&gpio0 25 GPIO_ACTIVE_HIGH> /* TXD */
;
/* Pro Micro
row-gpios
= <&pro_micro 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 15 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 18 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 19 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 21 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
col-gpios
= <&pro_micro 1 GPIO_ACTIVE_HIGH>
, <&pro_micro 0 GPIO_ACTIVE_HIGH>
, <&pro_micro 2 GPIO_ACTIVE_HIGH>
, <&pro_micro 3 GPIO_ACTIVE_HIGH>
, <&pro_micro 4 GPIO_ACTIVE_HIGH>
, <&pro_micro 5 GPIO_ACTIVE_HIGH>
, <&pro_micro 6 GPIO_ACTIVE_HIGH>
, <&pro_micro 7 GPIO_ACTIVE_HIGH>
, <&pro_micro 8 GPIO_ACTIVE_HIGH>
;
*/
};
default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <9>;
rows = <8>;
// | MX1 | MX2 | MX3 | MX4 | MX5 | MX6 | MX7 | MX8 | MX9 | MX10 | MX11 | MX12 | MX13 | MX14 | MX15 | MX16 |
// | MX17 | MX18 | MX19 | MX20 | MX21 | MX22 | MX23 | MX24 | MX25 | MX26 | MX27 | MX28 | MX29 | MX30 | MX31 | MX32 |
// | MX33 | MX34 | MX35 | MX36 | MX37 | MX38 | MX39 | MX40 | MX41 | MX42 | MX43 | MX44 | MX45 |
// | MX46 | MX47 | MX48 | MX49 | MX50 | MX51 | MX52 | MX53 | MX54 | MX55 | MX56 | MX57 | MX58 |
// | MX59 | MX60 | MX61 | MX62 | MX63 | MX64 | MX65 | MX66 | MX67 | MX68 |
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(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(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(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(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(4,8)
RC(5,0) RC(5,1) RC(5,2) RC(5,3) RC(5,4) RC(5,5) RC(5,6) RC(5,7) RC(5,8) RC(6,0) RC(6,1) RC(6,2) RC(6,3)
RC(6,4) RC(6,5) RC(6,6) RC(6,7) RC(6,8) RC(7,0) RC(7,1) RC(7,2) RC(7,3) RC(7,4)
>;
};
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View file

@ -0,0 +1,7 @@
file_format: "1"
id: mf68
name: MF68
type: shield
url: https://github.com/di0ib/tmk_keyboard/tree/master/keyboard/mf68
features:
- keys