diff --git a/app/boards/arm/rotr/CMakeLists.txt b/app/boards/arm/rotr/CMakeLists.txt new file mode 100644 index 00000000000..7b388db0c65 --- /dev/null +++ b/app/boards/arm/rotr/CMakeLists.txt @@ -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 +) diff --git a/app/boards/arm/rotr/Kconfig b/app/boards/arm/rotr/Kconfig new file mode 100644 index 00000000000..280a3852977 --- /dev/null +++ b/app/boards/arm/rotr/Kconfig @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT + +config BOARD_ENABLE_DCDC + bool "Enable DCDC mode" + select SOC_DCDC_NRF52X + default y + depends on BOARD_ROTR diff --git a/app/boards/arm/rotr/Kconfig.board b/app/boards/arm/rotr/Kconfig.board new file mode 100644 index 00000000000..44281190775 --- /dev/null +++ b/app/boards/arm/rotr/Kconfig.board @@ -0,0 +1,8 @@ +# ROTR board configuration + +# Copyright (c) 2021 Polarity Works +# SPDX-License-Identifier: MIT + +config BOARD_ROTR + bool "ROTR" + depends on SOC_NRF52840_QIAA diff --git a/app/boards/arm/rotr/Kconfig.defconfig b/app/boards/arm/rotr/Kconfig.defconfig new file mode 100644 index 00000000000..6ab26da1acf --- /dev/null +++ b/app/boards/arm/rotr/Kconfig.defconfig @@ -0,0 +1,36 @@ +# ROTR board configuration + +# Copyright (c) 2021 Polarity Works +# SPDX-License-Identifier: MIT + +if BOARD_ROTR + +config BOARD + default "rotr" + +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 + +config ZMK_BATTERY_VOLTAGE_DIVIDER + default y + +config ZMK_KEYBOARD_NAME + default "ROTR" + +endif # BOARD_ROTR diff --git a/app/boards/arm/rotr/board.cmake b/app/boards/arm/rotr/board.cmake new file mode 100644 index 00000000000..fa847d50595 --- /dev/null +++ b/app/boards/arm/rotr/board.cmake @@ -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) diff --git a/app/boards/arm/rotr/rotr.dts b/app/boards/arm/rotr/rotr.dts new file mode 100644 index 00000000000..439c79eb8c3 --- /dev/null +++ b/app/boards/arm/rotr/rotr.dts @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2021 Polarity Works + * + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; +#include + +/ { + model = "ROTR"; + compatible = "rotr"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zmk,kscan = &kscan0; + zmk,underglow = &led_strip; + zephyr,code-partition = &code_partition; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + row-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>; + col-gpios + = <&gpio0 2 GPIO_ACTIVE_HIGH> + , <&gpio0 3 GPIO_ACTIVE_HIGH> + , <&gpio1 15 GPIO_ACTIVE_HIGH> + ; + }; + + ext-power { + compatible = "zmk,ext-power-generic"; + label = "EXT_POWER"; + control-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>; + }; + + sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&encoder0>; + }; + + vbatt { + compatible = "zmk,battery-voltage-divider"; + label = "BATTERY"; + io-channels = <&adc 2>; + output-ohms = <2000000>; + full-ohms = <(2000000 + 806000)>; + }; +}; + +&adc { + status = "okay"; +}; + +&gpiote { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&i2c0 { + compatible = "nordic,nrf-twi"; + sda-pin = <17>; + scl-pin = <20>; +}; + +&uart0 { + compatible = "nordic,nrf-uarte"; + tx-pin = <6>; + rx-pin = <8>; +}; + +&usbd { + status = "okay"; +}; + +&spi1 { + status = "okay"; + + compatible = "nordic,nrf-spim"; + mosi-pin = <24>; + sck-pin = <21>; + miso-pin = <19>; + + cs-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>; + + encoder0: encoder@0 { + compatible = "magalpha,ma730"; + label = "KNOB"; + + a-gpios = <&gpio1 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&gpio1 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + + reg = <0>; + spi-max-frequency = <25000000>; + + resolution = <8>; //degrees per keypress + }; +}; + + +&flash0 { + /* + * For more information, see: + * http: //docs.zephyrproject.org/latest/devices/dts/flash_partitions.html + */ + 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>; + }; + }; +}; + + +&spi2 { + compatible = "nordic,nrf-spim"; + status = "okay"; + mosi-pin = <5>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <6>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <3>; /* number of LEDs */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; diff --git a/app/boards/arm/rotr/rotr.keymap b/app/boards/arm/rotr/rotr.keymap new file mode 100644 index 00000000000..fd3ee71130a --- /dev/null +++ b/app/boards/arm/rotr/rotr.keymap @@ -0,0 +1,19 @@ +#include +#include +#include + +&inc_dec_cp { + triggers-per-rotation = <4>; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + //PREV | PLAY/PAUSE | NEXT + bindings = <&bootloader &rgb_ug RGB_TOG &kp C_VOL_DN>; + sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN>; + }; + }; +}; diff --git a/app/boards/arm/rotr/rotr.yaml b/app/boards/arm/rotr/rotr.yaml new file mode 100644 index 00000000000..9a35e0d77ec --- /dev/null +++ b/app/boards/arm/rotr/rotr.yaml @@ -0,0 +1,15 @@ +identifier: rotr +name: ROTR +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - usb_device + - ble + - ieee802154 + - pwm + - watchdog diff --git a/app/boards/arm/rotr/rotr_defconfig b/app/boards/arm/rotr/rotr_defconfig new file mode 100644 index 00000000000..885e7c3eb27 --- /dev/null +++ b/app/boards/arm/rotr/rotr_defconfig @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: MIT + +CONFIG_SOC_SERIES_NRF52X=y +CONFIG_SOC_NRF52840_QIAA=y +CONFIG_BOARD_ROTR=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# enable GPIO +CONFIG_GPIO=y + +CONFIG_MA730=y +CONFIG_MA730_TRIGGER_GLOBAL_THREAD=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 + +CONFIG_ZMK_RGB_UNDERGLOW=y +# Use the STRIP config specific to the LEDs you're using +CONFIG_WS2812_STRIP=y +CONFIG_ZMK_RGB_UNDERGLOW_SAT_START=50 +CONFIG_BT_CTLR_TX_PWR_PLUS_8=y diff --git a/app/prj.conf b/app/prj.conf index e69de29bb2d..9b1d4159471 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -0,0 +1,2 @@ +# Turn on logging, and set ZMK logging to debug output +CONFIG_ZMK_USB_LOGGING=y