diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 3580b8f..cbc32bf 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -30,6 +30,7 @@ jobs: {boardname: "nrf52840dk/nrf52840", fileformat: "hex", filename: "SlimeNRF_nRF52840dk_Receiver"}, {boardname: "butterfly_p1_uf2/nrf52833", fileformat: "uf2", filename: "SlimeNRF_Butterfly_P1_Receiver"}, {boardname: "butterfly_p2_uf2/nrf52833", fileformat: "uf2", filename: "SlimeNRF_Butterfly_P2_Receiver"}, + {boardname: "butterfly_p3/nrf52820", fileformat: "hex", filename: "SlimeNRF_Butterfly_P3_Receiver"}, ] if: always() runs-on: ubuntu-latest diff --git a/boards/slimevr/butterfly_p3/CMakeLists.txt b/boards/slimevr/butterfly_p3/CMakeLists.txt new file mode 100644 index 0000000..218a060 --- /dev/null +++ b/boards/slimevr/butterfly_p3/CMakeLists.txt @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 + +zephyr_library() +zephyr_library_sources(board.c) diff --git a/boards/slimevr/butterfly_p3/Kconfig.butterfly_p3 b/boards/slimevr/butterfly_p3/Kconfig.butterfly_p3 new file mode 100644 index 0000000..ed3c42b --- /dev/null +++ b/boards/slimevr/butterfly_p3/Kconfig.butterfly_p3 @@ -0,0 +1,5 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_BUTTERFLY_P3 + select SOC_NRF52820_QDAA diff --git a/boards/slimevr/butterfly_p3/board.c b/boards/slimevr/butterfly_p3/board.c new file mode 100644 index 0000000..cf88ba0 --- /dev/null +++ b/boards/slimevr/butterfly_p3/board.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018 Nordic Semiconductor ASA. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +static int board_butterfly_p3_init(void) +{ + + /* needed for fem and debugging + */ + if ((nrf_power_mainregstatus_get(NRF_POWER) == + NRF_POWER_MAINREGSTATUS_HIGH) && + ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) == + (UICR_REGOUT0_VOUT_DEFAULT << UICR_REGOUT0_VOUT_Pos))) { + + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { + ; + } + + NRF_UICR->REGOUT0 = + (NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) | + (UICR_REGOUT0_VOUT_3V0 << UICR_REGOUT0_VOUT_Pos); + + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { + ; + } + + /* a reset is required for changes to take effect */ + NVIC_SystemReset(); + } + + return 0; +} + +SYS_INIT(board_butterfly_p3_init, PRE_KERNEL_1, + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); diff --git a/boards/slimevr/butterfly_p3/board.cmake b/boards/slimevr/butterfly_p3/board.cmake new file mode 100644 index 0000000..546320d --- /dev/null +++ b/boards/slimevr/butterfly_p3/board.cmake @@ -0,0 +1,9 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=nrf52820_xxaa" "--speed=4000") +board_runner_args(pyocd "--target=nrf52820" "--frequency=4000000") + +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) +include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) diff --git a/boards/slimevr/butterfly_p3/board.yml b/boards/slimevr/butterfly_p3/board.yml new file mode 100644 index 0000000..cb18a66 --- /dev/null +++ b/boards/slimevr/butterfly_p3/board.yml @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +board: + name: butterfly_p3 + vendor: slimevr + socs: + - name: nrf52820 diff --git a/boards/slimevr/butterfly_p3/butterfly_p3.dts b/boards/slimevr/butterfly_p3/butterfly_p3.dts new file mode 100644 index 0000000..a2dfe61 --- /dev/null +++ b/boards/slimevr/butterfly_p3/butterfly_p3.dts @@ -0,0 +1,67 @@ +// Copyright (c) 2024 Nordic Semiconductor ASA +// SPDX-License-Identifier: Apache-2.0 + +/dts-v1/; +#include + +/ { + model = "butterfly_p3"; + compatible = "butterfly_p3"; + + aliases { + sw0 = &button0; + }; + + buttons { + compatible = "gpio-keys"; + button0: button_0 { + gpios = <&gpio0 15 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Push button switch 0"; + }; + }; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,console = &cdc_acm_uart0; + zephyr,shell-uart = &cdc_acm_uart0; + }; + + nrf_radio_fem: skyFem { // ripped straight from holyiot dts, but it works + compatible = "skyworks,sky66112-11", "generic-fem-two-ctrl-pins"; + ctx-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>; + ctx-settle-time-us = <1>; + crx-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + crx-settle-time-us = <1>; + tx-gain-db = <22>; + rx-gain-db = <12>; + }; + + zephyr,user { + led-gpios = <&gpio0 14 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>; + }; +}; + +®0 { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; + +&gpiote { + status = "okay"; +}; + +&radio { + fem = <&nrf_radio_fem>; +}; + +zephyr_udc0: &usbd { + compatible = "nordic,nrf-usbd"; + status = "okay"; + cdc_acm_uart0: cdc_acm_uart0 { + compatible = "zephyr,cdc-acm-uart"; + }; +}; diff --git a/boards/slimevr/butterfly_p3/butterfly_p3.yaml b/boards/slimevr/butterfly_p3/butterfly_p3.yaml new file mode 100644 index 0000000..a524a7e --- /dev/null +++ b/boards/slimevr/butterfly_p3/butterfly_p3.yaml @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +identifier: butterfly_p3 +name: butterfly_p3 +vendor: slimevr +type: mcu +arch: arm +ram: 32 +flash: 256 +toolchain: + - zephyr + - gnuarmemb + - xtools diff --git a/boards/slimevr/butterfly_p3/butterfly_p3_defconfig b/boards/slimevr/butterfly_p3/butterfly_p3_defconfig new file mode 100644 index 0000000..465c3fb --- /dev/null +++ b/boards/slimevr/butterfly_p3/butterfly_p3_defconfig @@ -0,0 +1,12 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_ARM_MPU=y +CONFIG_HW_STACK_PROTECTION=y + +CONFIG_USB_DEVICE_MANUFACTURER="SlimeVR" +CONFIG_USB_DEVICE_PRODUCT="SlimeNRF Receiver Butterfly P3" + +#generate for adafruit uf2 bootloader flashing +#CONFIG_BUILD_OUTPUT_UF2=y +#CONFIG_FLASH_LOAD_OFFSET=0x1000