From 0a6c2453785816a60149b5fe125d6cb9b8146921 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Mon, 17 Nov 2025 22:00:04 +0100 Subject: [PATCH 1/7] nrf52840_m2 update --- app/boards/arm/nrf52840_m2/Kconfig.defconfig | 10 ++++ .../arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi | 56 +++++++++++++++++++ app/boards/arm/nrf52840_m2/nrf52840_m2.dts | 46 +++++++++++++-- .../arm/nrf52840_m2/nrf52840_m2_defconfig | 4 +- 4 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 app/boards/arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi diff --git a/app/boards/arm/nrf52840_m2/Kconfig.defconfig b/app/boards/arm/nrf52840_m2/Kconfig.defconfig index a5227fc0a..cc466ff5f 100644 --- a/app/boards/arm/nrf52840_m2/Kconfig.defconfig +++ b/app/boards/arm/nrf52840_m2/Kconfig.defconfig @@ -16,4 +16,14 @@ endif # USB_DEVICE_STACK config BT_CTLR default BT +if ZMK_BACKLIGHT + +config PWM + default y + +config LED_PWM + default y + +endif # ZMK_BACKLIGHT + endif # BOARD_NRF52840_M2 diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi b/app/boards/arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi new file mode 100644 index 000000000..00342f1e6 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi @@ -0,0 +1,56 @@ +&pinctrl { + /* configuration for spi0 device, default state */ + spi0_default: spi0_default { + /* node name is arbitrary */ + group1 { + /* main role: configure P1.11 as SPI clock, P0.02 as SPI MOSI, P0.03 as SPI MISO */ + psels = , + , + ; + }; + }; + + /* configuration for spi0 device, sleep state */ + spi0_sleep: spi0_sleep { + group1 { + /* main role: configure P1.11 as SPI clock, P0.02 as SPI MOSI, P0.03 as SPI MISO */ + psels = , + , + ; + low-power-enable; + }; + }; + + /* configuration for pwm device, default state */ + pwm0_default: pwm0_default { + group1 { + psels = , // LED 0 (red) + , // LED 1 (green) + ; // LED 2 (blue) + }; + }; + pwm0_sleep: pwm0_sleep { + group1 { + psels = , // LED 0 + , // LED 1 + ; // LED 2 + low-power-enable; + }; + }; + + /* configuration for i2c0 device, default state */ + i2c0_default: i2c0_default { + group1 { + psels = , + ; + }; + }; + + i2c0_sleep: i2c0_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts index 39569f0b7..8e7b1e6f1 100644 --- a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts @@ -6,6 +6,7 @@ /dts-v1/; #include +#include "nrf52840_m2-pinctrl.dtsi" / { model = "Makerdiary nRF52840 M.2 module"; @@ -16,18 +17,23 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zmk,battery = &vbatt; + zmk,backlight = &backlight; + zmk,led = &is31fl3733; }; leds { compatible = "gpio-leds"; - red_led: led_0 { + led1_red: led_1 { gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; + label = "Red LED 1"; }; - green_led: led_1 { + led1_green: led_2 { gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>; + label = "Green LED 1"; }; - blue_led: led_2 { + led1_blue: led_3 { gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>; + label = "Blue LED 1"; }; }; @@ -38,6 +44,18 @@ full-ohms = <(1000000 + 1000000)>; }; + backlight: pwmleds { + compatible = "pwm-leds"; + red_pwm_led: pwm_led_0 { + pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + green_pwm_led: pwm_led_1 { + pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + blue_pwm_led: pwm_led_2 { + pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + }; }; &adc { @@ -56,12 +74,32 @@ status = "okay"; }; +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_default>; + pinctrl-1 = <&pwm0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&i2c0 { + compatible = "nordic,nrf-twim"; + status = "okay"; + pinctrl-0 = <&i2c0_default>; + pinctrl-1 = <&i2c0_sleep>; + pinctrl-names = "default", "sleep"; + clock-frequency = ; + is31fl3733: is31fl3733@50 { + compatible = "issi,is31fl3733"; + reg = <0x50>; + sdb-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; + }; +}; + zephyr_udc0: &usbd { compatible = "nordic,nrf-usbd"; status = "okay"; }; - &flash0 { /* * For more information, see: diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig b/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig index 93eef9e6e..5a67ff5cc 100644 --- a/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig @@ -16,10 +16,10 @@ CONFIG_BUILD_OUTPUT_UF2=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 CONFIG_ZMK_USB=y -CONFIG_ZMK_BLE=y \ No newline at end of file +CONFIG_ZMK_BLE=y +CONFIG_PINCTRL=y From 750ee41a57b121f2c046fb6a868b40ada9f0b299 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Tue, 18 Nov 2025 19:46:39 +0100 Subject: [PATCH 2/7] Removing spi0 from pinctrl, the m2 board had a QSPI --- .../arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi b/app/boards/arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi index 00342f1e6..f2348f341 100644 --- a/app/boards/arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2-pinctrl.dtsi @@ -1,26 +1,4 @@ &pinctrl { - /* configuration for spi0 device, default state */ - spi0_default: spi0_default { - /* node name is arbitrary */ - group1 { - /* main role: configure P1.11 as SPI clock, P0.02 as SPI MOSI, P0.03 as SPI MISO */ - psels = , - , - ; - }; - }; - - /* configuration for spi0 device, sleep state */ - spi0_sleep: spi0_sleep { - group1 { - /* main role: configure P1.11 as SPI clock, P0.02 as SPI MOSI, P0.03 as SPI MISO */ - psels = , - , - ; - low-power-enable; - }; - }; - /* configuration for pwm device, default state */ pwm0_default: pwm0_default { group1 { From b894f98ed6bbfcfa21330592745b253dfaecd021 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Tue, 18 Nov 2025 20:29:20 +0100 Subject: [PATCH 3/7] Enable the led kconfig at the board level --- app/boards/arm/nrf52840_m2/Kconfig.defconfig | 10 ---------- app/boards/shields/m60/Kconfig.defconfig | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/boards/arm/nrf52840_m2/Kconfig.defconfig b/app/boards/arm/nrf52840_m2/Kconfig.defconfig index cc466ff5f..a5227fc0a 100644 --- a/app/boards/arm/nrf52840_m2/Kconfig.defconfig +++ b/app/boards/arm/nrf52840_m2/Kconfig.defconfig @@ -16,14 +16,4 @@ endif # USB_DEVICE_STACK config BT_CTLR default BT -if ZMK_BACKLIGHT - -config PWM - default y - -config LED_PWM - default y - -endif # ZMK_BACKLIGHT - endif # BOARD_NRF52840_M2 diff --git a/app/boards/shields/m60/Kconfig.defconfig b/app/boards/shields/m60/Kconfig.defconfig index a46969540..5292e3691 100644 --- a/app/boards/shields/m60/Kconfig.defconfig +++ b/app/boards/shields/m60/Kconfig.defconfig @@ -6,4 +6,14 @@ if SHIELD_M60 config ZMK_KEYBOARD_NAME default "m60" +if ZMK_BACKLIGHT + +config PWM + default y + +config LED_PWM + default y + +endif # ZMK_BACKLIGHT + endif From 9a94d6f1d42fceb62f774220d39091ad48065354 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Tue, 18 Nov 2025 21:24:00 +0100 Subject: [PATCH 4/7] Remove backlight configuration from board, we configure it from the shield --- app/boards/arm/nrf52840_m2/nrf52840_m2.dts | 3 +-- app/boards/shields/m60/m60.overlay | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts index 8e7b1e6f1..78df82558 100644 --- a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts @@ -17,7 +17,6 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zmk,battery = &vbatt; - zmk,backlight = &backlight; zmk,led = &is31fl3733; }; @@ -44,7 +43,7 @@ full-ohms = <(1000000 + 1000000)>; }; - backlight: pwmleds { + pwmleds: pwmleds { compatible = "pwm-leds"; red_pwm_led: pwm_led_0 { pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; diff --git a/app/boards/shields/m60/m60.overlay b/app/boards/shields/m60/m60.overlay index 15690f524..1abbad625 100644 --- a/app/boards/shields/m60/m60.overlay +++ b/app/boards/shields/m60/m60.overlay @@ -12,6 +12,7 @@ chosen { zmk,kscan = &kscan0; zmk,physical-layout = &layout_60_ansi; + zmk,backlight = &pwmleds; }; kscan0: kscan { From ea2704b60f3ede1e6157595450a9d1e9ff5102fc Mon Sep 17 00:00:00 2001 From: BarbUk Date: Tue, 18 Nov 2025 21:25:01 +0100 Subject: [PATCH 5/7] Add more readable layer documentation --- app/boards/shields/m60/m60.keymap | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/app/boards/shields/m60/m60.keymap b/app/boards/shields/m60/m60.keymap index 7fa07bbb7..0b8222807 100644 --- a/app/boards/shields/m60/m60.keymap +++ b/app/boards/shields/m60/m60.keymap @@ -14,13 +14,18 @@ default_layer { display-name = "Default Layer"; -// ------------------------------------------------------------------------------------------ -// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BSPC | -// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | -// | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | -// | SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | -// | CTL | WIN | ALT | SPACE | ALT | MO(1) | WIN | CTRL | -// ------------------------------------------------------------------------------------------ + + // ╭─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────────╮ + // | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | ⌫ | + // |─────┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───────| + // | ─>| | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | + // |───────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴───────| + // | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ↵ | + // |────────┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴────────────| + // | ⇧ | Z | X | C | V | B | N | M | , | . | / | ⇧ | + // |──────┬───┴──┬──┴──┬──┴─────┴─────┴─────┴─────┴─────┴───┬─┴─────┼─────┴┬──────┬────────| + // | Ctrl | Win | Alt | | 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 @@ -32,6 +37,18 @@ fn_layer { display-name = "Fn Layer"; + + // ╭─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────────╮ + // | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | BOOT | + // |─────┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───────| + // | ─>| | BTc | | | | | | | | | | | | reset | + // |───────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴───────| + // | CAPS | BT0 | BT1 | BT2 | BT3 | BT4 | ← | ↓ | ↑ | → | | | ↵ | + // |────────┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴────────────| + // | ⇧ | | | | | | | | | | | ⇧ | + // |──────┬───┴──┬──┴──┬──┴─────┴─────┴─────┴─────┴─────┴───┬─┴─────┼─────┴┬──────┬────────| + // | Ctrl | Win | alt | | alt | MO(1)| WIN | Ctrl | + // ╰──────┴──────┴─────┴────────────────────────────────────┴───────┴──────┴──────┴────────╯ 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 &sys_reset From de97a998f2650bf8e341870c07f1d9900e090221 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Tue, 18 Nov 2025 21:33:06 +0100 Subject: [PATCH 6/7] Add backlight control to default keymap --- app/boards/shields/m60/m60.keymap | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/boards/shields/m60/m60.keymap b/app/boards/shields/m60/m60.keymap index 0b8222807..6471e5973 100644 --- a/app/boards/shields/m60/m60.keymap +++ b/app/boards/shields/m60/m60.keymap @@ -7,6 +7,7 @@ #include #include #include +#include / { keymap0: keymap { @@ -41,7 +42,7 @@ // ╭─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────────╮ // | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | BOOT | // |─────┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───────| - // | ─>| | BTc | | | | | | | | | | | | reset | + // | ─>| | BTc | BLt | BLc | | | | | | | | | | reset | // |───────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴───────| // | CAPS | BT0 | BT1 | BT2 | BT3 | BT4 | ← | ↓ | ↑ | → | | | ↵ | // |────────┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴────────────| @@ -51,7 +52,7 @@ // ╰──────┴──────┴─────┴────────────────────────────────────┴───────┴──────┴──────┴────────╯ 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 &sys_reset +&trans &bt BT_CLR &bl BL_TOG &bl BL_CYCLE &none &none &none &none &none &none &none &none &none &sys_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 From 155322d370692e5e15ae3231a1d95008a52a385f Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 19 Nov 2025 04:47:22 +0100 Subject: [PATCH 7/7] Removing zmk,led from board, it will be added in the shield in another PR --- app/boards/arm/nrf52840_m2/nrf52840_m2.dts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts index 78df82558..1bd19cd96 100644 --- a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts @@ -17,7 +17,6 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zmk,battery = &vbatt; - zmk,led = &is31fl3733; }; leds {