diff --git a/.gitmodules b/.gitmodules index c98df3f4d..0e7eb87be 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,6 +13,3 @@ [submodule "lib/SDK_2.8.0_MKL17Z32xxx4"] path = lib/SDK_2.8.0_MKL17Z32xxx4 url = https://github.com/UltimateHackingKeyboard/SDK_2.8.0_MKL17Z32xxx4.git -[submodule "lib/c2usb"] - path = lib/c2usb - url = https://github.com/IntergatedCircuits/c2usb.git diff --git a/.vscode/settings.json b/.vscode/settings.json index 311ccca9e..4f5e6394d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { - "nrf-connect.toolchain.path": "${nrf-connect.toolchain:2.6.1}", - "nrf-connect.topdir": "${nrf-connect.sdk:2.4.1}", + "nrf-connect.toolchain.path": "${nrf-connect.toolchain:2.8.0}", + "nrf-connect.topdir": "${nrf-connect.sdk:2.8.0}", "nrf-connect.applications": [ "${workspaceFolder}/device" ], diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 473e9a060..db48e9927 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,15 +5,187 @@ "label": "Build UHK 60 v2 firmware", "type": "shell", "command": "make", - "args": ["${command:cpptools.activeConfigName}"], + "args": [ + "${command:cpptools.activeConfigName}" + ], "options": { "cwd": "${workspaceFolder}/right/uhk60v2" }, - "problemMatcher": ["$gcc"], + "problemMatcher": [ + "$gcc" + ], "group": { "kind": "build", "isDefault": true } }, + { + "label": "Generate UHK versions", + "type": "shell", + "command": "node", + "args": [ + "scripts/generate-versions.mjs" + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [], + "group": { + "kind": "none", + "isDefault": true + } + }, + { + "label": "West update", + "group": { + "kind": "none", + "isDefault": true + }, + "options": { + "cwd": "${workspaceFolder}" + }, + "type": "process", + "command": "nrfutil", + "args": [ + "toolchain-manager", + "launch", + "--shell", + "--", + "west", + "update" + ] + }, + { + "label": "West patch", + "group": { + "kind": "none", + "isDefault": true + }, + "options": { + "cwd": "${workspaceFolder}" + }, + "type": "process", + "command": "nrfutil", + "args": [ + "toolchain-manager", + "launch", + "--shell", + "--", + "west", + "patch" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "West update" + ] + }, + { + "label": "Build UHK 80 left firmware", + "group": { + "kind": "build", + "isDefault": true + }, + "options": { + "cwd": "${workspaceFolder}" + }, + "type": "process", + "command": "nrfutil", + "args": [ + "toolchain-manager", + "launch", + "--shell", + "--", + "west", + "build", + "--build-dir", + "${cwd}/device/build/uhk-80-left", + "${cwd}/device", + "--pristine", + "--board", + "uhk-80-left", + "--no-sysbuild", + "--", + "-DNCS_TOOLCHAIN_VERSION=NONE", + "-DCONF_FILE=${cwd}/device/prj.conf", + "-DEXTRA_CONF_FILE=${cwd}/device/prj.conf.overlays/nrf_shared.conf;${cwd}/device/prj.conf.overlays/c2usb.conf;${cwd}/device/prj.conf.overlays/uhk-80.conf;${cwd}/device/prj.conf.overlays/ble_nus.conf", + "-DBOARD_ROOT=${cwd}", + "-Dmcuboot_OVERLAY_CONFIG=${cwd}/device/child_image/mcuboot.conf;${cwd}/device/child_image/uhk-80-left.mcuboot.conf" + ], + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "Build UHK 80 right firmware", + "group": { + "kind": "build", + "isDefault": true + }, + "options": { + "cwd": "${workspaceFolder}" + }, + "type": "process", + "command": "nrfutil", + "args": [ + "toolchain-manager", + "launch", + "--shell", + "--", + "west", + "build", + "--build-dir", + "${cwd}/device/build/uhk-80-right", + "${cwd}/device", + "--pristine", + "--board", + "uhk-80-right", + "--no-sysbuild", + "--", + "-DNCS_TOOLCHAIN_VERSION=NONE", + "-DCONF_FILE=${cwd}/device/prj.conf", + "-DEXTRA_CONF_FILE=${cwd}/device/prj.conf.overlays/nrf_shared.conf;${cwd}/device/prj.conf.overlays/c2usb.conf;${cwd}/device/prj.conf.overlays/uhk-80.conf;${cwd}/device/prj.conf.overlays/ble_nus.conf;${cwd}/device/prj.conf.overlays/ble_nus_client.conf;${cwd}/device/prj.conf.overlays/ble_hid.conf", + "-DBOARD_ROOT=${cwd}", + "-Dmcuboot_OVERLAY_CONFIG=${cwd}/device/child_image/mcuboot.conf;${cwd}/device/child_image/uhk-80-right.mcuboot.conf" + ], + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "Build UHK dongle firmware", + "group": { + "kind": "build", + "isDefault": true + }, + "options": { + "cwd": "${workspaceFolder}" + }, + "type": "process", + "command": "nrfutil", + "args": [ + "toolchain-manager", + "launch", + "--shell", + "--", + "west", + "build", + "--build-dir", + "${cwd}/device/build/uhk-dongle", + "${cwd}/device", + "--pristine", + "--board", + "uhk-dongle", + "--no-sysbuild", + "--", + "-DNCS_TOOLCHAIN_VERSION=NONE", + "-DCONF_FILE=${cwd}/device/prj.conf", + "-DEXTRA_CONF_FILE=${cwd}/device/prj.conf.overlays/nrf_shared.conf;${cwd}/device/prj.conf.overlays/c2usb.conf;${cwd}/device/prj.conf.overlays/ble_nus_client.conf", + "-DBOARD_ROOT=${cwd}", + "-Dmcuboot_OVERLAY_CONFIG=${cwd}/device/child_image/mcuboot.conf;${cwd}/device/child_image/uhk-dongle.mcuboot.conf" + ], + "problemMatcher": [ + "$gcc" + ] + } ] -} +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..54a7e43d2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.20) + +# until https://github.com/zephyrproject-rtos/zephyr/pull/69490 is merged +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# zephyr's build system doesn't define standard build type symbols, fix that here +if(NOT CONFIG_DEBUG) + add_definitions(-DNDEBUG) +endif() + +if(NOT CONFIG_DEVICE_ID) + # uhk code isn't added to bootloader + return() +endif() + +project(uhk) +add_library(${PROJECT_NAME}) +target_link_libraries(${PROJECT_NAME} PUBLIC + zephyr_interface +) +add_subdirectory(device/src) +add_subdirectory(right/src) +add_subdirectory(shared) diff --git a/README.md b/README.md index 93c26ba83..75e27e8bf 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Then, depending whether you want a full IDE experience or just minimal tools for - If the `build.sh` doesn't suit you, then launch the nrfutil shell: ``` - nrfutil toolchain-manager launch --shell --ncs-version v2.6.1 + nrfutil toolchain-manager launch --shell --ncs-version v2.8.0 ``` - In the shell, you can build (e.g.) uhk-80-left as follows: diff --git a/boards/arm/uhk-80-left/Kconfig.defconfig b/boards/arm/uhk-80-left/Kconfig.defconfig deleted file mode 100644 index 95c641e03..000000000 --- a/boards/arm/uhk-80-left/Kconfig.defconfig +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -if BOARD_UHK_80_LEFT - -config BOARD - default "uhk-80-left" - -config BT_CTLR - default BT - -endif diff --git a/boards/arm/uhk-80-left/board.cmake b/boards/arm/uhk-80-left/board.cmake deleted file mode 100644 index da4efd187..000000000 --- a/boards/arm/uhk-80-left/board.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -board_runner_args(jlink "--device=nrf52" "--speed=4000") -board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000") -board_runner_args(nrfjprog "--softreset") -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/arm/uhk-80-right/Kconfig.defconfig b/boards/arm/uhk-80-right/Kconfig.defconfig deleted file mode 100644 index 4868033f7..000000000 --- a/boards/arm/uhk-80-right/Kconfig.defconfig +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -if BOARD_UHK_80_RIGHT - -config BOARD - default "uhk-80-right" - -config BT_CTLR - default BT - -endif diff --git a/boards/arm/uhk-80-right/board.cmake b/boards/arm/uhk-80-right/board.cmake deleted file mode 100644 index da4efd187..000000000 --- a/boards/arm/uhk-80-right/board.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -board_runner_args(jlink "--device=nrf52" "--speed=4000") -board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000") -board_runner_args(nrfjprog "--softreset") -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/arm/uhk-80-right/pre_dt_board.cmake b/boards/arm/uhk-80-right/pre_dt_board.cmake deleted file mode 100644 index 3369c21d3..000000000 --- a/boards/arm/uhk-80-right/pre_dt_board.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) 2022 Nordic Semiconductor -# SPDX-License-Identifier: Apache-2.0 - -# Suppress "unique_unit_address_if_enabled" to handle the following overlaps: -# - power@40000000 & clock@40000000 & bprot@40000000 -# - acl@4001e000 & flash-controller@4001e000 -list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled") diff --git a/boards/arm/uhk-dongle/Kconfig.defconfig b/boards/arm/uhk-dongle/Kconfig.defconfig deleted file mode 100644 index 2bf872a39..000000000 --- a/boards/arm/uhk-dongle/Kconfig.defconfig +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -if BOARD_UHK_DONGLE - -config BOARD - default "uhk-dongle" - -config BT_CTLR - default BT - -endif diff --git a/boards/arm/uhk-dongle/pre_dt_board.cmake b/boards/arm/uhk-dongle/pre_dt_board.cmake deleted file mode 100644 index 3369c21d3..000000000 --- a/boards/arm/uhk-dongle/pre_dt_board.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) 2022 Nordic Semiconductor -# SPDX-License-Identifier: Apache-2.0 - -# Suppress "unique_unit_address_if_enabled" to handle the following overlaps: -# - power@40000000 & clock@40000000 & bprot@40000000 -# - acl@4001e000 & flash-controller@4001e000 -list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled") diff --git a/boards/arm/uhk-60-right/Kconfig.board b/boards/ugl/uhk-60-right/Kconfig.board similarity index 100% rename from boards/arm/uhk-60-right/Kconfig.board rename to boards/ugl/uhk-60-right/Kconfig.board diff --git a/boards/arm/uhk-60-right/Kconfig.defconfig b/boards/ugl/uhk-60-right/Kconfig.defconfig similarity index 100% rename from boards/arm/uhk-60-right/Kconfig.defconfig rename to boards/ugl/uhk-60-right/Kconfig.defconfig diff --git a/boards/arm/uhk-60-right/board.cmake b/boards/ugl/uhk-60-right/board.cmake similarity index 100% rename from boards/arm/uhk-60-right/board.cmake rename to boards/ugl/uhk-60-right/board.cmake diff --git a/boards/arm/uhk-60-right/uhk-60-right.dts b/boards/ugl/uhk-60-right/uhk-60-right.dts similarity index 100% rename from boards/arm/uhk-60-right/uhk-60-right.dts rename to boards/ugl/uhk-60-right/uhk-60-right.dts diff --git a/boards/arm/uhk-60-right/uhk-60-right.yaml b/boards/ugl/uhk-60-right/uhk-60-right.yaml similarity index 66% rename from boards/arm/uhk-60-right/uhk-60-right.yaml rename to boards/ugl/uhk-60-right/uhk-60-right.yaml index 0417e11e3..63f3d97fa 100644 --- a/boards/arm/uhk-60-right/uhk-60-right.yaml +++ b/boards/ugl/uhk-60-right/uhk-60-right.yaml @@ -19,3 +19,5 @@ supported: - spi - usb_device - watchdog + +# TODO: use board revisions: https://docs.zephyrproject.org/latest/hardware/porting/board_porting.html#multiple-board-revisions \ No newline at end of file diff --git a/boards/arm/uhk-60-right/uhk-60-right_defconfig b/boards/ugl/uhk-60-right/uhk-60-right_defconfig similarity index 100% rename from boards/arm/uhk-60-right/uhk-60-right_defconfig rename to boards/ugl/uhk-60-right/uhk-60-right_defconfig diff --git a/boards/ugl/uhk-80/CMakeLists.txt b/boards/ugl/uhk-80/CMakeLists.txt new file mode 100644 index 000000000..1e446521c --- /dev/null +++ b/boards/ugl/uhk-80/CMakeLists.txt @@ -0,0 +1,4 @@ +zephyr_library() +if(CONFIG_DEVICE_ID) # don't add it to bootloader image as well + zephyr_library_sources(board.c) +endif() diff --git a/boards/ugl/uhk-80/Kconfig.board b/boards/ugl/uhk-80/Kconfig.board new file mode 100644 index 000000000..cbbbab86f --- /dev/null +++ b/boards/ugl/uhk-80/Kconfig.board @@ -0,0 +1,14 @@ +# Copyright (c) 2023 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_UHK_80_LEFT + bool "UHK 80 left" + depends on SOC_NRF52840_QIAA + +config BOARD_UHK_80_RIGHT + bool "UHK 80 right" + depends on SOC_NRF52840_QIAA + +config BOARD_UHK_DONGLE + bool "UHK dongle" + depends on SOC_NRF52840_QIAA diff --git a/boards/ugl/uhk-80/Kconfig.defconfig b/boards/ugl/uhk-80/Kconfig.defconfig new file mode 100644 index 000000000..1b3b747b9 --- /dev/null +++ b/boards/ugl/uhk-80/Kconfig.defconfig @@ -0,0 +1,85 @@ +# SPDX-License-Identifier: Apache-2.0 +# used for both zephyr and mcuboot -> no custom kconfig symbols here + +if SHELL_BACKEND_RTT + if BOARD_UHK_80_LEFT + config SHELL_PROMPT_RTT + default "uhk80:left$ " + endif + if BOARD_UHK_80_RIGHT + config SHELL_PROMPT_RTT + default "uhk80:right$ " + endif + if BOARD_UHK_DONGLE + config SHELL_PROMPT_RTT + default "uhk-dongle$ " + endif +endif # SHELL_BACKEND_RTT + +if SHELL_BACKEND_SERIAL + if BOARD_UHK_80_LEFT + config SHELL_PROMPT_UART + default "uhk80:left$ " + endif + if BOARD_UHK_80_RIGHT + config SHELL_PROMPT_UART + default "uhk80:right$ " + endif + if BOARD_UHK_DONGLE + config SHELL_PROMPT_UART + default "uhk-dongle$ " + endif +endif # SHELL_BACKEND_SERIAL + +if BOARD_UHK_80_LEFT + config USB_DEVICE_PRODUCT + default "UHK 80 left half" + config USB_DEVICE_PID + default 0x0007 + if BT_DIS && BT_DIS_PNP + config BT_DIS_PNP_PID + default 0x8007 + endif # BT_DIS && BT_DIS_PNP +endif # BOARD_UHK_80_LEFT + +if BOARD_UHK_80_RIGHT + config USB_DEVICE_PRODUCT + default "UHK 80 right half" + config USB_DEVICE_PID + default 0x0009 + + if BT_DIS && BT_DIS_PNP + config BT_DIS_PNP_PID + default 0x8009 + endif # BT_DIS && BT_DIS_PNP + + if BT + # uhk-80-right is NUS server AND client, and HID server + config BT_MAX_CONN + default 3 + # use different connection parameters for HID clients and dongle + config BT_GAP_AUTO_UPDATE_CONN_PARAMS + default n + endif # BT +endif # BOARD_UHK_80_RIGHT + +if BOARD_UHK_DONGLE + config USB_DEVICE_PRODUCT + default "UHK dongle" + config USB_DEVICE_PID + default 0x0005 + if BT_DIS && BT_DIS_PNP + config BT_DIS_PNP_PID + default 0x8005 + endif # BT_DIS && BT_DIS_PNP +endif # BOARD_UHK_DONGLE + +if BT + config BT_DEVICE_NAME + default "UHK 80" if BOARD_UHK_80_LEFT || BOARD_UHK_80_RIGHT + config BT_DEVICE_APPEARANCE + default 961 +endif # BT + +config BT_CTLR + default BT diff --git a/boards/arm/uhk-80-left/Kconfig.board b/boards/ugl/uhk-80/Kconfig.uhk-80-left similarity index 66% rename from boards/arm/uhk-80-left/Kconfig.board rename to boards/ugl/uhk-80/Kconfig.uhk-80-left index ab0a2c5ba..2ba45af08 100644 --- a/boards/arm/uhk-80-left/Kconfig.board +++ b/boards/ugl/uhk-80/Kconfig.uhk-80-left @@ -2,5 +2,4 @@ # SPDX-License-Identifier: Apache-2.0 config BOARD_UHK_80_LEFT - bool "UHK 80 left" - depends on SOC_NRF52840_QIAA + select SOC_NRF52840_QIAA diff --git a/boards/arm/uhk-80-right/Kconfig.board b/boards/ugl/uhk-80/Kconfig.uhk-80-right similarity index 66% rename from boards/arm/uhk-80-right/Kconfig.board rename to boards/ugl/uhk-80/Kconfig.uhk-80-right index e29fdbeb0..639e4f6c4 100644 --- a/boards/arm/uhk-80-right/Kconfig.board +++ b/boards/ugl/uhk-80/Kconfig.uhk-80-right @@ -2,5 +2,4 @@ # SPDX-License-Identifier: Apache-2.0 config BOARD_UHK_80_RIGHT - bool "UHK 80 right" - depends on SOC_NRF52840_QIAA + select SOC_NRF52840_QIAA diff --git a/boards/arm/uhk-dongle/Kconfig.board b/boards/ugl/uhk-80/Kconfig.uhk-dongle similarity index 66% rename from boards/arm/uhk-dongle/Kconfig.board rename to boards/ugl/uhk-80/Kconfig.uhk-dongle index 165551096..fe9bc1ab2 100644 --- a/boards/arm/uhk-dongle/Kconfig.board +++ b/boards/ugl/uhk-80/Kconfig.uhk-dongle @@ -2,5 +2,4 @@ # SPDX-License-Identifier: Apache-2.0 config BOARD_UHK_DONGLE - bool "UHK dongle" - depends on SOC_NRF52840_QIAA + select SOC_NRF52840_QIAA diff --git a/boards/ugl/uhk-80/board.c b/boards/ugl/uhk-80/board.c new file mode 100644 index 000000000..1f8d0c317 --- /dev/null +++ b/boards/ugl/uhk-80/board.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018 Nordic Semiconductor ASA. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +#ifdef CONFIG_BOARD_UHK_DONGLE_NRF52840 +static int board_uhk_dongle_nrf52840_init(void) +{ + /* if the nrf52840dongle_nrf52840 board is powered from USB + * (high voltage mode), GPIO output voltage is set to 1.8 volts by + * default and that is not enough to turn the green and blue LEDs on. + * Increase GPIO voltage to 3.3 volts. */ + 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_3V3 << 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_uhk_dongle_nrf52840_init, PRE_KERNEL_1, + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); +#endif diff --git a/boards/arm/uhk-dongle/board.cmake b/boards/ugl/uhk-80/board.cmake similarity index 69% rename from boards/arm/uhk-dongle/board.cmake rename to boards/ugl/uhk-80/board.cmake index da4efd187..5c6b5319f 100644 --- a/boards/arm/uhk-dongle/board.cmake +++ b/boards/ugl/uhk-80/board.cmake @@ -1,9 +1,12 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA +# Copyright (c) 2021 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 board_runner_args(jlink "--device=nrf52" "--speed=4000") board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000") -board_runner_args(nrfjprog "--softreset") + +set(OPENOCD_NRF5_SUBFAMILY "nrf52") + include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake) diff --git a/boards/ugl/uhk-80/board.yml b/boards/ugl/uhk-80/board.yml new file mode 100644 index 000000000..d9adb6a70 --- /dev/null +++ b/boards/ugl/uhk-80/board.yml @@ -0,0 +1,13 @@ +boards: + - name: uhk-80-left + vendor: ugl + socs: + - name: nrf52840 + - name: uhk-80-right + vendor: ugl + socs: + - name: nrf52840 + - name: uhk-dongle + vendor: ugl + socs: + - name: nrf52840 diff --git a/boards/arm/uhk-80-left/pre_dt_board.cmake b/boards/ugl/uhk-80/pre_dt_board.cmake similarity index 100% rename from boards/arm/uhk-80-left/pre_dt_board.cmake rename to boards/ugl/uhk-80/pre_dt_board.cmake diff --git a/boards/arm/shared.dtsi b/boards/ugl/uhk-80/shared.dtsi similarity index 100% rename from boards/arm/shared.dtsi rename to boards/ugl/uhk-80/shared.dtsi diff --git a/boards/arm/uhk-80-left/uhk-80-left.dts b/boards/ugl/uhk-80/uhk-80-left.dts similarity index 90% rename from boards/arm/uhk-80-left/uhk-80-left.dts rename to boards/ugl/uhk-80/uhk-80-left.dts index 0d0d4ab0c..521717940 100644 --- a/boards/arm/uhk-80-left/uhk-80-left.dts +++ b/boards/ugl/uhk-80/uhk-80-left.dts @@ -1,6 +1,6 @@ /dts-v1/; #include -#include "../shared.dtsi" +#include "shared.dtsi" &gpio1 { status = "okay"; @@ -53,7 +53,7 @@ uart0_sleep: uart0_sleep { group1 { psels = , - ; + ; low-power-enable; }; }; @@ -71,7 +71,7 @@ uart1_sleep: uart1_sleep { group1 { psels = , - ; + ; low-power-enable; }; }; @@ -93,18 +93,18 @@ i2c2_default: i2c2_default { group1 { - psels = , - ; - bias-pull-up; + psels = , + ; + bias-pull-up; }; - }; - i2c2_sleep: i2c2_sleep { + }; + i2c2_sleep: i2c2_sleep { group1 { - psels = , - ; - low-power-enable; + psels = , + ; + low-power-enable; }; - }; + }; }; &spi1 { @@ -171,8 +171,8 @@ }; col1: col1 { - gpios = <&gpio0 19 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>; - label = "col1"; + gpios = <&gpio0 19 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>; + label = "col1"; }; col2: col2 { gpios = <&gpio0 15 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>; diff --git a/boards/arm/uhk-80-left/uhk-80-left.yaml b/boards/ugl/uhk-80/uhk-80-left.yaml similarity index 94% rename from boards/arm/uhk-80-left/uhk-80-left.yaml rename to boards/ugl/uhk-80/uhk-80-left.yaml index b7cb42d4a..537bf09f0 100644 --- a/boards/arm/uhk-80-left/uhk-80-left.yaml +++ b/boards/ugl/uhk-80/uhk-80-left.yaml @@ -3,6 +3,7 @@ identifier: uhk-80-left name: UHK 80 left +vendor: ugl type: mcu arch: arm ram: 256 diff --git a/boards/arm/uhk-80-left/uhk-80-left_defconfig b/boards/ugl/uhk-80/uhk-80-left_defconfig similarity index 50% rename from boards/arm/uhk-80-left/uhk-80-left_defconfig rename to boards/ugl/uhk-80/uhk-80-left_defconfig index 3170f72a9..4a8311115 100644 --- a/boards/arm/uhk-80-left/uhk-80-left_defconfig +++ b/boards/ugl/uhk-80/uhk-80-left_defconfig @@ -1,10 +1,5 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 - -CONFIG_SOC_SERIES_NRF52X=y -CONFIG_SOC_NRF52840_QIAA=y -CONFIG_BOARD_UHK_80_LEFT=y - +# used for both zephyr and mcuboot -> only shared kconfig symbols here # Enable MPU CONFIG_ARM_MPU=y diff --git a/boards/arm/uhk-80-right/uhk-80-right.dts b/boards/ugl/uhk-80/uhk-80-right.dts similarity index 93% rename from boards/arm/uhk-80-right/uhk-80-right.dts rename to boards/ugl/uhk-80/uhk-80-right.dts index 2b871039d..245c1727a 100644 --- a/boards/arm/uhk-80-right/uhk-80-right.dts +++ b/boards/ugl/uhk-80/uhk-80-right.dts @@ -1,6 +1,6 @@ /dts-v1/; #include -#include "../shared.dtsi" +#include "shared.dtsi" &gpio1 { status = "okay"; @@ -53,7 +53,7 @@ uart0_sleep: uart0_sleep { group1 { psels = , - ; + ; low-power-enable; }; }; @@ -71,7 +71,7 @@ uart1_sleep: uart1_sleep { group1 { psels = , - ; + ; low-power-enable; }; }; @@ -92,16 +92,16 @@ }; i2c2_default: i2c2_default { group1 { - psels = , - ; - bias-pull-up; + psels = , + ; + bias-pull-up; }; - }; - i2c2_sleep: i2c2_sleep { + }; + i2c2_sleep: i2c2_sleep { group1 { - psels = , - ; - low-power-enable; + psels = , + ; + low-power-enable; }; }; }; diff --git a/boards/arm/uhk-80-right/uhk-80-right.yaml b/boards/ugl/uhk-80/uhk-80-right.yaml similarity index 94% rename from boards/arm/uhk-80-right/uhk-80-right.yaml rename to boards/ugl/uhk-80/uhk-80-right.yaml index 82a54f1e5..6c1ced07f 100644 --- a/boards/arm/uhk-80-right/uhk-80-right.yaml +++ b/boards/ugl/uhk-80/uhk-80-right.yaml @@ -3,6 +3,7 @@ identifier: uhk-80-right name: UHK 80 right +vendor: ugl type: mcu arch: arm ram: 256 diff --git a/boards/arm/uhk-80-right/uhk-80-right_defconfig b/boards/ugl/uhk-80/uhk-80-right_defconfig similarity index 50% rename from boards/arm/uhk-80-right/uhk-80-right_defconfig rename to boards/ugl/uhk-80/uhk-80-right_defconfig index 63d485bf2..4a8311115 100644 --- a/boards/arm/uhk-80-right/uhk-80-right_defconfig +++ b/boards/ugl/uhk-80/uhk-80-right_defconfig @@ -1,10 +1,5 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 - -CONFIG_SOC_SERIES_NRF52X=y -CONFIG_SOC_NRF52840_QIAA=y -CONFIG_BOARD_UHK_80_RIGHT=y - +# used for both zephyr and mcuboot -> only shared kconfig symbols here # Enable MPU CONFIG_ARM_MPU=y diff --git a/boards/arm/uhk-dongle/uhk-dongle.dts b/boards/ugl/uhk-80/uhk-dongle.dts similarity index 88% rename from boards/arm/uhk-dongle/uhk-dongle.dts rename to boards/ugl/uhk-80/uhk-dongle.dts index 9a0da29e3..8d5792d54 100644 --- a/boards/arm/uhk-dongle/uhk-dongle.dts +++ b/boards/ugl/uhk-80/uhk-dongle.dts @@ -1,6 +1,6 @@ /dts-v1/; #include -#include "../shared.dtsi" +#include "shared.dtsi" &pwm0 { status = "okay"; @@ -23,7 +23,7 @@ uart0_sleep: uart0_sleep { group1 { psels = , - ; + ; low-power-enable; }; }; @@ -31,8 +31,8 @@ pwm0_default: pwm0_default { group1 { psels = , - , - ; + , + ; nordic,invert; }; }; @@ -40,8 +40,8 @@ pwm0_sleep: pwm0_sleep { group1 { psels = , - , - ; + , + ; low-power-enable; }; }; diff --git a/boards/arm/uhk-dongle/uhk-dongle.yaml b/boards/ugl/uhk-80/uhk-dongle.yaml similarity index 94% rename from boards/arm/uhk-dongle/uhk-dongle.yaml rename to boards/ugl/uhk-80/uhk-dongle.yaml index a9470e937..a3bced58e 100644 --- a/boards/arm/uhk-dongle/uhk-dongle.yaml +++ b/boards/ugl/uhk-80/uhk-dongle.yaml @@ -3,6 +3,7 @@ identifier: uhk-dongle name: UHK dongle +vendor: ugl type: mcu arch: arm ram: 256 diff --git a/boards/arm/uhk-dongle/uhk-dongle_defconfig b/boards/ugl/uhk-80/uhk-dongle_defconfig similarity index 51% rename from boards/arm/uhk-dongle/uhk-dongle_defconfig rename to boards/ugl/uhk-80/uhk-dongle_defconfig index 4d9381c91..167ab1774 100644 --- a/boards/arm/uhk-dongle/uhk-dongle_defconfig +++ b/boards/ugl/uhk-80/uhk-dongle_defconfig @@ -1,12 +1,9 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 - -CONFIG_SOC_SERIES_NRF52X=y -CONFIG_SOC_NRF52840_QIAA=y -CONFIG_BOARD_UHK_DONGLE=y - +# used for both zephyr and mcuboot -> only shared kconfig symbols here # Enable MPU CONFIG_ARM_MPU=y # Enable hardware stack protection CONFIG_HW_STACK_PROTECTION=y + +CONFIG_PWM=y diff --git a/build.sh b/build.sh index 0d4f33b07..159f39002 100755 --- a/build.sh +++ b/build.sh @@ -1,9 +1,10 @@ #!/bin/bash -NCS_VERSION=v2.6.1 +NCS_VERSION=v2.8.0 -BUILD_SESSION_NAME="buildsession" -UART_SESSION_NAME="uartsession" +ROOT_HASH=`realpath . | md5sum | sed 's/ .*//g'` +BUILD_SESSION_NAME="buildsession_$ROOT_HASH" +UART_SESSION_NAME="uartsession_$ROOT_HASH" function help() { cat << END @@ -224,6 +225,12 @@ function createCentralCompileCommands() { mv $TEMP_COMMANDS $ROOT/compile_commands.json } +function getExtraConfFiles() { + DEVICE=$1 + EXTRA_CONF_FILES=`jq -r '.configurePresets[] | select(.name == "build/'"$DEVICE"'") | .cacheVariables.EXTRA_CONF_FILE' device/CMakePresets.json` + echo "$EXTRA_CONF_FILES" | sed 's=${sourceDir}='"$ROOT"/device'=g' +} + function performAction() { DEVICE=$1 ACTION=$2 @@ -240,7 +247,7 @@ function performAction() { ./generate-versions.mjs ;; clean) - rm -rf device/build .west bootloader modules nrf nrfxlib test tools zephyr + rm -rf ../bootloader ../c2usb ../hal_nxp ../modules ../nrf ../nrfxlib ../zephyr ../.west ;; setup) # basic dependencies @@ -271,8 +278,17 @@ function performAction() { nrfutil toolchain-manager launch --shell --ncs-version $NCS_VERSION << END unset PYTHONPATH unset PYTHONHOME - ZEPHYR_TOOLCHAIN_VARIANT=zephyr west build --build-dir "$ROOT/device/build/$DEVICE" "$ROOT/device" --pristine --board "$DEVICE" --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DEXTRA_CONF_FILE=prj.conf.overlays/$DEVICE.prj.conf -DBOARD_ROOT="$ROOT" -Dmcuboot_OVERLAY_CONFIG="$ROOT/device/child_image/mcuboot.conf;$ROOT/device/child_image/$DEVICE.mcuboot.conf" - + ZEPHYR_TOOLCHAIN_VARIANT=zephyr west build \ + --build-dir "$ROOT/device/build/$DEVICE" "$ROOT/device" \ + --pristine \ + --board "$DEVICE" \ + --no-sysbuild \ + -- \ + -DNCS_TOOLCHAIN_VERSION=NONE \ + -DCONF_FILE="$ROOT/device/prj_release.conf" \ + -DEXTRA_CONF_FILE="`getExtraConfFiles $DEVICE`" \ + -DBOARD_ROOT="$ROOT" \ + -Dmcuboot_OVERLAY_CONFIG="$ROOT/device/child_image/mcuboot.conf;$ROOT/device/child_image/$DEVICE.mcuboot.conf" END createCentralCompileCommands ;; diff --git a/device/CMakeLists.txt b/device/CMakeLists.txt index 7168199ae..7cc0551a8 100644 --- a/device/CMakeLists.txt +++ b/device/CMakeLists.txt @@ -1,48 +1,21 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(uhk) +project(app) -target_include_directories(app PUBLIC - src - src/legacy - src/legacy/config_parser - src/shared -) - -file(GLOB usb_sources src/usb/*.c) -file(GLOB usb_cpp_sources src/usb/*.cpp) -file(GLOB_RECURSE keyboard_sources src/keyboard/*.c) -file(GLOB app_sources src/*.c) -file(GLOB app_cpp_sources src/*.cpp) -file(GLOB lvgl_dummy src/lvgl/*.c) -file(GLOB_RECURSE legacy_sources src/legacy/*.c) -file(GLOB_RECURSE shared_sources src/shared/*.c) - -# add the versions.c source file conditionally -if(NOT NOVERSIONS) - target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../shared/versions.c) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/../shared/versions.c PROPERTIES GENERATED TRUE) -endif() - -if(BOARD STREQUAL "uhk-60-right") - file(GLOB main src/uhk60/main.c) - target_sources(app PRIVATE ${main}) -elseif ((BOARD STREQUAL "uhk-dongle")) - target_sources(app PRIVATE ${app_sources} ${app_cpp_sources} ${usb_sources} ${usb_cpp_sources} ${legacy_sources} ${shared_sources}) -else() - target_sources(app PRIVATE ${app_sources} ${app_cpp_sources} ${usb_sources} ${usb_cpp_sources} ${legacy_sources} ${shared_sources} ${keyboard_sources} ${lvgl_dummy}) +if(NOT CONFIG_DEBUG) + add_definitions(-DNDEBUG) endif() -if(NOT BOARD STREQUAL "uhk-60-right") - # C headers compiled with C++ give pointer conversion errors, turn them to warnings - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") - - set(C2USB_PATH "c2usb") - - add_subdirectory(${C2USB_PATH}) +target_link_libraries(app PRIVATE + uhk +) - # Link app to c2usb - target_link_libraries(app PRIVATE - c2usb +if(CONFIG_BOARD_UHK_60_RIGHT) + target_sources(app PRIVATE + src/uhk60/main.c + ) +else() + target_sources(app PRIVATE + src/main.c ) endif() diff --git a/device/CMakePresets.json b/device/CMakePresets.json index 517bd40c2..ae40300cd 100644 --- a/device/CMakePresets.json +++ b/device/CMakePresets.json @@ -32,9 +32,6 @@ "BOARD_ROOT": "${sourceParentDir}/", "CONF_FILE": "${sourceDir}/prj.conf", "OVERLAY_CONFIG": "${sourceDir}/prj.conf.overlays/uhk-60-v2-right.prj.conf" - }, - "warnings": { - "dev": false } }, { @@ -47,10 +44,7 @@ "BOARD": "uhk-80-right", "BOARD_ROOT": "${sourceParentDir}/", "mcuboot_OVERLAY_CONFIG": "${sourceDir}/child_image/mcuboot.conf;${sourceDir}/child_image/uhk-80-right.mcuboot.conf", - "EXTRA_CONF_FILE": "${sourceDir}/prj.conf.overlays/uhk-80-right.prj.conf" - }, - "warnings": { - "dev": false + "EXTRA_CONF_FILE": "${sourceDir}/prj.conf.overlays/nrf_shared.conf;${sourceDir}/prj.conf.overlays/c2usb.conf;${sourceDir}/prj.conf.overlays/uhk-80.conf;${sourceDir}/prj.conf.overlays/ble_nus.conf;${sourceDir}/prj.conf.overlays/ble_nus_client.conf;${sourceDir}/prj.conf.overlays/ble_hid.conf" } }, { @@ -63,10 +57,7 @@ "BOARD": "uhk-80-left", "BOARD_ROOT": "${sourceParentDir}/", "mcuboot_OVERLAY_CONFIG": "${sourceDir}/child_image/mcuboot.conf;${sourceDir}/child_image/uhk-80-left.mcuboot.conf", - "EXTRA_CONF_FILE": "${sourceDir}/prj.conf.overlays/uhk-80-left.prj.conf" - }, - "warnings": { - "dev": false + "EXTRA_CONF_FILE": "${sourceDir}/prj.conf.overlays/nrf_shared.conf;${sourceDir}/prj.conf.overlays/c2usb.conf;${sourceDir}/prj.conf.overlays/uhk-80.conf;${sourceDir}/prj.conf.overlays/ble_nus.conf" } }, { @@ -79,10 +70,7 @@ "BOARD": "uhk-dongle", "BOARD_ROOT": "${sourceParentDir}/", "mcuboot_OVERLAY_CONFIG": "${sourceDir}/child_image/mcuboot.conf;${sourceDir}/child_image/uhk-dongle.mcuboot.conf", - "EXTRA_CONF_FILE": "${sourceDir}/prj.conf.overlays/uhk-dongle.prj.conf" - }, - "warnings": { - "dev": false + "EXTRA_CONF_FILE": "${sourceDir}/prj.conf.overlays/nrf_shared.conf;${sourceDir}/prj.conf.overlays/c2usb.conf;${sourceDir}/prj.conf.overlays/ble_nus_client.conf" } } ] diff --git a/device/Kconfig b/device/Kconfig index d42383526..273fd3d86 100644 --- a/device/Kconfig +++ b/device/Kconfig @@ -1,13 +1,19 @@ -source "Kconfig.zephyr" - -rsource "c2usb/c2usb/port/zephyr/Kconfig" - +# custom Kconfig defaults are set per board here, +# as the board-specific Kconfig files are used for mcuboot build as well config DEVICE_ID int "UHK device id" - default 0 + default 5 if BOARD_UHK_DONGLE + default 3 if BOARD_UHK_80_LEFT + default 4 if BOARD_UHK_80_RIGHT help The device id that identifies the specific UHK half or dongle. +config UHK_BATTERY_DEVICE + bool + default y if BOARD_UHK_80_LEFT || BOARD_UHK_80_RIGHT + default n + imply ADC + config KEYBOARD_MAX_SCANCODE hex "highest keyboard scancode" default 0x86 @@ -18,8 +24,57 @@ config KEYBOARD_MAX_SCANCODE still receive the "NKRO" report layout. If a higher scancode is used, the report size will exceed this size, causing a fallback to 6KRO report layout on Android. -config USB_PID +# by using the same Kconfig symbol names as mcuboot, the board Kconfig files can contain the values +config USB_DEVICE_VID + hex "USB vendor ID" + range 0x0000 0xFFFF + default 0x37A8 + help + The USB vendor ID is used to identify the specific UHK device. + +config USB_DEVICE_MANUFACTURER + string "USB vendor name" + default "Ultimate Gadget Laboratories" + help + The USB vendor name is used to describe the specific UHK device to the host OS user. + +config USB_DEVICE_PID hex "USB product ID" range 0x0000 0xFFFF help The USB product ID is used to identify the specific UHK device. + +config USB_DEVICE_PRODUCT + string "USB product name" + help + The USB product name is used to describe the specific UHK device to the host OS user. + +config USB_DEVICE_PRODUCT_VERSION + hex "USB product version" + range 0x0000 0xFFFF + default 0x0001 + help + The USB product version is used to identify the UHK device operating mode. + +# copy over the USB properties to BT +configdefault BT_DIS_MANUF + default USB_DEVICE_MANUFACTURER +configdefault BT_DIS_MODEL + default USB_DEVICE_PRODUCT +configdefault BT_DIS_PNP + default y +configdefault BT_DIS_PNP_VID_SRC + default 2 +configdefault BT_DIS_PNP_VID + default USB_DEVICE_VID +configdefault BT_DIS_PNP_VER + default USB_DEVICE_PRODUCT_VERSION + +# CONFIG_NCS_SAMPLES_DEFAULTS: +configdefault LOG_DEFAULT_MINIMAL + default y + +# configdefaults must come before sourcing "Kconfig.zephyr" in order to give precedence +# to these application-specific defaults instead of the unconditional default in the Zephyr Kconfig tree. +# https://github.com/nrfconnect/sdk-nrf/blob/4b9841a28e97e9d61b93f8981375d644b9d04ea0/samples/bluetooth/mesh/light/Kconfig#L11C1-L13C30 +source "Kconfig.zephyr" diff --git a/device/c2usb b/device/c2usb deleted file mode 120000 index 060933c71..000000000 --- a/device/c2usb +++ /dev/null @@ -1 +0,0 @@ -../lib/c2usb \ No newline at end of file diff --git a/device/prj.conf b/device/prj.conf index cfc45635b..b053aa5c6 100644 --- a/device/prj.conf +++ b/device/prj.conf @@ -1,97 +1,14 @@ -CONFIG_PINCTRL=y -CONFIG_RETAINED_MEM=y -CONFIG_RETENTION=y -CONFIG_RETENTION_BOOT_MODE=y - -CONFIG_EXTRA_EXCEPTION_INFO=y -CONFIG_INIT_STACKS=y - -CONFIG_CPP=y -CONFIG_STD_CPP20=y -CONFIG_NEWLIB_LIBC=y -CONFIG_GLIBCXX_LIBCPP=y - -CONFIG_UDC_DRIVER=y - -CONFIG_NCS_SAMPLES_DEFAULTS=y - -CONFIG_BT=y -# CONFIG_BT_DEBUG_LOG=y -CONFIG_BT_MAX_CONN=4 -CONFIG_BT_MAX_PAIRED=20 -CONFIG_BT_SMP=y -CONFIG_BT_L2CAP_TX_BUF_COUNT=5 -CONFIG_BT_PERIPHERAL=y -CONFIG_BT_DEVICE_NAME="UHK 80" -CONFIG_BT_DEVICE_APPEARANCE=961 - -CONFIG_BT_BAS=y - -CONFIG_BT_DIS=y -CONFIG_BT_DIS_PNP=y -CONFIG_BT_DIS_PNP_VID_SRC=2 -CONFIG_BT_DIS_PNP_VID=0x37A8 -CONFIG_BT_DIS_MANUF="Ultimate Gadget Laboratories" - -CONFIG_BT_SETTINGS=y -CONFIG_FLASH=y -CONFIG_FLASH_PAGE_LAYOUT=y -CONFIG_FLASH_MAP=y -CONFIG_NVS=y -CONFIG_SETTINGS=y - -CONFIG_SERIAL=y - -CONFIG_CONSOLE=y -CONFIG_UART_CONSOLE=y -CONFIG_UART_LINE_CTRL=y -CONFIG_UART_ASYNC_API=y - -CONFIG_SHELL=y -CONFIG_SHELL_VT100_COMMANDS=y -CONFIG_SHELL_VT100_COLORS=y -CONFIG_BT_SHELL=y -CONFIG_SHELL_BT_NUS=y -CONFIG_HWINFO=y -CONFIG_HWINFO_SHELL=y -CONFIG_I2C=y -CONFIG_I2C_SHELL=y -CONFIG_STREAM_FLASH=y -CONFIG_SETTINGS_SHELL=y -CONFIG_SHELL_BACKENDS=y - +# settings only for debug build +# for build independent settings use extra-conf/.conf +# for board-specific settings use ../boards///_defconfig +# for board AND build type specific settings use boards//_.conf CONFIG_USE_SEGGER_RTT=y CONFIG_RTT_CONSOLE=y -CONFIG_SHELL_BACKEND_SERIAL=y CONFIG_SHELL_BACKEND_RTT=y # CONFIG_LOG_BACKEND_RTT=y -CONFIG_BUILD_OUTPUT_HEX=y - -CONFIG_BT_CENTRAL=y -CONFIG_BT_GATT_CLIENT=y -CONFIG_BT_OBSERVER=y -CONFIG_BT_NUS=y -CONFIG_BT_NUS_CLIENT=y -CONFIG_BT_SCAN=y -CONFIG_BT_SCAN_FILTER_ENABLE=y -CONFIG_BT_SCAN_UUID_CNT=1 -CONFIG_BT_GATT_DM=y -CONFIG_HEAP_MEM_POOL_SIZE=2048 -CONFIG_BT_SCAN_ADDRESS_CNT=2 -CONFIG_WARN_EXPERIMENTAL=n - -CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n - -CONFIG_BT_USER_DATA_LEN_UPDATE=y -CONFIG_BT_BUF_ACL_RX_SIZE=251 -CONFIG_BT_BUF_ACL_TX_SIZE=251 -CONFIG_BT_L2CAP_TX_MTU=247 - -CONFIG_BT_ATT_PREPARE_COUNT=4 - -CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y -# Apply config requires deep stack, and since Agent expects response code, -# we can't just do it from the main thread -CONFIG_C2USB_UDC_MAC_THREAD_STACK_SIZE=2048 +CONFIG_DEBUG_THREAD_INFO=y +CONFIG_DEBUG=y +# re-enable these behaviors that change their default in debug builds? +CONFIG_REBOOT=y diff --git a/device/prj.conf.overlays/ble_hid.conf b/device/prj.conf.overlays/ble_hid.conf new file mode 100644 index 000000000..f64653814 --- /dev/null +++ b/device/prj.conf.overlays/ble_hid.conf @@ -0,0 +1,13 @@ +CONFIG_BT_PERIPHERAL=y + +# BLE link key management: keep the most recent keys, at the cost of flash wear +CONFIG_BT_KEYS_OVERWRITE_OLDEST=y +CONFIG_BT_KEYS_SAVE_AGING_COUNTER_ON_PAIRING=y +CONFIG_BT_MAX_PAIRED=20 + +# use BLE HID over GATT from c2usb +CONFIG_C2USB_BLUETOOTH=y +# battery status to generic client +CONFIG_BT_BAS=y +# device information to generic client +CONFIG_BT_DIS=y diff --git a/device/prj.conf.overlays/ble_nus.conf b/device/prj.conf.overlays/ble_nus.conf new file mode 100644 index 000000000..72eb25b3b --- /dev/null +++ b/device/prj.conf.overlays/ble_nus.conf @@ -0,0 +1,3 @@ +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_NUS=y +CONFIG_BT_NUS_AUTHEN=y diff --git a/device/prj.conf.overlays/ble_nus_client.conf b/device/prj.conf.overlays/ble_nus_client.conf new file mode 100644 index 000000000..b4e83058c --- /dev/null +++ b/device/prj.conf.overlays/ble_nus_client.conf @@ -0,0 +1,9 @@ +CONFIG_BT_CENTRAL=y +CONFIG_BT_GATT_CLIENT=y +CONFIG_BT_NUS_CLIENT=y +CONFIG_BT_SCAN=y +CONFIG_BT_SCAN_FILTER_ENABLE=y +CONFIG_BT_SCAN_UUID_CNT=1 +CONFIG_BT_GATT_DM=y +CONFIG_HEAP_MEM_POOL_SIZE=2048 +CONFIG_BT_SCAN_ADDRESS_CNT=2 diff --git a/device/prj.conf.overlays/c2usb.conf b/device/prj.conf.overlays/c2usb.conf new file mode 100644 index 000000000..95b6e7163 --- /dev/null +++ b/device/prj.conf.overlays/c2usb.conf @@ -0,0 +1,14 @@ +CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_NANO=y + +CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y +CONFIG_WARN_EXPERIMENTAL=n + +CONFIG_C2USB_UDC_MAC=y + +# Apply config requires deep stack, and since Agent expects response code, +# we can't just do it from the main thread +CONFIG_C2USB_UDC_MAC_THREAD_STACK_SIZE=2048 + +# needed as at suspend the msgq is flooded otherwise +CONFIG_C2USB_UDC_MAC_MSGQ_SIZE=32 diff --git a/device/prj.conf.overlays/nrf_shared.conf b/device/prj.conf.overlays/nrf_shared.conf new file mode 100644 index 000000000..6193e8f0f --- /dev/null +++ b/device/prj.conf.overlays/nrf_shared.conf @@ -0,0 +1,65 @@ +# Kconfig options to be shared across nRF52-based UHK devices +CONFIG_PINCTRL=y + +CONFIG_EXTRA_EXCEPTION_INFO=y +CONFIG_INIT_STACKS=y + +# CONFIG_NCS_SAMPLES_DEFAULTS: +CONFIG_LOG=y +CONFIG_ASSERT=y +CONFIG_ASSERT_NO_COND_INFO=y +CONFIG_ASSERT_NO_MSG_INFO=y +CONFIG_RESET_ON_FATAL_ERROR=y + +CONFIG_BT=y +# CONFIG_BT_DEBUG_LOG=y +CONFIG_BT_SMP=y + +CONFIG_BT_L2CAP_TX_BUF_COUNT=5 + +# negotiate larger MTU for NUS +CONFIG_BT_USER_DATA_LEN_UPDATE=y +CONFIG_BT_BUF_ACL_RX_SIZE=251 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_L2CAP_TX_MTU=247 + +# allow BLE buffering +CONFIG_BT_ATT_PREPARE_COUNT=4 + +# store BLE link keys in flash +CONFIG_BT_SETTINGS=y +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_FLASH_MAP=y +CONFIG_SETTINGS=y +CONFIG_NVS=y + +CONFIG_SERIAL=y + +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_UART_LINE_CTRL=y +CONFIG_UART_ASYNC_API=y + +# mainly shell related features +CONFIG_SHELL=y +CONFIG_SHELL_VT100_COMMANDS=y +CONFIG_SHELL_VT100_COLORS=y +CONFIG_BT_SHELL=y +CONFIG_SHELL_BT_NUS=y +CONFIG_HWINFO=y +CONFIG_HWINFO_SHELL=y +CONFIG_I2C=y +CONFIG_I2C_SHELL=y +CONFIG_STREAM_FLASH=y +CONFIG_SETTINGS_SHELL=y +CONFIG_SHELL_BACKENDS=y +CONFIG_SHELL_BACKEND_SERIAL=y + +CONFIG_BUILD_OUTPUT_HEX=y + +# mcuboot +CONFIG_BOOTLOADER_MCUBOOT=y +CONFIG_RETAINED_MEM=y +CONFIG_RETENTION=y +CONFIG_RETENTION_BOOT_MODE=y diff --git a/device/prj.conf.overlays/uhk-80-left.prj.conf b/device/prj.conf.overlays/uhk-80-left.prj.conf deleted file mode 100644 index 3fd36bc24..000000000 --- a/device/prj.conf.overlays/uhk-80-left.prj.conf +++ /dev/null @@ -1,15 +0,0 @@ -# DEVICE_ID_UHK80_LEFT -CONFIG_SPI=y -CONFIG_UART_1_ASYNC=y -CONFIG_UART_1_NRF_HW_ASYNC=y -CONFIG_UART_1_NRF_HW_ASYNC_TIMER=1 -CONFIG_ADC=y -CONFIG_UDC_NRF=y -CONFIG_BOOTLOADER_MCUBOOT=y -CONFIG_DEVICE_ID=3 -CONFIG_SHELL_PROMPT_UART="uhk80:left$ " -CONFIG_SHELL_PROMPT_RTT="uhk80:left$ " - -CONFIG_BT_DIS_MODEL="UHK 80 left half" -CONFIG_BT_DIS_PNP_PID=0x8007 -CONFIG_USB_PID=0x0007 diff --git a/device/prj.conf.overlays/uhk-80-right.prj.conf b/device/prj.conf.overlays/uhk-80-right.prj.conf deleted file mode 100644 index e848bdd57..000000000 --- a/device/prj.conf.overlays/uhk-80-right.prj.conf +++ /dev/null @@ -1,19 +0,0 @@ -# DEVICE_ID_UHK80_RIGHT -CONFIG_C2USB_BLUETOOTH=y -CONFIG_BT_KEYS_OVERWRITE_OLDEST=y -CONFIG_BT_KEYS_SAVE_AGING_COUNTER_ON_PAIRING=y - -CONFIG_SPI=y -CONFIG_UART_1_ASYNC=y -CONFIG_UART_1_NRF_HW_ASYNC=y -CONFIG_UART_1_NRF_HW_ASYNC_TIMER=1 -CONFIG_ADC=y -CONFIG_UDC_NRF=y -CONFIG_BOOTLOADER_MCUBOOT=y -CONFIG_DEVICE_ID=4 -CONFIG_SHELL_PROMPT_UART="uhk80:right$ " -CONFIG_SHELL_PROMPT_RTT="uhk80:right$ " - -CONFIG_BT_DIS_MODEL="UHK 80 right half" -CONFIG_BT_DIS_PNP_PID=0x8009 -CONFIG_USB_PID=0x0009 diff --git a/device/prj.conf.overlays/uhk-80.conf b/device/prj.conf.overlays/uhk-80.conf new file mode 100644 index 000000000..f6fdddf8a --- /dev/null +++ b/device/prj.conf.overlays/uhk-80.conf @@ -0,0 +1,13 @@ +# LEDs control +CONFIG_SPI=y + +# wired link between left and right +CONFIG_UART_LINE_CTRL=y +CONFIG_UART_ASYNC_API=y +CONFIG_UART_1_ASYNC=y +CONFIG_UART_1_NRF_HW_ASYNC=y +CONFIG_UART_1_NRF_HW_ASYNC_TIMER=1 +CONFIG_UART_1_INTERRUPT_DRIVEN=n + +# battery level measurement +CONFIG_ADC=y diff --git a/device/prj.conf.overlays/uhk-dongle.prj.conf b/device/prj.conf.overlays/uhk-dongle.prj.conf deleted file mode 100644 index 264ac82df..000000000 --- a/device/prj.conf.overlays/uhk-dongle.prj.conf +++ /dev/null @@ -1,12 +0,0 @@ -# DEVICE_ID_UHK_DONGLE -CONFIG_ADC=n -CONFIG_PWM=y -CONFIG_UDC_NRF=y -CONFIG_BOOTLOADER_MCUBOOT=y -CONFIG_DEVICE_ID=5 -CONFIG_SHELL_PROMPT_UART="uhk-dongle$ " -CONFIG_SHELL_PROMPT_RTT="uhk-dongle$ " - -CONFIG_BT_DIS_MODEL="UHK dongle" -CONFIG_BT_DIS_PNP_PID=0x8005 -CONFIG_USB_PID=0x0005 diff --git a/device/prj_release.conf b/device/prj_release.conf new file mode 100644 index 000000000..65fbfc689 --- /dev/null +++ b/device/prj_release.conf @@ -0,0 +1,5 @@ +# settings only for release build +CONFIG_USE_SEGGER_RTT=y +CONFIG_RTT_CONSOLE=y +CONFIG_SHELL_BACKEND_RTT=y +# CONFIG_LOG_BACKEND_RTT=y diff --git a/device/src/CMakeLists.txt b/device/src/CMakeLists.txt new file mode 100644 index 000000000..adf9d11d4 --- /dev/null +++ b/device/src/CMakeLists.txt @@ -0,0 +1,69 @@ +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + usb +) + +set(usb_cpp_sources + usb/app_base.cpp + usb/command_app.cpp + usb/controls_app.cpp + usb/gamepad_app.cpp + usb/hid_battery_app.cpp + usb/keyboard_app.cpp + usb/mouse_app.cpp + usb/usb_compatibility.cpp + usb/usb.cpp +) +file(GLOB_RECURSE keyboard_sources keyboard/*.c) +file(GLOB lvgl_dummy lvgl/*.c) + +if(NOT CONFIG_BOARD_UHK_60_RIGHT) + # C headers compiled with C++ give pointer conversion errors, turn them to warnings + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") + target_link_libraries(${PROJECT_NAME} PRIVATE + c2usb + ) + + target_sources(${PROJECT_NAME} PRIVATE + ${usb_cpp_sources} + bt_conn.c + bt_manager.c + bt_pair.c + debug_eventloop_timing.c + device_state.c + flash.c + logger.c + messenger_queue.c + messenger.c + settings.c + shell.c + stack_trace.c + state_sync.c + ) + if(CONFIG_BT_PERIPHERAL) + target_sources(${PROJECT_NAME} PRIVATE + bt_advertise.c + nus_server.c + ) + endif() + if(CONFIG_BT_CENTRAL) + target_sources(${PROJECT_NAME} PRIVATE + bt_scan.c + nus_client.c + ) + endif() + if(CONFIG_BOARD_UHK_DONGLE) + target_sources(${PROJECT_NAME} PRIVATE + dongle_leds.c + ) + else() + target_sources(${PROJECT_NAME} PRIVATE + ${keyboard_sources} + ) + if(CONFIG_BOARD_UHK_80_RIGHT) + target_sources(${PROJECT_NAME} PRIVATE + ${lvgl_dummy} + ) + endif() + endif() +endif() diff --git a/device/src/bt_conn.c b/device/src/bt_conn.c index ff468361c..037ea9076 100644 --- a/device/src/bt_conn.c +++ b/device/src/bt_conn.c @@ -1,14 +1,16 @@ #include #include #include +#ifdef CONFIG_BT_SCAN #include +#endif #include "bt_advertise.h" #include "bt_conn.h" #include "bt_scan.h" #include "device_state.h" #include "keyboard/oled/screens/screen_manager.h" #include "keyboard/oled/widgets/widget.h" -#include "legacy/host_connection.h" +#include "host_connection.h" #include "nus_client.h" #include "nus_server.h" #include "device.h" @@ -142,12 +144,12 @@ static void connected(struct bt_conn *conn, uint8_t err) { if (err) { printk("Failed to connect to %s, err %u\n", GetPeerStringByConn(conn), err); - if (DEVICE_IS_UHK80_RIGHT) { - err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE); - if (err) { - printk("Scanning failed to start (err %d)\n", err); - } +#if DEVICE_IS_UHK80_RIGHT + err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE); + if (err) { + printk("Scanning failed to start (err %d)\n", err); } +#endif return; } @@ -161,6 +163,9 @@ static void connected(struct bt_conn *conn, uint8_t err) { 100 // connection timeout (*10ms) ); bt_conn_le_param_update(conn, &conn_params); +#if DEVICE_IS_UHK80_RIGHT + USB_DisableHid(); +#endif } if (peerId == PeerIdUnknown) { @@ -170,13 +175,12 @@ static void connected(struct bt_conn *conn, uint8_t err) { assignPeer(bt_conn_get_dst(conn), peerId); if (peerId == PeerIdHid) { - // USB_DisableHid(); } else { bt_conn_set_security(conn, BT_SECURITY_L4); // continue connection process in in `connectionSecured()` } - if (DEVICE_IS_UHK80_RIGHT && (peerId == PeerIdHid || peerId == PeerIdUnknown || peerId == PeerIdDongle)) { + if (DEVICE_IS_UHK80_RIGHT && (peerId != PeerIdLeft)) { BtAdvertise_Start(BtAdvertise_Type()); } } @@ -191,7 +195,7 @@ static void disconnected(struct bt_conn *conn, uint8_t reason) { if (DEVICE_IS_UHK80_RIGHT) { if (peerId == PeerIdHid || peerId == PeerIdUnknown) { BtAdvertise_Start(BtAdvertise_Type()); - // USB_EnableHid(); + USB_EnableHid(); } if (peerId == PeerIdDongle) { BtAdvertise_Start(BtAdvertise_Type()); diff --git a/device/src/bt_conn_auth.c b/device/src/bt_conn_auth.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/device/src/bt_manager.c b/device/src/bt_manager.c index 6ef6684c0..7cd68f4dc 100644 --- a/device/src/bt_manager.c +++ b/device/src/bt_manager.c @@ -4,7 +4,7 @@ #include "bt_advertise.h" #include "nus_client.h" #include "nus_server.h" -#include "legacy/event_scheduler.h" +#include "event_scheduler.h" #include #include #include diff --git a/device/src/bt_pair.c b/device/src/bt_pair.c index dbb02ba71..3f19e7d05 100644 --- a/device/src/bt_pair.c +++ b/device/src/bt_pair.c @@ -7,11 +7,11 @@ #include #include "bt_conn.h" #include "bt_scan.h" -#include "legacy/event_scheduler.h" +#include "event_scheduler.h" #include "zephyr/kernel.h" #include "bt_manager.h" #include "bt_advertise.h" -#include "legacy/host_connection.h" +#include "host_connection.h" #include "settings.h" bool BtPair_LastPairingSucceeded = true; @@ -49,6 +49,7 @@ void BtPair_SetRemoteOob(const struct bt_le_oob* oob) { oobRemote = *oob; } +#ifdef CONFIG_BT_CENTRAL void BtPair_PairCentral() { pairingAsCentral = true; Settings_Reload(); @@ -57,7 +58,9 @@ void BtPair_PairCentral() { printk ("Scanning for pairable device\n"); EventScheduler_Reschedule(k_uptime_get_32() + PAIRING_TIMEOUT, EventSchedulerEvent_EndBtPairing, "Oob pairing timeout."); } +#endif +#ifdef CONFIG_BT_PERIPHERAL void BtPair_PairPeripheral() { pairingAsCentral = false; Settings_Reload(); @@ -66,6 +69,7 @@ void BtPair_PairPeripheral() { printk ("Waiting for central to pair to me.\n"); EventScheduler_Reschedule(k_uptime_get_32() + PAIRING_TIMEOUT, EventSchedulerEvent_EndBtPairing, "Oob pairing timeout."); } +#endif void BtPair_EndPairing(bool success, const char* msg) { printk("--- Pairing ended, success = %d: %s ---\n", success, msg); @@ -81,9 +85,13 @@ void BtPair_EndPairing(bool success, const char* msg) { EventScheduler_Unschedule(EventSchedulerEvent_EndBtPairing); if (pairingAsCentral) { +#ifdef CONFIG_BT_SCAN BtScan_Stop(); +#endif } else { +#ifdef CONFIG_BT_PERIPHERAL BtAdvertise_Stop(); +#endif } k_sleep(K_MSEC(100)); diff --git a/device/src/bt_scan.c b/device/src/bt_scan.c index a0c04de83..572dc550f 100644 --- a/device/src/bt_scan.c +++ b/device/src/bt_scan.c @@ -2,7 +2,7 @@ #include "bt_conn.h" #include "bt_pair.h" #include "device.h" -#include "legacy/host_connection.h" +#include "host_connection.h" static void scan_filter_match(struct bt_scan_device_info *device_info, struct bt_scan_filter_match *filter_match, bool connectable) diff --git a/device/src/debug_eventloop_timing.h b/device/src/debug_eventloop_timing.h index 02d0508e8..9238a8e1d 100644 --- a/device/src/debug_eventloop_timing.h +++ b/device/src/debug_eventloop_timing.h @@ -5,7 +5,7 @@ #include #include - #include "legacy/debug.h" + #include "debug.h" // Macros: diff --git a/device/src/device.h b/device/src/device.h deleted file mode 120000 index 7048efe19..000000000 --- a/device/src/device.h +++ /dev/null @@ -1 +0,0 @@ -../../shared/device.h \ No newline at end of file diff --git a/device/src/device_state.c b/device/src/device_state.c index d4f14d5bc..9ed03d174 100644 --- a/device/src/device_state.c +++ b/device/src/device_state.c @@ -3,11 +3,11 @@ #include "device.h" #include "keyboard/uart.h" #include "keyboard/oled/widgets/widgets.h" -#include "legacy/slave_drivers/uhk_module_driver.h" +#include "slave_drivers/uhk_module_driver.h" #include "state_sync.h" #include "shared/slave_protocol.h" -#include "legacy/event_scheduler.h" -#include "legacy/power_mode.h" +#include "event_scheduler.h" +#include "power_mode.h" #include "dongle_leds.h" static connection_type_t isConnected[ConnectionId_Count] = {}; diff --git a/device/src/dongle_leds.c b/device/src/dongle_leds.c index 10c9fa34b..f423d6e86 100644 --- a/device/src/dongle_leds.c +++ b/device/src/dongle_leds.c @@ -27,7 +27,7 @@ void DongleLeds_Set(bool r, bool g, bool b) { set_dongle_led(&blue_pwm_led, b ? 100 : 0); } -void DongleLeds_Update() { +void DongleLeds_Update(void) { if (DeviceState_IsConnected(ConnectionId_Right)) { DongleLeds_Set(false, true, false); return; diff --git a/device/src/dongle_leds.h b/device/src/dongle_leds.h index a4f158923..a5e1106f5 100644 --- a/device/src/dongle_leds.h +++ b/device/src/dongle_leds.h @@ -13,7 +13,7 @@ // Functions: extern void DongleLeds_Set(bool r, bool g, bool b); - extern void DongleLeds_Update(); + extern void DongleLeds_Update(void); extern void set_dongle_led(const struct pwm_dt_spec *device, uint8_t percentage); // Variables: diff --git a/device/src/flash.c b/device/src/flash.c index b6ed6295a..903e7ea69 100644 --- a/device/src/flash.c +++ b/device/src/flash.c @@ -1,5 +1,5 @@ #include "flash.h" -#include "legacy/storage.h" +#include "storage.h" #include const struct flash_area *hardwareConfigArea; diff --git a/device/src/keyboard/charger.c b/device/src/keyboard/charger.c index 6bc87c64b..2c85073bc 100644 --- a/device/src/keyboard/charger.c +++ b/device/src/keyboard/charger.c @@ -4,11 +4,13 @@ #include "charger.h" #include "keyboard/charger.h" #include "shell.h" -#include "legacy/timer.h" +#include "timer.h" #include "attributes.h" -#include "legacy/event_scheduler.h" +#include "event_scheduler.h" #include "state_sync.h" #include +#include "device.h" +#include const struct gpio_dt_spec chargerEnDt = GPIO_DT_SPEC_GET(DT_ALIAS(charger_en), gpios); const struct gpio_dt_spec chargerStatDt = GPIO_DT_SPEC_GET(DT_ALIAS(charger_stat), gpios); @@ -121,6 +123,14 @@ void Charger_UpdateBatteryState() { if (stateChanged) { StateSync_UpdateProperty(StateSyncPropertyId_Battery, &batteryState); + +#ifdef CONFIG_BT_BAS + bt_bas_set_battery_level(batteryState.batteryPercentage); +#endif +#if DEVICE_HAS_BATTERY + extern void HID_SetBatteryStatus(uint8_t remaining_capacity, bool charging); + HID_SetBatteryStatus(batteryState.batteryPercentage, batteryState.batteryCharging); +#endif } } diff --git a/device/src/keyboard/i2c.c b/device/src/keyboard/i2c.c index 30f77cb44..b45106fa1 100644 --- a/device/src/keyboard/i2c.c +++ b/device/src/keyboard/i2c.c @@ -2,11 +2,11 @@ #include #include "device.h" #include "i2c_compatibility.h" -#include "legacy/timer.h" +#include "timer.h" #include "shared/slave_protocol.h" -#include "legacy/slave_scheduler.h" -#include "legacy/slave_drivers/uhk_module_driver.h" -#include "legacy/i2c.h" +#include "slave_scheduler.h" +#include "slave_drivers/uhk_module_driver.h" +#include "i2c.h" #include "keyboard/i2c.h" // Thread definitions diff --git a/device/src/keyboard/input_interceptor.h b/device/src/keyboard/input_interceptor.h index 869d7fee8..e7f59fa2d 100644 --- a/device/src/keyboard/input_interceptor.h +++ b/device/src/keyboard/input_interceptor.h @@ -5,7 +5,7 @@ #include #include - #include "legacy/usb_interfaces/usb_interface_basic_keyboard.h" + #include "usb_interfaces/usb_interface_basic_keyboard.h" // Macros: diff --git a/device/src/keyboard/key_scanner.c b/device/src/keyboard/key_scanner.c index 5b222d72e..d85b30d6c 100644 --- a/device/src/keyboard/key_scanner.c +++ b/device/src/keyboard/key_scanner.c @@ -11,17 +11,17 @@ #include "logger.h" #include "key_states.h" #include "bool_array_converter.h" -#include "legacy/module.h" +#include "module.h" #include "logger.h" #include "messenger.h" #include "device.h" -#include "legacy/event_scheduler.h" +#include "event_scheduler.h" #include "main.h" -#include "legacy/config_manager.h" -#include "legacy/macros/keyid_parser.h" +#include "config_manager.h" +#include "macros/keyid_parser.h" #include "attributes.h" -#include "legacy/layouts/key_layout.h" -#include "legacy/layouts/key_layout_80_to_universal.h" +#include "layouts/key_layout.h" +#include "layouts/key_layout_80_to_universal.h" // Thread definitions diff --git a/device/src/keyboard/leds.c b/device/src/keyboard/leds.c index ea82d1c80..dcb1ec79e 100644 --- a/device/src/keyboard/leds.c +++ b/device/src/keyboard/leds.c @@ -5,8 +5,8 @@ #include "leds.h" #include "shell.h" #include "keyboard/key_scanner.h" -#include "legacy/ledmap.h" -#include "legacy/slave_drivers/is31fl3xxx_driver.h" +#include "ledmap.h" +#include "slave_drivers/is31fl3xxx_driver.h" // Thread definitions diff --git a/device/src/keyboard/legacy_ports.h b/device/src/keyboard/legacy_ports.h deleted file mode 100644 index 466b51f59..000000000 --- a/device/src/keyboard/legacy_ports.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __LEGACY_PORTS_H__ -#define __LEGACY_PORTS_H__ - -// Typedefs: - -#ifdef __ZEPHYR__ - typedef enum _usb_status - { - kStatus_USB_Success = 0x00U, /*!< Success */ - kStatus_USB_Error, /*!< Failed */ - - kStatus_USB_Busy, /*!< Busy */ - kStatus_USB_InvalidHandle, /*!< Invalid handle */ - kStatus_USB_InvalidParameter, /*!< Invalid parameter */ - kStatus_USB_InvalidRequest, /*!< Invalid request */ - kStatus_USB_ControllerNotFound, /*!< Controller cannot be found */ - kStatus_USB_InvalidControllerInterface, /*!< Invalid controller interface */ - - kStatus_USB_NotSupported, /*!< Configuration is not supported */ - kStatus_USB_Retry, /*!< Enumeration get configuration retry */ - kStatus_USB_TransferStall, /*!< Transfer stalled */ - kStatus_USB_TransferFailed, /*!< Transfer failed */ - kStatus_USB_AllocFail, /*!< Allocation failed */ - kStatus_USB_LackSwapBuffer, /*!< Insufficient swap buffer for KHCI */ - kStatus_USB_TransferCancel, /*!< The transfer cancelled */ - kStatus_USB_BandwidthFail, /*!< Allocate bandwidth failed */ - kStatus_USB_MSDStatusFail, /*!< For MSD, the CSW status means fail */ - } usb_status_t; - - typedef uint8_t usb_hid_protocol_t; -#endif - -#endif diff --git a/device/src/keyboard/oled/framebuffer.h b/device/src/keyboard/oled/framebuffer.h index 660c5ca60..a7fae825e 100644 --- a/device/src/keyboard/oled/framebuffer.h +++ b/device/src/keyboard/oled/framebuffer.h @@ -6,7 +6,7 @@ #include "oled_display.h" #include #include - #include "legacy/led_display.h" + #include "led_display.h" #include // Macros: diff --git a/device/src/keyboard/oled/oled.c b/device/src/keyboard/oled/oled.c index 66c6c276f..d2c8fb9bf 100644 --- a/device/src/keyboard/oled/oled.c +++ b/device/src/keyboard/oled/oled.c @@ -4,9 +4,9 @@ #include "oled_display.h" #include "oled_buffer.h" #include "screens/screen_manager.h" -#include "legacy/event_scheduler.h" -#include "legacy/timer.h" -#include "legacy/led_manager.h" +#include "event_scheduler.h" +#include "timer.h" +#include "led_manager.h" #include "keyboard/oled/screens/screens.h" #if DEVICE_HAS_OLED diff --git a/device/src/keyboard/oled/oled_text_renderer.c b/device/src/keyboard/oled/oled_text_renderer.c index 773a4f02f..7fefd1ac3 100644 --- a/device/src/keyboard/oled/oled_text_renderer.c +++ b/device/src/keyboard/oled/oled_text_renderer.c @@ -10,7 +10,7 @@ #include "widgets/widget.h" #include #include -#include "legacy/str_utils.h" +#include "str_utils.h" static int16_t computeAlignment(int16_t width, int16_t objectWidth, int16_t alignment) { diff --git a/device/src/keyboard/oled/screens/pairing_screen.c b/device/src/keyboard/oled/screens/pairing_screen.c index f4c2bf809..06962b380 100644 --- a/device/src/keyboard/oled/screens/pairing_screen.c +++ b/device/src/keyboard/oled/screens/pairing_screen.c @@ -4,10 +4,10 @@ #include "keyboard/oled/oled.h" #include "keyboard/oled/oled_buffer.h" #include "logger.h" -#include "legacy/lufa/HIDClassCommon.h" +#include "lufa/HIDClassCommon.h" #include "bt_conn.h" #include "screen_manager.h" -#include "legacy/key_action.h" +#include "key_action.h" static widget_t splitterWidget; static widget_t questionLine; diff --git a/device/src/keyboard/oled/screens/pairing_screen.h b/device/src/keyboard/oled/screens/pairing_screen.h index 2daaa5bb6..1115694ca 100644 --- a/device/src/keyboard/oled/screens/pairing_screen.h +++ b/device/src/keyboard/oled/screens/pairing_screen.h @@ -6,7 +6,7 @@ #include #include #include "../widgets/widget.h" - #include "legacy/key_action.h" + #include "key_action.h" // Macros: diff --git a/device/src/keyboard/oled/screens/screen_manager.c b/device/src/keyboard/oled/screens/screen_manager.c index 7b23abf4a..8c79d9d30 100644 --- a/device/src/keyboard/oled/screens/screen_manager.c +++ b/device/src/keyboard/oled/screens/screen_manager.c @@ -3,11 +3,11 @@ #include "keyboard/oled/widgets/widgets.h" #include "keyboard/oled/screens/screens.h" #include "keyboard/oled/oled.h" -#include "legacy/timer.h" -#include "legacy/event_scheduler.h" -#include "legacy/timer.h" -#include "legacy/event_scheduler.h" -#include "legacy/ledmap.h" +#include "timer.h" +#include "event_scheduler.h" +#include "timer.h" +#include "event_scheduler.h" +#include "ledmap.h" screen_id_t ActiveScreen = ScreenId_Main; diff --git a/device/src/keyboard/oled/widgets/text_widget.c b/device/src/keyboard/oled/widgets/text_widget.c index e3e89e1d7..418e8557b 100644 --- a/device/src/keyboard/oled/widgets/text_widget.c +++ b/device/src/keyboard/oled/widgets/text_widget.c @@ -2,7 +2,7 @@ #include "keyboard/oled/widgets/widgets.h" #include "keyboard/oled/oled.h" #include -#include "legacy/str_utils.h" +#include "str_utils.h" void TextWidget_Draw(widget_t* self, framebuffer_t* buffer) { diff --git a/device/src/keyboard/oled/widgets/widget.h b/device/src/keyboard/oled/widgets/widget.h index 1a140d0c6..69db6eea4 100644 --- a/device/src/keyboard/oled/widgets/widget.h +++ b/device/src/keyboard/oled/widgets/widget.h @@ -7,7 +7,7 @@ #include #include "../framebuffer.h" #include "keyboard/oled/fonts/fonts.h" - #include "legacy/str_utils.h" + #include "str_utils.h" // Macros: diff --git a/device/src/keyboard/oled/widgets/widget_store.c b/device/src/keyboard/oled/widgets/widget_store.c index 2d682104a..ac4e50d7f 100644 --- a/device/src/keyboard/oled/widgets/widget_store.c +++ b/device/src/keyboard/oled/widgets/widget_store.c @@ -8,10 +8,10 @@ #include "keyboard/oled/oled_text_renderer.h" #include "text_widget.h" #include "widget.h" -#include "legacy/keymap.h" -#include "legacy/layer.h" -#include "legacy/layer_switcher.h" -#include "legacy/str_utils.h" +#include "keymap.h" +#include "layer.h" +#include "layer_switcher.h" +#include "str_utils.h" #include "keyboard/uart.h" #include "bt_conn.h" #include "state_sync.h" diff --git a/device/src/keyboard/uart.c b/device/src/keyboard/uart.c index a6a7f3621..e38e74f8f 100644 --- a/device/src/keyboard/uart.c +++ b/device/src/keyboard/uart.c @@ -1,13 +1,13 @@ #include #include -#include "legacy/timer.h" +#include "timer.h" #include "uart.h" #include "messenger.h" #include "messenger_queue.h" #include "device.h" #include "device_state.h" -#include "legacy/debug.h" -#include "legacy/event_scheduler.h" +#include "debug.h" +#include "event_scheduler.h" // Thread definitions diff --git a/device/src/legacy/arduino_hid/ConsumerAPI.h b/device/src/legacy/arduino_hid/ConsumerAPI.h deleted file mode 120000 index 81839e6f1..000000000 --- a/device/src/legacy/arduino_hid/ConsumerAPI.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/arduino_hid/ConsumerAPI.h \ No newline at end of file diff --git a/device/src/legacy/arduino_hid/SystemAPI.h b/device/src/legacy/arduino_hid/SystemAPI.h deleted file mode 120000 index f6a065be8..000000000 --- a/device/src/legacy/arduino_hid/SystemAPI.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/arduino_hid/SystemAPI.h \ No newline at end of file diff --git a/device/src/legacy/caret_config.c b/device/src/legacy/caret_config.c deleted file mode 120000 index c4eda29e4..000000000 --- a/device/src/legacy/caret_config.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/caret_config.c \ No newline at end of file diff --git a/device/src/legacy/caret_config.h b/device/src/legacy/caret_config.h deleted file mode 120000 index 1b5fa2fb3..000000000 --- a/device/src/legacy/caret_config.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/caret_config.h \ No newline at end of file diff --git a/device/src/legacy/config_manager.c b/device/src/legacy/config_manager.c deleted file mode 120000 index 454030746..000000000 --- a/device/src/legacy/config_manager.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/config_manager.c \ No newline at end of file diff --git a/device/src/legacy/config_manager.h b/device/src/legacy/config_manager.h deleted file mode 120000 index fa3bffa45..000000000 --- a/device/src/legacy/config_manager.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/config_manager.h \ No newline at end of file diff --git a/device/src/legacy/config_parser/basic_types.c b/device/src/legacy/config_parser/basic_types.c deleted file mode 120000 index af120a88d..000000000 --- a/device/src/legacy/config_parser/basic_types.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/basic_types.c \ No newline at end of file diff --git a/device/src/legacy/config_parser/basic_types.h b/device/src/legacy/config_parser/basic_types.h deleted file mode 120000 index 49c15dae4..000000000 --- a/device/src/legacy/config_parser/basic_types.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/basic_types.h \ No newline at end of file diff --git a/device/src/legacy/config_parser/config_globals.c b/device/src/legacy/config_parser/config_globals.c deleted file mode 120000 index a12d48b8a..000000000 --- a/device/src/legacy/config_parser/config_globals.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/config_globals.c \ No newline at end of file diff --git a/device/src/legacy/config_parser/config_globals.h b/device/src/legacy/config_parser/config_globals.h deleted file mode 120000 index 5dc84014b..000000000 --- a/device/src/legacy/config_parser/config_globals.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/config_globals.h \ No newline at end of file diff --git a/device/src/legacy/config_parser/error_reporting.c b/device/src/legacy/config_parser/error_reporting.c deleted file mode 120000 index fefc49287..000000000 --- a/device/src/legacy/config_parser/error_reporting.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/error_reporting.c \ No newline at end of file diff --git a/device/src/legacy/config_parser/error_reporting.h b/device/src/legacy/config_parser/error_reporting.h deleted file mode 120000 index cad46a086..000000000 --- a/device/src/legacy/config_parser/error_reporting.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/error_reporting.h \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_config.c b/device/src/legacy/config_parser/parse_config.c deleted file mode 120000 index 9f022856b..000000000 --- a/device/src/legacy/config_parser/parse_config.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_config.c \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_config.h b/device/src/legacy/config_parser/parse_config.h deleted file mode 120000 index a8aecc277..000000000 --- a/device/src/legacy/config_parser/parse_config.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_config.h \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_host_connection.c b/device/src/legacy/config_parser/parse_host_connection.c deleted file mode 120000 index 734ff0120..000000000 --- a/device/src/legacy/config_parser/parse_host_connection.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_host_connection.c \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_host_connection.h b/device/src/legacy/config_parser/parse_host_connection.h deleted file mode 120000 index 7155652c4..000000000 --- a/device/src/legacy/config_parser/parse_host_connection.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_host_connection.h \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_keymap.c b/device/src/legacy/config_parser/parse_keymap.c deleted file mode 120000 index 63cf99fff..000000000 --- a/device/src/legacy/config_parser/parse_keymap.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_keymap.c \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_keymap.h b/device/src/legacy/config_parser/parse_keymap.h deleted file mode 120000 index 5a4447a10..000000000 --- a/device/src/legacy/config_parser/parse_keymap.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_keymap.h \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_macro.c b/device/src/legacy/config_parser/parse_macro.c deleted file mode 120000 index bc869228f..000000000 --- a/device/src/legacy/config_parser/parse_macro.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_macro.c \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_macro.h b/device/src/legacy/config_parser/parse_macro.h deleted file mode 120000 index e37827061..000000000 --- a/device/src/legacy/config_parser/parse_macro.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_macro.h \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_module_config.c b/device/src/legacy/config_parser/parse_module_config.c deleted file mode 120000 index 2fd3971bb..000000000 --- a/device/src/legacy/config_parser/parse_module_config.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_module_config.c \ No newline at end of file diff --git a/device/src/legacy/config_parser/parse_module_config.h b/device/src/legacy/config_parser/parse_module_config.h deleted file mode 120000 index 1abf9e4d6..000000000 --- a/device/src/legacy/config_parser/parse_module_config.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/config_parser/parse_module_config.h \ No newline at end of file diff --git a/device/src/legacy/debug.c b/device/src/legacy/debug.c deleted file mode 120000 index 6be27d501..000000000 --- a/device/src/legacy/debug.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/debug.c \ No newline at end of file diff --git a/device/src/legacy/debug.h b/device/src/legacy/debug.h deleted file mode 120000 index cb3eb62dc..000000000 --- a/device/src/legacy/debug.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/debug.h \ No newline at end of file diff --git a/device/src/legacy/eeprom.c b/device/src/legacy/eeprom.c deleted file mode 120000 index 1ea632f18..000000000 --- a/device/src/legacy/eeprom.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/eeprom.c \ No newline at end of file diff --git a/device/src/legacy/eeprom.h b/device/src/legacy/eeprom.h deleted file mode 120000 index 7997074cb..000000000 --- a/device/src/legacy/eeprom.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/eeprom.h \ No newline at end of file diff --git a/device/src/legacy/event_scheduler.c b/device/src/legacy/event_scheduler.c deleted file mode 120000 index 5774cae3c..000000000 --- a/device/src/legacy/event_scheduler.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/event_scheduler.c \ No newline at end of file diff --git a/device/src/legacy/event_scheduler.h b/device/src/legacy/event_scheduler.h deleted file mode 120000 index 6f073e3a9..000000000 --- a/device/src/legacy/event_scheduler.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/event_scheduler.h \ No newline at end of file diff --git a/device/src/legacy/host_connection.c b/device/src/legacy/host_connection.c deleted file mode 120000 index 946909088..000000000 --- a/device/src/legacy/host_connection.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/host_connection.c \ No newline at end of file diff --git a/device/src/legacy/host_connection.h b/device/src/legacy/host_connection.h deleted file mode 120000 index bf11f4788..000000000 --- a/device/src/legacy/host_connection.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/host_connection.h \ No newline at end of file diff --git a/device/src/legacy/i2c.c b/device/src/legacy/i2c.c deleted file mode 120000 index cf7045b2e..000000000 --- a/device/src/legacy/i2c.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/i2c.c \ No newline at end of file diff --git a/device/src/legacy/i2c.h b/device/src/legacy/i2c.h deleted file mode 120000 index 9044e8779..000000000 --- a/device/src/legacy/i2c.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/i2c.h \ No newline at end of file diff --git a/device/src/legacy/i2c_error_logger.c b/device/src/legacy/i2c_error_logger.c deleted file mode 120000 index c96f860b0..000000000 --- a/device/src/legacy/i2c_error_logger.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/i2c_error_logger.c \ No newline at end of file diff --git a/device/src/legacy/i2c_error_logger.h b/device/src/legacy/i2c_error_logger.h deleted file mode 120000 index f6ca55391..000000000 --- a/device/src/legacy/i2c_error_logger.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/i2c_error_logger.h \ No newline at end of file diff --git a/device/src/legacy/key_action.h b/device/src/legacy/key_action.h deleted file mode 120000 index bbd6a30d2..000000000 --- a/device/src/legacy/key_action.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/key_action.h \ No newline at end of file diff --git a/device/src/legacy/key_states.c b/device/src/legacy/key_states.c deleted file mode 120000 index 7f380b228..000000000 --- a/device/src/legacy/key_states.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/key_states.c \ No newline at end of file diff --git a/device/src/legacy/key_states.h b/device/src/legacy/key_states.h deleted file mode 120000 index 621f46b76..000000000 --- a/device/src/legacy/key_states.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/key_states.h \ No newline at end of file diff --git a/device/src/legacy/keymap.c b/device/src/legacy/keymap.c deleted file mode 120000 index d11056c26..000000000 --- a/device/src/legacy/keymap.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/keymap.c \ No newline at end of file diff --git a/device/src/legacy/keymap.h b/device/src/legacy/keymap.h deleted file mode 120000 index 4166ab564..000000000 --- a/device/src/legacy/keymap.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/keymap.h \ No newline at end of file diff --git a/device/src/legacy/layer.c b/device/src/legacy/layer.c deleted file mode 120000 index 2b70d7530..000000000 --- a/device/src/legacy/layer.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/layer.c \ No newline at end of file diff --git a/device/src/legacy/layer.h b/device/src/legacy/layer.h deleted file mode 120000 index d071a4f0f..000000000 --- a/device/src/legacy/layer.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/layer.h \ No newline at end of file diff --git a/device/src/legacy/layer_stack.c b/device/src/legacy/layer_stack.c deleted file mode 120000 index e80288390..000000000 --- a/device/src/legacy/layer_stack.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/layer_stack.c \ No newline at end of file diff --git a/device/src/legacy/layer_stack.h b/device/src/legacy/layer_stack.h deleted file mode 120000 index ceedd56c8..000000000 --- a/device/src/legacy/layer_stack.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/layer_stack.h \ No newline at end of file diff --git a/device/src/legacy/layer_switcher.c b/device/src/legacy/layer_switcher.c deleted file mode 120000 index 39cf6b2e0..000000000 --- a/device/src/legacy/layer_switcher.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/layer_switcher.c \ No newline at end of file diff --git a/device/src/legacy/layer_switcher.h b/device/src/legacy/layer_switcher.h deleted file mode 120000 index 873becff4..000000000 --- a/device/src/legacy/layer_switcher.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/layer_switcher.h \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout.c b/device/src/legacy/layouts/key_layout.c deleted file mode 120000 index cebed70f0..000000000 --- a/device/src/legacy/layouts/key_layout.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/layouts/key_layout.c \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout.h b/device/src/legacy/layouts/key_layout.h deleted file mode 120000 index 4a2a0807a..000000000 --- a/device/src/legacy/layouts/key_layout.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/layouts/key_layout.h \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout_60_to_universal.c b/device/src/legacy/layouts/key_layout_60_to_universal.c deleted file mode 120000 index 28f4b7df9..000000000 --- a/device/src/legacy/layouts/key_layout_60_to_universal.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/layouts/key_layout_60_to_universal.c \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout_60_to_universal.h b/device/src/legacy/layouts/key_layout_60_to_universal.h deleted file mode 120000 index 78f0fa4c2..000000000 --- a/device/src/legacy/layouts/key_layout_60_to_universal.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/layouts/key_layout_60_to_universal.h \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout_80_to_universal.c b/device/src/legacy/layouts/key_layout_80_to_universal.c deleted file mode 120000 index 745f8a106..000000000 --- a/device/src/legacy/layouts/key_layout_80_to_universal.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/layouts/key_layout_80_to_universal.c \ No newline at end of file diff --git a/device/src/legacy/layouts/key_layout_80_to_universal.h b/device/src/legacy/layouts/key_layout_80_to_universal.h deleted file mode 120000 index 0046c71e6..000000000 --- a/device/src/legacy/layouts/key_layout_80_to_universal.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/layouts/key_layout_80_to_universal.h \ No newline at end of file diff --git a/device/src/legacy/led_display.c b/device/src/legacy/led_display.c deleted file mode 120000 index 5d4d891f5..000000000 --- a/device/src/legacy/led_display.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/led_display.c \ No newline at end of file diff --git a/device/src/legacy/led_display.h b/device/src/legacy/led_display.h deleted file mode 120000 index b7bedb476..000000000 --- a/device/src/legacy/led_display.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/led_display.h \ No newline at end of file diff --git a/device/src/legacy/led_manager.c b/device/src/legacy/led_manager.c deleted file mode 120000 index 6277120f7..000000000 --- a/device/src/legacy/led_manager.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/led_manager.c \ No newline at end of file diff --git a/device/src/legacy/led_manager.h b/device/src/legacy/led_manager.h deleted file mode 120000 index 1de3c2d1a..000000000 --- a/device/src/legacy/led_manager.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/led_manager.h \ No newline at end of file diff --git a/device/src/legacy/ledmap.c b/device/src/legacy/ledmap.c deleted file mode 120000 index 2e911d84d..000000000 --- a/device/src/legacy/ledmap.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/ledmap.c \ No newline at end of file diff --git a/device/src/legacy/ledmap.h b/device/src/legacy/ledmap.h deleted file mode 120000 index 59c7548b6..000000000 --- a/device/src/legacy/ledmap.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/ledmap.h \ No newline at end of file diff --git a/device/src/legacy/lufa/HIDClassCommon.h b/device/src/legacy/lufa/HIDClassCommon.h deleted file mode 120000 index b268be5fd..000000000 --- a/device/src/legacy/lufa/HIDClassCommon.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/lufa/HIDClassCommon.h \ No newline at end of file diff --git a/device/src/legacy/macro_events.c b/device/src/legacy/macro_events.c deleted file mode 120000 index dacf1fc46..000000000 --- a/device/src/legacy/macro_events.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/macro_events.c \ No newline at end of file diff --git a/device/src/legacy/macro_events.h b/device/src/legacy/macro_events.h deleted file mode 120000 index 4da8f0669..000000000 --- a/device/src/legacy/macro_events.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/macro_events.h \ No newline at end of file diff --git a/device/src/legacy/macro_recorder.c b/device/src/legacy/macro_recorder.c deleted file mode 120000 index 9aaa6fdf0..000000000 --- a/device/src/legacy/macro_recorder.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/macro_recorder.c \ No newline at end of file diff --git a/device/src/legacy/macro_recorder.h b/device/src/legacy/macro_recorder.h deleted file mode 120000 index 2979f89ab..000000000 --- a/device/src/legacy/macro_recorder.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/macro_recorder.h \ No newline at end of file diff --git a/device/src/legacy/macros/commands.c b/device/src/legacy/macros/commands.c deleted file mode 120000 index 5632ee0b6..000000000 --- a/device/src/legacy/macros/commands.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/commands.c \ No newline at end of file diff --git a/device/src/legacy/macros/commands.h b/device/src/legacy/macros/commands.h deleted file mode 120000 index 84b66d3ea..000000000 --- a/device/src/legacy/macros/commands.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/commands.h \ No newline at end of file diff --git a/device/src/legacy/macros/core.c b/device/src/legacy/macros/core.c deleted file mode 120000 index ced86e042..000000000 --- a/device/src/legacy/macros/core.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/core.c \ No newline at end of file diff --git a/device/src/legacy/macros/core.h b/device/src/legacy/macros/core.h deleted file mode 120000 index c4ec995ef..000000000 --- a/device/src/legacy/macros/core.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/core.h \ No newline at end of file diff --git a/device/src/legacy/macros/debug_commands.c b/device/src/legacy/macros/debug_commands.c deleted file mode 120000 index 51f3630d6..000000000 --- a/device/src/legacy/macros/debug_commands.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/debug_commands.c \ No newline at end of file diff --git a/device/src/legacy/macros/debug_commands.h b/device/src/legacy/macros/debug_commands.h deleted file mode 120000 index 18963497a..000000000 --- a/device/src/legacy/macros/debug_commands.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/debug_commands.h \ No newline at end of file diff --git a/device/src/legacy/macros/key_timing.c b/device/src/legacy/macros/key_timing.c deleted file mode 120000 index 0bd987b55..000000000 --- a/device/src/legacy/macros/key_timing.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/key_timing.c \ No newline at end of file diff --git a/device/src/legacy/macros/key_timing.h b/device/src/legacy/macros/key_timing.h deleted file mode 120000 index f9ff340bd..000000000 --- a/device/src/legacy/macros/key_timing.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/key_timing.h \ No newline at end of file diff --git a/device/src/legacy/macros/keyid_parser.c b/device/src/legacy/macros/keyid_parser.c deleted file mode 120000 index 8257aef8b..000000000 --- a/device/src/legacy/macros/keyid_parser.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/keyid_parser.c \ No newline at end of file diff --git a/device/src/legacy/macros/keyid_parser.h b/device/src/legacy/macros/keyid_parser.h deleted file mode 120000 index c0c6dc037..000000000 --- a/device/src/legacy/macros/keyid_parser.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/keyid_parser.h \ No newline at end of file diff --git a/device/src/legacy/macros/scancode_commands.c b/device/src/legacy/macros/scancode_commands.c deleted file mode 120000 index d5b2fe4f5..000000000 --- a/device/src/legacy/macros/scancode_commands.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/scancode_commands.c \ No newline at end of file diff --git a/device/src/legacy/macros/scancode_commands.h b/device/src/legacy/macros/scancode_commands.h deleted file mode 120000 index d7f2bc7a9..000000000 --- a/device/src/legacy/macros/scancode_commands.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/scancode_commands.h \ No newline at end of file diff --git a/device/src/legacy/macros/set_command.c b/device/src/legacy/macros/set_command.c deleted file mode 120000 index 1de4b5b69..000000000 --- a/device/src/legacy/macros/set_command.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/set_command.c \ No newline at end of file diff --git a/device/src/legacy/macros/set_command.h b/device/src/legacy/macros/set_command.h deleted file mode 120000 index a27dede42..000000000 --- a/device/src/legacy/macros/set_command.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/set_command.h \ No newline at end of file diff --git a/device/src/legacy/macros/shortcut_parser.c b/device/src/legacy/macros/shortcut_parser.c deleted file mode 120000 index 98374cde5..000000000 --- a/device/src/legacy/macros/shortcut_parser.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/shortcut_parser.c \ No newline at end of file diff --git a/device/src/legacy/macros/shortcut_parser.h b/device/src/legacy/macros/shortcut_parser.h deleted file mode 120000 index 85c1a1f59..000000000 --- a/device/src/legacy/macros/shortcut_parser.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/shortcut_parser.h \ No newline at end of file diff --git a/device/src/legacy/macros/status_buffer.c b/device/src/legacy/macros/status_buffer.c deleted file mode 120000 index 0d4ab7b3f..000000000 --- a/device/src/legacy/macros/status_buffer.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/status_buffer.c \ No newline at end of file diff --git a/device/src/legacy/macros/status_buffer.h b/device/src/legacy/macros/status_buffer.h deleted file mode 120000 index 43467817c..000000000 --- a/device/src/legacy/macros/status_buffer.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/status_buffer.h \ No newline at end of file diff --git a/device/src/legacy/macros/string_reader.c b/device/src/legacy/macros/string_reader.c deleted file mode 120000 index 63925fe21..000000000 --- a/device/src/legacy/macros/string_reader.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/string_reader.c \ No newline at end of file diff --git a/device/src/legacy/macros/string_reader.h b/device/src/legacy/macros/string_reader.h deleted file mode 120000 index 42e34ce02..000000000 --- a/device/src/legacy/macros/string_reader.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/string_reader.h \ No newline at end of file diff --git a/device/src/legacy/macros/typedefs.h b/device/src/legacy/macros/typedefs.h deleted file mode 120000 index b22048007..000000000 --- a/device/src/legacy/macros/typedefs.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/typedefs.h \ No newline at end of file diff --git a/device/src/legacy/macros/vars.c b/device/src/legacy/macros/vars.c deleted file mode 120000 index 2f8d5d222..000000000 --- a/device/src/legacy/macros/vars.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/vars.c \ No newline at end of file diff --git a/device/src/legacy/macros/vars.h b/device/src/legacy/macros/vars.h deleted file mode 120000 index 995c88cee..000000000 --- a/device/src/legacy/macros/vars.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/macros/vars.h \ No newline at end of file diff --git a/device/src/legacy/module.c b/device/src/legacy/module.c deleted file mode 120000 index 080022091..000000000 --- a/device/src/legacy/module.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/module.c \ No newline at end of file diff --git a/device/src/legacy/module.h b/device/src/legacy/module.h deleted file mode 120000 index 904998ba5..000000000 --- a/device/src/legacy/module.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/module.h \ No newline at end of file diff --git a/device/src/legacy/mouse_controller.c b/device/src/legacy/mouse_controller.c deleted file mode 120000 index 44d2a3e32..000000000 --- a/device/src/legacy/mouse_controller.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/mouse_controller.c \ No newline at end of file diff --git a/device/src/legacy/mouse_controller.h b/device/src/legacy/mouse_controller.h deleted file mode 120000 index f78e06abd..000000000 --- a/device/src/legacy/mouse_controller.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/mouse_controller.h \ No newline at end of file diff --git a/device/src/legacy/mouse_keys.c b/device/src/legacy/mouse_keys.c deleted file mode 120000 index d469e3035..000000000 --- a/device/src/legacy/mouse_keys.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/mouse_keys.c \ No newline at end of file diff --git a/device/src/legacy/mouse_keys.h b/device/src/legacy/mouse_keys.h deleted file mode 120000 index 6ce6a2ba5..000000000 --- a/device/src/legacy/mouse_keys.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/mouse_keys.h \ No newline at end of file diff --git a/device/src/legacy/peripherals/led_driver.h b/device/src/legacy/peripherals/led_driver.h deleted file mode 120000 index bd82f18eb..000000000 --- a/device/src/legacy/peripherals/led_driver.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/peripherals/led_driver.h \ No newline at end of file diff --git a/device/src/legacy/peripherals/merge_sensor.c b/device/src/legacy/peripherals/merge_sensor.c deleted file mode 120000 index 307d15742..000000000 --- a/device/src/legacy/peripherals/merge_sensor.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/peripherals/merge_sensor.c \ No newline at end of file diff --git a/device/src/legacy/peripherals/merge_sensor.h b/device/src/legacy/peripherals/merge_sensor.h deleted file mode 120000 index ee59348ab..000000000 --- a/device/src/legacy/peripherals/merge_sensor.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/peripherals/merge_sensor.h \ No newline at end of file diff --git a/device/src/legacy/peripherals/reset_button.c b/device/src/legacy/peripherals/reset_button.c deleted file mode 120000 index 9b11b0275..000000000 --- a/device/src/legacy/peripherals/reset_button.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/peripherals/reset_button.c \ No newline at end of file diff --git a/device/src/legacy/peripherals/reset_button.h b/device/src/legacy/peripherals/reset_button.h deleted file mode 120000 index 1dc4091ce..000000000 --- a/device/src/legacy/peripherals/reset_button.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/peripherals/reset_button.h \ No newline at end of file diff --git a/device/src/legacy/postponer.c b/device/src/legacy/postponer.c deleted file mode 120000 index 2cd8a6571..000000000 --- a/device/src/legacy/postponer.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/postponer.c \ No newline at end of file diff --git a/device/src/legacy/postponer.h b/device/src/legacy/postponer.h deleted file mode 120000 index 6cee20cbb..000000000 --- a/device/src/legacy/postponer.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/postponer.h \ No newline at end of file diff --git a/device/src/legacy/power_mode.c b/device/src/legacy/power_mode.c deleted file mode 120000 index 50912722d..000000000 --- a/device/src/legacy/power_mode.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/power_mode.c \ No newline at end of file diff --git a/device/src/legacy/power_mode.h b/device/src/legacy/power_mode.h deleted file mode 120000 index c16be5d95..000000000 --- a/device/src/legacy/power_mode.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/power_mode.h \ No newline at end of file diff --git a/device/src/legacy/secondary_role_driver.c b/device/src/legacy/secondary_role_driver.c deleted file mode 120000 index 8224494e2..000000000 --- a/device/src/legacy/secondary_role_driver.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/secondary_role_driver.c \ No newline at end of file diff --git a/device/src/legacy/secondary_role_driver.h b/device/src/legacy/secondary_role_driver.h deleted file mode 120000 index 7c0b4b0c9..000000000 --- a/device/src/legacy/secondary_role_driver.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/secondary_role_driver.h \ No newline at end of file diff --git a/device/src/legacy/segment_display.c b/device/src/legacy/segment_display.c deleted file mode 120000 index 5aa96c1b3..000000000 --- a/device/src/legacy/segment_display.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/segment_display.c \ No newline at end of file diff --git a/device/src/legacy/segment_display.h b/device/src/legacy/segment_display.h deleted file mode 120000 index aadd3c4c9..000000000 --- a/device/src/legacy/segment_display.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/segment_display.h \ No newline at end of file diff --git a/device/src/legacy/slave_drivers/is31fl3xxx_driver.c b/device/src/legacy/slave_drivers/is31fl3xxx_driver.c deleted file mode 120000 index 142e50152..000000000 --- a/device/src/legacy/slave_drivers/is31fl3xxx_driver.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/slave_drivers/is31fl3xxx_driver.c \ No newline at end of file diff --git a/device/src/legacy/slave_drivers/is31fl3xxx_driver.h b/device/src/legacy/slave_drivers/is31fl3xxx_driver.h deleted file mode 120000 index a8695c548..000000000 --- a/device/src/legacy/slave_drivers/is31fl3xxx_driver.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/slave_drivers/is31fl3xxx_driver.h \ No newline at end of file diff --git a/device/src/legacy/slave_drivers/touchpad_driver.c b/device/src/legacy/slave_drivers/touchpad_driver.c deleted file mode 120000 index c370498cc..000000000 --- a/device/src/legacy/slave_drivers/touchpad_driver.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/slave_drivers/touchpad_driver.c \ No newline at end of file diff --git a/device/src/legacy/slave_drivers/touchpad_driver.h b/device/src/legacy/slave_drivers/touchpad_driver.h deleted file mode 120000 index 34d893029..000000000 --- a/device/src/legacy/slave_drivers/touchpad_driver.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/slave_drivers/touchpad_driver.h \ No newline at end of file diff --git a/device/src/legacy/slave_drivers/uhk_module_driver.c b/device/src/legacy/slave_drivers/uhk_module_driver.c deleted file mode 120000 index 166cb8769..000000000 --- a/device/src/legacy/slave_drivers/uhk_module_driver.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/slave_drivers/uhk_module_driver.c \ No newline at end of file diff --git a/device/src/legacy/slave_drivers/uhk_module_driver.h b/device/src/legacy/slave_drivers/uhk_module_driver.h deleted file mode 120000 index 998976223..000000000 --- a/device/src/legacy/slave_drivers/uhk_module_driver.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/slave_drivers/uhk_module_driver.h \ No newline at end of file diff --git a/device/src/legacy/slave_scheduler.c b/device/src/legacy/slave_scheduler.c deleted file mode 120000 index 012395c24..000000000 --- a/device/src/legacy/slave_scheduler.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/slave_scheduler.c \ No newline at end of file diff --git a/device/src/legacy/slave_scheduler.h b/device/src/legacy/slave_scheduler.h deleted file mode 120000 index d5ae59beb..000000000 --- a/device/src/legacy/slave_scheduler.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/slave_scheduler.h \ No newline at end of file diff --git a/device/src/legacy/slot.h b/device/src/legacy/slot.h deleted file mode 120000 index c3d3583e8..000000000 --- a/device/src/legacy/slot.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/slot.h \ No newline at end of file diff --git a/device/src/legacy/storage.c b/device/src/legacy/storage.c deleted file mode 120000 index e803bfde6..000000000 --- a/device/src/legacy/storage.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/storage.c \ No newline at end of file diff --git a/device/src/legacy/storage.h b/device/src/legacy/storage.h deleted file mode 120000 index 0e878e12a..000000000 --- a/device/src/legacy/storage.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/storage.h \ No newline at end of file diff --git a/device/src/legacy/str_utils.c b/device/src/legacy/str_utils.c deleted file mode 120000 index 064f0b950..000000000 --- a/device/src/legacy/str_utils.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/str_utils.c \ No newline at end of file diff --git a/device/src/legacy/str_utils.h b/device/src/legacy/str_utils.h deleted file mode 120000 index c3f841108..000000000 --- a/device/src/legacy/str_utils.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/str_utils.h \ No newline at end of file diff --git a/device/src/legacy/stubs.c b/device/src/legacy/stubs.c deleted file mode 120000 index 6a20b7a4a..000000000 --- a/device/src/legacy/stubs.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/stubs.c \ No newline at end of file diff --git a/device/src/legacy/stubs.h b/device/src/legacy/stubs.h deleted file mode 120000 index 631f203a7..000000000 --- a/device/src/legacy/stubs.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/stubs.h \ No newline at end of file diff --git a/device/src/legacy/test_switches.c b/device/src/legacy/test_switches.c deleted file mode 120000 index 73ce46265..000000000 --- a/device/src/legacy/test_switches.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/test_switches.c \ No newline at end of file diff --git a/device/src/legacy/test_switches.h b/device/src/legacy/test_switches.h deleted file mode 120000 index f3bed02b2..000000000 --- a/device/src/legacy/test_switches.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/test_switches.h \ No newline at end of file diff --git a/device/src/legacy/timer.c b/device/src/legacy/timer.c deleted file mode 120000 index 568d3b278..000000000 --- a/device/src/legacy/timer.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/timer.c \ No newline at end of file diff --git a/device/src/legacy/timer.h b/device/src/legacy/timer.h deleted file mode 120000 index a8f8b9dc3..000000000 --- a/device/src/legacy/timer.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/timer.h \ No newline at end of file diff --git a/device/src/legacy/usb_api.h b/device/src/legacy/usb_api.h deleted file mode 120000 index 7b7715fa2..000000000 --- a/device/src/legacy/usb_api.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/usb_api.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_apply_config.c b/device/src/legacy/usb_commands/usb_command_apply_config.c deleted file mode 120000 index 783756a77..000000000 --- a/device/src/legacy/usb_commands/usb_command_apply_config.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_apply_config.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_apply_config.h b/device/src/legacy/usb_commands/usb_command_apply_config.h deleted file mode 120000 index 07ee5e339..000000000 --- a/device/src/legacy/usb_commands/usb_command_apply_config.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_apply_config.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_draw_oled.c b/device/src/legacy/usb_commands/usb_command_draw_oled.c deleted file mode 120000 index 33383383f..000000000 --- a/device/src/legacy/usb_commands/usb_command_draw_oled.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_draw_oled.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_draw_oled.h b/device/src/legacy/usb_commands/usb_command_draw_oled.h deleted file mode 120000 index f1c15b43e..000000000 --- a/device/src/legacy/usb_commands/usb_command_draw_oled.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_draw_oled.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_exec_macro_command.c b/device/src/legacy/usb_commands/usb_command_exec_macro_command.c deleted file mode 120000 index 487f2146e..000000000 --- a/device/src/legacy/usb_commands/usb_command_exec_macro_command.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_exec_macro_command.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_exec_macro_command.h b/device/src/legacy/usb_commands/usb_command_exec_macro_command.h deleted file mode 120000 index e2316a365..000000000 --- a/device/src/legacy/usb_commands/usb_command_exec_macro_command.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_exec_macro_command.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_debug_buffer.c b/device/src/legacy/usb_commands/usb_command_get_debug_buffer.c deleted file mode 120000 index 31e1236a5..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_debug_buffer.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_debug_buffer.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_debug_buffer.h b/device/src/legacy/usb_commands/usb_command_get_debug_buffer.h deleted file mode 120000 index a993ff99d..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_debug_buffer.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_debug_buffer.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_device_property.c b/device/src/legacy/usb_commands/usb_command_get_device_property.c deleted file mode 120000 index 1f8cb5368..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_device_property.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_device_property.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_device_property.h b/device/src/legacy/usb_commands/usb_command_get_device_property.h deleted file mode 120000 index b7539958f..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_device_property.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_device_property.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_device_state.c b/device/src/legacy/usb_commands/usb_command_get_device_state.c deleted file mode 120000 index 949590371..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_device_state.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_device_state.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_device_state.h b/device/src/legacy/usb_commands/usb_command_get_device_state.h deleted file mode 120000 index 3da9110d3..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_device_state.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_device_state.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_module_property.c b/device/src/legacy/usb_commands/usb_command_get_module_property.c deleted file mode 120000 index 9551110f6..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_module_property.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_module_property.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_module_property.h b/device/src/legacy/usb_commands/usb_command_get_module_property.h deleted file mode 120000 index f4bc42d01..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_module_property.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_module_property.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_new_pairings.c b/device/src/legacy/usb_commands/usb_command_get_new_pairings.c deleted file mode 120000 index 6fa515616..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_new_pairings.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_new_pairings.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_new_pairings.h b/device/src/legacy/usb_commands/usb_command_get_new_pairings.h deleted file mode 120000 index f2611136a..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_new_pairings.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_new_pairings.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_variable.c b/device/src/legacy/usb_commands/usb_command_get_variable.c deleted file mode 120000 index e55651151..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_variable.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_variable.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_get_variable.h b/device/src/legacy/usb_commands/usb_command_get_variable.h deleted file mode 120000 index 9a2315488..000000000 --- a/device/src/legacy/usb_commands/usb_command_get_variable.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_get_variable.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_launch_storage_transfer.c b/device/src/legacy/usb_commands/usb_command_launch_storage_transfer.c deleted file mode 120000 index 1d463b5be..000000000 --- a/device/src/legacy/usb_commands/usb_command_launch_storage_transfer.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_launch_storage_transfer.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_launch_storage_transfer.h b/device/src/legacy/usb_commands/usb_command_launch_storage_transfer.h deleted file mode 120000 index ca2de2063..000000000 --- a/device/src/legacy/usb_commands/usb_command_launch_storage_transfer.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_launch_storage_transfer.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_pairing.c b/device/src/legacy/usb_commands/usb_command_pairing.c deleted file mode 120000 index 15aceaa26..000000000 --- a/device/src/legacy/usb_commands/usb_command_pairing.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_pairing.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_pairing.h b/device/src/legacy/usb_commands/usb_command_pairing.h deleted file mode 120000 index d87599a79..000000000 --- a/device/src/legacy/usb_commands/usb_command_pairing.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_pairing.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_read_config.c b/device/src/legacy/usb_commands/usb_command_read_config.c deleted file mode 120000 index 3395bdbaa..000000000 --- a/device/src/legacy/usb_commands/usb_command_read_config.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_read_config.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_read_config.h b/device/src/legacy/usb_commands/usb_command_read_config.h deleted file mode 120000 index e4149de33..000000000 --- a/device/src/legacy/usb_commands/usb_command_read_config.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_read_config.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_reenumerate.c b/device/src/legacy/usb_commands/usb_command_reenumerate.c deleted file mode 120000 index 36935f457..000000000 --- a/device/src/legacy/usb_commands/usb_command_reenumerate.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_reenumerate.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_reenumerate.h b/device/src/legacy/usb_commands/usb_command_reenumerate.h deleted file mode 120000 index 79cb2b793..000000000 --- a/device/src/legacy/usb_commands/usb_command_reenumerate.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_reenumerate.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_set_variable.c b/device/src/legacy/usb_commands/usb_command_set_variable.c deleted file mode 120000 index 35afb5da6..000000000 --- a/device/src/legacy/usb_commands/usb_command_set_variable.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_set_variable.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_set_variable.h b/device/src/legacy/usb_commands/usb_command_set_variable.h deleted file mode 120000 index 24ebbbc8c..000000000 --- a/device/src/legacy/usb_commands/usb_command_set_variable.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_set_variable.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_switch_keymap.c b/device/src/legacy/usb_commands/usb_command_switch_keymap.c deleted file mode 120000 index c5b01a813..000000000 --- a/device/src/legacy/usb_commands/usb_command_switch_keymap.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_switch_keymap.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_switch_keymap.h b/device/src/legacy/usb_commands/usb_command_switch_keymap.h deleted file mode 120000 index 48f75932c..000000000 --- a/device/src/legacy/usb_commands/usb_command_switch_keymap.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_switch_keymap.h \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_write_config.c b/device/src/legacy/usb_commands/usb_command_write_config.c deleted file mode 120000 index d21fda651..000000000 --- a/device/src/legacy/usb_commands/usb_command_write_config.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_write_config.c \ No newline at end of file diff --git a/device/src/legacy/usb_commands/usb_command_write_config.h b/device/src/legacy/usb_commands/usb_command_write_config.h deleted file mode 120000 index 0da04dc1a..000000000 --- a/device/src/legacy/usb_commands/usb_command_write_config.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_commands/usb_command_write_config.h \ No newline at end of file diff --git a/device/src/legacy/usb_composite_device.h b/device/src/legacy/usb_composite_device.h deleted file mode 120000 index 84bdb4b85..000000000 --- a/device/src/legacy/usb_composite_device.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/usb_composite_device.h \ No newline at end of file diff --git a/device/src/legacy/usb_descriptors/usb_descriptor_basic_keyboard_report.h b/device/src/legacy/usb_descriptors/usb_descriptor_basic_keyboard_report.h deleted file mode 120000 index 0cdb73347..000000000 --- a/device/src/legacy/usb_descriptors/usb_descriptor_basic_keyboard_report.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_descriptors/usb_descriptor_basic_keyboard_report.h \ No newline at end of file diff --git a/device/src/legacy/usb_descriptors/usb_descriptor_configuration.h b/device/src/legacy/usb_descriptors/usb_descriptor_configuration.h deleted file mode 120000 index cc99c7788..000000000 --- a/device/src/legacy/usb_descriptors/usb_descriptor_configuration.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_descriptors/usb_descriptor_configuration.h \ No newline at end of file diff --git a/device/src/legacy/usb_descriptors/usb_descriptor_media_keyboard_report.h b/device/src/legacy/usb_descriptors/usb_descriptor_media_keyboard_report.h deleted file mode 120000 index 2d344e121..000000000 --- a/device/src/legacy/usb_descriptors/usb_descriptor_media_keyboard_report.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_descriptors/usb_descriptor_media_keyboard_report.h \ No newline at end of file diff --git a/device/src/legacy/usb_descriptors/usb_descriptor_system_keyboard_report.h b/device/src/legacy/usb_descriptors/usb_descriptor_system_keyboard_report.h deleted file mode 120000 index ef95c0b8d..000000000 --- a/device/src/legacy/usb_descriptors/usb_descriptor_system_keyboard_report.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_descriptors/usb_descriptor_system_keyboard_report.h \ No newline at end of file diff --git a/device/src/legacy/usb_device_config.h b/device/src/legacy/usb_device_config.h deleted file mode 120000 index 9b3840b6c..000000000 --- a/device/src/legacy/usb_device_config.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/usb_device_config.h \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_basic_keyboard.c b/device/src/legacy/usb_interfaces/usb_interface_basic_keyboard.c deleted file mode 120000 index 2d229ba12..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_basic_keyboard.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_basic_keyboard.c \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_basic_keyboard.h b/device/src/legacy/usb_interfaces/usb_interface_basic_keyboard.h deleted file mode 120000 index 1e3dc9426..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_basic_keyboard.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_basic_keyboard.h \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_gamepad.c b/device/src/legacy/usb_interfaces/usb_interface_gamepad.c deleted file mode 120000 index c8ab04756..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_gamepad.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_gamepad.c \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_gamepad.h b/device/src/legacy/usb_interfaces/usb_interface_gamepad.h deleted file mode 120000 index c966b7cab..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_gamepad.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_gamepad.h \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_generic_hid.c b/device/src/legacy/usb_interfaces/usb_interface_generic_hid.c deleted file mode 120000 index 5b3188c55..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_generic_hid.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_generic_hid.c \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_generic_hid.h b/device/src/legacy/usb_interfaces/usb_interface_generic_hid.h deleted file mode 120000 index cd0da0296..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_generic_hid.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_generic_hid.h \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_media_keyboard.c b/device/src/legacy/usb_interfaces/usb_interface_media_keyboard.c deleted file mode 120000 index d11d00b30..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_media_keyboard.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_media_keyboard.c \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_media_keyboard.h b/device/src/legacy/usb_interfaces/usb_interface_media_keyboard.h deleted file mode 120000 index 7eabcce2f..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_media_keyboard.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_media_keyboard.h \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_mouse.c b/device/src/legacy/usb_interfaces/usb_interface_mouse.c deleted file mode 120000 index 2c88cbe30..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_mouse.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_mouse.c \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_mouse.h b/device/src/legacy/usb_interfaces/usb_interface_mouse.h deleted file mode 120000 index 1b75c27c4..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_mouse.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_mouse.h \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_system_keyboard.c b/device/src/legacy/usb_interfaces/usb_interface_system_keyboard.c deleted file mode 120000 index 6f410eef1..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_system_keyboard.c +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_system_keyboard.c \ No newline at end of file diff --git a/device/src/legacy/usb_interfaces/usb_interface_system_keyboard.h b/device/src/legacy/usb_interfaces/usb_interface_system_keyboard.h deleted file mode 120000 index 0704407e0..000000000 --- a/device/src/legacy/usb_interfaces/usb_interface_system_keyboard.h +++ /dev/null @@ -1 +0,0 @@ -../../../../right/src/usb_interfaces/usb_interface_system_keyboard.h \ No newline at end of file diff --git a/device/src/legacy/usb_protocol_handler.c b/device/src/legacy/usb_protocol_handler.c deleted file mode 120000 index 74022275a..000000000 --- a/device/src/legacy/usb_protocol_handler.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/usb_protocol_handler.c \ No newline at end of file diff --git a/device/src/legacy/usb_protocol_handler.h b/device/src/legacy/usb_protocol_handler.h deleted file mode 120000 index 54c870237..000000000 --- a/device/src/legacy/usb_protocol_handler.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/usb_protocol_handler.h \ No newline at end of file diff --git a/device/src/legacy/usb_report_updater.c b/device/src/legacy/usb_report_updater.c deleted file mode 120000 index 5f398dd9b..000000000 --- a/device/src/legacy/usb_report_updater.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/usb_report_updater.c \ No newline at end of file diff --git a/device/src/legacy/usb_report_updater.h b/device/src/legacy/usb_report_updater.h deleted file mode 120000 index 9a5e6bfdd..000000000 --- a/device/src/legacy/usb_report_updater.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/usb_report_updater.h \ No newline at end of file diff --git a/device/src/legacy/user_logic.c b/device/src/legacy/user_logic.c deleted file mode 120000 index eac1ed206..000000000 --- a/device/src/legacy/user_logic.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/user_logic.c \ No newline at end of file diff --git a/device/src/legacy/user_logic.h b/device/src/legacy/user_logic.h deleted file mode 120000 index 135248d0f..000000000 --- a/device/src/legacy/user_logic.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/user_logic.h \ No newline at end of file diff --git a/device/src/legacy/utils.c b/device/src/legacy/utils.c deleted file mode 120000 index da84c19bf..000000000 --- a/device/src/legacy/utils.c +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/utils.c \ No newline at end of file diff --git a/device/src/legacy/utils.h b/device/src/legacy/utils.h deleted file mode 120000 index 30a018054..000000000 --- a/device/src/legacy/utils.h +++ /dev/null @@ -1 +0,0 @@ -../../../right/src/utils.h \ No newline at end of file diff --git a/device/src/logger.c b/device/src/logger.c index 01dc4d22b..57305a836 100644 --- a/device/src/logger.c +++ b/device/src/logger.c @@ -8,7 +8,7 @@ #include "nus_server.h" #include "device.h" #include "messenger.h" -#include "legacy/macros/status_buffer.h" +#include "macros/status_buffer.h" #include "zephyr/device.h" #ifdef DEVICE_HAS_OLED diff --git a/device/src/main.c b/device/src/main.c index 08e31897e..5fb5b3118 100644 --- a/device/src/main.c +++ b/device/src/main.c @@ -3,8 +3,8 @@ #include "nus_client.h" #include "nus_server.h" #include "bt_manager.h" -#include "legacy/config_parser/config_globals.h" -#include "legacy/ledmap.h" +#include "config_parser/config_globals.h" +#include "ledmap.h" #include "shared/attributes.h" #include "zephyr/kernel.h" #include "zephyr/storage/flash_map.h" @@ -26,12 +26,12 @@ #include "macros/shortcut_parser.h" #include "macros/keyid_parser.h" #include "macros/core.h" -#include "legacy/timer.h" -#include "legacy/user_logic.h" -#include "legacy/config_manager.h" +#include "timer.h" +#include "user_logic.h" +#include "config_manager.h" #include "messenger.h" -#include "legacy/led_manager.h" -#include "legacy/debug.h" +#include "led_manager.h" +#include "debug.h" #include "state_sync.h" #include "keyboard/charger.h" #include @@ -39,7 +39,7 @@ #include "debug_eventloop_timing.h" #include #include "dongle_leds.h" -#include "legacy/usb_protocol_handler.h" +#include "usb_protocol_handler.h" k_tid_t Main_ThreadId = 0; @@ -141,15 +141,15 @@ int main(void) { Flash_ReadAreaSync(userConfigArea, 0, StagingUserConfigBuffer.buffer, USER_CONFIG_SIZE); printk("Applying user config\n"); bool factoryMode = false; - if (factoryMode || UsbCommand_ApplyConfig() != UsbStatusCode_Success) { - UsbCommand_ApplyFactory(); + if (factoryMode || UsbCommand_ApplyConfig(NULL, NULL) != UsbStatusCode_Success) { + UsbCommand_ApplyFactory(NULL, NULL); } printk("User config applied\n"); ShortcutParser_initialize(); KeyIdParser_initialize(); Macros_Initialize(); } else { - UsbCommand_ApplyFactory(); + UsbCommand_ApplyFactory(NULL, NULL); } } diff --git a/device/src/messenger.c b/device/src/messenger.c index 60f04460c..c84d544aa 100644 --- a/device/src/messenger.c +++ b/device/src/messenger.c @@ -11,12 +11,12 @@ #include "usb/usb_compatibility.h" #include "nus_server.h" #include "nus_client.h" -#include "legacy/module.h" -#include "legacy/key_states.h" +#include "module.h" +#include "key_states.h" #include "shared/attributes.h" -#include "legacy/str_utils.h" -#include "legacy/event_scheduler.h" -#include "legacy/slave_drivers/uhk_module_driver.h" +#include "str_utils.h" +#include "event_scheduler.h" +#include "slave_drivers/uhk_module_driver.h" #if DEVICE_IS_KEYBOARD #include "keyboard/uart.h" @@ -32,73 +32,54 @@ typedef enum { } messenger_channel_t; static messenger_channel_t determineChannel(device_id_t dst) { -#if DEVICE_IS_KEYBOARD +#if DEVICE_IS_UHK80_LEFT if (Uart_IsConnected()) { - if (DEVICE_IS_UHK80_LEFT) { - switch (dst) { - case DeviceId_Uhk_Dongle: - case DeviceId_Uhk80_Right: - return MessengerChannel_Uart; - default: - break; - } - } - - if (DEVICE_IS_UHK80_RIGHT) { - switch (dst) { - case DeviceId_Uhk_Dongle: - break; - case DeviceId_Uhk80_Left: - return MessengerChannel_Uart; - default: - break; - } + switch (dst) { + case DeviceId_Uhk_Dongle: + case DeviceId_Uhk80_Right: + return MessengerChannel_Uart; + default: + break; } } -#endif - - if (DEVICE_IS_UHK80_LEFT && Bt_DeviceIsConnected(DeviceId_Uhk80_Right)) { + if (Bt_DeviceIsConnected(DeviceId_Uhk80_Right)) { switch (dst) { case DeviceId_Uhk_Dongle: case DeviceId_Uhk80_Right: - if (Bt_DeviceIsConnected(DeviceId_Uhk80_Right)) { - return MessengerChannel_NusServer; - } + return MessengerChannel_NusServer; default: - return MessengerChannel_None; + break; } } +#endif - if (DEVICE_IS_UHK80_RIGHT) { +#if DEVICE_IS_UHK80_RIGHT + if (Uart_IsConnected() && (dst == DeviceId_Uhk80_Left)) { + return MessengerChannel_Uart; + } + if (Bt_DeviceIsConnected(dst)) { switch (dst) { case DeviceId_Uhk_Dongle: - if (Bt_DeviceIsConnected(DeviceId_Uhk_Dongle)) { - return MessengerChannel_NusServer; - } - break; + return MessengerChannel_NusServer; case DeviceId_Uhk80_Left: - if (Bt_DeviceIsConnected(DeviceId_Uhk80_Left)) { - return MessengerChannel_NusClient; - } - break; + return MessengerChannel_NusClient; default: - return MessengerChannel_None; + break; } } +#endif - if (DEVICE_IS_UHK_DONGLE) { +#if DEVICE_IS_UHK_DONGLE + if (Bt_DeviceIsConnected(DeviceId_Uhk80_Right)) { switch (dst) { case DeviceId_Uhk80_Right: case DeviceId_Uhk80_Left: - if (Bt_DeviceIsConnected(DeviceId_Uhk80_Right)) { - return MessengerChannel_NusClient; - } - break; + return MessengerChannel_NusClient; default: - return MessengerChannel_None; + break; } } - +#endif return MessengerChannel_None; } @@ -312,12 +293,21 @@ bool Messenger_Availability(device_id_t dst, messenger_availability_op_t operati case MessengerChannel_Uart: #if DEVICE_IS_KEYBOARD return Uart_Availability(operation); -#endif +#else return false; +#endif case MessengerChannel_NusServer: +#ifdef CONFIG_BT_NUS return NusServer_Availability(operation); +#else + return false; +#endif case MessengerChannel_NusClient: +#ifdef CONFIG_BT_NUS_CLIENT return NusClient_Availability(operation); +#else + return false; +#endif default: return false; } @@ -334,10 +324,14 @@ void Messenger_SendMessage(message_t message) { #endif break; case MessengerChannel_NusServer: +#if defined(CONFIG_BT_NUS) && defined(CONFIG_BT_PERIPHERAL) NusServer_SendMessage(message); +#endif break; case MessengerChannel_NusClient: +#ifdef CONFIG_BT_NUS_CLIENT NusClient_SendMessage(message); +#endif break; default: printk("Failed to send message from %s to %s\n", Utils_DeviceIdToString(DEVICE_ID), Utils_DeviceIdToString(dst)); diff --git a/device/src/nus_client.c b/device/src/nus_client.c index 7f438928d..98d422258 100644 --- a/device/src/nus_client.c +++ b/device/src/nus_client.c @@ -4,21 +4,21 @@ #include "bt_scan.h" #include "bt_conn.h" #include "device.h" -#include "legacy/usb_interfaces/usb_interface_basic_keyboard.h" -#include "legacy/usb_interfaces/usb_interface_mouse.h" +#include "usb_interfaces/usb_interface_basic_keyboard.h" +#include "usb_interfaces/usb_interface_mouse.h" #include "messenger.h" #include "nus_client.h" #include "bool_array_converter.h" -#include "legacy/slot.h" +#include "slot.h" #include "shared/bool_array_converter.h" -#include "legacy/module.h" -#include "legacy/key_states.h" +#include "module.h" +#include "key_states.h" #include "keyboard/oled/widgets/console_widget.h" #include "state_sync.h" #include "usb/usb_compatibility.h" #include "link_protocol.h" #include "messenger_queue.h" -#include "legacy/debug.h" +#include "debug.h" #include static struct bt_nus_client nus_client; diff --git a/device/src/nus_server.c b/device/src/nus_server.c index 19f9485c5..ec45f292e 100644 --- a/device/src/nus_server.c +++ b/device/src/nus_server.c @@ -6,7 +6,7 @@ #include "messenger.h" #include "device.h" #include "messenger_queue.h" -#include "legacy/debug.h" +#include "debug.h" #include "zephyr/bluetooth/addr.h" #define NUS_SLOTS 2 diff --git a/device/src/shared/atomicity.h b/device/src/shared/atomicity.h deleted file mode 120000 index 6e6f4c116..000000000 --- a/device/src/shared/atomicity.h +++ /dev/null @@ -1 +0,0 @@ -../../../shared/atomicity.h \ No newline at end of file diff --git a/device/src/shared/attributes.h b/device/src/shared/attributes.h deleted file mode 120000 index df86e53a2..000000000 --- a/device/src/shared/attributes.h +++ /dev/null @@ -1 +0,0 @@ -../../../shared/attributes.h \ No newline at end of file diff --git a/device/src/shared/bool_array_converter.c b/device/src/shared/bool_array_converter.c deleted file mode 120000 index 77f5ca0f5..000000000 --- a/device/src/shared/bool_array_converter.c +++ /dev/null @@ -1 +0,0 @@ -../../../shared/bool_array_converter.c \ No newline at end of file diff --git a/device/src/shared/bool_array_converter.h b/device/src/shared/bool_array_converter.h deleted file mode 120000 index 7e8aabd13..000000000 --- a/device/src/shared/bool_array_converter.h +++ /dev/null @@ -1 +0,0 @@ -../../../shared/bool_array_converter.h \ No newline at end of file diff --git a/device/src/shared/buffer.c b/device/src/shared/buffer.c deleted file mode 120000 index 87b66f8ae..000000000 --- a/device/src/shared/buffer.c +++ /dev/null @@ -1 +0,0 @@ -../../../shared/buffer.c \ No newline at end of file diff --git a/device/src/shared/buffer.h b/device/src/shared/buffer.h deleted file mode 120000 index 68c7f5889..000000000 --- a/device/src/shared/buffer.h +++ /dev/null @@ -1 +0,0 @@ -../../../shared/buffer.h \ No newline at end of file diff --git a/device/src/shared/crc16.c b/device/src/shared/crc16.c deleted file mode 120000 index b4ddbf8d1..000000000 --- a/device/src/shared/crc16.c +++ /dev/null @@ -1 +0,0 @@ -../../../shared/crc16.c \ No newline at end of file diff --git a/device/src/shared/crc16.h b/device/src/shared/crc16.h deleted file mode 120000 index a73d7cacc..000000000 --- a/device/src/shared/crc16.h +++ /dev/null @@ -1 +0,0 @@ -../../../shared/crc16.h \ No newline at end of file diff --git a/device/src/shared/fallback_versions.c b/device/src/shared/fallback_versions.c deleted file mode 120000 index d4f54d7f1..000000000 --- a/device/src/shared/fallback_versions.c +++ /dev/null @@ -1 +0,0 @@ -../../../shared/fallback_versions.c \ No newline at end of file diff --git a/device/src/shared/i2c_addresses.h b/device/src/shared/i2c_addresses.h deleted file mode 120000 index 3c544991d..000000000 --- a/device/src/shared/i2c_addresses.h +++ /dev/null @@ -1 +0,0 @@ -../../../shared/i2c_addresses.h \ No newline at end of file diff --git a/device/src/shared/key_matrix.c b/device/src/shared/key_matrix.c deleted file mode 120000 index 966921f38..000000000 --- a/device/src/shared/key_matrix.c +++ /dev/null @@ -1 +0,0 @@ -../../../shared/key_matrix.c \ No newline at end of file diff --git a/device/src/shared/key_matrix.h b/device/src/shared/key_matrix.h deleted file mode 120000 index 1fd7e18da..000000000 --- a/device/src/shared/key_matrix.h +++ /dev/null @@ -1 +0,0 @@ -../../../shared/key_matrix.h \ No newline at end of file diff --git a/device/src/shared/slave_protocol.c b/device/src/shared/slave_protocol.c deleted file mode 120000 index 9f808ac9d..000000000 --- a/device/src/shared/slave_protocol.c +++ /dev/null @@ -1 +0,0 @@ -../../../shared/slave_protocol.c \ No newline at end of file diff --git a/device/src/shared/slave_protocol.h b/device/src/shared/slave_protocol.h deleted file mode 120000 index 0ed1b5785..000000000 --- a/device/src/shared/slave_protocol.h +++ /dev/null @@ -1 +0,0 @@ -../../../shared/slave_protocol.h \ No newline at end of file diff --git a/device/src/shared/versioning.h b/device/src/shared/versioning.h deleted file mode 120000 index 7a1d374ff..000000000 --- a/device/src/shared/versioning.h +++ /dev/null @@ -1 +0,0 @@ -../../../shared/versioning.h \ No newline at end of file diff --git a/device/src/shell.c b/device/src/shell.c index dc5b5904c..b9c94baa5 100644 --- a/device/src/shell.c +++ b/device/src/shell.c @@ -10,8 +10,8 @@ #include #include "bt_conn.h" #include "keyboard/charger.h" -#include "legacy/ledmap.h" -#include "legacy/event_scheduler.h" +#include "ledmap.h" +#include "event_scheduler.h" shell_t Shell = { .keyLog = 0, diff --git a/device/src/state_sync.c b/device/src/state_sync.c index a2c9e5651..212218c4a 100644 --- a/device/src/state_sync.c +++ b/device/src/state_sync.c @@ -4,27 +4,29 @@ #include "event_scheduler.h" #include "keyboard/charger.h" #include "keyboard/oled/widgets/widgets.h" -#include "legacy/config_manager.h" -#include "legacy/config_parser/config_globals.h" -#include "legacy/debug.h" -#include "legacy/event_scheduler.h" -#include "legacy/keymap.h" -#include "legacy/led_manager.h" -#include "legacy/ledmap.h" -#include "legacy/module.h" -#include "legacy/slave_drivers/uhk_module_driver.h" -#include "legacy/slot.h" -#include "legacy/str_utils.h" -#include "legacy/stubs.h" -#include "legacy/utils.h" +#include "config_manager.h" +#include "config_parser/config_globals.h" +#include "debug.h" +#include "event_scheduler.h" +#include "keymap.h" +#include "led_manager.h" +#include "ledmap.h" +#include "module.h" +#include "slave_drivers/uhk_module_driver.h" +#include "slot.h" +#include "str_utils.h" +#include "stubs.h" +#include "utils.h" #include "messenger.h" #include "state_sync.h" #include "usb/usb_compatibility.h" #include #include -#include "legacy/peripherals/merge_sensor.h" +#include "peripherals/merge_sensor.h" #include "power_mode.h" +#define WAKE(TID) if (TID != 0) { k_wakeup(TID); } + #define STATE_SYNC_SEND_DELAY 2 #define THREAD_STACK_SIZE 2000 @@ -141,14 +143,14 @@ static void invalidateProperty(state_sync_prop_id_t propId) { bool isRightLeftLink = (stateSyncProps[propId].direction & (SyncDirection_RightToLeft | SyncDirection_LeftToRight)); if (isRightLeftLink && isRightLeftDevice) { - k_wakeup(stateSyncThreadLeftId); + WAKE(stateSyncThreadLeftId); } bool isRightDongleDevice = (DEVICE_ID == DeviceId_Uhk80_Right || DEVICE_ID == DeviceId_Uhk_Dongle); bool isRightDongleLink = (stateSyncProps[propId].direction & (SyncDirection_DongleToRight | SyncDirection_RightToDongle)); if (isRightDongleLink && isRightDongleDevice) { - k_wakeup(stateSyncThreadDongleId); + WAKE(stateSyncThreadDongleId); } } @@ -635,7 +637,7 @@ void StateSync_UpdateLayer(layer_id_t layerId, bool fullUpdate) { stateSyncProps[propId].dirtyState = fullUpdate ? DirtyState_NeedsUpdate : DirtyState_NeedsClearing; stateSyncProps[propId].defaultDirty = stateSyncProps[propId].dirtyState; - k_wakeup(stateSyncThreadLeftId); + WAKE(stateSyncThreadLeftId); } void StateSync_Init() { diff --git a/device/src/state_sync.h b/device/src/state_sync.h index f38554df6..a332e5813 100644 --- a/device/src/state_sync.h +++ b/device/src/state_sync.h @@ -5,12 +5,12 @@ #include #include - #include "legacy/layer_switcher.h" - #include "legacy/key_action.h" - #include "legacy/module.h" + #include "layer_switcher.h" + #include "key_action.h" + #include "module.h" #include "keyboard/charger.h" #include "shared/attributes.h" - #include "legacy/slave_drivers/uhk_module_driver.h" + #include "slave_drivers/uhk_module_driver.h" #include "versioning.h" // Macros: diff --git a/device/src/usb/app_base.cpp b/device/src/usb/app_base.cpp new file mode 100644 index 000000000..7019598a7 --- /dev/null +++ b/device/src/usb/app_base.cpp @@ -0,0 +1,40 @@ +#include "app_base.hpp" + +void app_base::stop() +{ + sending_sem_.release(); +} + +void app_base::send(const std::span &buffer) +{ + if (!active()) { + return; + } + if (!sending_sem_.try_acquire_for(SEMAPHORE_RESET_TIMEOUT)) { + //return; + } + std::copy(buffer.begin(), buffer.end(), in_buffer_.data() + sizeof(in_id_)); + auto result = send_report(in_buffer_); + if (result != hid::result::OK) { + sending_sem_.release(); + } +} + +void app_base::in_report_sent(const std::span &data) +{ + if (data.front() != in_id_) { + return; + } + sending_sem_.release(); +} + +void app_base::get_report(hid::report::selector select, const std::span &buffer) +{ + if (select != hid::report::selector(hid::report::type::INPUT, in_id_)) { + return; + } + assert(buffer.size() >= in_buffer_.size()); + + memcpy(buffer.data(), in_buffer_.data(), in_buffer_.size()); + send_report(buffer.subspan(0, in_buffer_.size())); +} diff --git a/device/src/usb/app_base.hpp b/device/src/usb/app_base.hpp new file mode 100644 index 000000000..c57b3449f --- /dev/null +++ b/device/src/usb/app_base.hpp @@ -0,0 +1,42 @@ +#ifndef __APP_BASE_HEADER__ +#define __APP_BASE_HEADER__ + +#include "hid/application.hpp" +#include "hid/rdf/descriptor.hpp" +#include "hid/report_protocol.hpp" +#include "port/zephyr/semaphore.hpp" +#include + +class app_base : public hid::application { + public: + bool active() const; + + protected: + static constexpr std::chrono::milliseconds SEMAPHORE_RESET_TIMEOUT{100}; + + template + static hid::report_protocol rp() + { + static constexpr const auto rd{T::report_desc()}; + constexpr hid::report_protocol rp{rd}; + return rp; + } + template + constexpr app_base([[maybe_unused]] T *t, TReport &in_report_buffer) + : application(rp()), + in_id_(in_report_buffer.ID), + in_buffer_(in_report_buffer.data(), sizeof(TReport)) + {} + + void stop() override; + void set_report(hid::report::type type, const std::span &data) override {} + void get_report(hid::report::selector select, const std::span &buffer) override; + void in_report_sent(const std::span &data) override; + void send(const std::span &buffer); + + const hid::report::id in_id_; + const std::span in_buffer_; + os::zephyr::binary_semaphore sending_sem_{1}; +}; + +#endif // __APP_BASE_HEADER__ diff --git a/device/src/usb/command_app.cpp b/device/src/usb/command_app.cpp index 74bd3bb6a..899dec924 100644 --- a/device/src/usb/command_app.cpp +++ b/device/src/usb/command_app.cpp @@ -3,24 +3,21 @@ #include "hid/report_protocol.hpp" #include "zephyr/sys/printk.h" -extern "C" bool CommandProtocolTx(const uint8_t *data, size_t size) -{ - return command_app::handle().send(std::span(data, size)); -} - -extern "C" void CommandProtocolRxHandler(const uint8_t *data, size_t size); +extern "C" void UsbProtocolHandler(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); -void __attribute__((weak)) CommandProtocolRxHandler(const uint8_t *data, size_t size) +command_app &command_app::usb_handle() { - printk("CommandProtocolRxHandler: data[0]:%u size:%d\n", data[0], size); - CommandProtocolTx(data, size); + static command_app app{}; + return app; } +#if DEVICE_IS_UHK80_RIGHT command_app &command_app::handle() { - static command_app app{}; - return app; + static command_app ble_app{}; + return ble_app; } +#endif void command_app::start(hid::protocol prot) { @@ -33,12 +30,20 @@ void command_app::set_report(hid::report::type type, const std::span(data.data()); - CommandProtocolRxHandler(out.payload.data(), data.size() - (report_out::has_id() ? 1 : 0)); - // always keep receiving new reports out_buffer_.swap_sides(); receive_report(&out_buffer_[out_buffer_.active_side()]); + + auto &out = *reinterpret_cast(data.data()); + auto buf_idx = in_buffer_.active_side(); + auto &in = in_buffer_[buf_idx]; + UsbProtocolHandler(out.payload.data(), in.payload.data()); + auto err = send_report(&in); + if (err == hid::result::OK) { + in_buffer_.compare_swap(buf_idx); + } else { + printk("Command app failed to send report with: %d\n", (int)err); + } } void command_app::get_report(hid::report::selector select, const std::span &buffer) @@ -53,24 +58,6 @@ void command_app::get_report(hid::report::selector select, const std::span buffer) -{ - auto buf_idx = in_buffer_.active_side(); - auto &report = in_buffer_[buf_idx]; - if (buffer.size() > report.payload.max_size()) { - printk("Usb payload exceeded maximum size!\n"); - return false; - } - std::copy(buffer.begin(), buffer.end(), report.payload.begin()); - c2usb::result err = send_report(&in_buffer_[buf_idx]); - if (err == hid::result::OK) { - in_buffer_.compare_swap(buf_idx); - return true; - } - printk("Command app failed to send report with: %i\n", (int)err); - return false; -} - void command_app::in_report_sent(const std::span &data) { if (data.front() != report_ids::IN_COMMAND) { diff --git a/device/src/usb/command_app.hpp b/device/src/usb/command_app.hpp index e9166a0e4..a31bfbcc6 100644 --- a/device/src/usb/command_app.hpp +++ b/device/src/usb/command_app.hpp @@ -6,6 +6,7 @@ #include "hid/rdf/descriptor.hpp" #include "hid/report_protocol.hpp" #include "report_ids.h" +#include "device.h" namespace hid::page { enum class ugl : uint8_t; @@ -61,9 +62,10 @@ class command_app : public hid::application { using report_in = report_base; using report_out = report_base; + static command_app& usb_handle(); +#if DEVICE_IS_UHK80_RIGHT static command_app& handle(); - - bool send(std::span buffer); +#endif void start(hid::protocol prot) override; void set_report(hid::report::type type, const std::span& data) override; diff --git a/device/src/usb/controls_app.cpp b/device/src/usb/controls_app.cpp index 17452c08d..7696705ee 100644 --- a/device/src/usb/controls_app.cpp +++ b/device/src/usb/controls_app.cpp @@ -1,14 +1,6 @@ #include "controls_app.hpp" -extern "C" -{ -#include "usb/usb.h" -#include -} - -static K_SEM_DEFINE(reportSending, 1, 1); - -controls_app& controls_app::handle() +controls_app &controls_app::handle() { static controls_app app{}; return app; @@ -17,56 +9,10 @@ controls_app& controls_app::handle() void controls_app::start(hid::protocol prot) { // TODO start handling controls events - report_buffer_.reset(); -} - -void controls_app::stop() -{ - // TODO stop handling controls events + report_buffer_ = {}; } void controls_app::set_report_state(const controls_report_base<0> &data) { - k_sem_take(&reportSending, K_MSEC(SEMAPHORE_RESET_TIMEOUT)); - auto buf_idx = report_buffer_.active_side(); - auto &report = report_buffer_[buf_idx]; - report.consumer_codes = data.consumer_codes; - report.system_codes = data.system_codes; - report.telephony_codes = data.telephony_codes; - send_buffer(buf_idx); -} - -void controls_app::send_buffer(uint8_t buf_idx) -{ - if (!report_buffer_.differs()) { - k_sem_give(&reportSending); - return; - } - if (send_report(&report_buffer_[buf_idx]) == hid::result::OK) { - report_buffer_.compare_swap_copy(buf_idx); - k_sem_give(&reportSending); - } -} - -void controls_app::in_report_sent(const std::span &data) -{ - if (data.front() != report_ids::IN_CONTROLS) { - return; - } - auto buf_idx = report_buffer_.indexof(data.data()); - if (!report_buffer_.compare_swap_copy(buf_idx)) { - send_buffer(1 - buf_idx); - } -} - -void controls_app::get_report(hid::report::selector select, const std::span &buffer) -{ - if (select != controls_report::selector()) { - return; - } - // copy to buffer to avoid overwriting data in transit - auto &report = report_buffer_[report_buffer_.inactive_side()]; - assert(buffer.size() >= sizeof(report)); - memcpy(buffer.data(), report.data(), sizeof(report)); - send_report(buffer.subspan(0, sizeof(report))); + send({data.data(), sizeof(data)}); } diff --git a/device/src/usb/controls_app.hpp b/device/src/usb/controls_app.hpp index f9f2d4e62..ef1b93e0f 100644 --- a/device/src/usb/controls_app.hpp +++ b/device/src/usb/controls_app.hpp @@ -1,27 +1,22 @@ #ifndef __CONTROLS_APP_HEADER__ #define __CONTROLS_APP_HEADER__ -#include "double_buffer.hpp" -#include "hid/application.hpp" +#include "app_base.hpp" #include "hid/page/consumer.hpp" #include "hid/page/generic_desktop.hpp" #include "hid/page/telephony.hpp" -#include "hid/rdf/descriptor.hpp" #include "hid/report_array.hpp" -#include "hid/report_protocol.hpp" #include "report_ids.h" using system_code = hid::page::generic_desktop; using consumer_code = hid::page::consumer; using telephony_code = hid::page::telephony; -class controls_app : public hid::application { +class controls_app : public app_base { static constexpr size_t CONSUMER_CODE_COUNT = 2; static constexpr size_t SYSTEM_CODE_COUNT = 2; static constexpr size_t TELEPHONY_CODE_COUNT = 2; - controls_app() : application(report_protocol()) {} - public: template struct controls_report_base : public hid::report::base { @@ -82,25 +77,12 @@ class controls_app : public hid::application { void set_report_state(const controls_report_base<0> &data); private: - static hid::report_protocol report_protocol() - { - static constexpr const auto rd{report_desc()}; - constexpr hid::report_protocol rp{rd}; - return rp; - } + controls_app() : app_base(this, report_buffer_) {} void start(hid::protocol prot) override; - void stop() override; - void set_report(hid::report::type type, const std::span &data) override - { - // no FEATURE or OUTPUT reports - } - void in_report_sent(const std::span &data) override; - void get_report(hid::report::selector select, const std::span &buffer) override; - void send_buffer(uint8_t buf_idx); using controls_report = controls_report_base; - double_buffer report_buffer_{}; + C2USB_USB_TRANSFER_ALIGN(controls_report, report_buffer_){}; }; using controls_buffer = controls_app::controls_report_base<0>; diff --git a/device/src/usb/double_buffer.hpp b/device/src/usb/double_buffer.hpp index d13ae6467..f0a45c123 100644 --- a/device/src/usb/double_buffer.hpp +++ b/device/src/usb/double_buffer.hpp @@ -3,23 +3,23 @@ #include #include -#include #include +#include template -class double_buffer -{ - struct aligned_storage - { +class double_buffer { + struct aligned_storage { C2USB_USB_TRANSFER_ALIGN(T, m_){}; + constexpr bool operator==(const aligned_storage &other) const = default; + constexpr bool operator!=(const aligned_storage &other) const = default; }; public: constexpr double_buffer() {} - T& operator[](uint8_t i) { return buffers_[i].m_; } + T &operator[](uint8_t i) { return buffers_[i].m_; } - const T& operator[](uint8_t i) const { return buffers_[i].m_; } + const T &operator[](uint8_t i) const { return buffers_[i].m_; } uint8_t active_side(std::memory_order mo = std::memory_order::seq_cst) const { @@ -32,7 +32,7 @@ class double_buffer } template - uint8_t indexof(TArg* ptr) const + uint8_t indexof(TArg *ptr) const { auto oneptr = reinterpret_cast(&buffers_[1]); auto dataptr = reinterpret_cast(ptr); @@ -48,8 +48,7 @@ class double_buffer bool compare_swap_copy(uint8_t i, std::memory_order mo = std::memory_order::seq_cst) { - if (compare_swap(i, mo)) - { + if (compare_swap(i, mo)) { buffers_[1 - i] = buffers_[i]; return true; } @@ -58,7 +57,8 @@ class double_buffer void reset() { buffers_ = {}; } - bool differs() const { return std::memcmp(&buffers_[0], &buffers_[1], sizeof(T)) != 0; } + // bool differs() const { return std::memcmp(&buffers_[0] != &buffers_[1], sizeof(T)) != 0; } + bool differs() const { return buffers_[0] != buffers_[1]; } private: std::array buffers_{}; diff --git a/device/src/usb/gamepad_app.cpp b/device/src/usb/gamepad_app.cpp index b76ebf23f..faee5c8b6 100644 --- a/device/src/usb/gamepad_app.cpp +++ b/device/src/usb/gamepad_app.cpp @@ -1,14 +1,6 @@ #include "gamepad_app.hpp" -extern "C" -{ -#include "usb/usb.h" -#include -} - -static K_SEM_DEFINE(reportSending, 1, 1); - -gamepad_app& gamepad_app::handle() +gamepad_app &gamepad_app::handle() { static gamepad_app app{}; return app; @@ -31,7 +23,6 @@ void gamepad_app::stop() void gamepad_app::set_report_state(const gamepad_report &data) { - k_sem_take(&reportSending, K_MSEC(SEMAPHORE_RESET_TIMEOUT)); auto buf_idx = report_buffer_.active_side(); auto &report = report_buffer_[buf_idx]; report.buttons = data.buttons; @@ -45,12 +36,10 @@ void gamepad_app::set_report_state(const gamepad_report &data) void gamepad_app::send_buffer(uint8_t buf_idx) { if (!report_buffer_.differs()) { - k_sem_give(&reportSending); return; } if (send_report(&report_buffer_[buf_idx]) == hid::result::OK) { report_buffer_.compare_swap_copy(buf_idx); - k_sem_give(&reportSending); } } diff --git a/device/src/usb/hid_battery_app.cpp b/device/src/usb/hid_battery_app.cpp new file mode 100644 index 000000000..d28460ae2 --- /dev/null +++ b/device/src/usb/hid_battery_app.cpp @@ -0,0 +1,57 @@ +extern "C" { +#include "device.h" +} +#if DEVICE_HAS_BATTERY + #include "hid_battery_app.hpp" + +extern "C" void HID_SetBatteryStatus(uint8_t remaining_capacity, bool charging) +{ + return hid_battery_app::handle().send(remaining_capacity, charging); +} + +hid_battery_app &hid_battery_app::handle() +{ + static hid_battery_app app{}; + return app; +} + +void hid_battery_app::send(uint8_t remaining_capacity, bool charging) +{ + auto buf_idx = report_buffer_.active_side(); + auto &r = report_buffer_[buf_idx]; + r.remaining_capacity = remaining_capacity; + r.charging = charging; + send_buffer(buf_idx); +} + +void hid_battery_app::send_buffer(uint8_t buf_idx) +{ + if (!report_buffer_.differs()) { + return; + } + if (send_report(&report_buffer_[buf_idx]) == hid::result::OK) { + report_buffer_.compare_swap_copy(buf_idx); + } +} + +void hid_battery_app::in_report_sent(const std::span &data) +{ + auto buf_idx = report_buffer_.indexof(data.data()); + if (!report_buffer_.compare_swap_copy(buf_idx)) { + send_buffer(1 - buf_idx); + } +} + +void hid_battery_app::get_report(hid::report::selector select, const std::span &buffer) +{ + if (select != report::selector()) { + return; + } + // copy to buffer to avoid overwriting data in transit + auto &report = report_buffer_[report_buffer_.inactive_side()]; + assert(buffer.size() >= sizeof(report)); + memcpy(buffer.data(), report.data(), sizeof(report)); + send_report(buffer.subspan(0, sizeof(report))); +} + +#endif // DEVICE_HAS_BATTERY diff --git a/device/src/usb/hid_battery_app.hpp b/device/src/usb/hid_battery_app.hpp new file mode 100644 index 000000000..ef92c7772 --- /dev/null +++ b/device/src/usb/hid_battery_app.hpp @@ -0,0 +1,73 @@ +#ifndef __HID_BATTERY_APP_HEADER__ +#define __HID_BATTERY_APP_HEADER__ + +#include "double_buffer.hpp" +#include "hid/application.hpp" +#include "hid/page/battery_system.hpp" +#include "hid/page/generic_desktop.hpp" +#include "hid/page/generic_device.hpp" +#include "hid/page/power.hpp" +#include "hid/rdf/descriptor.hpp" +#include "hid/report_protocol.hpp" + +class hid_battery_app : public hid::application { + hid_battery_app() : application(report_protocol()) {} + + public: + static constexpr auto report_desc() + { + using namespace hid::page; + using namespace hid::rdf; + + // clang-format off + return descriptor( + usage_page(), + usage(generic_desktop::SYSTEM_CONTROL), + collection::application( + usage_page(), + usage(battery_system::ABSOLUTE_STATE_OF_CHARGE), + logical_limits<1, 1>(0, 100), + report_size(7), + report_count(1), + input::absolute_variable(), + usage(battery_system::CHARGING), + logical_limits<1, 1>(0, 1), + report_size(1), + input::absolute_variable() + ) + ); + // clang-format off + } + + struct report : public hid::report::base + { + uint8_t remaining_capacity : 7; + bool charging : 1; + + bool operator==(const report &other) const = default; + }; + + static hid_battery_app& handle(); + + void send(uint8_t remaining_capacity, bool charging); + + void set_report(hid::report::type type, const std::span &data) override + { + // no FEATURE or OUTPUT reports + } + void get_report(hid::report::selector select, const std::span& buffer) override; + void in_report_sent(const std::span& data) override; + + private: + void send_buffer(uint8_t buf_idx); + static hid::report_protocol report_protocol() + { + static constexpr const auto rd{report_desc()}; + constexpr hid::report_protocol rp{rd}; + return rp; + } + + double_buffer report_buffer_{}; +}; + +#endif // __HID_BATTERY_APP_HEADER__ diff --git a/device/src/usb/keyboard_app.cpp b/device/src/usb/keyboard_app.cpp index e613fee76..3262e10b0 100644 --- a/device/src/usb/keyboard_app.cpp +++ b/device/src/usb/keyboard_app.cpp @@ -1,16 +1,11 @@ #include "keyboard_app.hpp" #include "zephyr/sys/printk.h" -extern "C" -{ -#include "usb/usb.h" +extern "C" { #include "usb/usb_compatibility.h" -#include } -static K_SEM_DEFINE(reportSending, 1, 1); - -keyboard_app& keyboard_app::handle() +keyboard_app &keyboard_app::handle() { static keyboard_app app{}; return app; @@ -26,20 +21,24 @@ void keyboard_app::set_rollover(rollover mode) if (prot_ == hid::protocol::BOOT) { return; } + reset_keys(); +} - keys_.reset(); +void keyboard_app::reset_keys() +{ + keys_ = {}; // TODO: make sure that no keys are pressed when this happens // or send an empty report on the virtual keyboard that is deactivated by this switch? if ((rollover_ == rollover::N_KEY) && (rollover_override_ == rollover::N_KEY)) { - keys_[0].nkro = {}; - keys_[1].nkro = {}; + keys_.nkro = {}; + keys_.nkro = {}; } else { - keys_[0].sixkro = {}; - keys_[1].sixkro = {}; + keys_.sixkro = {}; + keys_.sixkro = {}; } } -extern void hidmgr_set_transport(const hid::transport* tp); +extern void hidmgr_set_transport(const hid::transport *tp); void keyboard_app::start(hid::protocol prot) { @@ -50,23 +49,14 @@ void keyboard_app::start(hid::protocol prot) receive_report(&leds_buffer_); // TODO start handling keyboard events - keys_.reset(); - if (prot == hid::protocol::BOOT) { - keys_[0].boot = {}; - keys_[1].boot = {}; - } else if ((rollover_ == rollover::N_KEY) && (rollover_override_ == rollover::N_KEY)) { - keys_[0].nkro = {}; - keys_[1].nkro = {}; - } else { - keys_[0].sixkro = {}; - keys_[1].sixkro = {}; - } + reset_keys(); hidmgr_set_transport(get_transport()); } void keyboard_app::stop() { + sending_sem_.release(); // TODO stop handling keyboard events hidmgr_set_transport(get_transport()); } @@ -79,13 +69,16 @@ bool keyboard_app::using_nkro() const void keyboard_app::set_report_state(const keys_nkro_report_base<> &data) { - // DOCS: For report sending logic, see comments in mouse_app.cpp - k_sem_take(&reportSending, K_MSEC(SEMAPHORE_RESET_TIMEOUT)); - - auto buf_idx = keys_.active_side(); + if (!active()) { + return; + } + if (!sending_sem_.try_acquire_for(SEMAPHORE_RESET_TIMEOUT)) { + //return; + } + auto result = hid::result::INVALID; if (!using_nkro()) { if (prot_ == hid::protocol::BOOT) { - auto &keys_6kro = keys_[buf_idx].boot; + auto &keys_6kro = keys_.boot; keys_6kro.modifiers = data.modifiers; keys_6kro.scancodes.reset(); for (auto code = LOWEST_SCANCODE; code <= HIGHEST_SCANCODE; @@ -93,7 +86,7 @@ void keyboard_app::set_report_state(const keys_nkro_report_base<> &data) keys_6kro.scancodes.set(code, data.test(code)); } } else { - auto &keys_6kro = keys_[buf_idx].sixkro; + auto &keys_6kro = keys_.sixkro; keys_6kro.modifiers = data.modifiers; keys_6kro.scancodes.reset(); for (auto code = LOWEST_SCANCODE; code <= HIGHEST_SCANCODE; @@ -101,64 +94,43 @@ void keyboard_app::set_report_state(const keys_nkro_report_base<> &data) keys_6kro.scancodes.set(code, data.test(code)); } } - send_6kro_buffer(buf_idx); + + if (prot_ == hid::protocol::BOOT) { + result = send_report(&keys_.boot); + } else { + result = send_report(&keys_.sixkro); + } } else { - auto &keys_nkro = keys_[buf_idx].nkro; + auto &keys_nkro = keys_.nkro; // fill up the report keys_nkro.modifiers = data.modifiers; keys_nkro.scancodes = data.scancodes; - send_nkro_buffer(buf_idx); - } -} + result = send_report(&keys_.nkro); + if (result == hid::result::NO_MEMORY) { + printk("keyboard NKRO mode fails, falling back to 6KRO\n"); -void keyboard_app::send_6kro_buffer(uint8_t buf_idx) -{ - if (!keys_.differs() || !has_transport()) { - k_sem_give(&reportSending); - return; - } - auto result = hid::result::INVALID; - auto &report = keys_[buf_idx]; - if (prot_ == hid::protocol::BOOT) { - result = send_report(&report.boot); - } else { - result = send_report(&report.sixkro); - } + // save key state + keys_nkro_report_base<> data{ + .modifiers = keys_.nkro.modifiers, .scancodes = keys_.nkro.scancodes}; - // swap sides only if the callback hasn't done yet - if (result == hid::result::OK) { - keys_.compare_swap_copy(buf_idx); - k_sem_give(&reportSending); - } -} + // switch report layout + rollover_override_ = rollover::SIX_KEY; + keys_ = {}; + keys_.sixkro = {}; -void keyboard_app::send_nkro_buffer(uint8_t buf_idx) -{ - if (!keys_.differs() || !has_transport()) { - k_sem_give(&reportSending); - return; + keys_.sixkro.modifiers = data.modifiers; + keys_.sixkro.scancodes.reset(); + for (auto code = LOWEST_SCANCODE; code <= HIGHEST_SCANCODE; + code = static_cast(static_cast(code) + 1)) { + keys_.sixkro.scancodes.set(code, data.test(code)); + } + + result = send_report(&keys_.sixkro); + } } - auto result = send_report(&keys_[buf_idx].nkro); - if (result == hid::result::NO_MEMORY) { - printk("keyboard NKRO mode fails, falling back to 6KRO\n"); - - // save key state - keys_nkro_report_base<> data{ - .modifiers = keys_[buf_idx].nkro.modifiers, .scancodes = keys_[buf_idx].nkro.scancodes}; - - // switch report layout - rollover_override_ = rollover::SIX_KEY; - keys_.reset(); - keys_[0].sixkro = {}; - keys_[1].sixkro = {}; - - // apply current state - set_report_state(data); - - } else if (result == hid::result::OK) { - keys_.compare_swap_copy(buf_idx); - k_sem_give(&reportSending); + if (result != hid::result::OK) { + sending_sem_.release(); } } @@ -176,7 +148,8 @@ void keyboard_app::set_report(hid::report::type type, const std::span &data) (data.front() != KEYS_6KRO_REPORT_ID)) { return; } - auto buf_idx = keys_.indexof(data.data()); - if (!keys_.compare_swap_copy(buf_idx)) { - if (using_nkro()) { - send_nkro_buffer(1 - buf_idx); - } else { - send_6kro_buffer(1 - buf_idx); - } - } + sending_sem_.release(); } void keyboard_app::get_report(hid::report::selector select, const std::span &buffer) @@ -212,14 +178,13 @@ void keyboard_app::get_report(hid::report::selector select, const std::span(buffer.data()); if (using_nkro()) { *report = {}; } else { - *report = keys.sixkro; + *report = keys_.sixkro; } send_report(report); break; @@ -227,7 +192,7 @@ void keyboard_app::get_report(hid::report::selector select, const std::span(buffer.data()); if (using_nkro()) { - *report = keys.nkro; + *report = keys_.nkro; } else { *report = {}; } @@ -236,7 +201,7 @@ void keyboard_app::get_report(hid::report::selector select, const std::span(buffer.data()); - *report = keys.boot; + *report = keys_.boot; send_report(report); break; } diff --git a/device/src/usb/keyboard_app.hpp b/device/src/usb/keyboard_app.hpp index 6465bb8bc..45522c509 100644 --- a/device/src/usb/keyboard_app.hpp +++ b/device/src/usb/keyboard_app.hpp @@ -1,23 +1,20 @@ #ifndef __KEYBOARD_APP_HEADER__ #define __KEYBOARD_APP_HEADER__ -#include "double_buffer.hpp" +#include "app_base.hpp" #include "hid/app/keyboard.hpp" -#include "hid/application.hpp" -#include "hid/report_protocol.hpp" #include "report_ids.h" using scancode = hid::page::keyboard_keypad; -class keyboard_app : public hid::application { +class keyboard_app : public app_base { static constexpr uint8_t KEYS_6KRO_REPORT_ID = report_ids::IN_KEYBOARD_6KRO; static constexpr uint8_t KEYS_NKRO_REPORT_ID = report_ids::IN_KEYBOARD_NKRO; static constexpr uint8_t LEDS_REPORT_ID = report_ids::OUT_KEYBOARD_LEDS; static constexpr auto NKRO_FIRST_USAGE = scancode::KEYBOARD_A; // the first 4 codes are error codes - static constexpr auto NKRO_LAST_USAGE = - (scancode)CONFIG_KEYBOARD_MAX_SCANCODE; + static constexpr auto NKRO_LAST_USAGE = (scancode)CONFIG_KEYBOARD_MAX_SCANCODE; static constexpr auto LOWEST_SCANCODE = NKRO_FIRST_USAGE; static constexpr auto HIGHEST_SCANCODE = NKRO_LAST_USAGE; @@ -110,14 +107,7 @@ class keyboard_app : public hid::application { void set_report_state(const keys_nkro_report_base<> &data); private: - static hid::report_protocol report_protocol() - { - static constexpr const auto rd{report_desc()}; - constexpr hid::report_protocol rp{rd}; - return rp; - } - - keyboard_app() : application(report_protocol()) {} + keyboard_app() : app_base(this, keys_.nkro) {} using keys_boot_report = hid::app::keyboard::keys_input_report<0>; using keys_6kro_report = hid::app::keyboard::keys_input_report; @@ -137,6 +127,8 @@ class keyboard_app : public hid::application { void send_6kro_buffer(uint8_t buf_idx); void send_nkro_buffer(uint8_t buf_idx); + void reset_keys(); + C2USB_USB_TRANSFER_ALIGN(leds_report, leds_buffer_){}; hid::protocol prot_{}; rollover rollover_{}; @@ -146,7 +138,7 @@ class keyboard_app : public hid::application { keys_boot_report boot; keys_6kro_report sixkro; }; - double_buffer keys_{}; + C2USB_USB_TRANSFER_ALIGN(keys_reports, keys_){}; }; using scancode_buffer = keyboard_app::keys_nkro_report_base<>; diff --git a/device/src/usb/mouse_app.cpp b/device/src/usb/mouse_app.cpp index b829bfa9e..352d19383 100644 --- a/device/src/usb/mouse_app.cpp +++ b/device/src/usb/mouse_app.cpp @@ -1,14 +1,8 @@ #include "mouse_app.hpp" +#include "zephyr/sys/printk.h" -extern "C" { -#include "usb/usb.h" -#include -#include "legacy/debug.h" -} - -static K_SEM_DEFINE(reportSending, 1, 1); - -mouse_app& mouse_app::handle() { +mouse_app &mouse_app::handle() +{ static mouse_app app{}; return app; } @@ -16,97 +10,10 @@ mouse_app& mouse_app::handle() { void mouse_app::start(hid::protocol prot) { // TODO start handling mouse events - report_buffer_.reset(); -} - -void mouse_app::stop() -{ - // TODO stop handling mouse events + report_buffer_ = {}; } void mouse_app::set_report_state(const mouse_report_base<> &data) { - k_sem_take(&reportSending, K_MSEC(SEMAPHORE_RESET_TIMEOUT)); - auto buf_idx = report_buffer_.active_side(); - auto &report = report_buffer_[buf_idx]; - report.buttons = data.buttons; - report.x = data.x; - report.y = data.y; - report.wheel_x = data.wheel_x; - report.wheel_y = data.wheel_y; - send_buffer(buf_idx); -} - -bool mouse_app::swap_buffers(uint8_t buf_idx) { - auto& otherReport = report_buffer_[1-buf_idx]; - - if (report_buffer_.compare_swap_copy(buf_idx)) { - // buf_idx report is now inactive and waiting to be sent - // otherReport is now active and ready to be written - otherReport.x = 0; - otherReport.y = 0; - otherReport.wheel_x = 0; - otherReport.wheel_y = 0; - return true; - } - return false; -} - -void mouse_app::send_buffer(uint8_t buf_idx) -{ - auto& report = report_buffer_[buf_idx]; - if ( - !report_buffer_.differs() - && report.x == (hid::le_int16_t)0 - && report.y == (hid::le_int16_t)0 - && report.wheel_x == (int16_t)0 - && report.wheel_y == (int16_t)0 - ) { - k_sem_give(&reportSending); - return; - } - // an asynchronous api to send the buffer - // OK means that the report is scheduled to be sent - // BUSY: means that another report is already being sent. - // In that case, in_report_sent will trigger another sent attempt - if (send_report(&report_buffer_[buf_idx]) == hid::result::OK) - { - // report has been submitted for sending, so swap buffers - swap_buffers(buf_idx); - // now inactive buffer is waiting to be sent - // and active buffer is prepared for further writing - k_sem_give(&reportSending); - } -} - -void mouse_app::in_report_sent(const std::span &data) -{ - if (data.front() != report_ids::IN_MOUSE) { - return; - } - // inactive buffer has been sent - auto buf_idx = report_buffer_.indexof(data.data()); // this should now point to inactive buffer - // so swapping should fail, which means that everything is ok and we can - // continue and try to send the active buffer - if (!swap_buffers(buf_idx)) - { - // If someone tried to set_report_state inbetween, they have failed to - // send the buffer, so we need to take care of that. - send_buffer(1 - buf_idx); - } - // else we have swapped buffers before the send_buffer (above) managed to - // do so. In that case, *we* have swapped buffers, and the send_buffer's - // swap will fail -} - -void mouse_app::get_report(hid::report::selector select, const std::span &buffer) -{ - if (select != mouse_report::selector()) { - return; - } - // copy to buffer to avoid overwriting data in transit - auto& report = report_buffer_[report_buffer_.inactive_side()]; - assert(buffer.size() >= sizeof(report)); - memcpy(buffer.data(), report.data(), sizeof(report)); - send_report(buffer.subspan(0, sizeof(report))); + send({data.data(), sizeof(data)}); } diff --git a/device/src/usb/mouse_app.hpp b/device/src/usb/mouse_app.hpp index 01e725f60..87c8259b7 100644 --- a/device/src/usb/mouse_app.hpp +++ b/device/src/usb/mouse_app.hpp @@ -1,11 +1,10 @@ #ifndef __MOUSE_APP_HEADER__ #define __MOUSE_APP_HEADER__ +#include "app_base.hpp" #include "double_buffer.hpp" #include "hid/app/mouse.hpp" -#include "hid/application.hpp" #include "hid/page/consumer.hpp" -#include "hid/report_protocol.hpp" #include "report_ids.h" enum class mouse_button { @@ -19,13 +18,11 @@ enum class mouse_button { _8 }; -class mouse_app : public hid::application { +class mouse_app : public app_base { static constexpr auto LAST_BUTTON = hid::page::button(20); static constexpr int16_t AXIS_LIMIT = 4096; static constexpr int8_t WHEEL_LIMIT = 127; - mouse_app() : application(report_protocol()) {} - public: static constexpr auto report_desc() { @@ -98,27 +95,12 @@ class mouse_app : public hid::application { void set_report_state(const mouse_report_base<> &data); private: - static hid::report_protocol report_protocol() - { - static constexpr const auto rd{report_desc()}; - constexpr hid::report_protocol rp{rd}; - return rp; - } + mouse_app() : app_base(this, report_buffer_) {} void start(hid::protocol prot) override; - void stop() override; - void set_report(hid::report::type type, const std::span &data) override - { - // no FEATURE or OUTPUT reports - } - void in_report_sent(const std::span &data) override; - void get_report(hid::report::selector select, const std::span &buffer) override; - void send_buffer(uint8_t buf_idx); using mouse_report = mouse_report_base; - double_buffer report_buffer_{}; - - bool swap_buffers(uint8_t buf_idx); + C2USB_USB_TRANSFER_ALIGN(mouse_report, report_buffer_){}; }; using mouse_buffer = mouse_app::mouse_report_base<>; diff --git a/device/src/usb/usb.cpp b/device/src/usb/usb.cpp index 58172d77c..522146f6c 100644 --- a/device/src/usb/usb.cpp +++ b/device/src/usb/usb.cpp @@ -4,12 +4,12 @@ extern "C" { #include "key_states.h" #include "keyboard/charger.h" #include "keyboard/key_scanner.h" -#include "legacy/timer.h" -#include "legacy/user_logic.h" +#include "power_mode.h" +#include "timer.h" +#include "user_logic.h" +#include "logger.h" #include #include -#include "logger.h" -#include "legacy/power_mode.h" } #include "command_app.hpp" #include "controls_app.hpp" @@ -27,21 +27,21 @@ extern "C" { #include "device_state.h" #include "usb_report_updater.h" } - +#if DEVICE_HAS_BATTERY + #include "hid_battery_app.hpp" +#endif #if DEVICE_IS_UHK80_RIGHT #include "port/zephyr/bluetooth/hid.hpp" using namespace magic_enum::bitwise_operators; #endif -// make sure that the USB IDs are used in BT -static_assert(CONFIG_BT_DIS_PNP_VID_SRC == 2); - uint8_t UsbSerialNumber[5]; -constexpr usb::product_info product_info{CONFIG_BT_DIS_PNP_VID, CONFIG_BT_DIS_MANUF, - CONFIG_USB_PID, CONFIG_BT_DIS_MODEL, - usb::version(CONFIG_BT_DIS_PNP_VER >> 8, CONFIG_BT_DIS_PNP_VER), UsbSerialNumber}; +constexpr usb::product_info product_info{CONFIG_USB_DEVICE_VID, CONFIG_USB_DEVICE_MANUFACTURER, + CONFIG_USB_DEVICE_PID, CONFIG_USB_DEVICE_PRODUCT, + usb::version(CONFIG_USB_DEVICE_PRODUCT_VERSION >> 8, CONFIG_USB_DEVICE_PRODUCT_VERSION), + UsbSerialNumber}; template class multi_hid : public hid::multi_application { @@ -65,28 +65,82 @@ class multi_hid : public hid::multi_application { }; struct usb_manager { - static usb::df::zephyr::udc_mac &mac() { return instance().mac_; } + static usb::zephyr::udc_mac &mac() { return instance().mac_; } static usb::df::device &device() { return instance().device_; } static bool active() { return device().is_open(); } + static usb_manager &instance() + { + static usb_manager um; + return um; + } + void select_config(hid_config_t conf) + { + if (conf == next_config_.load()) { + return; + } + auto config = next_config_.exchange(conf | launch_flag | change_flag); + if (config & launch_flag) { + return; + } + [[maybe_unused]] auto result = mac().queue_task([]() { instance().change_config(); }); + assert(result == usb::result::OK); + } + + private: + void change_config() + { + next_config_.fetch_and(~launch_flag); + // pretend that the device is disconnected + if (device().is_open()) { + device().close(); + k_msleep(80); + } + // attempt to avoid unnecessary races + int new_conf = next_config_.fetch_and(~(launch_flag | change_flag)); + for (; new_conf & (launch_flag | change_flag); + new_conf = next_config_.fetch_and(~(launch_flag | change_flag))) { + k_msleep(50); // TODO: this is guesswork so far + } + + open_config((hid_config_t)new_conf); + } + + void open_config(hid_config_t conf) { static constexpr auto speed = usb::speed::FULL; static usb::df::hid::function usb_kb{ keyboard_app::handle(), usb::hid::boot_protocol_mode::KEYBOARD}; static usb::df::hid::function usb_mouse{mouse_app::handle()}; - static usb::df::hid::function usb_command{command_app::handle()}; + static usb::df::hid::function usb_command{command_app::usb_handle()}; static usb::df::hid::function usb_controls{controls_app::handle()}; static usb::df::hid::function usb_gamepad{gamepad_app::handle()}; static usb::df::microsoft::xfunction usb_xpad{gamepad_app::handle()}; +#if DEVICE_HAS_BATTERY + static usb::df::hid::function usb_battery{hid_battery_app::handle()}; +#endif constexpr auto config_header = usb::df::config::header(usb::df::config::power::bus(500, true)); const auto shared_config_elems = usb::df::config::join_elements( usb::df::hid::config(usb_kb, speed, usb::endpoint::address(0x81), 1), usb::df::hid::config(usb_mouse, speed, usb::endpoint::address(0x82), 1), - usb::df::hid::config(usb_command, speed, usb::endpoint::address(0x83), 20), - usb::df::hid::config(usb_controls, speed, usb::endpoint::address(0x84), 1)); + usb::df::hid::config(usb_command, speed, usb::endpoint::address(0x83), 10), + usb::df::hid::config(usb_controls, speed, usb::endpoint::address(0x84), 1) +#if DEVICE_HAS_BATTERY + , + usb::df::hid::config(usb_battery, speed, usb::endpoint::address(0x86), 1) + // not very useful at the moment +#endif + ); + static const auto inactive_config = usb::df::config::make_config(config_header, + usb::df::hid::config(usb_command, speed, usb::endpoint::address(0x83), 10) +#if DEVICE_HAS_BATTERY + , + usb::df::hid::config(usb_battery, speed, usb::endpoint::address(0x86), 1) +#endif + ); static const auto base_config = usb::df::config::make_config(config_header, shared_config_elems); @@ -100,16 +154,11 @@ struct usb_manager { usb::df::microsoft::xconfig( usb_xpad, usb::endpoint::address(0x85), 1, usb::endpoint::address(0x05), 255)); - if (device_.is_open()) { - device_.close(); - if (conf == Hid_Empty) { - return; - } - k_msleep(100); - } + printk("USB config changing to %s\n", magic_enum::enum_name(conf).data()); switch (conf) { case Hid_Empty: - assert(false); // returned already + ms_enum_.set_config({}); + device_.set_config(inactive_config); break; case Hid_NoGamepad: ms_enum_.set_config({}); @@ -123,13 +172,6 @@ struct usb_manager { device_.open(); } - static usb_manager &instance() - { - static usb_manager um; - return um; - } - - private: usb_manager() { device_.set_power_event_delegate([](usb::df::device &dev, usb::df::device::event ev) { @@ -165,9 +207,12 @@ struct usb_manager { }); } - usb::df::zephyr::udc_mac mac_{DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0))}; + usb::zephyr::udc_mac mac_{DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0))}; usb::df::microsoft::alternate_enumeration ms_enum_{}; usb::df::device_instance device_{mac_, product_info, ms_enum_}; + static constexpr int change_flag = 0x100; + static constexpr int launch_flag = 0x200; + std::atomic next_config_{0xff}; }; extern "C" void USB_EnableHid() @@ -182,7 +227,14 @@ extern "C" void USB_DisableHid() extern "C" void USB_RemoteWakeup() { - usb_manager::instance().device().remote_wakeup(); + printk("USB: requesting remote wakeup\n"); + usb_manager::instance().mac().queue_task([]() { + if (usb_manager::instance().device().remote_wakeup()) { + printk("USB: sending remote wakeup\n"); + } else { + printk("USB: remote wakeup disabled\n"); + } + }); } #if DEVICE_IS_UHK80_RIGHT @@ -197,10 +249,7 @@ struct hogp_manager { return hm; } - static bool active() - { - return instance().hogp_nopad_.active(); - } + static bool active() { return instance().hogp_nopad_.active(); } void select_config(hid_config_t conf) { @@ -219,10 +268,7 @@ struct hogp_manager { } } - const bluetooth::zephyr::hid::service& main_service() - { - return hogp_nopad_; - } + const bluetooth::zephyr::hid::service &main_service() { return hogp_nopad_; } private: hogp_manager() {} @@ -248,7 +294,20 @@ extern "C" void HOGP_Disable() } #endif -void hidmgr_set_transport(const hid::transport* tp) +bool app_base::active() const +{ + if (!get_transport()) { + return false; + } +#if DEVICE_IS_UHK80_RIGHT + if (get_transport() == &hogp_manager::instance().main_service()) { + return true; + } +#endif + return usb_manager::instance().device().power_state() == usb::power::state::L0_ON; +} + +void hidmgr_set_transport(const hid::transport *tp) { // tp is the transport of the keyboard app if (tp == nullptr) { @@ -297,7 +356,8 @@ extern "C" void HID_SetKeyboardRollover(rollover_t mode) keyboard_app::handle().set_rollover((keyboard_app::rollover)mode); } -extern "C" void USB_SetSerialNumber(uint32_t serialNumber) { +extern "C" void USB_SetSerialNumber(uint32_t serialNumber) +{ // Ensure UsbSerialNumber has enough space if (sizeof(UsbSerialNumber) < 5) { return; diff --git a/device/src/usb/usb.h b/device/src/usb/usb.h index b09d65d3a..fb8e00364 100644 --- a/device/src/usb/usb.h +++ b/device/src/usb/usb.h @@ -8,10 +8,6 @@ #include #include -// Macros: - - #define SEMAPHORE_RESET_TIMEOUT 100 - // Typedefs: typedef enum diff --git a/device/src/usb/usb_compatibility.cpp b/device/src/usb/usb_compatibility.cpp index 11e655b7f..02f0016c9 100644 --- a/device/src/usb/usb_compatibility.cpp +++ b/device/src/usb/usb_compatibility.cpp @@ -1,27 +1,26 @@ -extern "C" -{ +extern "C" { #include "usb_compatibility.h" -#include "usb_interfaces/usb_interface_basic_keyboard.h" -#include "usb_interfaces/usb_interface_media_keyboard.h" -#include "usb_interfaces/usb_interface_system_keyboard.h" -#include "usb_interfaces/usb_interface_mouse.h" +#include "bt_conn.h" +#include "debug.h" +#include "event_scheduler.h" +#include "key_states.h" +#include "macro_events.h" #include "link_protocol.h" -#include "legacy/debug.h" -#include "nus_server.h" #include "messenger.h" -#include "bt_conn.h" +#include "nus_server.h" #include "state_sync.h" -#include "legacy/event_scheduler.h" -#include "legacy/macro_events.h" -#include "legacy/key_states.h" +#include "usb_interfaces/usb_interface_basic_keyboard.h" +#include "usb_interfaces/usb_interface_media_keyboard.h" +#include "usb_interfaces/usb_interface_mouse.h" +#include "usb_interfaces/usb_interface_system_keyboard.h" } -#include "usb/df/class/hid.hpp" #include "command_app.hpp" #include "controls_app.hpp" #include "gamepad_app.hpp" #include "keyboard_app.hpp" -#include "mouse_app.hpp" #include "logger.h" +#include "mouse_app.hpp" +#include "usb/df/class/hid.hpp" static scancode_buffer keys; static mouse_buffer mouseState; @@ -29,85 +28,84 @@ static controls_buffer controls; keyboard_led_state_t KeyboardLedsState; - /* - gamepad.set_button(gamepad_button::X, KeyStates[CURRENT_SLOT_ID][3].current); - // gamepad.left.X = 50; - // gamepad.right.Y = 50; - // gamepad.right_trigger = 50; - gamepad_app::handle().set_report_state(gamepad); - */ - -extern "C" void UsbCompatibility_SendKeyboardReport(const usb_basic_keyboard_report_t* report) +extern "C" void UsbCompatibility_SendKeyboardReport(const usb_basic_keyboard_report_t *report) { - keyboard_app& keyboard_app = keyboard_app::handle(); + keyboard_app &keyboard_app = keyboard_app::handle(); - if (keyboard_app.has_transport()) { - keyboard_app.set_report_state(*reinterpret_cast(report)); - } else if (DEVICE_IS_UHK80_RIGHT && Bt_DeviceIsConnected(DeviceId_Uhk_Dongle)) { - Messenger_Send2(DeviceId_Uhk_Dongle, MessageId_SyncableProperty, SyncablePropertyId_KeyboardReport, (const uint8_t*)report, sizeof(*report)); + if (keyboard_app.active()) { + keyboard_app.set_report_state(*reinterpret_cast(report)); + } else if (DEVICE_IS_UHK80_RIGHT && Bt_DeviceIsConnected(DeviceId_Uhk_Dongle)) { + Messenger_Send2(DeviceId_Uhk_Dongle, MessageId_SyncableProperty, + SyncablePropertyId_KeyboardReport, (const uint8_t *)report, sizeof(*report)); } } -extern "C" void UsbCompatibility_SendMouseReport(const usb_mouse_report_t* report) +extern "C" void UsbCompatibility_SendMouseReport(const usb_mouse_report_t *report) { - mouse_app& mouse_app = mouse_app::handle(); + mouse_app &mouse_app = mouse_app::handle(); - if (mouse_app.has_transport()) { - mouse_app.set_report_state(*reinterpret_cast(report)); - } else if (DEVICE_IS_UHK80_RIGHT && Bt_DeviceIsConnected(DeviceId_Uhk_Dongle)) { - Messenger_Send2(DeviceId_Uhk_Dongle, MessageId_SyncableProperty, SyncablePropertyId_MouseReport, (const uint8_t*)report, sizeof(*report)); + if (mouse_app.active()) { + mouse_app.set_report_state(*reinterpret_cast(report)); + } else if (DEVICE_IS_UHK80_RIGHT && Bt_DeviceIsConnected(DeviceId_Uhk_Dongle)) { + Messenger_Send2(DeviceId_Uhk_Dongle, MessageId_SyncableProperty, + SyncablePropertyId_MouseReport, (const uint8_t *)report, sizeof(*report)); } } -extern "C" void UsbCompatibility_ConsumerKeyboardAddScancode(uint8_t scancode) +extern "C" void UsbCompatibility_ConsumerKeyboardAddScancode(uint8_t scancode) { controls.system_codes.set(static_cast(scancode), true); } -extern "C" void UsbCompatibility_SendConsumerReport(const usb_media_keyboard_report_t* mediaReport, const usb_system_keyboard_report_t* systemReport) +extern "C" void UsbCompatibility_SendConsumerReport(const usb_media_keyboard_report_t *mediaReport, + const usb_system_keyboard_report_t *systemReport) { controls = controls_buffer(); - for(uint8_t i = 0; i < USB_MEDIA_KEYBOARD_MAX_KEYS && mediaReport->scancodes[i] != 0; i++) { - controls.consumer_codes.set(static_cast(mediaReport->scancodes[i]), true); + for (uint8_t i = 0; i < USB_MEDIA_KEYBOARD_MAX_KEYS && mediaReport->scancodes[i] != 0; i++) { + controls.consumer_codes.set( + static_cast(mediaReport->scancodes[i]), true); } UsbSystemKeyboard_ForeachScancode(systemReport, &UsbCompatibility_ConsumerKeyboardAddScancode); - controls_app& controls_app = controls_app::handle(); + controls_app &controls_app = controls_app::handle(); - if (controls_app.has_transport()) { + if (controls_app.active()) { controls_app.set_report_state(controls); } else if (DEVICE_IS_UHK80_RIGHT && Bt_DeviceIsConnected(DeviceId_Uhk_Dongle)) { - Messenger_Send2(DeviceId_Uhk_Dongle, MessageId_SyncableProperty, SyncablePropertyId_ControlsReport, (const uint8_t*)(&controls), sizeof(controls)); + Messenger_Send2(DeviceId_Uhk_Dongle, MessageId_SyncableProperty, + SyncablePropertyId_ControlsReport, (const uint8_t *)(&controls), sizeof(controls)); } } -extern "C" void UsbCompatibility_SendConsumerReport2(const uint8_t* report) +extern "C" void UsbCompatibility_SendConsumerReport2(const uint8_t *report) { - controls_app& controls_app = controls_app::handle(); + controls_app &controls_app = controls_app::handle(); - if (controls_app.has_transport()) { - controls_app.set_report_state(*(const controls_buffer*)report); + if (controls_app.active()) { + controls_app.set_report_state(*(const controls_buffer *)report); } } -extern "C" bool UsbCompatibility_UsbConnected() { +extern "C" bool UsbCompatibility_UsbConnected() +{ return keyboard_app::handle().has_transport(); } -extern "C" void UsbCompatibility_SetKeyboardLedsState(bool capsLock, bool numLock, bool scrollLock) { - if ( KeyboardLedsState.capsLock != capsLock ) { +extern "C" void UsbCompatibility_SetKeyboardLedsState(bool capsLock, bool numLock, bool scrollLock) +{ + if (KeyboardLedsState.capsLock != capsLock) { KeyboardLedsState.capsLock = capsLock; UsbBasicKeyboard_CapsLockOn = capsLock; EventVector_Set(EventVector_KeyboardLedState); MacroEvent_CapsLockStateChanged = true; } - if ( KeyboardLedsState.numLock != numLock ) { + if (KeyboardLedsState.numLock != numLock) { KeyboardLedsState.numLock = numLock; UsbBasicKeyboard_NumLockOn = numLock; EventVector_Set(EventVector_KeyboardLedState); MacroEvent_NumLockStateChanged = true; } - if ( KeyboardLedsState.scrollLock != scrollLock ) { + if (KeyboardLedsState.scrollLock != scrollLock) { KeyboardLedsState.scrollLock = scrollLock; UsbBasicKeyboard_ScrollLockOn = scrollLock; EventVector_Set(EventVector_KeyboardLedState); diff --git a/lib/c2usb b/lib/c2usb deleted file mode 160000 index bc5e5ae06..000000000 --- a/lib/c2usb +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bc5e5ae068594f99d8152b0c237231220ca02737 diff --git a/package.json b/package.json index c342888a6..dbaf225f2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "md5": "^2.3.0", "npm": "^10.0.0" } } diff --git a/patches/sdk-nrf/0001-Remove-mcuboot-build-warnings.patch b/patches/sdk-nrf/0001-Remove-mcuboot-build-warnings.patch index c3e57486f..89f690342 100644 --- a/patches/sdk-nrf/0001-Remove-mcuboot-build-warnings.patch +++ b/patches/sdk-nrf/0001-Remove-mcuboot-build-warnings.patch @@ -1,36 +1,12 @@ From 9f6342a09c416553381e4d478c894903ead17566 Mon Sep 17 00:00:00 2001 From: Benedek Kupper Date: Tue, 9 Jul 2024 22:38:48 +0200 -Subject: [PATCH] Remove mcuboot build warnings +Subject: [PATCH] Remove mcuboot default key build warning --- - cmake/partition_manager.cmake | 12 ------------ modules/mcuboot/CMakeLists.txt | 7 ------- - 2 files changed, 19 deletions(-) + 1 files changed, 7 deletions(-) -diff --git a/cmake/partition_manager.cmake b/cmake/partition_manager.cmake -index a45650a2d..292dd9c3f 100644 ---- a/cmake/partition_manager.cmake -+++ b/cmake/partition_manager.cmake -@@ -76,18 +76,6 @@ endif() - - if (NOT static_configuration AND - (CONFIG_BOOTLOADER_MCUBOOT OR CONFIG_SECURE_BOOT)) -- message(WARNING " -- --------------------------------------------------------------------- -- --- WARNING: Using a bootloader without pm_static.yml. --- -- --- There are cases where a deployed product can consist of --- -- --- multiple images, and only a subset of these images can be --- -- --- upgraded through a firmware update mechanism. In such cases, --- -- --- the upgradable images must have partitions that are static --- -- --- and are matching the partition map used by the bootloader --- -- --- programmed onto the device. --- -- --------------------------------------------------------------------- -- \n" -- ) - endif() - - diff --git a/modules/mcuboot/CMakeLists.txt b/modules/mcuboot/CMakeLists.txt index 5ec2643d7..70c706d52 100644 --- a/modules/mcuboot/CMakeLists.txt diff --git a/patches/zephyr/0001-drivers-udc-eliminate-C-compiler-warnings.patch b/patches/zephyr/0001-drivers-udc-eliminate-C-compiler-warnings.patch index 3172eb9de..0c11b6d64 100644 --- a/patches/zephyr/0001-drivers-udc-eliminate-C-compiler-warnings.patch +++ b/patches/zephyr/0001-drivers-udc-eliminate-C-compiler-warnings.patch @@ -1,19 +1,18 @@ -From df36898ebd062b07764d8437ccf17d16a0d70411 Mon Sep 17 00:00:00 2001 +From f5755b7348d6ee2464ad41652a1a93950349738d Mon Sep 17 00:00:00 2001 From: Benedek Kupper Date: Tue, 9 Jul 2024 22:34:13 +0200 Subject: [PATCH] drivers: udc: eliminate C++ compiler warnings Pending upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/69490 - --- - include/zephyr/drivers/usb/udc.h | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) + include/zephyr/drivers/usb/udc.h | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/zephyr/drivers/usb/udc.h b/include/zephyr/drivers/usb/udc.h -index 0f01d877e..70012660d 100644 +index 15b99cf5251..fd35c8e2749 100644 --- a/include/zephyr/drivers/usb/udc.h +++ b/include/zephyr/drivers/usb/udc.h -@@ -299,7 +299,7 @@ struct udc_data { +@@ -309,7 +309,7 @@ struct udc_data { */ static inline bool udc_is_initialized(const struct device *dev) { @@ -22,7 +21,7 @@ index 0f01d877e..70012660d 100644 return atomic_test_bit(&data->status, UDC_STATUS_INITIALIZED); } -@@ -313,7 +313,7 @@ static inline bool udc_is_initialized(const struct device *dev) +@@ -323,7 +323,7 @@ static inline bool udc_is_initialized(const struct device *dev) */ static inline bool udc_is_enabled(const struct device *dev) { @@ -31,7 +30,7 @@ index 0f01d877e..70012660d 100644 return atomic_test_bit(&data->status, UDC_STATUS_ENABLED); } -@@ -327,7 +327,7 @@ static inline bool udc_is_enabled(const struct device *dev) +@@ -337,7 +337,7 @@ static inline bool udc_is_enabled(const struct device *dev) */ static inline bool udc_is_suspended(const struct device *dev) { @@ -40,7 +39,7 @@ index 0f01d877e..70012660d 100644 return atomic_test_bit(&data->status, UDC_STATUS_SUSPENDED); } -@@ -400,7 +400,7 @@ int udc_shutdown(const struct device *dev); +@@ -413,7 +413,7 @@ int udc_shutdown(const struct device *dev); */ static inline struct udc_device_caps udc_caps(const struct device *dev) { @@ -49,7 +48,7 @@ index 0f01d877e..70012660d 100644 return data->caps; } -@@ -430,7 +430,7 @@ enum udc_bus_speed udc_device_speed(const struct device *dev); +@@ -443,7 +443,7 @@ enum udc_bus_speed udc_device_speed(const struct device *dev); */ static inline int udc_set_address(const struct device *dev, const uint8_t addr) { @@ -58,7 +57,16 @@ index 0f01d877e..70012660d 100644 int ret; if (!udc_is_enabled(dev)) { -@@ -456,7 +456,7 @@ static inline int udc_set_address(const struct device *dev, const uint8_t addr) +@@ -475,7 +475,7 @@ static inline int udc_set_address(const struct device *dev, const uint8_t addr) + static inline int udc_test_mode(const struct device *dev, + const uint8_t mode, const bool dryrun) + { +- const struct udc_api *api = dev->api; ++ const struct udc_api *api = (const struct udc_api *)dev->api; + int ret; + + if (!udc_is_enabled(dev)) { +@@ -505,7 +505,7 @@ static inline int udc_test_mode(const struct device *dev, */ static inline int udc_host_wakeup(const struct device *dev) { @@ -67,6 +75,15 @@ index 0f01d877e..70012660d 100644 int ret; if (!udc_is_enabled(dev)) { +@@ -722,7 +722,7 @@ static inline struct udc_buf_info *udc_get_buf_info(const struct net_buf *const + */ + static inline const void *udc_get_event_ctx(const struct device *dev) + { +- struct udc_data *data = dev->data; ++ struct udc_data *data = (struct udc_data *)dev->data; + + return data->event_ctx; + } -- -2.44.0 +2.43.0 diff --git a/right/src/CMakeLists.txt b/right/src/CMakeLists.txt new file mode 100644 index 000000000..785cb8d63 --- /dev/null +++ b/right/src/CMakeLists.txt @@ -0,0 +1,50 @@ +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/arduino_hid +) + +add_subdirectory(config_parser) +add_subdirectory(layouts) +add_subdirectory(macros) +add_subdirectory(peripherals) +add_subdirectory(slave_drivers) +add_subdirectory(usb_commands) +add_subdirectory(usb_interfaces) + +target_sources(${PROJECT_NAME} PRIVATE + caret_config.c + config_manager.c + debug.c + eeprom.c + event_scheduler.c + host_connection.c + i2c.c + i2c_error_logger.c + key_states.c + keymap.c + layer.c + layer_stack.c + layer_switcher.c + led_display.c + led_manager.c + ledmap.c + macro_events.c + macro_recorder.c + mouse_controller.c + mouse_keys.c + module.c + postponer.c + power_mode.c + secondary_role_driver.c + segment_display.c + slave_scheduler.c + storage.c + str_utils.c + stubs.c + test_switches.c + timer.c + usb_protocol_handler.c + usb_report_updater.c + user_logic.c + utils.c +) diff --git a/right/src/buspal/bootloader_common.h b/right/src/buspal/bootloader_common.h index 309328419..6436f1584 100644 --- a/right/src/buspal/bootloader_common.h +++ b/right/src/buspal/bootloader_common.h @@ -5,7 +5,6 @@ #include #include #include -#include "bootloader_common.h" #include "fsl_common.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/right/src/config_parser/CMakeLists.txt b/right/src/config_parser/CMakeLists.txt new file mode 100644 index 000000000..0da4b876e --- /dev/null +++ b/right/src/config_parser/CMakeLists.txt @@ -0,0 +1,10 @@ +target_sources(${PROJECT_NAME} PRIVATE + basic_types.c + config_globals.c + error_reporting.c + parse_config.c + parse_host_connection.c + parse_keymap.c + parse_macro.c + parse_module_config.c +) diff --git a/right/src/config_parser/basic_types.h b/right/src/config_parser/basic_types.h index dd44b7e1c..c4bfb746e 100644 --- a/right/src/config_parser/basic_types.h +++ b/right/src/config_parser/basic_types.h @@ -5,9 +5,6 @@ #include #include -#ifndef __ZEPHYR__ - #include "fsl_common.h" -#endif // Typedefs: diff --git a/right/src/layouts/CMakeLists.txt b/right/src/layouts/CMakeLists.txt new file mode 100644 index 000000000..777c9dec0 --- /dev/null +++ b/right/src/layouts/CMakeLists.txt @@ -0,0 +1,5 @@ +target_sources(${PROJECT_NAME} PRIVATE + key_layout_60_to_universal.c + key_layout_80_to_universal.c + key_layout.c +) diff --git a/right/src/macros/CMakeLists.txt b/right/src/macros/CMakeLists.txt new file mode 100644 index 000000000..ab8f58a3e --- /dev/null +++ b/right/src/macros/CMakeLists.txt @@ -0,0 +1,13 @@ +target_sources(${PROJECT_NAME} PRIVATE + commands.c + core.c + debug_commands.c + key_timing.c + keyid_parser.c + scancode_commands.c + set_command.c + shortcut_parser.c + status_buffer.c + string_reader.c + vars.c +) diff --git a/right/src/main.c b/right/src/main.c index 9a0ba8863..9a3d4eef2 100644 --- a/right/src/main.c +++ b/right/src/main.c @@ -57,8 +57,8 @@ static void initConfig() while (!IsConfigInitialized) { if (IsEepromInitialized) { - if (IsFactoryResetModeEnabled || UsbCommand_ApplyConfig() != UsbStatusCode_Success) { - UsbCommand_ApplyFactory(); + if (IsFactoryResetModeEnabled || UsbCommand_ApplyConfig(NULL, NULL) != UsbStatusCode_Success) { + UsbCommand_ApplyFactory(NULL, NULL); } ShortcutParser_initialize(); KeyIdParser_initialize(); diff --git a/right/src/peripherals/CMakeLists.txt b/right/src/peripherals/CMakeLists.txt new file mode 100644 index 000000000..2840cfa22 --- /dev/null +++ b/right/src/peripherals/CMakeLists.txt @@ -0,0 +1,7 @@ +target_sources(${PROJECT_NAME} PRIVATE + #adc.c + #led_driver.c + merge_sensor.c + reset_button.c + #test_led.c +) diff --git a/right/src/slave_drivers/CMakeLists.txt b/right/src/slave_drivers/CMakeLists.txt new file mode 100644 index 000000000..ca9d464a8 --- /dev/null +++ b/right/src/slave_drivers/CMakeLists.txt @@ -0,0 +1,6 @@ +target_sources(${PROJECT_NAME} PRIVATE + is31fl3xxx_driver.c + #kboot_driver.c + touchpad_driver.c + uhk_module_driver.c +) diff --git a/right/src/stubs.c b/right/src/stubs.c index 7ed2ed56e..807b12d22 100644 --- a/right/src/stubs.c +++ b/right/src/stubs.c @@ -6,3 +6,26 @@ #include "device.h" #endif +#define ATTRS __attribute__((weak)) + + ATTRS bool SegmentDisplay_NeedsUpdate = false; + ATTRS bool RunningOnBattery = false; + ATTRS bool RightRunningOnBattery = false; + ATTRS void Oled_UpdateBrightness() {}; + ATTRS void Oled_ShiftScreen() {}; + ATTRS void ScreenManager_SwitchScreenEvent() {}; + ATTRS void Charger_UpdateBatteryState() {}; + ATTRS const rgb_t* PairingScreen_ActionColor(key_action_t* action) { return NULL; }; + ATTRS void Uart_Reenable() {}; + ATTRS void Uart_Enable() {}; + ATTRS status_t ZephyrI2c_MasterTransferNonBlocking(i2c_master_transfer_t *transfer) { return kStatus_Fail; }; + ATTRS void Oled_LogConstant(const char* text) {}; + ATTRS void Oled_Log(const char *fmt, ...) {}; + ATTRS void Uart_LogConstant(const char* buffer) {}; + ATTRS void Uart_Log(const char *fmt, ...) {}; + ATTRS void Log(const char *fmt, ...) {}; + ATTRS void LogBt(const char *fmt, ...) {}; + ATTRS void BtPair_EndPairing(bool success, const char* msg) {}; + ATTRS void BtManager_RestartBt() {}; + ATTRS void DongleLeds_Update(void) {}; + ATTRS void BtPair_ClearUnknownBonds() {}; diff --git a/right/src/stubs.h b/right/src/stubs.h index 836802edf..349239c21 100644 --- a/right/src/stubs.h +++ b/right/src/stubs.h @@ -18,33 +18,31 @@ // Macros: -#define ATTRS __attribute__((weak)) __attribute__((unused)) - // Variables: // Functions: - ATTRS bool SegmentDisplay_NeedsUpdate = false; - ATTRS bool RunningOnBattery = false; - ATTRS bool RightRunningOnBattery = false; - ATTRS void Oled_UpdateBrightness() {}; - ATTRS void Oled_ShiftScreen() {}; - ATTRS void ScreenManager_SwitchScreenEvent() {}; - ATTRS void Charger_UpdateBatteryState() {}; - ATTRS const rgb_t* PairingScreen_ActionColor(key_action_t* action) { return NULL; }; - ATTRS void Uart_Reenable() {}; - ATTRS void Uart_Enable() {}; - ATTRS status_t ZephyrI2c_MasterTransferNonBlocking(i2c_master_transfer_t *transfer) { return kStatus_Fail; }; - ATTRS void Oled_LogConstant(const char* text) {}; - ATTRS void Oled_Log(const char *fmt, ...) {}; - ATTRS void Uart_LogConstant(const char* buffer) {}; - ATTRS void Uart_Log(const char *fmt, ...) {}; - ATTRS void Log(const char *fmt, ...) {}; - ATTRS void LogBt(const char *fmt, ...) {}; - ATTRS void BtPair_EndPairing(bool success, const char* msg) {}; - ATTRS void BtManager_RestartBt() {}; - ATTRS void DongleLeds_Update() {}; - ATTRS void BtPair_ClearUnknownBonds() {}; + extern bool SegmentDisplay_NeedsUpdate; + extern bool RunningOnBattery; + extern bool RightRunningOnBattery; + extern void Oled_UpdateBrightness(); + extern void Oled_ShiftScreen(); + extern void ScreenManager_SwitchScreenEvent(); + extern void Charger_UpdateBatteryState(); + extern const rgb_t* PairingScreen_ActionColor(key_action_t* action); + extern void Uart_Reenable(); + extern void Uart_Enable(); + extern status_t ZephyrI2c_MasterTransferNonBlocking(i2c_master_transfer_t *transfer); + extern void Oled_LogConstant(const char* text); + extern void Oled_Log(const char *fmt, ...); + extern void Uart_LogConstant(const char* buffer); + extern void Uart_Log(const char *fmt, ...); + extern void Log(const char *fmt, ...); + extern void LogBt(const char *fmt, ...); + extern void BtPair_EndPairing(bool success, const char* msg); + extern void BtManager_RestartBt(); + extern void DongleLeds_Update(void); + extern void BtPair_ClearUnknownBonds(); #if DEVICE_HAS_OLED #define WIDGET_REFRESH(W) Widget_Refresh(W) diff --git a/right/src/usb_api.h b/right/src/usb_api.h index 6f09f24d9..25a174de2 100644 --- a/right/src/usb_api.h +++ b/right/src/usb_api.h @@ -86,6 +86,33 @@ #define HID_RI_COLLECTION_APPLICATION 0x01 #define HID_RI_COLLECTION_LOGICAL 0x02 +#ifdef __ZEPHYR__ + typedef enum _usb_status + { + kStatus_USB_Success = 0x00U, /*!< Success */ + kStatus_USB_Error, /*!< Failed */ + + kStatus_USB_Busy, /*!< Busy */ + kStatus_USB_InvalidHandle, /*!< Invalid handle */ + kStatus_USB_InvalidParameter, /*!< Invalid parameter */ + kStatus_USB_InvalidRequest, /*!< Invalid request */ + kStatus_USB_ControllerNotFound, /*!< Controller cannot be found */ + kStatus_USB_InvalidControllerInterface, /*!< Invalid controller interface */ + + kStatus_USB_NotSupported, /*!< Configuration is not supported */ + kStatus_USB_Retry, /*!< Enumeration get configuration retry */ + kStatus_USB_TransferStall, /*!< Transfer stalled */ + kStatus_USB_TransferFailed, /*!< Transfer failed */ + kStatus_USB_AllocFail, /*!< Allocation failed */ + kStatus_USB_LackSwapBuffer, /*!< Insufficient swap buffer for KHCI */ + kStatus_USB_TransferCancel, /*!< The transfer cancelled */ + kStatus_USB_BandwidthFail, /*!< Allocate bandwidth failed */ + kStatus_USB_MSDStatusFail, /*!< For MSD, the CSW status means fail */ + } usb_status_t; + + typedef uint8_t usb_hid_protocol_t; +#endif + // Functions: static inline bool test_bit(unsigned nr, const uint8_t *addr) { diff --git a/right/src/usb_commands/CMakeLists.txt b/right/src/usb_commands/CMakeLists.txt new file mode 100644 index 000000000..f545a0218 --- /dev/null +++ b/right/src/usb_commands/CMakeLists.txt @@ -0,0 +1,24 @@ +target_sources(${PROJECT_NAME} PRIVATE + usb_command_apply_config.c + usb_command_draw_oled.c + usb_command_exec_macro_command.c + #usb_command_get_adc_value.c + usb_command_get_debug_buffer.c + usb_command_get_device_property.c + usb_command_get_device_state.c + usb_command_get_module_property.c + usb_command_get_new_pairings.c + #usb_command_get_slave_i2c_errors.c + usb_command_get_variable.c + #usb_command_jump_to_module_bootloader.c + usb_command_launch_storage_transfer.c + usb_command_pairing.c + usb_command_read_config.c + usb_command_reenumerate.c + #usb_command_send_kboot_command_to_module.c + #usb_command_set_i2c_baudrate.c + #usb_command_set_led_pwm_brightness.c + usb_command_set_variable.c + usb_command_switch_keymap.c + usb_command_write_config.c +) diff --git a/right/src/usb_commands/usb_command_apply_config.c b/right/src/usb_commands/usb_command_apply_config.c index 457f91508..ce3a3162c 100644 --- a/right/src/usb_commands/usb_command_apply_config.c +++ b/right/src/usb_commands/usb_command_apply_config.c @@ -16,29 +16,30 @@ #ifdef __ZEPHYR__ #include "state_sync.h" -#include "legacy/event_scheduler.h" +#include "event_scheduler.h" #include "main.h" #endif -void updateUsbBuffer(uint8_t usbStatusCode, uint16_t parserOffset, parser_stage_t parserStage) +void updateUsbBuffer(uint8_t *GenericHidInBuffer, uint8_t usbStatusCode, uint16_t parserOffset, parser_stage_t parserStage) { SetUsbTxBufferUint8(0, usbStatusCode); SetUsbTxBufferUint16(1, parserOffset); SetUsbTxBufferUint8(3, parserStage); } -static uint8_t validateConfig() { +static uint8_t validateConfig(uint8_t *GenericHidInBuffer) { // Validate the staging configuration. ParserRunDry = true; StagingUserConfigBuffer.offset = 0; uint8_t parseConfigStatus = ParseConfig(&StagingUserConfigBuffer); - updateUsbBuffer(UsbStatusCode_Success, StagingUserConfigBuffer.offset, ParsingStage_Validate); - + if (GenericHidInBuffer) { + updateUsbBuffer(GenericHidInBuffer, UsbStatusCode_Success, StagingUserConfigBuffer.offset, ParsingStage_Validate); + } return parseConfigStatus; } -void UsbCommand_ApplyConfigAsync(void) { - if (validateConfig() == UsbStatusCode_Success) { +void UsbCommand_ApplyConfigAsync(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { + if (validateConfig(GenericHidInBuffer) == UsbStatusCode_Success) { EventVector_Set(EventVector_ApplyConfig); #ifdef __ZEPHYR__ Main_Wake(); @@ -56,7 +57,7 @@ static bool hwConfigEmpty() { return HardwareConfig->majorVersion == 0 || HardwareConfig->majorVersion == 255; } -void UsbCommand_ApplyFactory(void) +void UsbCommand_ApplyFactory(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { EventVector_Unset(EventVector_ApplyConfig); @@ -78,12 +79,12 @@ void UsbCommand_ApplyFactory(void) LedManager_FullUpdate(); } -uint8_t UsbCommand_ApplyConfig(void) +uint8_t UsbCommand_ApplyConfig(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { static bool isBoot = true; EventVector_Unset(EventVector_ApplyConfig); - uint8_t parseConfigStatus = validateConfig(); + uint8_t parseConfigStatus = validateConfig(GenericHidInBuffer); if (parseConfigStatus != UsbStatusCode_Success) { return parseConfigStatus; diff --git a/right/src/usb_commands/usb_command_apply_config.h b/right/src/usb_commands/usb_command_apply_config.h index cdd09ae22..2527156f3 100644 --- a/right/src/usb_commands/usb_command_apply_config.h +++ b/right/src/usb_commands/usb_command_apply_config.h @@ -15,8 +15,8 @@ // Functions: - uint8_t UsbCommand_ApplyConfig(void); - void UsbCommand_ApplyFactory(void); - void UsbCommand_ApplyConfigAsync(void); + uint8_t UsbCommand_ApplyConfig(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); + void UsbCommand_ApplyFactory(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); + void UsbCommand_ApplyConfigAsync(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_draw_oled.c b/right/src/usb_commands/usb_command_draw_oled.c index 74be314f5..fab8e885e 100644 --- a/right/src/usb_commands/usb_command_draw_oled.c +++ b/right/src/usb_commands/usb_command_draw_oled.c @@ -15,7 +15,7 @@ #include "debug.h" #include -void UsbCommand_DrawOled() +void UsbCommand_DrawOled(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { #if defined(__ZEPHYR__) && DEVICE_HAS_OLED uint8_t x = GetUsbRxBufferUint8(1); diff --git a/right/src/usb_commands/usb_command_draw_oled.h b/right/src/usb_commands/usb_command_draw_oled.h index a3a1371a0..7d57c742f 100644 --- a/right/src/usb_commands/usb_command_draw_oled.h +++ b/right/src/usb_commands/usb_command_draw_oled.h @@ -11,6 +11,6 @@ // Functions: - void UsbCommand_DrawOled(); + void UsbCommand_DrawOled(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_exec_macro_command.c b/right/src/usb_commands/usb_command_exec_macro_command.c index 7bfcade42..f1c81cfdd 100644 --- a/right/src/usb_commands/usb_command_exec_macro_command.c +++ b/right/src/usb_commands/usb_command_exec_macro_command.c @@ -14,7 +14,7 @@ char UsbMacroCommand[USB_GENERIC_HID_OUT_BUFFER_LENGTH+1]; uint8_t UsbMacroCommandLength = 0; key_state_t dummyState; -static void requestExecution() +static void requestExecution(const uint8_t *GenericHidOutBuffer) { Utils_SafeStrCopy(UsbMacroCommand, ((char*)GenericHidOutBuffer) + 1, sizeof(GenericHidOutBuffer)-1); UsbMacroCommandLength = strlen(UsbMacroCommand); @@ -41,9 +41,9 @@ void UsbMacroCommand_ExecuteSynchronously() EventVector_Unset(EventVector_UsbMacroCommandWaitingForExecution); } -void UsbCommand_ExecMacroCommand() +void UsbCommand_ExecMacroCommand(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { if (canExecute()) { - requestExecution(); + requestExecution(GenericHidOutBuffer); } } diff --git a/right/src/usb_commands/usb_command_exec_macro_command.h b/right/src/usb_commands/usb_command_exec_macro_command.h index 0a6ef294f..f87dc4300 100644 --- a/right/src/usb_commands/usb_command_exec_macro_command.h +++ b/right/src/usb_commands/usb_command_exec_macro_command.h @@ -16,6 +16,6 @@ // Functions: void UsbMacroCommand_ExecuteSynchronously(); - void UsbCommand_ExecMacroCommand(); + void UsbCommand_ExecMacroCommand(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_get_adc_value.c b/right/src/usb_commands/usb_command_get_adc_value.c index 852ea0f47..b191a4c2b 100644 --- a/right/src/usb_commands/usb_command_get_adc_value.c +++ b/right/src/usb_commands/usb_command_get_adc_value.c @@ -2,7 +2,7 @@ #include "usb_commands/usb_command_get_adc_value.h" #include "peripherals/adc.h" -void UsbCommand_GetAdcValue(void) +void UsbCommand_GetAdcValue(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { SetUsbTxBufferUint32(1, ADC_Measure()); } diff --git a/right/src/usb_commands/usb_command_get_adc_value.h b/right/src/usb_commands/usb_command_get_adc_value.h index b699602e5..b8830ce8c 100644 --- a/right/src/usb_commands/usb_command_get_adc_value.h +++ b/right/src/usb_commands/usb_command_get_adc_value.h @@ -1,8 +1,12 @@ #ifndef __USB_COMMAND_GET_ADC_VALUE_H__ #define __USB_COMMAND_GET_ADC_VALUE_H__ +// Includes: + + #include + // Functions: - void UsbCommand_GetAdcValue(void); + void UsbCommand_GetAdcValue(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_get_debug_buffer.c b/right/src/usb_commands/usb_command_get_debug_buffer.c index e280dcdcb..f8065bce9 100644 --- a/right/src/usb_commands/usb_command_get_debug_buffer.c +++ b/right/src/usb_commands/usb_command_get_debug_buffer.c @@ -19,7 +19,7 @@ uint8_t DebugBuffer[USB_GENERIC_HID_IN_BUFFER_LENGTH]; -void UsbCommand_GetDebugBuffer(void) +void UsbCommand_GetDebugBuffer(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { #ifndef __ZEPHYR__ SetDebugBufferUint32(1, I2C_Watchdog); diff --git a/right/src/usb_commands/usb_command_get_debug_buffer.h b/right/src/usb_commands/usb_command_get_debug_buffer.h index 06619b403..d726e3150 100644 --- a/right/src/usb_commands/usb_command_get_debug_buffer.h +++ b/right/src/usb_commands/usb_command_get_debug_buffer.h @@ -11,7 +11,7 @@ // Functions: - void UsbCommand_GetDebugBuffer(void); + void UsbCommand_GetDebugBuffer(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); void SetDebugBufferUint8(uint32_t offset, uint8_t value); void SetDebugBufferUint16(uint32_t offset, uint16_t value); diff --git a/right/src/usb_commands/usb_command_get_device_property.c b/right/src/usb_commands/usb_command_get_device_property.c index efd76ae3e..f45c7fd1b 100644 --- a/right/src/usb_commands/usb_command_get_device_property.c +++ b/right/src/usb_commands/usb_command_get_device_property.c @@ -25,7 +25,7 @@ uint16_t configSizes[] = {HARDWARE_CONFIG_SIZE, USER_CONFIG_SIZE}; -void UsbCommand_GetDeviceProperty(void) +void UsbCommand_GetDeviceProperty(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { uint8_t propertyId = GetUsbRxBufferUint8(1); uint8_t *dest = GenericHidInBuffer + 1; @@ -105,7 +105,7 @@ void UsbCommand_GetDeviceProperty(void) } break; case DevicePropertyId_NewPairings: #ifdef __ZEPHYR__ - UsbCommand_GetNewPairings(); + UsbCommand_GetNewPairings(GenericHidOutBuffer, GenericHidInBuffer); #endif break; default: diff --git a/right/src/usb_commands/usb_command_get_device_property.h b/right/src/usb_commands/usb_command_get_device_property.h index cce6ca492..517490f2f 100644 --- a/right/src/usb_commands/usb_command_get_device_property.h +++ b/right/src/usb_commands/usb_command_get_device_property.h @@ -1,6 +1,10 @@ #ifndef __USB_COMMAND_GET_DEVICE_PROPERTY_H__ #define __USB_COMMAND_GET_DEVICE_PROPERTY_H__ +// Includes: + + #include + // Typedefs: typedef enum { @@ -31,6 +35,6 @@ // Functions: - void UsbCommand_GetDeviceProperty(void); + void UsbCommand_GetDeviceProperty(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_get_device_state.c b/right/src/usb_commands/usb_command_get_device_state.c index 63ab15f1c..6b06339e4 100644 --- a/right/src/usb_commands/usb_command_get_device_state.c +++ b/right/src/usb_commands/usb_command_get_device_state.c @@ -29,7 +29,7 @@ #define Bt_NewPairedDevice 0 #endif -void UsbCommand_GetKeyboardState(void) +void UsbCommand_GetKeyboardState(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { #ifdef __ZEPHYR__ diff --git a/right/src/usb_commands/usb_command_get_device_state.h b/right/src/usb_commands/usb_command_get_device_state.h index 4b14970ea..1b1b20f9b 100644 --- a/right/src/usb_commands/usb_command_get_device_state.h +++ b/right/src/usb_commands/usb_command_get_device_state.h @@ -1,6 +1,10 @@ #ifndef __USB_COMMAND_GET_KEYBOARD_STATE_H__ #define __USB_COMMAND_GET_KEYBOARD_STATE_H__ +// Includes: + + #include + // Typedefs: typedef enum { @@ -18,6 +22,6 @@ typedef enum { // Functions: - void UsbCommand_GetKeyboardState(void); + void UsbCommand_GetKeyboardState(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_get_module_property.c b/right/src/usb_commands/usb_command_get_module_property.c index a7eda47b5..5b5efdaa6 100644 --- a/right/src/usb_commands/usb_command_get_module_property.c +++ b/right/src/usb_commands/usb_command_get_module_property.c @@ -10,7 +10,7 @@ #include "utils.h" #include "versioning.h" -void UsbCommand_GetModuleProperty() +void UsbCommand_GetModuleProperty(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { slot_t slotId = GetUsbRxBufferUint8(1); diff --git a/right/src/usb_commands/usb_command_get_module_property.h b/right/src/usb_commands/usb_command_get_module_property.h index 2237aaf24..101574cbf 100644 --- a/right/src/usb_commands/usb_command_get_module_property.h +++ b/right/src/usb_commands/usb_command_get_module_property.h @@ -1,9 +1,13 @@ #ifndef __USB_COMMAND_GET_MODULE_PROPERTY_H__ #define __USB_COMMAND_GET_MODULE_PROPERTY_H__ +// Includes: + + #include + // Functions: - void UsbCommand_GetModuleProperty(); + void UsbCommand_GetModuleProperty(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); // Typedefs: diff --git a/right/src/usb_commands/usb_command_get_new_pairings.c b/right/src/usb_commands/usb_command_get_new_pairings.c index d86d030dc..168f319b8 100644 --- a/right/src/usb_commands/usb_command_get_new_pairings.c +++ b/right/src/usb_commands/usb_command_get_new_pairings.c @@ -7,12 +7,20 @@ #include #include "host_connection.h" -static uint8_t idx; -static uint8_t count; +typedef struct { + const uint8_t *OutBuffer; + uint8_t *InBuffer; + uint8_t idx; + uint8_t count; +} CommandUserData; + static void bt_foreach_bond_cb(const struct bt_bond_info *info, void *user_data) { - if (idx + BLE_ADDR_LEN+1 >= USB_GENERIC_HID_IN_BUFFER_LENGTH) { + CommandUserData *data = (CommandUserData *)user_data; + uint8_t *GenericHidInBuffer = data->InBuffer; + + if ((data->idx + BLE_ADDR_LEN + 1) >= USB_GENERIC_HID_IN_BUFFER_LENGTH) { return; } @@ -20,22 +28,26 @@ static void bt_foreach_bond_cb(const struct bt_bond_info *info, void *user_data) return; } - count++; + data->count++; - SetUsbTxBufferBleAddress(idx, &info->addr); - idx += BLE_ADDR_LEN; + SetUsbTxBufferBleAddress(data->idx, &info->addr); + data->idx += BLE_ADDR_LEN; // Name placeholder - SetUsbTxBufferUint8(idx++, 0); + SetUsbTxBufferUint8(data->idx++, 0); } -void UsbCommand_GetNewPairings(void) { - count = 0; - idx = 2; +void UsbCommand_GetNewPairings(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { + CommandUserData data = { + .OutBuffer = GenericHidOutBuffer, + .InBuffer = GenericHidInBuffer, + .idx = 2, + .count = 0 + }; - bt_foreach_bond(BT_ID_DEFAULT, bt_foreach_bond_cb, NULL); + bt_foreach_bond(BT_ID_DEFAULT, bt_foreach_bond_cb, &data); - SetUsbTxBufferUint8(1, count); + SetUsbTxBufferUint8(1, data.count); Bt_NewPairedDevice = false; } diff --git a/right/src/usb_commands/usb_command_get_new_pairings.h b/right/src/usb_commands/usb_command_get_new_pairings.h index a62b0cb41..726e12064 100644 --- a/right/src/usb_commands/usb_command_get_new_pairings.h +++ b/right/src/usb_commands/usb_command_get_new_pairings.h @@ -1,13 +1,17 @@ #ifndef __USB_COMMAND_GET_NEW_PAIRINGS_H__ #define __USB_COMMAND_GET_NEW_PAIRINGS_H__ +// Includes: + + #include + #ifdef __ZEPHYR__ // Typedefs: // Functions: - void UsbCommand_GetNewPairings(void); + void UsbCommand_GetNewPairings(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_get_slave_i2c_errors.c b/right/src/usb_commands/usb_command_get_slave_i2c_errors.c index 0843a330f..3e62cad94 100644 --- a/right/src/usb_commands/usb_command_get_slave_i2c_errors.c +++ b/right/src/usb_commands/usb_command_get_slave_i2c_errors.c @@ -4,7 +4,7 @@ #include "slave_scheduler.h" #include "i2c_error_logger.h" -void UsbCommand_GetSlaveI2cErrors() +void UsbCommand_GetSlaveI2cErrors(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { uint8_t slaveId = GetUsbRxBufferUint8(1); diff --git a/right/src/usb_commands/usb_command_get_slave_i2c_errors.h b/right/src/usb_commands/usb_command_get_slave_i2c_errors.h index d62d459ae..f06357d65 100644 --- a/right/src/usb_commands/usb_command_get_slave_i2c_errors.h +++ b/right/src/usb_commands/usb_command_get_slave_i2c_errors.h @@ -1,9 +1,13 @@ #ifndef __USB_COMMAND_GET_SLAVE_I2C_ERRORS_H__ #define __USB_COMMAND_GET_SLAVE_I2C_ERRORS_H__ +// Includes: + + #include + // Functions: - void UsbCommand_GetSlaveI2cErrors(); + void UsbCommand_GetSlaveI2cErrors(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); // Typedefs: diff --git a/right/src/usb_commands/usb_command_get_variable.c b/right/src/usb_commands/usb_command_get_variable.c index c96cddb0e..95391bd9d 100644 --- a/right/src/usb_commands/usb_command_get_variable.c +++ b/right/src/usb_commands/usb_command_get_variable.c @@ -6,7 +6,7 @@ #include "macros/core.h" #include "config_manager.h" -void UsbCommand_GetVariable(void) +void UsbCommand_GetVariable(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { usb_variable_id_t variableId = GetUsbRxBufferUint8(1); diff --git a/right/src/usb_commands/usb_command_get_variable.h b/right/src/usb_commands/usb_command_get_variable.h index 5e5992aeb..88bf2498e 100644 --- a/right/src/usb_commands/usb_command_get_variable.h +++ b/right/src/usb_commands/usb_command_get_variable.h @@ -1,8 +1,12 @@ #ifndef __USB_COMMAND_GET_VARIABLE_H__ #define __USB_COMMAND_GET_VARIABLE_H__ +// Includes: + + #include + // Functions: - void UsbCommand_GetVariable(void); + void UsbCommand_GetVariable(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_jump_to_module_bootloader.c b/right/src/usb_commands/usb_command_jump_to_module_bootloader.c index 5cff7e00d..e93a4541f 100644 --- a/right/src/usb_commands/usb_command_jump_to_module_bootloader.c +++ b/right/src/usb_commands/usb_command_jump_to_module_bootloader.c @@ -3,7 +3,7 @@ #include "slot.h" #include "slave_drivers/uhk_module_driver.h" -void UsbCommand_JumpToModuleBootloader(void) +void UsbCommand_JumpToModuleBootloader(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { uint8_t slotId = GetUsbRxBufferUint8(1); diff --git a/right/src/usb_commands/usb_command_jump_to_module_bootloader.h b/right/src/usb_commands/usb_command_jump_to_module_bootloader.h index e004f3ae6..1d5b28779 100644 --- a/right/src/usb_commands/usb_command_jump_to_module_bootloader.h +++ b/right/src/usb_commands/usb_command_jump_to_module_bootloader.h @@ -1,9 +1,13 @@ #ifndef __USB_COMMAND_JUMP_TO_MODULE_BOOTLOADER_H__ #define __USB_COMMAND_JUMP_TO_MODULE_BOOTLOADER_H__ +// Includes: + + #include + // Functions: - void UsbCommand_JumpToModuleBootloader(void); + void UsbCommand_JumpToModuleBootloader(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); // Typedefs: diff --git a/right/src/usb_commands/usb_command_launch_storage_transfer.c b/right/src/usb_commands/usb_command_launch_storage_transfer.c index c6a258815..259b1494e 100644 --- a/right/src/usb_commands/usb_command_launch_storage_transfer.c +++ b/right/src/usb_commands/usb_command_launch_storage_transfer.c @@ -20,7 +20,7 @@ enum _generic_status #include "eeprom.h" #endif -void UsbCommand_LaunchStorageTransfer(void) +void UsbCommand_LaunchStorageTransfer(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { storage_operation_t storageOperation = GetUsbRxBufferUint8(1); config_buffer_id_t configBufferId = GetUsbRxBufferUint8(2); diff --git a/right/src/usb_commands/usb_command_launch_storage_transfer.h b/right/src/usb_commands/usb_command_launch_storage_transfer.h index e2b7796da..2c7aae96b 100644 --- a/right/src/usb_commands/usb_command_launch_storage_transfer.h +++ b/right/src/usb_commands/usb_command_launch_storage_transfer.h @@ -1,6 +1,10 @@ #ifndef __USB_COMMAND_LAUNCH_STORAGE_TRANSFER_H__ #define __USB_COMMAND_LAUNCH_STORAGE_TRANSFER_H__ +// Includes: + + #include + // Typedef typedef enum { @@ -11,6 +15,6 @@ // Functions: - void UsbCommand_LaunchStorageTransfer(void); + void UsbCommand_LaunchStorageTransfer(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_pairing.c b/right/src/usb_commands/usb_command_pairing.c index 2cb92fe18..b1a1bee22 100644 --- a/right/src/usb_commands/usb_command_pairing.c +++ b/right/src/usb_commands/usb_command_pairing.c @@ -15,7 +15,7 @@ #define BUF_KEY_R_POS 7 #define BUF_KEY_C_POS 23 -void UsbCommand_GetPairingData(void) { +void UsbCommand_GetPairingData(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { struct bt_le_oob* oob = BtPair_GetLocalOob(); SetUsbTxBufferBleAddress(BUF_ADR_POS, &oob->addr); @@ -23,7 +23,7 @@ void UsbCommand_GetPairingData(void) { memcpy(GenericHidInBuffer + BUF_KEY_C_POS, oob->le_sc_data.c, BLE_KEY_LEN); } -void UsbCommand_SetPairingData(void) { +void UsbCommand_SetPairingData(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { struct bt_le_oob oob; uint8_t peerId = GenericHidOutBuffer[BUF_PEER_POS]; @@ -53,27 +53,31 @@ void UsbCommand_SetPairingData(void) { } } -void UsbCommand_PairCentral(void) { +void UsbCommand_PairCentral(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { +#ifdef CONFIG_BT_CENTRAL BtPair_PairCentral(); +#endif } -void UsbCommand_PairPeripheral(void) { +void UsbCommand_PairPeripheral(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { +#ifdef CONFIG_BT_PERIPHERAL BtPair_PairPeripheral(); +#endif } // If zero address is provided, all existing bonds will be deleted -void UsbCommand_Unpair(void) { +void UsbCommand_Unpair(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { bt_addr_le_t addr = GetUsbRxBufferBleAddress(1); BtPair_Unpair(addr); } -void UsbCommand_IsPaired(void) { +void UsbCommand_IsPaired(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { bt_addr_le_t addr = GetUsbRxBufferBleAddress(1); bool isPaired = BtPair_IsDeviceBonded(&addr); SetUsbTxBufferUint8(1, isPaired); } -void UsbCommand_EnterPairingMode(void) { +void UsbCommand_EnterPairingMode(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { BtManager_EnterPairingMode(); } diff --git a/right/src/usb_commands/usb_command_pairing.h b/right/src/usb_commands/usb_command_pairing.h index b6312f0df..64bb6b1f1 100644 --- a/right/src/usb_commands/usb_command_pairing.h +++ b/right/src/usb_commands/usb_command_pairing.h @@ -1,15 +1,19 @@ #ifndef __USB_COMMAND_PAIRING_H__ #define __USB_COMMAND_PAIRING_H__ +// Includes: + + #include + // Functions: - void UsbCommand_GetPairingData(void); - void UsbCommand_SetPairingData(void); - void UsbCommand_PairCentral(void); - void UsbCommand_PairPeripheral(void); - void UsbCommand_Unpair(void); - void UsbCommand_IsPaired(void); - void UsbCommand_EnterPairingMode(void); + void UsbCommand_GetPairingData(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); + void UsbCommand_SetPairingData(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); + void UsbCommand_PairCentral(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); + void UsbCommand_PairPeripheral(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); + void UsbCommand_Unpair(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); + void UsbCommand_IsPaired(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); + void UsbCommand_EnterPairingMode(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); // Typedefs: diff --git a/right/src/usb_commands/usb_command_read_config.c b/right/src/usb_commands/usb_command_read_config.c index 7dd09de27..99212d2fd 100644 --- a/right/src/usb_commands/usb_command_read_config.c +++ b/right/src/usb_commands/usb_command_read_config.c @@ -11,7 +11,7 @@ #include "usb_protocol_handler.h" #include "eeprom.h" -void UsbCommand_ReadConfig() +void UsbCommand_ReadConfig(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { config_buffer_id_t configBufferId = GetUsbRxBufferUint8(1); uint8_t length = GetUsbRxBufferUint8(2); diff --git a/right/src/usb_commands/usb_command_read_config.h b/right/src/usb_commands/usb_command_read_config.h index 889d3ec6a..f2be164dc 100644 --- a/right/src/usb_commands/usb_command_read_config.h +++ b/right/src/usb_commands/usb_command_read_config.h @@ -1,9 +1,13 @@ #ifndef __USB_COMMAND_READ_CONFIG_H__ #define __USB_COMMAND_READ_CONFIG_H__ +// Includes: + + #include + // Functions: - void UsbCommand_ReadConfig(); + void UsbCommand_ReadConfig(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); // Typedefs: diff --git a/right/src/usb_commands/usb_command_reenumerate.c b/right/src/usb_commands/usb_command_reenumerate.c index 86ba1cdf8..256b32e94 100644 --- a/right/src/usb_commands/usb_command_reenumerate.c +++ b/right/src/usb_commands/usb_command_reenumerate.c @@ -9,7 +9,7 @@ #include "usb_commands/usb_command_reenumerate.h" #include "usb_protocol_handler.h" -void UsbCommand_Reenumerate(void) +void UsbCommand_Reenumerate(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { #ifdef __ZEPHYR__ bootmode_set(BOOT_MODE_TYPE_BOOTLOADER); diff --git a/right/src/usb_commands/usb_command_reenumerate.h b/right/src/usb_commands/usb_command_reenumerate.h index fccefd32f..d4dcd7161 100644 --- a/right/src/usb_commands/usb_command_reenumerate.h +++ b/right/src/usb_commands/usb_command_reenumerate.h @@ -1,8 +1,12 @@ #ifndef __USB_COMMAND_REENUMERATE_H__ #define __USB_COMMAND_REENUMERATE_H__ +// Includes: + + #include + // Functions: - void UsbCommand_Reenumerate(void); + void UsbCommand_Reenumerate(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_send_kboot_command_to_module.c b/right/src/usb_commands/usb_command_send_kboot_command_to_module.c index 08397fbf6..c96817df2 100644 --- a/right/src/usb_commands/usb_command_send_kboot_command_to_module.c +++ b/right/src/usb_commands/usb_command_send_kboot_command_to_module.c @@ -2,7 +2,7 @@ #include "usb_commands/usb_command_send_kboot_command_to_module.h" #include "slave_drivers/kboot_driver.h" -void UsbCommand_SendKbootCommandToModule(void) +void UsbCommand_SendKbootCommandToModule(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { KbootDriverState.phase = 0; KbootDriverState.i2cAddress = GetUsbRxBufferUint8(2); diff --git a/right/src/usb_commands/usb_command_send_kboot_command_to_module.h b/right/src/usb_commands/usb_command_send_kboot_command_to_module.h index e1b3b0907..b67dfd10e 100644 --- a/right/src/usb_commands/usb_command_send_kboot_command_to_module.h +++ b/right/src/usb_commands/usb_command_send_kboot_command_to_module.h @@ -1,8 +1,12 @@ #ifndef __USB_COMMAND_SEND_KBOOT_COMMAND_TO_MODULE_H__ #define __USB_COMMAND_SEND_KBOOT_COMMAND_TO_MODULE_H__ +// Includes: + + #include + // Functions: - void UsbCommand_SendKbootCommandToModule(void); + void UsbCommand_SendKbootCommandToModule(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_set_i2c_baud_rate.c b/right/src/usb_commands/usb_command_set_i2c_baud_rate.c index 90b121337..c294fee75 100644 --- a/right/src/usb_commands/usb_command_set_i2c_baud_rate.c +++ b/right/src/usb_commands/usb_command_set_i2c_baud_rate.c @@ -3,7 +3,7 @@ #include "init_peripherals.h" #include "fsl_i2c.h" -void UsbCommand_SetI2cBaudRate(void) +void UsbCommand_SetI2cBaudRate(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { uint32_t i2cBaudRate = GetUsbRxBufferUint32(1); ChangeI2cBaudRate(i2cBaudRate); diff --git a/right/src/usb_commands/usb_command_set_i2c_baud_rate.h b/right/src/usb_commands/usb_command_set_i2c_baud_rate.h index c95c4d321..22881e24b 100644 --- a/right/src/usb_commands/usb_command_set_i2c_baud_rate.h +++ b/right/src/usb_commands/usb_command_set_i2c_baud_rate.h @@ -1,8 +1,12 @@ #ifndef __USB_COMMAND_SET_I2C_BAUD_RATE__ #define __USB_COMMAND_SET_I2C_BAUD_RATE__ +// Includes: + + #include + // Functions: - void UsbCommand_SetI2cBaudRate(void); + void UsbCommand_SetI2cBaudRate(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_set_led_pwm_brightness.c b/right/src/usb_commands/usb_command_set_led_pwm_brightness.c index 3cb465a3e..035f38bca 100644 --- a/right/src/usb_commands/usb_command_set_led_pwm_brightness.c +++ b/right/src/usb_commands/usb_command_set_led_pwm_brightness.c @@ -3,7 +3,7 @@ #include "slave_drivers/uhk_module_driver.h" #include "led_pwm.h" -void UsbCommand_SetLedPwmBrightness(void) +void UsbCommand_SetLedPwmBrightness(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { uint8_t brightnessPercent = GetUsbRxBufferUint8(1); LedPwm_SetBrightness(brightnessPercent); diff --git a/right/src/usb_commands/usb_command_set_led_pwm_brightness.h b/right/src/usb_commands/usb_command_set_led_pwm_brightness.h index 48a9ac140..73daafb25 100644 --- a/right/src/usb_commands/usb_command_set_led_pwm_brightness.h +++ b/right/src/usb_commands/usb_command_set_led_pwm_brightness.h @@ -1,8 +1,12 @@ #ifndef __USB_COMMAND_SET_LED_PWM_BRIGHTNESS_H__ #define __USB_COMMAND_SET_LED_PWM_BRIGHTNESS_H__ +// Includes: + + #include + // Functions: - void UsbCommand_SetLedPwmBrightness(void); + void UsbCommand_SetLedPwmBrightness(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_set_test_led.c b/right/src/usb_commands/usb_command_set_test_led.c index 0104270e4..82dfd3467 100644 --- a/right/src/usb_commands/usb_command_set_test_led.c +++ b/right/src/usb_commands/usb_command_set_test_led.c @@ -3,7 +3,7 @@ #include "peripherals/test_led.h" #include "slave_drivers/uhk_module_driver.h" -void UsbCommand_SetTestLed(void) +void UsbCommand_SetTestLed(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { bool isTestLedOn = GetUsbRxBufferUint8(1); TestLed_Set(isTestLedOn); diff --git a/right/src/usb_commands/usb_command_set_test_led.h b/right/src/usb_commands/usb_command_set_test_led.h index 718e8fe15..413616e7f 100644 --- a/right/src/usb_commands/usb_command_set_test_led.h +++ b/right/src/usb_commands/usb_command_set_test_led.h @@ -1,8 +1,12 @@ #ifndef __USB_COMMAND_SET_TEST_LED_H__ #define __USB_COMMAND_SET_TEST_LED_H__ +// Includes: + + #include + // Functions: - void UsbCommand_SetTestLed(void); + void UsbCommand_SetTestLed(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_set_variable.c b/right/src/usb_commands/usb_command_set_variable.c index f04f5a5ac..729413e85 100644 --- a/right/src/usb_commands/usb_command_set_variable.c +++ b/right/src/usb_commands/usb_command_set_variable.c @@ -8,7 +8,7 @@ #include "config_manager.h" #include "ledmap.h" -void UsbCommand_SetVariable(void) +void UsbCommand_SetVariable(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { usb_variable_id_t variableId = GetUsbRxBufferUint8(1); diff --git a/right/src/usb_commands/usb_command_set_variable.h b/right/src/usb_commands/usb_command_set_variable.h index e9b61218c..2f3148a77 100644 --- a/right/src/usb_commands/usb_command_set_variable.h +++ b/right/src/usb_commands/usb_command_set_variable.h @@ -1,8 +1,12 @@ #ifndef __USB_COMMAND_SET_VARIABLE_H__ #define __USB_COMMAND_SET_VARIABLE_H__ +// Includes: + + #include + // Functions: - void UsbCommand_SetVariable(void); + void UsbCommand_SetVariable(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_commands/usb_command_switch_keymap.c b/right/src/usb_commands/usb_command_switch_keymap.c index 2a822c778..60ef2a9ad 100644 --- a/right/src/usb_commands/usb_command_switch_keymap.c +++ b/right/src/usb_commands/usb_command_switch_keymap.c @@ -3,7 +3,7 @@ #include "keymap.h" #include "layer_stack.h" -void UsbCommand_SwitchKeymap(void) +void UsbCommand_SwitchKeymap(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { uint32_t keymapLength = GetUsbRxBufferUint8(1); char *keymapAbbrev = (char*)GenericHidOutBuffer + 2; diff --git a/right/src/usb_commands/usb_command_switch_keymap.h b/right/src/usb_commands/usb_command_switch_keymap.h index be22c7710..58e13480c 100644 --- a/right/src/usb_commands/usb_command_switch_keymap.h +++ b/right/src/usb_commands/usb_command_switch_keymap.h @@ -1,9 +1,13 @@ #ifndef __USB_COMMAND_SWITCH_KEYMAP_H__ #define __USB_COMMAND_SWITCH_KEYMAP_H__ +// Includes: + + #include + // Functions: - void UsbCommand_SwitchKeymap(void); + void UsbCommand_SwitchKeymap(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); // Typedefs: diff --git a/right/src/usb_commands/usb_command_write_config.c b/right/src/usb_commands/usb_command_write_config.c index 298792415..9c147e940 100644 --- a/right/src/usb_commands/usb_command_write_config.c +++ b/right/src/usb_commands/usb_command_write_config.c @@ -6,7 +6,7 @@ #include "usb_protocol_handler.h" #include "eeprom.h" -void UsbCommand_WriteConfig(config_buffer_id_t configBufferId) +void UsbCommand_WriteConfig(config_buffer_id_t configBufferId, const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { uint8_t length = GetUsbRxBufferUint8(1); uint16_t offset = GetUsbRxBufferUint16(2); diff --git a/right/src/usb_commands/usb_command_write_config.h b/right/src/usb_commands/usb_command_write_config.h index 7fde91bda..c8dcbc2ab 100644 --- a/right/src/usb_commands/usb_command_write_config.h +++ b/right/src/usb_commands/usb_command_write_config.h @@ -14,6 +14,6 @@ // Functions: - void UsbCommand_WriteConfig(config_buffer_id_t configBufferId); + void UsbCommand_WriteConfig(config_buffer_id_t configBufferId, const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/usb_device_config.h b/right/src/usb_device_config.h index a79f908bb..62822884f 100644 --- a/right/src/usb_device_config.h +++ b/right/src/usb_device_config.h @@ -1,9 +1,12 @@ #ifndef __USB_DEVICE_CONFIG_H__ #define __USB_DEVICE_CONFIG_H__ +#ifndef __ZEPHYR__ // KHCI instance count #define USB_DEVICE_CONFIG_KHCI 1 +#include "fsl_common.h" +#endif #include "usb_interfaces/usb_interface_basic_keyboard.h" #include "usb_interfaces/usb_interface_mouse.h" #include "usb_interfaces/usb_interface_media_keyboard.h" diff --git a/right/src/usb_interfaces/CMakeLists.txt b/right/src/usb_interfaces/CMakeLists.txt new file mode 100644 index 000000000..148ebfec1 --- /dev/null +++ b/right/src/usb_interfaces/CMakeLists.txt @@ -0,0 +1,8 @@ +target_sources(${PROJECT_NAME} PRIVATE + usb_interface_basic_keyboard.c + usb_interface_gamepad.c + #usb_interface_generic_hid.c + usb_interface_media_keyboard.c + usb_interface_mouse.c + usb_interface_system_keyboard.c +) diff --git a/right/src/usb_interfaces/usb_interface_basic_keyboard.h b/right/src/usb_interfaces/usb_interface_basic_keyboard.h index 57c20e162..dac5307ca 100644 --- a/right/src/usb_interfaces/usb_interface_basic_keyboard.h +++ b/right/src/usb_interfaces/usb_interface_basic_keyboard.h @@ -6,12 +6,6 @@ #include #include -#ifndef __ZEPHYR__ - #include "fsl_common.h" -#else - #include "keyboard/legacy_ports.h" -#endif - #include "attributes.h" #include "usb_api.h" #include "usb_descriptors/usb_descriptor_basic_keyboard_report.h" diff --git a/right/src/usb_interfaces/usb_interface_generic_hid.c b/right/src/usb_interfaces/usb_interface_generic_hid.c index 9ff60ceae..2b5fd9aa9 100644 --- a/right/src/usb_interfaces/usb_interface_generic_hid.c +++ b/right/src/usb_interfaces/usb_interface_generic_hid.c @@ -1,22 +1,10 @@ -#ifndef __ZEPHYR__ #include "usb_composite_device.h" -#endif - #include "usb_protocol_handler.h" -#ifndef __ZEPHYR__ uint32_t UsbGenericHidActionCounter; -#endif - -uint8_t GenericHidInBuffer[USB_GENERIC_HID_IN_BUFFER_LENGTH]; - -#ifdef __ZEPHYR__ -const uint8_t *GenericHidOutBuffer; -#else -uint8_t GenericHidOutBuffer[USB_GENERIC_HID_OUT_BUFFER_LENGTH]; -#endif +uint8_t GenericHidIn[USB_GENERIC_HID_IN_BUFFER_LENGTH]; +uint8_t GenericHidOut[USB_GENERIC_HID_OUT_BUFFER_LENGTH]; -#ifndef __ZEPHYR__ static usb_status_t UsbReceiveData(void) { if (!UsbCompositeDevice.attach) { @@ -25,7 +13,7 @@ static usb_status_t UsbReceiveData(void) return USB_DeviceHidRecv(UsbCompositeDevice.genericHidHandle, USB_GENERIC_HID_ENDPOINT_OUT_INDEX, - GenericHidOutBuffer, + GenericHidOut, USB_GENERIC_HID_OUT_BUFFER_LENGTH); } @@ -62,11 +50,11 @@ usb_status_t UsbGenericHidCallback(class_handle_t handle, uint32_t event, void * break; case kUSB_DeviceHidEventRecvResponse: - UsbProtocolHandler(); + UsbProtocolHandler(GenericHidOut, GenericHidIn); USB_DeviceHidSend(UsbCompositeDevice.genericHidHandle, USB_GENERIC_HID_ENDPOINT_IN_INDEX, - GenericHidInBuffer, + GenericHidIn, USB_GENERIC_HID_IN_BUFFER_LENGTH); UsbGenericHidActionCounter++; error = UsbReceiveData(); @@ -75,7 +63,7 @@ usb_status_t UsbGenericHidCallback(class_handle_t handle, uint32_t event, void * case kUSB_DeviceHidEventGetReport: { usb_device_hid_report_struct_t *report = (usb_device_hid_report_struct_t*)param; if (report->reportType == USB_DEVICE_HID_REQUEST_GET_REPORT_TYPE_INPUT && report->reportId == 0 && report->reportLength <= USB_GENERIC_HID_IN_BUFFER_LENGTH) { - report->reportBuffer = GenericHidInBuffer; + report->reportBuffer = GenericHidIn; UsbGenericHidActionCounter++; error = kStatus_USB_Success; } else { @@ -90,4 +78,3 @@ usb_status_t UsbGenericHidCallback(class_handle_t handle, uint32_t event, void * return error; } -#endif diff --git a/right/src/usb_interfaces/usb_interface_generic_hid.h b/right/src/usb_interfaces/usb_interface_generic_hid.h index 07c8a10c0..bbd51b2e2 100644 --- a/right/src/usb_interfaces/usb_interface_generic_hid.h +++ b/right/src/usb_interfaces/usb_interface_generic_hid.h @@ -28,13 +28,6 @@ // Variables: extern uint32_t UsbGenericHidActionCounter; - extern uint8_t GenericHidInBuffer[USB_GENERIC_HID_IN_BUFFER_LENGTH]; - -#ifdef __ZEPHYR__ - extern const uint8_t *GenericHidOutBuffer; -#else - extern uint8_t GenericHidOutBuffer[USB_GENERIC_HID_OUT_BUFFER_LENGTH]; -#endif // Functions: diff --git a/right/src/usb_interfaces/usb_interface_media_keyboard.h b/right/src/usb_interfaces/usb_interface_media_keyboard.h index 97d5387bd..9c955cf6d 100644 --- a/right/src/usb_interfaces/usb_interface_media_keyboard.h +++ b/right/src/usb_interfaces/usb_interface_media_keyboard.h @@ -3,12 +3,6 @@ // Includes: -#ifndef __ZEPHYR__ - #include "fsl_common.h" -#else - #include "keyboard/legacy_ports.h" -#endif - #include "usb_descriptors/usb_descriptor_media_keyboard_report.h" #include "usb_api.h" diff --git a/right/src/usb_interfaces/usb_interface_mouse.h b/right/src/usb_interfaces/usb_interface_mouse.h index 2403cc0da..fd2fe0b8b 100644 --- a/right/src/usb_interfaces/usb_interface_mouse.h +++ b/right/src/usb_interfaces/usb_interface_mouse.h @@ -6,10 +6,6 @@ #include "usb_api.h" // #include "usb_descriptors/usb_descriptor_device.h" -#ifdef __ZEPHYR__ - #include "keyboard/legacy_ports.h" -#endif - // Macros: #define USB_MOUSE_INTERFACE_INDEX 1 diff --git a/right/src/usb_interfaces/usb_interface_system_keyboard.h b/right/src/usb_interfaces/usb_interface_system_keyboard.h index af5b906da..40e5ec7c2 100644 --- a/right/src/usb_interfaces/usb_interface_system_keyboard.h +++ b/right/src/usb_interfaces/usb_interface_system_keyboard.h @@ -3,11 +3,6 @@ // Includes: -#ifndef __ZEPHYR__ - #include "fsl_common.h" -#else - #include "keyboard/legacy_ports.h" -#endif #include "usb_descriptors/usb_descriptor_system_keyboard_report.h" #include "attributes.h" #include "usb_api.h" diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c index 37de92881..0c7619430 100644 --- a/right/src/usb_protocol_handler.c +++ b/right/src/usb_protocol_handler.c @@ -1,7 +1,6 @@ #include #include "macros/status_buffer.h" #include "usb_protocol_handler.h" -#include "buffer.h" #include "usb_commands/usb_command_get_device_state.h" #include "usb_commands/usb_command_read_config.h" #include "usb_commands/usb_command_reenumerate.h" @@ -30,114 +29,104 @@ #include "usb_commands/usb_command_set_i2c_baud_rate.h" #endif -#ifdef __ZEPHYR__ -void CommandProtocolRxHandler(const uint8_t* data, size_t size) -{ - GenericHidOutBuffer = data; - // printk("CommandProtocolRxHandler: data[0]:%u size:%d\n", data[0], size); - UsbProtocolHandler(); - CommandProtocolTx(GenericHidInBuffer, USB_GENERIC_HID_OUT_BUFFER_LENGTH); -} -#endif - -void UsbProtocolHandler(void) +void UsbProtocolHandler(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer) { bzero(GenericHidInBuffer, USB_GENERIC_HID_IN_BUFFER_LENGTH); uint8_t command = GetUsbRxBufferUint8(0); switch (command) { case UsbCommandId_GetDeviceProperty: - UsbCommand_GetDeviceProperty(); + UsbCommand_GetDeviceProperty(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_Reenumerate: - UsbCommand_Reenumerate(); + UsbCommand_Reenumerate(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_ReadConfig: - UsbCommand_ReadConfig(); + UsbCommand_ReadConfig(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_WriteHardwareConfig: - UsbCommand_WriteConfig(ConfigBufferId_HardwareConfig); + UsbCommand_WriteConfig(ConfigBufferId_HardwareConfig, GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_WriteStagingUserConfig: - UsbCommand_WriteConfig(ConfigBufferId_StagingUserConfig); + UsbCommand_WriteConfig(ConfigBufferId_StagingUserConfig, GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_ApplyConfig: #ifdef __ZEPHYR__ - UsbCommand_ApplyConfigAsync(); + UsbCommand_ApplyConfigAsync(GenericHidOutBuffer, GenericHidInBuffer); #else - UsbCommand_ApplyConfig(); + UsbCommand_ApplyConfig(GenericHidOutBuffer, GenericHidInBuffer); #endif break; case UsbCommandId_GetDeviceState: - UsbCommand_GetKeyboardState(); + UsbCommand_GetKeyboardState(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_GetDebugBuffer: - UsbCommand_GetDebugBuffer(); + UsbCommand_GetDebugBuffer(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_SwitchKeymap: - UsbCommand_SwitchKeymap(); + UsbCommand_SwitchKeymap(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_GetVariable: - UsbCommand_GetVariable(); + UsbCommand_GetVariable(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_SetVariable: - UsbCommand_SetVariable(); + UsbCommand_SetVariable(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_ExecMacroCommand: - UsbCommand_ExecMacroCommand(); + UsbCommand_ExecMacroCommand(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_LaunchStorageTransfer: - UsbCommand_LaunchStorageTransfer(); + UsbCommand_LaunchStorageTransfer(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_GetModuleProperty: - UsbCommand_GetModuleProperty(); + UsbCommand_GetModuleProperty(GenericHidOutBuffer, GenericHidInBuffer); break; #ifdef __ZEPHYR__ case UsbCommandId_DrawOled: - UsbCommand_DrawOled(); + UsbCommand_DrawOled(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_GetPairingData: - UsbCommand_GetPairingData(); + UsbCommand_GetPairingData(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_SetPairingData: - UsbCommand_SetPairingData(); + UsbCommand_SetPairingData(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_PairCentral: - UsbCommand_PairCentral(); + UsbCommand_PairCentral(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_PairPeripheral: - UsbCommand_PairPeripheral(); + UsbCommand_PairPeripheral(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_UnpairAll: - UsbCommand_Unpair(); + UsbCommand_Unpair(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_IsPaired: - UsbCommand_IsPaired(); + UsbCommand_IsPaired(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_EnterPairingMode: - UsbCommand_EnterPairingMode(); + UsbCommand_EnterPairingMode(GenericHidOutBuffer, GenericHidInBuffer); break; #else case UsbCommandId_JumpToModuleBootloader: - UsbCommand_JumpToModuleBootloader(); + UsbCommand_JumpToModuleBootloader(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_SendKbootCommandToModule: - UsbCommand_SendKbootCommandToModule(); + UsbCommand_SendKbootCommandToModule(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_SetTestLed: - UsbCommand_SetTestLed(); + UsbCommand_SetTestLed(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_GetAdcValue: - UsbCommand_GetAdcValue(); + UsbCommand_GetAdcValue(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_SetLedPwmBrightness: - UsbCommand_SetLedPwmBrightness(); + UsbCommand_SetLedPwmBrightness(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_GetSlaveI2cErrors: - UsbCommand_GetSlaveI2cErrors(); + UsbCommand_GetSlaveI2cErrors(GenericHidOutBuffer, GenericHidInBuffer); break; case UsbCommandId_SetI2cBaudRate: - UsbCommand_SetI2cBaudRate(); + UsbCommand_SetI2cBaudRate(GenericHidOutBuffer, GenericHidInBuffer); break; #endif default: @@ -149,38 +138,8 @@ void UsbProtocolHandler(void) } } -uint8_t GetUsbRxBufferUint8(uint32_t offset) -{ - return GetBufferUint8(GenericHidOutBuffer, offset); -} - -uint16_t GetUsbRxBufferUint16(uint32_t offset) -{ - return GetBufferUint16(GenericHidOutBuffer, offset); -} - -uint32_t GetUsbRxBufferUint32(uint32_t offset) -{ - return GetBufferUint32(GenericHidOutBuffer, offset); -} - -void SetUsbTxBufferUint8(uint32_t offset, uint8_t value) -{ - SetBufferUint8(GenericHidInBuffer, offset, value); -} - -void SetUsbTxBufferUint16(uint32_t offset, uint16_t value) -{ - SetBufferUint16(GenericHidInBuffer, offset, value); -} - -void SetUsbTxBufferUint32(uint32_t offset, uint32_t value) -{ - SetBufferUint32(GenericHidInBuffer, offset, value); -} - #ifdef __ZEPHYR__ -bt_addr_le_t GetUsbRxBufferBleAddress(uint32_t offset) { +bt_addr_le_t GetBufferBleAddress(const uint8_t *GenericHidOutBuffer, uint32_t offset) { bt_addr_le_t addr; addr.type = 1; for (uint8_t i = 0; i < BLE_ADDR_LEN; i++) { @@ -189,7 +148,7 @@ bt_addr_le_t GetUsbRxBufferBleAddress(uint32_t offset) { return addr; } -void SetUsbTxBufferBleAddress(uint32_t offset, const bt_addr_le_t* addr) { +void SetBufferBleAddress(uint8_t *GenericHidInBuffer, uint32_t offset, const bt_addr_le_t* addr) { for (uint8_t i = 0; i < BLE_ADDR_LEN; i++) { GenericHidInBuffer[offset + i] = addr->a.val[i]; } diff --git a/right/src/usb_protocol_handler.h b/right/src/usb_protocol_handler.h index e8cacfc94..96a30e36e 100644 --- a/right/src/usb_protocol_handler.h +++ b/right/src/usb_protocol_handler.h @@ -7,6 +7,7 @@ #include #include #include "usb_interfaces/usb_interface_generic_hid.h" + #include "buffer.h" #ifdef __ZEPHYR__ #include #else @@ -17,6 +18,17 @@ #define USB_STATUS_CODE_SIZE 1 + #define GetUsbRxBufferUint8(OFFSET) (GetBufferUint8(GenericHidOutBuffer, OFFSET)) + #define GetUsbRxBufferUint16(OFFSET) (GetBufferUint16(GenericHidOutBuffer, OFFSET)) + #define GetUsbRxBufferUint32(OFFSET) (GetBufferUint32(GenericHidOutBuffer, OFFSET)) + + #define SetUsbTxBufferUint8(OFFSET, VALUE) (SetBufferUint8(GenericHidInBuffer, OFFSET, VALUE)) + #define SetUsbTxBufferUint16(OFFSET, VALUE) (SetBufferUint16(GenericHidInBuffer, OFFSET, VALUE)) + #define SetUsbTxBufferUint32(OFFSET, VALUE) (SetBufferUint32(GenericHidInBuffer, OFFSET, VALUE)) + + #define GetUsbRxBufferBleAddress(OFFSET) (GetBufferBleAddress(GenericHidOutBuffer, OFFSET)) + #define SetUsbTxBufferBleAddress(OFFSET, VALUE) (SetBufferBleAddress(GenericHidInBuffer, OFFSET, VALUE)) + // Typedefs: typedef enum { @@ -77,19 +89,9 @@ // Functions: #ifdef __ZEPHYR__ - extern bool CommandProtocolTx(const uint8_t* data, size_t size); - - void SetUsbTxBufferBleAddress(uint32_t offset, const bt_addr_le_t* addr); - extern bt_addr_le_t GetUsbRxBufferBleAddress(uint32_t offset); + bt_addr_le_t GetBufferBleAddress(const uint8_t *GenericHidOutBuffer, uint32_t offset); + void SetBufferBleAddress(uint8_t *GenericHidInBuffer, uint32_t offset, const bt_addr_le_t* addr); #endif - void UsbProtocolHandler(void); - - uint8_t GetUsbRxBufferUint8(uint32_t offset); - uint16_t GetUsbRxBufferUint16(uint32_t offset); - uint32_t GetUsbRxBufferUint32(uint32_t offset); - - void SetUsbTxBufferUint8(uint32_t offset, uint8_t value); - void SetUsbTxBufferUint16(uint32_t offset, uint16_t value); - void SetUsbTxBufferUint32(uint32_t offset, uint32_t value); + void UsbProtocolHandler(const uint8_t *GenericHidOutBuffer, uint8_t *GenericHidInBuffer); #endif diff --git a/right/src/user_logic.c b/right/src/user_logic.c index 438343b64..1e4cfe171 100644 --- a/right/src/user_logic.c +++ b/right/src/user_logic.c @@ -15,7 +15,7 @@ void RunUserLogic(void) { if (EventVector_IsSet(EventVector_ApplyConfig)) { - UsbCommand_ApplyConfig(); + UsbCommand_ApplyConfig(NULL, NULL); } if (EventVector_IsSet(EventVector_KeymapReloadNeeded)) { SwitchKeymapById(CurrentKeymapIndex); diff --git a/scripts/common.py b/scripts/common.py new file mode 100644 index 000000000..43f0a0fb2 --- /dev/null +++ b/scripts/common.py @@ -0,0 +1,17 @@ +import subprocess +import os +import json + +def exec(cmd): + return subprocess.check_output(cmd, shell=True).decode('utf-8').strip() + +def get_git_info(): + return { + 'repo': exec('git remote get-url origin').replace('https://github.com/', '').replace('git@github.com:', '').replace('.git', ''), + 'tag': exec('git tag --points-at HEAD') or exec('git rev-parse --short HEAD'), + 'root': exec('git rev-parse --show-toplevel') + } + +def read_package_json(): + with open(os.path.join(os.path.dirname(__file__), 'package.json'), 'r') as f: + return json.load(f) diff --git a/scripts/generate_versions.py b/scripts/generate_versions.py new file mode 100644 index 000000000..3f1c42da4 --- /dev/null +++ b/scripts/generate_versions.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +import sys +from common import get_git_info, read_package_json +from generate_versions_utils import generate_versions + +if __name__ == "__main__": + use_real_data = '--withMd5Sums' in sys.argv + use_zero_versions = '--withZeroVersions' in sys.argv + package_json = read_package_json() + git_info = get_git_info() + generate_versions(package_json, git_info, use_real_data, use_zero_versions) diff --git a/scripts/generate_versions_utils.py b/scripts/generate_versions_utils.py new file mode 100644 index 000000000..60a4cd2db --- /dev/null +++ b/scripts/generate_versions_utils.py @@ -0,0 +1,64 @@ +import hashlib +import os +import json +import shutil + +ZERO_MD5 = '00000000000000000000000000000000' + +version_property_prefixes = ['firmware', 'deviceProtocol', 'moduleProtocol', 'userConfig', 'hardwareConfig', 'smartMacros'] +patch_versions = ['Major', 'Minor', 'Patch'] + +def generate_versions(package_json, git_info, use_real_shas, use_zero_versions): + package_json = json.loads(json.dumps(package_json)) # Deep copy + + if use_zero_versions: + git_info = { + 'repo': '', + 'tag': '' + } + + version_variables = '\n'.join([ + f"const version_t {prefix}Version = {{ {', '.join(['0' if use_zero_versions else package_json[f'{prefix}Version'].split('.')[i] for i in range(len(patch_versions))])} }};" + for prefix in version_property_prefixes + ]) + + device_md5_sums = '\n'.join([ + f' [{device["deviceId"]}] = "{ZERO_MD5 if not use_real_shas else calculate_md5_checksum_of_file(os.path.join(os.path.dirname(__file__), "..", device["source"]))}",' + for device in package_json['devices'] + ]) + + module_md5_sums = '\n'.join([ + f' [{module["moduleId"]}] = "{ZERO_MD5 if not use_real_shas else calculate_md5_checksum_of_file(os.path.join(os.path.dirname(__file__), "..", module["source"]))}",' + for module in package_json['modules'] + ]) + + with open(os.path.join(os.path.dirname(__file__), '..', 'shared', 'versions.c'), 'w') as f: + f.write(f"""// Please do not edit this file by hand! +// It is to be regenerated by /scripts/generate_versions.py +#include "versioning.h" + +{version_variables} + +const char gitRepo[] = "{git_info['repo']}"; +const char gitTag[] = "{git_info['tag']}"; + +#ifdef DEVICE_COUNT +const char *const DeviceMD5Checksums[DEVICE_COUNT + 1] = {{ +{device_md5_sums} +}}; +#endif + +const char *const ModuleMD5Checksums[ModuleId_AllCount] = {{ +{module_md5_sums} +}}; +""") + + return { + 'devices': package_json['devices'], + 'modules': package_json['modules'] + } + +def calculate_md5_checksum_of_file(file_path): + with open(file_path, 'rb') as f: + file_data = f.read() + return hashlib.md5(file_data).hexdigest() diff --git a/scripts/make-release.mjs b/scripts/make-release.mjs index a6e6d1763..04c31a726 100755 --- a/scripts/make-release.mjs +++ b/scripts/make-release.mjs @@ -15,6 +15,21 @@ shell.config.verbose = true; const gitInfo = getGitInfo(); const packageJson = readPackageJson(); +function getZephyrBuildParameters(buildTarget) { + let cmakePresetsFile = fs.readFileSync(`${gitInfo.root}/device/CMakePresets.json`, 'utf8'); + cmakePresetsFile = cmakePresetsFile.replace(/\$\{sourceDir\}/g, `${gitInfo.root}/device`); + const cmakePresets = JSON.parse(cmakePresetsFile); + const configurePresets = cmakePresets.configurePresets; + + for (const preset of configurePresets) { + if (preset.cacheVariables.BOARD === buildTarget.name) { + return preset.cacheVariables; + } + } + console.error(`Unknown Zephyr build target: ${buildTarget.name}`); + process.exit(1); +} + function build(buildTarget, step) { const buildDir = path.dirname(`${__dirname}/../${buildTarget.source}`); if (step === 1) { @@ -29,6 +44,8 @@ function build(buildTarget, step) { shell.exec(`cd ${buildDir}/..; make -j8`); } } else if (buildTarget.platform === 'nordic') { + const cacheVariables = getZephyrBuildParameters(buildTarget); + shell.exec(`ZEPHYR_TOOLCHAIN_VARIANT=zephyr west build \ --build-dir ${gitInfo.root}/device/build/${buildTarget.name} \ ${gitInfo.root}/device \ @@ -36,10 +53,11 @@ function build(buildTarget, step) { --board ${buildTarget.name} \ --no-sysbuild \ -- \ - -DNCS_TOOLCHAIN_VERSION=NONE \ - -DEXTRA_CONF_FILE=prj.conf.overlays/${buildTarget.name}.prj.conf \ + -DNCS_TOOLCHAIN_VERSION=${cacheVariables.NCS_TOOLCHAIN_VERSION} \ + -DCONF_FILE=${gitInfo.root}/device/prj_release.conf \ + -DEXTRA_CONF_FILE="${cacheVariables.EXTRA_CONF_FILE}" \ -DBOARD_ROOT=${gitInfo.root} \ - -Dmcuboot_OVERLAY_CONFIG="${gitInfo.root}/device/child_image/mcuboot.conf;${gitInfo.root}/device/child_image/${buildTarget.name}.mcuboot.conf"` + -Dmcuboot_OVERLAY_CONFIG="${cacheVariables.mcuboot_OVERLAY_CONFIG}"` ); } } diff --git a/shared/CMakeLists.txt b/shared/CMakeLists.txt new file mode 100644 index 000000000..99acfa651 --- /dev/null +++ b/shared/CMakeLists.txt @@ -0,0 +1,28 @@ +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + # this really needs to be changed when time and restructuring permits + ${PROJECT_SOURCE_DIR} +) + +if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/versions.c") + message(WARNING "Generating missing versions.c for UHK") + find_package(Python 3 REQUIRED) + if(Python_VERSION_MAJOR LESS 3) + message(FATAL_ERROR "Python 3 is required versions generation.") + endif() + add_custom_command( + OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/versions.c" + COMMAND ${Python3_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/generate_versions.py" + DEPENDS "${PROJECT_SOURCE_DIR}/scripts/generate_versions.py" + ) +endif() +set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/versions.c PROPERTIES GENERATED TRUE) + +target_sources(${PROJECT_NAME} PRIVATE + bool_array_converter.c + buffer.c + crc16.c + key_matrix.c + slave_protocol.c + versions.c +) diff --git a/shared/device.h b/shared/device.h index b0fd275c6..9aa99ce71 100644 --- a/shared/device.h +++ b/shared/device.h @@ -43,7 +43,7 @@ #define DEVICE_IS_UHK60 (DEVICE_IS_UHK60V1_RIGHT || DEVICE_IS_UHK60V2_RIGHT) #define DEVICE_IS_MASTER (DEVICE_IS_UHK80_RIGHT || DEVICE_IS_UHK60V1_RIGHT || DEVICE_IS_UHK60V2_RIGHT) - #define DEVICE_NAME CONFIG_BT_DIS_MODEL + #define DEVICE_NAME CONFIG_USB_DEVICE_PRODUCT #if (DEVICE_ID == DEVICE_ID_UHK60V1_RIGHT || DEVICE_ID == DEVICE_ID_UHK60V2_RIGHT) #define KEY_MATRIX_ROWS 5 diff --git a/shared/fallback_versions.c b/shared/fallback_versions.c deleted file mode 100644 index 6598e22c8..000000000 --- a/shared/fallback_versions.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "attributes.h" -#include "versioning.h" - -// weak definitions of generated variables to be able to build without final artifacts available -const version_t firmwareVersion ATTR_WEAK = {}; -const version_t deviceProtocolVersion ATTR_WEAK = {}; -const version_t moduleProtocolVersion ATTR_WEAK = {}; -const version_t userConfigVersion ATTR_WEAK = {}; -const version_t hardwareConfigVersion ATTR_WEAK = {}; -const version_t smartMacrosVersion ATTR_WEAK = {}; - -const char gitRepo[] ATTR_WEAK = ""; -const char gitTag[] ATTR_WEAK = ""; - -#ifdef DEVICE_COUNT -const char *const DeviceMD5Checksums[DEVICE_COUNT + 1] ATTR_WEAK = { - [1] = "000000000000000000000000000000000", - [2] = "000000000000000000000000000000000", - [3] = "000000000000000000000000000000000", - [4] = "000000000000000000000000000000000", - [5] = "000000000000000000000000000000000", -}; -#endif - -const char *const ModuleMD5Checksums[ModuleId_AllCount] ATTR_WEAK = { - [1] = "000000000000000000000000000000000", - [2] = "000000000000000000000000000000000", - [3] = "000000000000000000000000000000000", - [4] = "000000000000000000000000000000000", -}; diff --git a/west.yml b/west.yml index 29462da0a..6aecb198f 100644 --- a/west.yml +++ b/west.yml @@ -7,12 +7,14 @@ manifest: url-base: https://github.com/nrfconnect - name: zephyr url-base: https://github.com/zephyrproject-rtos + - name: IntergatedCircuits + url-base: https://github.com/IntergatedCircuits projects: - name: sdk-nrf remote: sdk path: nrf - revision: v2.6.1 + revision: v2.8.0 import: path-prefix: nrfconnect clone-depth: 1 @@ -30,5 +32,9 @@ manifest: - name: hal_nxp remote: zephyr - path: nrfconnect/zephyr-hal-nxp + clone-depth: 1 + + - name: c2usb + remote: IntergatedCircuits + revision: da4ad86f1cd3a4f8b42aa2d9acdd43e384341ce4 clone-depth: 1 diff --git a/zephyr/module.yml b/zephyr/module.yml new file mode 100644 index 000000000..8a8055aa2 --- /dev/null +++ b/zephyr/module.yml @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +build: + # sharing common uhk source code between zephyr and legacy + cmake: . + settings: + # hardware model 2 doesn't work with out-of-tree board roots without this: + board_root: .