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

Refactor m60 #639

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions app/boards/arm/nrf52840_m2/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ config ZMK_BLE
config ZMK_USB
default y

config ZMK_BATTERY_VOLTAGE_DIVIDER
default y

endif # BOARD_NRF52840_M2
86 changes: 80 additions & 6 deletions app/boards/arm/nrf52840_m2/nrf52840_m2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,49 @@
zephyr,flash = &flash0;
};

vbatt {
compatible = "zmk,battery-voltage-divider";
label = "BATTERY";
io-channels = <&adc 0>;
output-ohms = <1000000>;
full-ohms = <(1000000 + 1000000)>;
};

leds {
compatible = "gpio-leds";
red_led: led_0 {
gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>;
pwr_led: led_0 {
gpios = <&gpio1 04 GPIO_ACTIVE_HIGH>;
label = "Power LED";
};
red_led: led_1 {
gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
label = "Red LED";
};
green_led: led_1 {
gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
green_led: led_2 {
gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
label = "Green LED";
};
blue_led: led_2 {
gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>;
blue_led: led_3 {
gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
label = "Blue LED";
};
};

pwmleds {
compatible = "pwm-leds";
red_led_pwm: pwm_led_0 {
pwms = <&pwm0 30>;
label = "Red PWM LED";
};
green_led_pwm: pwm_led_1 {
pwms = <&pwm0 29>;
label = "Green PWM LED";
};
blue_led_pwm: pwm_led_2 {
pwms = <&pwm0 31>;
label = "Blue PWM LED";
};
};
};

&adc {
Expand All @@ -51,11 +78,58 @@
status = "okay";
};

&i2c1 {
compatible = "nordic,nrf-twi";
/* status = "okay"; */
sda-pin = <26>;
scl-pin = <27>;
};

&pwm0 {
status = "okay";
ch0-pin = <30>;
ch0-inverted;
ch1-pin = <29>;
ch1-inverted;
ch2-pin = <31>;
ch2-inverted;
ch3-pin = <20>;
};

&spi2 {
compatible = "nordic,nrf-spi";
/* Cannot be used together with i2c1. */
status = "okay";
sck-pin = <27>;
mosi-pin = <26>;
miso-pin = <28>;
};

&usbd {
compatible = "nordic,nrf-usbd";
status = "okay";
};

&qspi {
status = "okay";
sck-pin = <43>;
io-pins = <42>, <46>, <47>, <44>;
csn-pins = <45>;
mx25r64: mx25r6435f@0 {
compatible = "nordic,qspi-nor";
reg = <0>;
writeoc = "pp4io";
readoc = "read4io";
sck-frequency = <8000000>;
label = "MX25R64";
jedec-id = [c2 28 17];
size = <67108864>;
has-be32k;
has-dpd;
t-enter-dpd = <10000>;
t-exit-dpd = <35000>;
};
};

&flash0 {
/*
Expand Down
5 changes: 5 additions & 0 deletions app/boards/arm/nrf52840_m2/nrf52840_m2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ supported:
- ieee802154
- pwm
- watchdog
- counter
- i2c
- spi
- usb_cdc
- usb_device
5 changes: 2 additions & 3 deletions app/boards/shields/m60/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# [Makerdiary M60](https://wiki.makerdiary.com/m60)
# Makerdiary M60

A 60% ANSI keyboard designed and manufactured by Makerdiary.
http://makerdiary.com
A 60% ANSI keyboard designed and manufactured by Makerdiary

## Features

Expand Down
1 change: 1 addition & 0 deletions app/boards/shields/m60/m60.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER=y
33 changes: 23 additions & 10 deletions app/boards/shields/m60/m60.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
#include <dt-bindings/zmk/bt.h>

/ {
behaviors {
bootreset: hold_tap {
compatible = "zmk,behavior-hold-tap";
label = "BOOT_RESET";
#binding-cells = <2>;
tapping_term_ms = <1000>;
flavor = "tap-preferred";
bindings = <&bootloader>, <&reset>;
};
};

keymap0: keymap {
compatible = "zmk,keymap";

Expand All @@ -21,21 +32,23 @@
// | CTL | WIN | ALT | SPACE | ALT | MO(1) | WIN | CTRL |
// ------------------------------------------------------------------------------------------
bindings = <
&kp ESC &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 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 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 LCTRL &kp LGUI &kp LALT &kp SPACE &kp RALT &mo 1 &kp RGUI &kp RCTRL
&kp ESC &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 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 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 LCTRL &kp LGUI &kp LALT &kp SPACE &kp RALT &mo 1 &kp RGUI &kp RCTRL
&bootreset 0 0
>;
};

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
&trans &bt BT_CLR &none &none &none &none &none &none &none &none &none &none &none &reset
&trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LEFT &kp DOWN &kp UP &kp RIGHT &none &none &trans
&trans &none &none &none &none &none &none &none &none &none &none &trans
&trans &trans &trans &trans &trans &trans &trans &trans
&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
&trans &bt BT_CLR &none &none &none &none &none &none &none &none &none &none &none &reset
&trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LEFT &kp DOWN &kp UP &kp RIGHT &none &none &trans
&trans &none &none &none &none &none &none &none &none &none &none &trans
&trans &trans &trans &trans &trans &trans &trans &trans
&bootreset 0 0
>;
};
};
Expand Down
34 changes: 30 additions & 4 deletions app/boards/shields/m60/m60.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,34 @@
zmk,matrix_transform = &default_transform;
};

kscan0: kscan {
kscan0: kscan0 {
compatible = "zmk,kscan-composite";
label = "KSCAN_COMP";
rows = <9>;
columns = <8>;

direct: direct {
kscan = <&kscan_direct>;
row-offset = <8>;
};

matrix: matrix {
kscan = <&kscan_matrix>;
};
};

kscan_direct: kscan1 {
compatible = "zmk,kscan-gpio-direct";
label = "KSCAN_DIRECT";

input-gpios
= <&gpio0 27 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>
;
};

kscan_matrix: kscan2 {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
label = "KSCAN_MATRIX";

diode-direction = "col2row";
row-gpios
Expand Down Expand Up @@ -42,7 +67,7 @@
default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <8>;
rows = <8>;
rows = <9>;
// | 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 |
Expand All @@ -54,7 +79,8 @@ RC(3,3) RC(3,2) RC(3,1) RC(3,0) RC(2,7) RC(2,6) RC(2,5) RC(2,4) RC(2,3) RC(2,
RC(3,4) RC(3,5) RC(3,6) RC(3,7) 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(5,0)
RC(6,4) RC(6,3) RC(6,2) RC(6,1) RC(6,0) RC(5,7) RC(5,6) RC(5,5) RC(5,4) RC(5,3) RC(5,2) RC(5,1)
RC(6,5) RC(6,6) RC(6,7) RC(7,0) RC(7,1) RC(7,2) RC(7,3) RC(7,4)
>;
RC(8,0)
>;
};
};