From 1fe242ab1fd2e7aef240b13aedca2cbf902af685 Mon Sep 17 00:00:00 2001 From: Xudong Zheng <7pkvm5aw@slicealias.com> Date: Sun, 6 Aug 2023 12:54:17 -0400 Subject: [PATCH] slicemk: serial split: setup Raytac MDBT50-DB-33 for development --- .../raytac_mdbt50q_rx_green/Kconfig.defconfig | 5 ++ .../raytac_mdbt50q_rx_green_defconfig | 11 ++- .../shields/slicemk_ergodox/Kconfig.defconfig | 16 ++++ .../shields/slicemk_ergodox/Kconfig.shield | 4 + .../slicemk_ergodox_uart.overlay | 80 +++++++++++++++++++ app/prj.conf | 4 +- 6 files changed, 112 insertions(+), 8 deletions(-) create mode 100644 app/boards/shields/slicemk_ergodox/slicemk_ergodox_uart.overlay diff --git a/app/boards/arm/raytac_mdbt50q_rx_green/Kconfig.defconfig b/app/boards/arm/raytac_mdbt50q_rx_green/Kconfig.defconfig index 97998a274056..62d7d3fa1fb2 100644 --- a/app/boards/arm/raytac_mdbt50q_rx_green/Kconfig.defconfig +++ b/app/boards/arm/raytac_mdbt50q_rx_green/Kconfig.defconfig @@ -16,4 +16,9 @@ endif # USB config BT_CTLR default BT +# Use maximum Bluetooth transmit power. +choice BT_CTLR_TX_PWR + default BT_CTLR_TX_PWR_PLUS_8 +endchoice + endif # BOARD_RAYTAC_MDBT50Q_RX_GREEN diff --git a/app/boards/arm/raytac_mdbt50q_rx_green/raytac_mdbt50q_rx_green_defconfig b/app/boards/arm/raytac_mdbt50q_rx_green/raytac_mdbt50q_rx_green_defconfig index 518ae1a4f564..ca7e98fd79e2 100644 --- a/app/boards/arm/raytac_mdbt50q_rx_green/raytac_mdbt50q_rx_green_defconfig +++ b/app/boards/arm/raytac_mdbt50q_rx_green/raytac_mdbt50q_rx_green_defconfig @@ -21,16 +21,15 @@ CONFIG_GPIO=y # Use NVS for settings. CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_NVS=y +CONFIG_SETTINGS=y CONFIG_SETTINGS_NVS=y CONFIG_FLASH=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_FLASH_MAP=y +# TODO TODO TODO serial shouldn't be enabled in main production build +CONFIG_SERIAL=y +CONFIG_PINCTRL=y + # The Adafruit bootloader allocates 7 pages for user data on nRF52833. CONFIG_SETTINGS_NVS_SECTOR_COUNT=7 - -# Use maximum Bluetooth transmit power. -CONFIG_BT_CTLR_TX_PWR_PLUS_8=y - -# Include support for Coded PHY. -CONFIG_BT_CTLR_PHY_CODED=y diff --git a/app/boards/shields/slicemk_ergodox/Kconfig.defconfig b/app/boards/shields/slicemk_ergodox/Kconfig.defconfig index c4035cea1258..6459d500c404 100644 --- a/app/boards/shields/slicemk_ergodox/Kconfig.defconfig +++ b/app/boards/shields/slicemk_ergodox/Kconfig.defconfig @@ -42,3 +42,19 @@ config ZMK_SPLIT_BLE_PREF_TIMEOUT default 900 endif + +if SHIELD_SLICEMK_ERGODOX_UART + +config ZMK_USB + default y + +config ZMK_SPLIT + default y + +config ZMK_SPLIT_ROLE_CENTRAL + default y + +config ZMK_KEYBOARD_NAME + default "SliceMK ErgoDox" + +endif diff --git a/app/boards/shields/slicemk_ergodox/Kconfig.shield b/app/boards/shields/slicemk_ergodox/Kconfig.shield index 6c1c96696f2d..a7a68f6edec8 100644 --- a/app/boards/shields/slicemk_ergodox/Kconfig.shield +++ b/app/boards/shields/slicemk_ergodox/Kconfig.shield @@ -12,3 +12,7 @@ config SHIELD_SLICEMK_ERGODOX_LEFTSINGLE config SHIELD_SLICEMK_ERGODOX_RIGHTSINGLE def_bool $(shields_list_contains,slicemk_ergodox_rightsingle) + +# TODO TODO TODO think about naming "uart" vs "converter" +config SHIELD_SLICEMK_ERGODOX_UART + def_bool $(shields_list_contains,slicemk_ergodox_uart) diff --git a/app/boards/shields/slicemk_ergodox/slicemk_ergodox_uart.overlay b/app/boards/shields/slicemk_ergodox/slicemk_ergodox_uart.overlay new file mode 100644 index 000000000000..9aa434d940cf --- /dev/null +++ b/app/boards/shields/slicemk_ergodox/slicemk_ergodox_uart.overlay @@ -0,0 +1,80 @@ +#include + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + + zmk,split-serial = &uart0; + zmk,underglow = &led_strip; + }; + + // TODO TODO TODO placeholder button, currently just an unused pin. probably + // abstract to &button or something as the actual pin would differ from + // board to board. maybe p0.15 since that's used on raytac dongle + kscan0: kscan { + compatible = "zmk,kscan-gpio-direct"; + label = "KSCAN"; + input-gpios = <&gpio0 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <15>; + rows = <7>; + 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(0,10) RC(0,11) RC(0,12) RC(0,13) RC(0,14) +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(1,10) RC(1,11) RC(1,12) RC(1,13) RC(1,14) +RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,9) RC(2,10) RC(2,11) RC(2,12) RC(2,13) RC(2,14) +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(3,9) RC(3,10) RC(3,11) RC(3,12) RC(3,13) RC(3,14) +RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,10) RC(4,11) RC(4,12) RC(4,13) RC(4,14) + RC(5,7) RC(5,6) RC(5,9) RC(5,8) + RC(5,5) RC(5,4) RC(5,3) RC(5,12) RC(5,11) RC(5,10) + RC(5,2) RC(5,13) + >; + }; +}; + +&pinctrl { + uart0_default: uart0_default { + group1 { + psels = ; + }; + group2 { + psels = ; + bias-pull-up; + }; + }; + + spi3_default: spi3_default { + group1 { + psels = ; + }; + }; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart0_default>; + pinctrl-names = "default"; +}; + +// Define LED strip. +&spi3 { + status = "okay"; + pinctrl-0 = <&spi3_default>; + pinctrl-names = "default"; + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + reg = <0>; + spi-max-frequency = <4000000>; + chain-length = <256>; + color-mapping = ; + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; diff --git a/app/prj.conf b/app/prj.conf index 3523a5b06f4e..366e103a7c4b 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -3,6 +3,6 @@ CONFIG_ZMK_BEHAVIORS_QUEUE_SIZE=512 # Increase stacks to reduce possibility of an overflow. CONFIG_MAIN_STACK_SIZE=2048 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 -CONFIG_ZMK_BLE_THREAD_STACK_SIZE=2048 -CONFIG_ZMK_SPLIT_BLE_CENTRAL_SPLIT_RUN_STACK_SIZE=2048 +# CONFIG_ZMK_BLE_THREAD_STACK_SIZE=2048 +# CONFIG_ZMK_SPLIT_BLE_CENTRAL_SPLIT_RUN_STACK_SIZE=2048 CONFIG_ISR_STACK_SIZE=2048