From ec018fbf4ed30b014b82f993246f8730687e649a Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 8 Oct 2020 17:17:37 +0700 Subject: clean up jlink default interface --- examples/rules.mk | 2 ++ hw/bsp/adafruit_clue/board.mk | 1 - hw/bsp/arduino_nano33_ble/board.mk | 1 - hw/bsp/circuitplayground_bluefruit/board.mk | 1 - hw/bsp/circuitplayground_express/board.mk | 1 - hw/bsp/d5035_01/board.mk | 1 - hw/bsp/da14695_dk_usb/board.mk | 1 - hw/bsp/da1469x_dk_pro/board.mk | 1 - hw/bsp/ea4088qs/board.mk | 1 - hw/bsp/ea4357/board.mk | 1 - hw/bsp/feather_m0_express/board.mk | 1 - hw/bsp/feather_m4_express/board.mk | 1 - hw/bsp/feather_nrf52840_express/board.mk | 1 - hw/bsp/feather_nrf52840_sense/board.mk | 1 - hw/bsp/feather_stm32f405/board.mk | 1 - hw/bsp/itsybitsy_m0/board.mk | 1 - hw/bsp/itsybitsy_m4/board.mk | 1 - hw/bsp/itsybitsy_nrf52840/board.mk | 1 - hw/bsp/lpcxpresso11u37/board.mk | 1 - hw/bsp/lpcxpresso11u68/board.mk | 1 - hw/bsp/lpcxpresso1347/board.mk | 1 - hw/bsp/lpcxpresso1549/board.mk | 1 - hw/bsp/lpcxpresso1769/board.mk | 1 - hw/bsp/lpcxpresso51u68/board.mk | 1 - hw/bsp/lpcxpresso54114/board.mk | 1 - hw/bsp/lpcxpresso55s69/board.mk | 1 - hw/bsp/luna/board.mk | 1 - hw/bsp/mbed1768/board.mk | 1 - hw/bsp/mcb1800/board.mk | 1 - hw/bsp/metro_m0_express/board.mk | 1 - hw/bsp/metro_m4_express/board.mk | 1 - hw/bsp/mimxrt1010_evk/board.mk | 1 - hw/bsp/mimxrt1020_evk/board.mk | 1 - hw/bsp/mimxrt1050_evkb/board.mk | 1 - hw/bsp/mimxrt1060_evk/board.mk | 1 - hw/bsp/mimxrt1064_evk/board.mk | 1 - hw/bsp/nrf52840_mdk_dongle/board.mk | 1 - hw/bsp/nutiny_nuc121s/board.mk | 1 - hw/bsp/nutiny_nuc125s/board.mk | 1 - hw/bsp/nutiny_nuc126v/board.mk | 1 - hw/bsp/nutiny_sdk_nuc120/board.mk | 1 - hw/bsp/nutiny_sdk_nuc505/board.mk | 1 - hw/bsp/pca10056/board.mk | 1 - hw/bsp/pca10059/board.mk | 1 - hw/bsp/pca10100/board.mk | 1 - hw/bsp/pyboardv11/board.mk | 1 - hw/bsp/raytac_mdbt50q_rx/board.mk | 1 - hw/bsp/samd11_xplained/board.mk | 1 - hw/bsp/samg55xplained/board.mk | 1 - hw/bsp/seeeduino_xiao/board.mk | 1 - hw/bsp/stm32f070rbnucleo/board.mk | 1 - hw/bsp/stm32f072disco/board.mk | 1 - hw/bsp/stm32f103bluepill/board.mk | 1 - hw/bsp/stm32f207nucleo/board.mk | 1 - hw/bsp/stm32f303disco/board.mk | 1 - hw/bsp/stm32f401blackpill/board.mk | 1 - hw/bsp/stm32f407disco/board.mk | 1 - hw/bsp/stm32f411blackpill/board.mk | 1 - hw/bsp/stm32f411disco/board.mk | 1 - hw/bsp/stm32f412disco/board.mk | 1 - hw/bsp/stm32h743eval/board.mk | 1 - hw/bsp/stm32h745disco/board.mk | 1 - hw/bsp/stm32l0538disco/board.mk | 1 - hw/bsp/stm32l476disco/board.mk | 1 - hw/bsp/teensy_40/board.mk | 1 - 65 files changed, 2 insertions(+), 64 deletions(-) diff --git a/examples/rules.mk b/examples/rules.mk index dacb81363..e972ce735 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -147,6 +147,8 @@ else JLINKEXE = JLinkExe endif +JLINK_IF ?= swd + # Flash using jlink flash-jlink: $(BUILD)/$(BOARD)-firmware.hex @echo halt > $(BUILD)/$(BOARD).jlink diff --git a/hw/bsp/adafruit_clue/board.mk b/hw/bsp/adafruit_clue/board.mk index 5290455cc..d5f7c7cd4 100644 --- a/hw/bsp/adafruit_clue/board.mk +++ b/hw/bsp/adafruit_clue/board.mk @@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # For uf2 conversion UF2_FAMILY = 0xADA52840 diff --git a/hw/bsp/arduino_nano33_ble/board.mk b/hw/bsp/arduino_nano33_ble/board.mk index 0a25d0b19..d1d62bdf2 100644 --- a/hw/bsp/arduino_nano33_ble/board.mk +++ b/hw/bsp/arduino_nano33_ble/board.mk @@ -51,7 +51,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # flash using bossac (as part of Nano33 BSP tools) # can be found in arduino15/packages/arduino/tools/bossac/ diff --git a/hw/bsp/circuitplayground_bluefruit/board.mk b/hw/bsp/circuitplayground_bluefruit/board.mk index 5290455cc..d5f7c7cd4 100644 --- a/hw/bsp/circuitplayground_bluefruit/board.mk +++ b/hw/bsp/circuitplayground_bluefruit/board.mk @@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # For uf2 conversion UF2_FAMILY = 0xADA52840 diff --git a/hw/bsp/circuitplayground_express/board.mk b/hw/bsp/circuitplayground_express/board.mk index e20272ad1..09b7b53a5 100644 --- a/hw/bsp/circuitplayground_express/board.mk +++ b/hw/bsp/circuitplayground_express/board.mk @@ -38,7 +38,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = ATSAMD21G18 -JLINK_IF = swd # flash using jlink flash: $(BUILD)/$(BOARD)-firmware.uf2 diff --git a/hw/bsp/d5035_01/board.mk b/hw/bsp/d5035_01/board.mk index cbc9ca5bb..0a7db6403 100644 --- a/hw/bsp/d5035_01/board.mk +++ b/hw/bsp/d5035_01/board.mk @@ -57,7 +57,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = ATSAME51J19 -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/da14695_dk_usb/board.mk b/hw/bsp/da14695_dk_usb/board.mk index f5b8873f9..8fef7d10f 100644 --- a/hw/bsp/da14695_dk_usb/board.mk +++ b/hw/bsp/da14695_dk_usb/board.mk @@ -38,7 +38,6 @@ FREERTOS_PORT = ARM_CM33_NTZ/non_secure # For flash-jlink target JLINK_DEVICE = DA14695 -JLINK_IF = swd # flash using jlink but with some twists flash: flash-dialog diff --git a/hw/bsp/da1469x_dk_pro/board.mk b/hw/bsp/da1469x_dk_pro/board.mk index 6708955f2..60a62378c 100644 --- a/hw/bsp/da1469x_dk_pro/board.mk +++ b/hw/bsp/da1469x_dk_pro/board.mk @@ -38,7 +38,6 @@ FREERTOS_PORT = ARM_CM33_NTZ/non_secure # For flash-jlink target JLINK_DEVICE = DA14699 -JLINK_IF = swd # flash using jlink but with some twists flash: flash-dialog diff --git a/hw/bsp/ea4088qs/board.mk b/hw/bsp/ea4088qs/board.mk index 51a6009a0..15e0bfb86 100644 --- a/hw/bsp/ea4088qs/board.mk +++ b/hw/bsp/ea4088qs/board.mk @@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = LPC4088 -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/ea4357/board.mk b/hw/bsp/ea4357/board.mk index 3ebe107e2..f6c42e0cf 100644 --- a/hw/bsp/ea4357/board.mk +++ b/hw/bsp/ea4357/board.mk @@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = LPC4357_M4 -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/feather_m0_express/board.mk b/hw/bsp/feather_m0_express/board.mk index 7b6891e03..4128ed264 100644 --- a/hw/bsp/feather_m0_express/board.mk +++ b/hw/bsp/feather_m0_express/board.mk @@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = ATSAMD21G18 -JLINK_IF = swd # flash using bossac at least version 1.8 # can be found in arduino15/packages/arduino/tools/bossac/ diff --git a/hw/bsp/feather_m4_express/board.mk b/hw/bsp/feather_m4_express/board.mk index 34c98597c..fadf65307 100644 --- a/hw/bsp/feather_m4_express/board.mk +++ b/hw/bsp/feather_m4_express/board.mk @@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = ATSAMD51J19 -JLINK_IF = swd # flash using bossac at least version 1.8 # can be found in arduino15/packages/arduino/tools/bossac/ diff --git a/hw/bsp/feather_nrf52840_express/board.mk b/hw/bsp/feather_nrf52840_express/board.mk index 7b2625cd4..6cc972835 100644 --- a/hw/bsp/feather_nrf52840_express/board.mk +++ b/hw/bsp/feather_nrf52840_express/board.mk @@ -50,7 +50,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # For uf2 conversion UF2_FAMILY = 0xADA52840 diff --git a/hw/bsp/feather_nrf52840_sense/board.mk b/hw/bsp/feather_nrf52840_sense/board.mk index 5290455cc..d5f7c7cd4 100644 --- a/hw/bsp/feather_nrf52840_sense/board.mk +++ b/hw/bsp/feather_nrf52840_sense/board.mk @@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # For uf2 conversion UF2_FAMILY = 0xADA52840 diff --git a/hw/bsp/feather_stm32f405/board.mk b/hw/bsp/feather_stm32f405/board.mk index 8233c6608..1988fa46e 100644 --- a/hw/bsp/feather_stm32f405/board.mk +++ b/hw/bsp/feather_stm32f405/board.mk @@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = stm32f405rg -JLINK_IF = swd # Path to STM32 Cube Programmer CLI, should be added into system path STM32Prog = STM32_Programmer_CLI diff --git a/hw/bsp/itsybitsy_m0/board.mk b/hw/bsp/itsybitsy_m0/board.mk index 7b6891e03..4128ed264 100644 --- a/hw/bsp/itsybitsy_m0/board.mk +++ b/hw/bsp/itsybitsy_m0/board.mk @@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = ATSAMD21G18 -JLINK_IF = swd # flash using bossac at least version 1.8 # can be found in arduino15/packages/arduino/tools/bossac/ diff --git a/hw/bsp/itsybitsy_m4/board.mk b/hw/bsp/itsybitsy_m4/board.mk index 34c98597c..fadf65307 100644 --- a/hw/bsp/itsybitsy_m4/board.mk +++ b/hw/bsp/itsybitsy_m4/board.mk @@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = ATSAMD51J19 -JLINK_IF = swd # flash using bossac at least version 1.8 # can be found in arduino15/packages/arduino/tools/bossac/ diff --git a/hw/bsp/itsybitsy_nrf52840/board.mk b/hw/bsp/itsybitsy_nrf52840/board.mk index 7b2625cd4..6cc972835 100644 --- a/hw/bsp/itsybitsy_nrf52840/board.mk +++ b/hw/bsp/itsybitsy_nrf52840/board.mk @@ -50,7 +50,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # For uf2 conversion UF2_FAMILY = 0xADA52840 diff --git a/hw/bsp/lpcxpresso11u37/board.mk b/hw/bsp/lpcxpresso11u37/board.mk index d1c48a2e5..d34125ac7 100644 --- a/hw/bsp/lpcxpresso11u37/board.mk +++ b/hw/bsp/lpcxpresso11u37/board.mk @@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = LPC11U37/401 -JLINK_IF = swd # flash using pyocd flash: $(BUILD)/$(BOARD)-firmware.hex diff --git a/hw/bsp/lpcxpresso11u68/board.mk b/hw/bsp/lpcxpresso11u68/board.mk index d9017ae1a..67124ab90 100644 --- a/hw/bsp/lpcxpresso11u68/board.mk +++ b/hw/bsp/lpcxpresso11u68/board.mk @@ -37,7 +37,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = LPC11U68 -JLINK_IF = swd # flash using pyocd flash: $(BUILD)/$(BOARD)-firmware.hex diff --git a/hw/bsp/lpcxpresso1347/board.mk b/hw/bsp/lpcxpresso1347/board.mk index 6dc3937f6..915834ddf 100644 --- a/hw/bsp/lpcxpresso1347/board.mk +++ b/hw/bsp/lpcxpresso1347/board.mk @@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM3 # For flash-jlink target JLINK_DEVICE = LPC1347 -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/lpcxpresso1549/board.mk b/hw/bsp/lpcxpresso1549/board.mk index 18325c5f7..27c3ca8d6 100644 --- a/hw/bsp/lpcxpresso1549/board.mk +++ b/hw/bsp/lpcxpresso1549/board.mk @@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM3 # For flash-jlink target JLINK_DEVICE = LPC1549 -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/lpcxpresso1769/board.mk b/hw/bsp/lpcxpresso1769/board.mk index a345e5a27..11da5f722 100644 --- a/hw/bsp/lpcxpresso1769/board.mk +++ b/hw/bsp/lpcxpresso1769/board.mk @@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM3 # For flash-jlink target JLINK_DEVICE = LPC1769 -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/lpcxpresso51u68/board.mk b/hw/bsp/lpcxpresso51u68/board.mk index 7dc7de341..cb36b3409 100644 --- a/hw/bsp/lpcxpresso51u68/board.mk +++ b/hw/bsp/lpcxpresso51u68/board.mk @@ -41,7 +41,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = LPC51U68 -JLINK_IF = swd # flash using pyocd (51u68 is not supported yet) flash: $(BUILD)/$(BOARD)-firmware.hex diff --git a/hw/bsp/lpcxpresso54114/board.mk b/hw/bsp/lpcxpresso54114/board.mk index 2bab0340f..cc0f6cd43 100644 --- a/hw/bsp/lpcxpresso54114/board.mk +++ b/hw/bsp/lpcxpresso54114/board.mk @@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = LPC54114J256_M4 -JLINK_IF = swd # flash using pyocd flash: $(BUILD)/$(BOARD)-firmware.hex diff --git a/hw/bsp/lpcxpresso55s69/board.mk b/hw/bsp/lpcxpresso55s69/board.mk index 24c5ae89c..f98144cc5 100644 --- a/hw/bsp/lpcxpresso55s69/board.mk +++ b/hw/bsp/lpcxpresso55s69/board.mk @@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM33_NTZ/non_secure # For flash-jlink target JLINK_DEVICE = LPC55S69 -JLINK_IF = swd # flash using pyocd flash: $(BUILD)/$(BOARD)-firmware.hex diff --git a/hw/bsp/luna/board.mk b/hw/bsp/luna/board.mk index 44f6fd75b..9969b97fe 100644 --- a/hw/bsp/luna/board.mk +++ b/hw/bsp/luna/board.mk @@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = ATSAMD21G18 -JLINK_IF = swd # flash using jlink flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/mbed1768/board.mk b/hw/bsp/mbed1768/board.mk index 3bdc8a27a..54a8357cc 100644 --- a/hw/bsp/mbed1768/board.mk +++ b/hw/bsp/mbed1768/board.mk @@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM3 # For flash-jlink target JLINK_DEVICE = LPC1768 -JLINK_IF = swd # flash using pyocd flash: $(BUILD)/$(BOARD)-firmware.hex diff --git a/hw/bsp/mcb1800/board.mk b/hw/bsp/mcb1800/board.mk index e3f07d0d0..f8fd25800 100644 --- a/hw/bsp/mcb1800/board.mk +++ b/hw/bsp/mcb1800/board.mk @@ -37,7 +37,6 @@ FREERTOS_PORT = ARM_CM3 # For flash-jlink target JLINK_DEVICE = LPC1857 -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/metro_m0_express/board.mk b/hw/bsp/metro_m0_express/board.mk index 7b6891e03..4128ed264 100644 --- a/hw/bsp/metro_m0_express/board.mk +++ b/hw/bsp/metro_m0_express/board.mk @@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = ATSAMD21G18 -JLINK_IF = swd # flash using bossac at least version 1.8 # can be found in arduino15/packages/arduino/tools/bossac/ diff --git a/hw/bsp/metro_m4_express/board.mk b/hw/bsp/metro_m4_express/board.mk index 34c98597c..fadf65307 100644 --- a/hw/bsp/metro_m4_express/board.mk +++ b/hw/bsp/metro_m4_express/board.mk @@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = ATSAMD51J19 -JLINK_IF = swd # flash using bossac at least version 1.8 # can be found in arduino15/packages/arduino/tools/bossac/ diff --git a/hw/bsp/mimxrt1010_evk/board.mk b/hw/bsp/mimxrt1010_evk/board.mk index 4dc11693a..6197c5365 100644 --- a/hw/bsp/mimxrt1010_evk/board.mk +++ b/hw/bsp/mimxrt1010_evk/board.mk @@ -46,7 +46,6 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1011DAE5A -JLINK_IF = swd # flash by copying bin file to DAP Mass Storage flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/mimxrt1020_evk/board.mk b/hw/bsp/mimxrt1020_evk/board.mk index 52148b684..c5b285b47 100644 --- a/hw/bsp/mimxrt1020_evk/board.mk +++ b/hw/bsp/mimxrt1020_evk/board.mk @@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1021DAG5A -JLINK_IF = swd # flash by copying bin file to DAP Mass Storage flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/mimxrt1050_evkb/board.mk b/hw/bsp/mimxrt1050_evkb/board.mk index 4b642085d..2148f8298 100644 --- a/hw/bsp/mimxrt1050_evkb/board.mk +++ b/hw/bsp/mimxrt1050_evkb/board.mk @@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1052xxx6B -JLINK_IF = swd # flash by copying bin file to DAP Mass Storage flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/mimxrt1060_evk/board.mk b/hw/bsp/mimxrt1060_evk/board.mk index fae0ad0ae..cf4007914 100644 --- a/hw/bsp/mimxrt1060_evk/board.mk +++ b/hw/bsp/mimxrt1060_evk/board.mk @@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1062xxx6A -JLINK_IF = swd # flash by copying bin file to DAP Mass Storage flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/mimxrt1064_evk/board.mk b/hw/bsp/mimxrt1064_evk/board.mk index d8a892442..5f230d687 100644 --- a/hw/bsp/mimxrt1064_evk/board.mk +++ b/hw/bsp/mimxrt1064_evk/board.mk @@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1064xxx6A -JLINK_IF = swd # flash by copying bin file to DAP Mass Storage flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/nrf52840_mdk_dongle/board.mk b/hw/bsp/nrf52840_mdk_dongle/board.mk index 9ba04ba1f..8ce8929b8 100644 --- a/hw/bsp/nrf52840_mdk_dongle/board.mk +++ b/hw/bsp/nrf52840_mdk_dongle/board.mk @@ -48,7 +48,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # flash using Nordic nrfutil (pip2 install nrfutil) # make BOARD=nrf52840_mdk_dongle SERIAL=/dev/ttyACM0 all flash diff --git a/hw/bsp/nutiny_nuc121s/board.mk b/hw/bsp/nutiny_nuc121s/board.mk index e89877820..0a8b6e048 100644 --- a/hw/bsp/nutiny_nuc121s/board.mk +++ b/hw/bsp/nutiny_nuc121s/board.mk @@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = NUC121SC2AE -JLINK_IF = swd # Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton # Please compile and install it from github source diff --git a/hw/bsp/nutiny_nuc125s/board.mk b/hw/bsp/nutiny_nuc125s/board.mk index 5bba8dee3..31577d800 100644 --- a/hw/bsp/nutiny_nuc125s/board.mk +++ b/hw/bsp/nutiny_nuc125s/board.mk @@ -33,7 +33,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = NUC125SC2AE -JLINK_IF = swd # Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton # Please compile and install it from github source diff --git a/hw/bsp/nutiny_nuc126v/board.mk b/hw/bsp/nutiny_nuc126v/board.mk index 21f2c9c53..7bf3989fc 100644 --- a/hw/bsp/nutiny_nuc126v/board.mk +++ b/hw/bsp/nutiny_nuc126v/board.mk @@ -53,7 +53,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = NUC126VG4AE -JLINK_IF = swd # Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton # Please compile and install it from github source diff --git a/hw/bsp/nutiny_sdk_nuc120/board.mk b/hw/bsp/nutiny_sdk_nuc120/board.mk index 95acdb5f2..51841643a 100644 --- a/hw/bsp/nutiny_sdk_nuc120/board.mk +++ b/hw/bsp/nutiny_sdk_nuc120/board.mk @@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = NUC120LE3 -JLINK_IF = swd # Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton # Please compile and install it from github source diff --git a/hw/bsp/nutiny_sdk_nuc505/board.mk b/hw/bsp/nutiny_sdk_nuc505/board.mk index 8752ef8ea..2d00cd9be 100644 --- a/hw/bsp/nutiny_sdk_nuc505/board.mk +++ b/hw/bsp/nutiny_sdk_nuc505/board.mk @@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = NUC505YO13Y -JLINK_IF = swd # Note # To be able to program the SPI flash, it need to boot with ICP mode "1011". diff --git a/hw/bsp/pca10056/board.mk b/hw/bsp/pca10056/board.mk index 0971e64c8..8f4887dcb 100644 --- a/hw/bsp/pca10056/board.mk +++ b/hw/bsp/pca10056/board.mk @@ -50,7 +50,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/pca10059/board.mk b/hw/bsp/pca10059/board.mk index 72dfefdcb..bd7a80c0e 100644 --- a/hw/bsp/pca10059/board.mk +++ b/hw/bsp/pca10059/board.mk @@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # flash using Nordic nrfutil (pip2 install nrfutil) # make BOARD=pca10059 SERIAL=/dev/ttyACM0 all flash diff --git a/hw/bsp/pca10100/board.mk b/hw/bsp/pca10100/board.mk index 5231aaf63..4b5be082e 100644 --- a/hw/bsp/pca10100/board.mk +++ b/hw/bsp/pca10100/board.mk @@ -50,7 +50,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52833_XXAA -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/pyboardv11/board.mk b/hw/bsp/pyboardv11/board.mk index 9da0541ec..3be06e844 100644 --- a/hw/bsp/pyboardv11/board.mk +++ b/hw/bsp/pyboardv11/board.mk @@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = stm32f405rg -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/raytac_mdbt50q_rx/board.mk b/hw/bsp/raytac_mdbt50q_rx/board.mk index 47bb430fc..e153aab0b 100644 --- a/hw/bsp/raytac_mdbt50q_rx/board.mk +++ b/hw/bsp/raytac_mdbt50q_rx/board.mk @@ -48,7 +48,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = nRF52840_xxAA -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/samd11_xplained/board.mk b/hw/bsp/samd11_xplained/board.mk index 6aec6509c..c80ece4a6 100644 --- a/hw/bsp/samd11_xplained/board.mk +++ b/hw/bsp/samd11_xplained/board.mk @@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = ATSAMD11D14 -JLINK_IF = swd # flash using edbg flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/samg55xplained/board.mk b/hw/bsp/samg55xplained/board.mk index a58a7b41d..79716d36d 100644 --- a/hw/bsp/samg55xplained/board.mk +++ b/hw/bsp/samg55xplained/board.mk @@ -47,7 +47,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = ATSAMG55J19 -JLINK_IF = swd # flash using edbg from https://github.com/ataradov/edbg flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/seeeduino_xiao/board.mk b/hw/bsp/seeeduino_xiao/board.mk index d762c4eca..172f6f537 100644 --- a/hw/bsp/seeeduino_xiao/board.mk +++ b/hw/bsp/seeeduino_xiao/board.mk @@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = ATSAMD21G18 -JLINK_IF = swd # flash using jlink flash: flash-jlink diff --git a/hw/bsp/stm32f070rbnucleo/board.mk b/hw/bsp/stm32f070rbnucleo/board.mk index 8ae75dd96..eec479bb4 100644 --- a/hw/bsp/stm32f070rbnucleo/board.mk +++ b/hw/bsp/stm32f070rbnucleo/board.mk @@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = stm32f070rb -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/stm32f072disco/board.mk b/hw/bsp/stm32f072disco/board.mk index e6787b266..4155acf84 100644 --- a/hw/bsp/stm32f072disco/board.mk +++ b/hw/bsp/stm32f072disco/board.mk @@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = stm32f072rb -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/stm32f103bluepill/board.mk b/hw/bsp/stm32f103bluepill/board.mk index 028c567b1..124b16021 100644 --- a/hw/bsp/stm32f103bluepill/board.mk +++ b/hw/bsp/stm32f103bluepill/board.mk @@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM3 # For flash-jlink target JLINK_DEVICE = stm32f103c8 -JLINK_IF = swd # flash target ROM bootloader flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/stm32f207nucleo/board.mk b/hw/bsp/stm32f207nucleo/board.mk index 9eaff8548..27d8638d3 100644 --- a/hw/bsp/stm32f207nucleo/board.mk +++ b/hw/bsp/stm32f207nucleo/board.mk @@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM3 # For flash-jlink target JLINK_DEVICE = stm32f207zg -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/stm32f303disco/board.mk b/hw/bsp/stm32f303disco/board.mk index 07312ac82..cb94dac3b 100644 --- a/hw/bsp/stm32f303disco/board.mk +++ b/hw/bsp/stm32f303disco/board.mk @@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = stm32f303vc -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/stm32f401blackpill/board.mk b/hw/bsp/stm32f401blackpill/board.mk index 38cabcc5a..993e29c5f 100644 --- a/hw/bsp/stm32f401blackpill/board.mk +++ b/hw/bsp/stm32f401blackpill/board.mk @@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = stm32f401cc -JLINK_IF = swd # flash target ROM bootloader flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/stm32f407disco/board.mk b/hw/bsp/stm32f407disco/board.mk index df2ee4ba5..87b7bea10 100644 --- a/hw/bsp/stm32f407disco/board.mk +++ b/hw/bsp/stm32f407disco/board.mk @@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = stm32f407vg -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/stm32f411blackpill/board.mk b/hw/bsp/stm32f411blackpill/board.mk index 36897607f..3441dbb52 100644 --- a/hw/bsp/stm32f411blackpill/board.mk +++ b/hw/bsp/stm32f411blackpill/board.mk @@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = stm32f411ce -JLINK_IF = swd # flash target ROM bootloader flash: $(BUILD)/$(BOARD)-firmware.bin diff --git a/hw/bsp/stm32f411disco/board.mk b/hw/bsp/stm32f411disco/board.mk index 5e0d6c3a0..f15d802ab 100644 --- a/hw/bsp/stm32f411disco/board.mk +++ b/hw/bsp/stm32f411disco/board.mk @@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = stm32f411ve -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/stm32f412disco/board.mk b/hw/bsp/stm32f412disco/board.mk index 5cf5e9b7a..0cc32da20 100644 --- a/hw/bsp/stm32f412disco/board.mk +++ b/hw/bsp/stm32f412disco/board.mk @@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = stm32f41zx -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/stm32h743eval/board.mk b/hw/bsp/stm32h743eval/board.mk index 47d592c58..543b40a30 100644 --- a/hw/bsp/stm32h743eval/board.mk +++ b/hw/bsp/stm32h743eval/board.mk @@ -57,7 +57,6 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = stm32h743xi -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/stm32h745disco/board.mk b/hw/bsp/stm32h745disco/board.mk index b3477b1e6..eb87e7461 100644 --- a/hw/bsp/stm32h745disco/board.mk +++ b/hw/bsp/stm32h745disco/board.mk @@ -52,7 +52,6 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = stm32h745xi -JLINK_IF = swd # flash target using on-board stlink flash: flash-stlink diff --git a/hw/bsp/stm32l0538disco/board.mk b/hw/bsp/stm32l0538disco/board.mk index 241ad5d28..bcfaee7ac 100644 --- a/hw/bsp/stm32l0538disco/board.mk +++ b/hw/bsp/stm32l0538disco/board.mk @@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM0 # For flash-jlink target JLINK_DEVICE = STM32L053R8 -JLINK_IF = swd # Path to STM32 Cube Programmer CLI, should be added into system path STM32Prog = STM32_Programmer_CLI diff --git a/hw/bsp/stm32l476disco/board.mk b/hw/bsp/stm32l476disco/board.mk index dc6b886db..e2fc010dc 100644 --- a/hw/bsp/stm32l476disco/board.mk +++ b/hw/bsp/stm32l476disco/board.mk @@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = stm32l476vg -JLINK_IF = swd # Path to STM32 Cube Programmer CLI, should be added into system path STM32Prog = STM32_Programmer_CLI diff --git a/hw/bsp/teensy_40/board.mk b/hw/bsp/teensy_40/board.mk index 0a19fe63a..e49f13a1f 100644 --- a/hw/bsp/teensy_40/board.mk +++ b/hw/bsp/teensy_40/board.mk @@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1062xxx6A -JLINK_IF = swd # flash by using teensy_loader_cli https://github.com/PaulStoffregen/teensy_loader_cli # Make sure it is in your PATH -- cgit v1.3.1 From e8b3af038edf2195a8b65e3f66f7097445f07ff2 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 8 Oct 2020 17:19:48 +0700 Subject: add flash-pyocd support --- examples/rules.mk | 4 ++++ hw/bsp/mimxrt1015_evk/board.mk | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/rules.mk b/examples/rules.mk index e972ce735..a062c29c5 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -163,4 +163,8 @@ flash-jlink: $(BUILD)/$(BOARD)-firmware.hex flash-stlink: $(BUILD)/$(BOARD)-firmware.elf STM32_Programmer_CLI --connect port=swd --write $< --go +# flash with pyocd +flash-pyocd: $(BUILD)/$(BOARD)-firmware.hex + pyocd flash -t $(PYOCD_TARGET) $< + endif # Make target diff --git a/hw/bsp/mimxrt1015_evk/board.mk b/hw/bsp/mimxrt1015_evk/board.mk index 7df60c2c6..3ce7c2f82 100644 --- a/hw/bsp/mimxrt1015_evk/board.mk +++ b/hw/bsp/mimxrt1015_evk/board.mk @@ -45,12 +45,9 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1015DAF5A -JLINK_IF = swd -# flash by copying bin file to DAP Mass Storage -flash: $(BUILD)/$(BOARD)-firmware.bin - cp $< /media/$(USER)/RT1015-EVK/ +# For flash-pyocd target +PYOCD_TARGET = mimxrt1015 # flash using pyocd -#flash: $(BUILD)/$(BOARD)-firmware.hex -# pyocd flash -b MIMXRT1015-EVK $< +flash: flash-pyocd -- cgit v1.3.1 From 344d589a354ec719333c10d315f4f186b178d2d7 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 9 Oct 2020 13:48:08 +0700 Subject: use pyocd for iMXRT boards --- examples/rules.mk | 1 + hw/bsp/mimxrt1010_evk/board.mk | 8 +++++--- hw/bsp/mimxrt1020_evk/board.mk | 8 +++++--- hw/bsp/mimxrt1050_evkb/board.mk | 9 ++++----- hw/bsp/mimxrt1060_evk/board.mk | 8 +++++--- hw/bsp/mimxrt1064_evk/board.mk | 8 +++++--- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/examples/rules.mk b/examples/rules.mk index a062c29c5..7ed648a8b 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -166,5 +166,6 @@ flash-stlink: $(BUILD)/$(BOARD)-firmware.elf # flash with pyocd flash-pyocd: $(BUILD)/$(BOARD)-firmware.hex pyocd flash -t $(PYOCD_TARGET) $< + pyocd reset -t $(PYOCD_TARGET) endif # Make target diff --git a/hw/bsp/mimxrt1010_evk/board.mk b/hw/bsp/mimxrt1010_evk/board.mk index 6197c5365..3ff916624 100644 --- a/hw/bsp/mimxrt1010_evk/board.mk +++ b/hw/bsp/mimxrt1010_evk/board.mk @@ -47,6 +47,8 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1011DAE5A -# flash by copying bin file to DAP Mass Storage -flash: $(BUILD)/$(BOARD)-firmware.bin - cp $< /media/$(USER)/RT1010-EVK/ +# For flash-pyocd target +PYOCD_TARGET = mimxrt1010 + +# flash using pyocd +flash: flash-pyocd diff --git a/hw/bsp/mimxrt1020_evk/board.mk b/hw/bsp/mimxrt1020_evk/board.mk index c5b285b47..66bcdf89b 100644 --- a/hw/bsp/mimxrt1020_evk/board.mk +++ b/hw/bsp/mimxrt1020_evk/board.mk @@ -46,6 +46,8 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1021DAG5A -# flash by copying bin file to DAP Mass Storage -flash: $(BUILD)/$(BOARD)-firmware.bin - cp $< /media/$(USER)/RT1020-EVK/ +# For flash-pyocd target +PYOCD_TARGET = mimxrt1020 + +# flash using pyocd +flash: flash-pyocd diff --git a/hw/bsp/mimxrt1050_evkb/board.mk b/hw/bsp/mimxrt1050_evkb/board.mk index 2148f8298..123e2ea82 100644 --- a/hw/bsp/mimxrt1050_evkb/board.mk +++ b/hw/bsp/mimxrt1050_evkb/board.mk @@ -43,9 +43,8 @@ CHIP_FAMILY = transdimension # For freeRTOS port source FREERTOS_PORT = ARM_CM7/r0p1 -# For flash-jlink target -JLINK_DEVICE = MIMXRT1052xxx6B +# For flash-pyocd target +PYOCD_TARGET = mimxrt1050 -# flash by copying bin file to DAP Mass Storage -flash: $(BUILD)/$(BOARD)-firmware.bin - cp $< /media/$(USER)/RT1050-EVK/ +# flash using pyocd +flash: flash-pyocd diff --git a/hw/bsp/mimxrt1060_evk/board.mk b/hw/bsp/mimxrt1060_evk/board.mk index cf4007914..5c93e1cdf 100644 --- a/hw/bsp/mimxrt1060_evk/board.mk +++ b/hw/bsp/mimxrt1060_evk/board.mk @@ -46,6 +46,8 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1062xxx6A -# flash by copying bin file to DAP Mass Storage -flash: $(BUILD)/$(BOARD)-firmware.bin - cp $< /media/$(USER)/RT1060-EVK/ +# For flash-pyocd target +PYOCD_TARGET = mimxrt1060 + +# flash using pyocd +flash: flash-pyocd diff --git a/hw/bsp/mimxrt1064_evk/board.mk b/hw/bsp/mimxrt1064_evk/board.mk index 5f230d687..f6a277497 100644 --- a/hw/bsp/mimxrt1064_evk/board.mk +++ b/hw/bsp/mimxrt1064_evk/board.mk @@ -46,6 +46,8 @@ FREERTOS_PORT = ARM_CM7/r0p1 # For flash-jlink target JLINK_DEVICE = MIMXRT1064xxx6A -# flash by copying bin file to DAP Mass Storage -flash: $(BUILD)/$(BOARD)-firmware.bin - cp $< /media/$(USER)/RT1064-EVK/ +# For flash-pyocd target +PYOCD_TARGET = mimxrt1064 + +# flash using pyocd +flash: flash-pyocd -- cgit v1.3.1 From 2219068371fa514e320ddf1c6059c3f6ed901ae7 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 9 Oct 2020 13:50:55 +0700 Subject: rename hid multiple interface --- .github/workflows/build.yml | 2 +- examples/device/hid_multiple_interface/Makefile | 12 ++ examples/device/hid_multiple_interface/src/main.c | 208 +++++++++++++++++++++ .../hid_multiple_interface/src/tusb_config.h | 110 +++++++++++ .../hid_multiple_interface/src/usb_descriptors.c | 188 +++++++++++++++++++ examples/device/hid_multipleinterface/Makefile | 12 -- examples/device/hid_multipleinterface/src/main.c | 208 --------------------- .../device/hid_multipleinterface/src/tusb_config.h | 110 ----------- .../hid_multipleinterface/src/usb_descriptors.c | 188 ------------------- 9 files changed, 519 insertions(+), 519 deletions(-) create mode 100644 examples/device/hid_multiple_interface/Makefile create mode 100644 examples/device/hid_multiple_interface/src/main.c create mode 100644 examples/device/hid_multiple_interface/src/tusb_config.h create mode 100644 examples/device/hid_multiple_interface/src/usb_descriptors.c delete mode 100644 examples/device/hid_multipleinterface/Makefile delete mode 100644 examples/device/hid_multipleinterface/src/main.c delete mode 100644 examples/device/hid_multipleinterface/src/tusb_config.h delete mode 100644 examples/device/hid_multipleinterface/src/usb_descriptors.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2db8f775..fd48eef1b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,7 @@ jobs: - 'device/hid_composite' - 'device/hid_composite_freertos' - 'device/hid_generic_inout' - - 'device/hid_multipleinterface' + - 'device/hid_multiple_interface' - 'device/midi_test' - 'device/msc_dual_lun' - 'device/net_lwip_webserver' diff --git a/examples/device/hid_multiple_interface/Makefile b/examples/device/hid_multiple_interface/Makefile new file mode 100644 index 000000000..69b633fea --- /dev/null +++ b/examples/device/hid_multiple_interface/Makefile @@ -0,0 +1,12 @@ +include ../../../tools/top.mk +include ../../make.mk + +INC += \ + src \ + $(TOP)/hw \ + +# Example source +EXAMPLE_SOURCE += $(wildcard src/*.c) +SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE)) + +include ../../rules.mk diff --git a/examples/device/hid_multiple_interface/src/main.c b/examples/device/hid_multiple_interface/src/main.c new file mode 100644 index 000000000..b1957b9fc --- /dev/null +++ b/examples/device/hid_multiple_interface/src/main.c @@ -0,0 +1,208 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include +#include +#include + +#include "bsp/board.h" +#include "tusb.h" + +//--------------------------------------------------------------------+ +// MACRO CONSTANT TYPEDEF PROTYPES +//--------------------------------------------------------------------+ + +/* Blink pattern + * - 250 ms : device not mounted + * - 1000 ms : device mounted + * - 2500 ms : device is suspended + */ +enum { + BLINK_NOT_MOUNTED = 250, + BLINK_MOUNTED = 1000, + BLINK_SUSPENDED = 2500, +}; + +static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED; + +void led_blinking_task(void); +void hid_task(void); + +/*------------- MAIN -------------*/ +int main(void) +{ + board_init(); + tusb_init(); + + while (1) + { + tud_task(); // tinyusb device task + led_blinking_task(); + + hid_task(); + } + + return 0; +} + +//--------------------------------------------------------------------+ +// Device callbacks +//--------------------------------------------------------------------+ + +// Invoked when device is mounted +void tud_mount_cb(void) +{ + blink_interval_ms = BLINK_MOUNTED; +} + +// Invoked when device is unmounted +void tud_umount_cb(void) +{ + blink_interval_ms = BLINK_NOT_MOUNTED; +} + +// Invoked when usb bus is suspended +// remote_wakeup_en : if host allow us to perform remote wakeup +// Within 7ms, device must draw an average of current less than 2.5 mA from bus +void tud_suspend_cb(bool remote_wakeup_en) +{ + (void) remote_wakeup_en; + blink_interval_ms = BLINK_SUSPENDED; +} + +// Invoked when usb bus is resumed +void tud_resume_cb(void) +{ + blink_interval_ms = BLINK_MOUNTED; +} + +//--------------------------------------------------------------------+ +// USB HID +//--------------------------------------------------------------------+ + +void hid_task(void) +{ + //Set up interfaces + const uint8_t keyboard_interface = 0; + const uint8_t mouse_interface = 1; + + // Poll every 10ms + const uint32_t interval_ms = 10; + static uint32_t start_ms = 0; + + if ( board_millis() - start_ms < interval_ms) return; // not enough time + start_ms += interval_ms; + + uint32_t const btn = board_button_read(); + + // Remote wakeup + if ( tud_suspended() && btn ) + { + // Wake up host if we are in suspend mode + // and REMOTE_WAKEUP feature is enabled by host + tud_remote_wakeup(); + } + + /*------------- Keyboard -------------*/ + if ( tud_hid_n_ready(keyboard_interface) ) + { + // use to avoid send multiple consecutive zero report for keyboard + static bool has_key = false; + + if ( btn ) + { + uint8_t keycode[6] = { 0 }; + keycode[0] = HID_KEY_A; + + tud_hid_n_keyboard_report(keyboard_interface, 0, 0, keycode); + + has_key = true; + }else + { + // send empty key report if previously has key pressed + if (has_key) tud_hid_n_keyboard_report(keyboard_interface, 0, 0, NULL); + has_key = false; + } + } + + /*------------- Mouse -------------*/ + if ( tud_hid_n_ready(mouse_interface) ) + { + if ( btn ) + { + int8_t const delta = 5; + + // no button, right + down, no scroll pan + tud_hid_n_mouse_report(mouse_interface, 0, 0x00, delta, delta, 0, 0); + + // delay a bit before attempt to send keyboard report + board_delay(10); + } + } +} + + +// Invoked when received GET_REPORT control request +// Application must fill buffer report's content and return its length. +// Return zero will cause the stack to STALL request +uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) +{ + // TODO not Implemented + (void) itf; + (void) report_id; + (void) report_type; + (void) buffer; + (void) reqlen; + + return 0; +} + +// Invoked when received SET_REPORT control request or +// received data on OUT endpoint ( Report ID = 0, Type = 0 ) +void tud_hid_n_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) +{ + // TODO set LED based on CAPLOCK, NUMLOCK etc... + (void) itf; + (void) report_id; + (void) report_type; + (void) buffer; + (void) bufsize; +} + +//--------------------------------------------------------------------+ +// BLINKING TASK +//--------------------------------------------------------------------+ +void led_blinking_task(void) +{ + static uint32_t start_ms = 0; + static bool led_state = false; + + // Blink every interval ms + if ( board_millis() - start_ms < blink_interval_ms) return; // not enough time + start_ms += blink_interval_ms; + + board_led_write(led_state); + led_state = 1 - led_state; // toggle +} diff --git a/examples/device/hid_multiple_interface/src/tusb_config.h b/examples/device/hid_multiple_interface/src/tusb_config.h new file mode 100644 index 000000000..412f9b004 --- /dev/null +++ b/examples/device/hid_multiple_interface/src/tusb_config.h @@ -0,0 +1,110 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#ifndef _TUSB_CONFIG_H_ +#define _TUSB_CONFIG_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +//-------------------------------------------------------------------- +// COMMON CONFIGURATION +//-------------------------------------------------------------------- + +// defined by board.mk +#ifndef CFG_TUSB_MCU + #error CFG_TUSB_MCU must be defined +#endif + +// RHPort number used for device can be defined by board.mk, default to port 0 +#ifndef BOARD_DEVICE_RHPORT_NUM + #define BOARD_DEVICE_RHPORT_NUM 0 +#endif + +// RHPort max operational speed can defined by board.mk +// Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed +#ifndef BOARD_DEVICE_RHPORT_SPEED + #if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \ + CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56) + #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED + #else + #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED + #endif +#endif + +// Device mode with rhport and speed defined by board.mk +#if BOARD_DEVICE_RHPORT_NUM == 0 + #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED) +#elif BOARD_DEVICE_RHPORT_NUM == 1 + #define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED) +#else + #error "Incorrect RHPort configuration" +#endif + +// This example doesn't use an RTOS +#define CFG_TUSB_OS OPT_OS_NONE + +// CFG_TUSB_DEBUG is defined by compiler in DEBUG build +// #define CFG_TUSB_DEBUG 0 + +/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. + * Tinyusb use follows macros to declare transferring memory so that they can be put + * into those specific section. + * e.g + * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) + * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) + */ +#ifndef CFG_TUSB_MEM_SECTION +#define CFG_TUSB_MEM_SECTION +#endif + +#ifndef CFG_TUSB_MEM_ALIGN +#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4))) +#endif + +//-------------------------------------------------------------------- +// DEVICE CONFIGURATION +//-------------------------------------------------------------------- + +#ifndef CFG_TUD_ENDPOINT0_SIZE +#define CFG_TUD_ENDPOINT0_SIZE 64 +#endif + +//------------- CLASS -------------// +#define CFG_TUD_HID 2 +#define CFG_TUD_CDC 0 +#define CFG_TUD_MSC 0 +#define CFG_TUD_MIDI 0 +#define CFG_TUD_VENDOR 0 + +// HID buffer size Should be sufficient to hold ID (if any) + Data +#define CFG_TUD_HID_EP_BUFSIZE 8 + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_CONFIG_H_ */ diff --git a/examples/device/hid_multiple_interface/src/usb_descriptors.c b/examples/device/hid_multiple_interface/src/usb_descriptors.c new file mode 100644 index 000000000..dd8ef7120 --- /dev/null +++ b/examples/device/hid_multiple_interface/src/usb_descriptors.c @@ -0,0 +1,188 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "tusb.h" + +/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug. + * Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC. + * + * Auto ProductID layout's Bitmap: + * [MSB] HID | MSC | CDC [LSB] + */ +#define _PID_MAP(itf, n) ( (CFG_TUD_##itf) << (n) ) +#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ + _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) ) + +//--------------------------------------------------------------------+ +// Device Descriptors +//--------------------------------------------------------------------+ +tusb_desc_device_t const desc_device = +{ + .bLength = sizeof(tusb_desc_device_t), + .bDescriptorType = TUSB_DESC_DEVICE, + .bcdUSB = 0x0200, + .bDeviceClass = 0x00, + .bDeviceSubClass = 0x00, + .bDeviceProtocol = 0x00, + .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, + + .idVendor = 0xCafe, + .idProduct = USB_PID, + .bcdDevice = 0x0100, + + .iManufacturer = 0x01, + .iProduct = 0x02, + .iSerialNumber = 0x03, + + .bNumConfigurations = 0x01 +}; + +// Invoked when received GET DEVICE DESCRIPTOR +// Application return pointer to descriptor +uint8_t const * tud_descriptor_device_cb(void) +{ + return (uint8_t const *) &desc_device; +} + +//--------------------------------------------------------------------+ +// HID Report Descriptor +//--------------------------------------------------------------------+ + +uint8_t const desc_hid_report1[] = +{ + TUD_HID_REPORT_DESC_KEYBOARD() +}; + +uint8_t const desc_hid_report2[] = +{ + TUD_HID_REPORT_DESC_MOUSE() +}; + +// Invoked when received GET HID REPORT DESCRIPTOR +// Application return pointer to descriptor +// Descriptor contents must exist long enough for transfer to complete +uint8_t const * tud_hid_n_descriptor_report_cb(uint8_t itf) +{ + if (itf == 0) + { + return desc_hid_report1; + } + else if (itf == 1) + { + return desc_hid_report2; + } + + return NULL; +} + +//--------------------------------------------------------------------+ +// Configuration Descriptor +//--------------------------------------------------------------------+ + +enum +{ + ITF_NUM_HID1, + ITF_NUM_HID2, + ITF_NUM_TOTAL +}; + +#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_DESC_LEN + TUD_HID_DESC_LEN) + +#define EPNUM_HID1 0x81 +#define EPNUM_HID2 0x82 + +uint8_t const desc_configuration[] = +{ + // Config number, interface count, string index, total length, attribute, power in mA + TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), + + // Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval + TUD_HID_DESCRIPTOR(ITF_NUM_HID1, 4, HID_PROTOCOL_NONE, sizeof(desc_hid_report1), EPNUM_HID1, CFG_TUD_HID_EP_BUFSIZE, 10), + TUD_HID_DESCRIPTOR(ITF_NUM_HID2, 5, HID_PROTOCOL_NONE, sizeof(desc_hid_report2), EPNUM_HID2, CFG_TUD_HID_EP_BUFSIZE, 10) +}; + +// Invoked when received GET CONFIGURATION DESCRIPTOR +// Application return pointer to descriptor +// Descriptor contents must exist long enough for transfer to complete +uint8_t const * tud_descriptor_configuration_cb(uint8_t index) +{ + (void) index; // for multiple configurations + return desc_configuration; +} + +//--------------------------------------------------------------------+ +// String Descriptors +//--------------------------------------------------------------------+ + +// array of pointer to string descriptors +char const* string_desc_arr [] = +{ + (const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409) + "TinyUSB", // 1: Manufacturer + "TinyUSB Device", // 2: Product + "123456", // 3: Serials, should use chip ID + "Keyboard Interface", // 4: Interface 1 String + "Mouse Interface", // 5: Interface 2 String +}; + +static uint16_t _desc_str[32]; + +// Invoked when received GET STRING DESCRIPTOR request +// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete +uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) +{ + (void) langid; + + uint8_t chr_count; + + if ( index == 0) + { + memcpy(&_desc_str[1], string_desc_arr[0], 2); + chr_count = 1; + }else + { + // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors. + // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors + + if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) return NULL; + + const char* str = string_desc_arr[index]; + + // Cap at max char + chr_count = strlen(str); + if ( chr_count > 31 ) chr_count = 31; + + // Convert ASCII string into UTF-16 + for(uint8_t i=0; i -#include -#include - -#include "bsp/board.h" -#include "tusb.h" - -//--------------------------------------------------------------------+ -// MACRO CONSTANT TYPEDEF PROTYPES -//--------------------------------------------------------------------+ - -/* Blink pattern - * - 250 ms : device not mounted - * - 1000 ms : device mounted - * - 2500 ms : device is suspended - */ -enum { - BLINK_NOT_MOUNTED = 250, - BLINK_MOUNTED = 1000, - BLINK_SUSPENDED = 2500, -}; - -static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED; - -void led_blinking_task(void); -void hid_task(void); - -/*------------- MAIN -------------*/ -int main(void) -{ - board_init(); - tusb_init(); - - while (1) - { - tud_task(); // tinyusb device task - led_blinking_task(); - - hid_task(); - } - - return 0; -} - -//--------------------------------------------------------------------+ -// Device callbacks -//--------------------------------------------------------------------+ - -// Invoked when device is mounted -void tud_mount_cb(void) -{ - blink_interval_ms = BLINK_MOUNTED; -} - -// Invoked when device is unmounted -void tud_umount_cb(void) -{ - blink_interval_ms = BLINK_NOT_MOUNTED; -} - -// Invoked when usb bus is suspended -// remote_wakeup_en : if host allow us to perform remote wakeup -// Within 7ms, device must draw an average of current less than 2.5 mA from bus -void tud_suspend_cb(bool remote_wakeup_en) -{ - (void) remote_wakeup_en; - blink_interval_ms = BLINK_SUSPENDED; -} - -// Invoked when usb bus is resumed -void tud_resume_cb(void) -{ - blink_interval_ms = BLINK_MOUNTED; -} - -//--------------------------------------------------------------------+ -// USB HID -//--------------------------------------------------------------------+ - -void hid_task(void) -{ - //Set up interfaces - const uint8_t keyboard_interface = 0; - const uint8_t mouse_interface = 1; - - // Poll every 10ms - const uint32_t interval_ms = 10; - static uint32_t start_ms = 0; - - if ( board_millis() - start_ms < interval_ms) return; // not enough time - start_ms += interval_ms; - - uint32_t const btn = board_button_read(); - - // Remote wakeup - if ( tud_suspended() && btn ) - { - // Wake up host if we are in suspend mode - // and REMOTE_WAKEUP feature is enabled by host - tud_remote_wakeup(); - } - - /*------------- Keyboard -------------*/ - if ( tud_hid_n_ready(keyboard_interface) ) - { - // use to avoid send multiple consecutive zero report for keyboard - static bool has_key = false; - - if ( btn ) - { - uint8_t keycode[6] = { 0 }; - keycode[0] = HID_KEY_A; - - tud_hid_n_keyboard_report(keyboard_interface, 0, 0, keycode); - - has_key = true; - }else - { - // send empty key report if previously has key pressed - if (has_key) tud_hid_n_keyboard_report(keyboard_interface, 0, 0, NULL); - has_key = false; - } - } - - /*------------- Mouse -------------*/ - if ( tud_hid_n_ready(mouse_interface) ) - { - if ( btn ) - { - int8_t const delta = 5; - - // no button, right + down, no scroll pan - tud_hid_n_mouse_report(mouse_interface, 0, 0x00, delta, delta, 0, 0); - - // delay a bit before attempt to send keyboard report - board_delay(10); - } - } -} - - -// Invoked when received GET_REPORT control request -// Application must fill buffer report's content and return its length. -// Return zero will cause the stack to STALL request -uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) -{ - // TODO not Implemented - (void) itf; - (void) report_id; - (void) report_type; - (void) buffer; - (void) reqlen; - - return 0; -} - -// Invoked when received SET_REPORT control request or -// received data on OUT endpoint ( Report ID = 0, Type = 0 ) -void tud_hid_n_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) -{ - // TODO set LED based on CAPLOCK, NUMLOCK etc... - (void) itf; - (void) report_id; - (void) report_type; - (void) buffer; - (void) bufsize; -} - -//--------------------------------------------------------------------+ -// BLINKING TASK -//--------------------------------------------------------------------+ -void led_blinking_task(void) -{ - static uint32_t start_ms = 0; - static bool led_state = false; - - // Blink every interval ms - if ( board_millis() - start_ms < blink_interval_ms) return; // not enough time - start_ms += blink_interval_ms; - - board_led_write(led_state); - led_state = 1 - led_state; // toggle -} diff --git a/examples/device/hid_multipleinterface/src/tusb_config.h b/examples/device/hid_multipleinterface/src/tusb_config.h deleted file mode 100644 index 412f9b004..000000000 --- a/examples/device/hid_multipleinterface/src/tusb_config.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef _TUSB_CONFIG_H_ -#define _TUSB_CONFIG_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -//-------------------------------------------------------------------- -// COMMON CONFIGURATION -//-------------------------------------------------------------------- - -// defined by board.mk -#ifndef CFG_TUSB_MCU - #error CFG_TUSB_MCU must be defined -#endif - -// RHPort number used for device can be defined by board.mk, default to port 0 -#ifndef BOARD_DEVICE_RHPORT_NUM - #define BOARD_DEVICE_RHPORT_NUM 0 -#endif - -// RHPort max operational speed can defined by board.mk -// Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed -#ifndef BOARD_DEVICE_RHPORT_SPEED - #if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \ - CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56) - #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED - #else - #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED - #endif -#endif - -// Device mode with rhport and speed defined by board.mk -#if BOARD_DEVICE_RHPORT_NUM == 0 - #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED) -#elif BOARD_DEVICE_RHPORT_NUM == 1 - #define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED) -#else - #error "Incorrect RHPort configuration" -#endif - -// This example doesn't use an RTOS -#define CFG_TUSB_OS OPT_OS_NONE - -// CFG_TUSB_DEBUG is defined by compiler in DEBUG build -// #define CFG_TUSB_DEBUG 0 - -/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. - * Tinyusb use follows macros to declare transferring memory so that they can be put - * into those specific section. - * e.g - * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) - * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) - */ -#ifndef CFG_TUSB_MEM_SECTION -#define CFG_TUSB_MEM_SECTION -#endif - -#ifndef CFG_TUSB_MEM_ALIGN -#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4))) -#endif - -//-------------------------------------------------------------------- -// DEVICE CONFIGURATION -//-------------------------------------------------------------------- - -#ifndef CFG_TUD_ENDPOINT0_SIZE -#define CFG_TUD_ENDPOINT0_SIZE 64 -#endif - -//------------- CLASS -------------// -#define CFG_TUD_HID 2 -#define CFG_TUD_CDC 0 -#define CFG_TUD_MSC 0 -#define CFG_TUD_MIDI 0 -#define CFG_TUD_VENDOR 0 - -// HID buffer size Should be sufficient to hold ID (if any) + Data -#define CFG_TUD_HID_EP_BUFSIZE 8 - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_CONFIG_H_ */ diff --git a/examples/device/hid_multipleinterface/src/usb_descriptors.c b/examples/device/hid_multipleinterface/src/usb_descriptors.c deleted file mode 100644 index dd8ef7120..000000000 --- a/examples/device/hid_multipleinterface/src/usb_descriptors.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#include "tusb.h" - -/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug. - * Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC. - * - * Auto ProductID layout's Bitmap: - * [MSB] HID | MSC | CDC [LSB] - */ -#define _PID_MAP(itf, n) ( (CFG_TUD_##itf) << (n) ) -#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ - _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) ) - -//--------------------------------------------------------------------+ -// Device Descriptors -//--------------------------------------------------------------------+ -tusb_desc_device_t const desc_device = -{ - .bLength = sizeof(tusb_desc_device_t), - .bDescriptorType = TUSB_DESC_DEVICE, - .bcdUSB = 0x0200, - .bDeviceClass = 0x00, - .bDeviceSubClass = 0x00, - .bDeviceProtocol = 0x00, - .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, - - .idVendor = 0xCafe, - .idProduct = USB_PID, - .bcdDevice = 0x0100, - - .iManufacturer = 0x01, - .iProduct = 0x02, - .iSerialNumber = 0x03, - - .bNumConfigurations = 0x01 -}; - -// Invoked when received GET DEVICE DESCRIPTOR -// Application return pointer to descriptor -uint8_t const * tud_descriptor_device_cb(void) -{ - return (uint8_t const *) &desc_device; -} - -//--------------------------------------------------------------------+ -// HID Report Descriptor -//--------------------------------------------------------------------+ - -uint8_t const desc_hid_report1[] = -{ - TUD_HID_REPORT_DESC_KEYBOARD() -}; - -uint8_t const desc_hid_report2[] = -{ - TUD_HID_REPORT_DESC_MOUSE() -}; - -// Invoked when received GET HID REPORT DESCRIPTOR -// Application return pointer to descriptor -// Descriptor contents must exist long enough for transfer to complete -uint8_t const * tud_hid_n_descriptor_report_cb(uint8_t itf) -{ - if (itf == 0) - { - return desc_hid_report1; - } - else if (itf == 1) - { - return desc_hid_report2; - } - - return NULL; -} - -//--------------------------------------------------------------------+ -// Configuration Descriptor -//--------------------------------------------------------------------+ - -enum -{ - ITF_NUM_HID1, - ITF_NUM_HID2, - ITF_NUM_TOTAL -}; - -#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_DESC_LEN + TUD_HID_DESC_LEN) - -#define EPNUM_HID1 0x81 -#define EPNUM_HID2 0x82 - -uint8_t const desc_configuration[] = -{ - // Config number, interface count, string index, total length, attribute, power in mA - TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), - - // Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval - TUD_HID_DESCRIPTOR(ITF_NUM_HID1, 4, HID_PROTOCOL_NONE, sizeof(desc_hid_report1), EPNUM_HID1, CFG_TUD_HID_EP_BUFSIZE, 10), - TUD_HID_DESCRIPTOR(ITF_NUM_HID2, 5, HID_PROTOCOL_NONE, sizeof(desc_hid_report2), EPNUM_HID2, CFG_TUD_HID_EP_BUFSIZE, 10) -}; - -// Invoked when received GET CONFIGURATION DESCRIPTOR -// Application return pointer to descriptor -// Descriptor contents must exist long enough for transfer to complete -uint8_t const * tud_descriptor_configuration_cb(uint8_t index) -{ - (void) index; // for multiple configurations - return desc_configuration; -} - -//--------------------------------------------------------------------+ -// String Descriptors -//--------------------------------------------------------------------+ - -// array of pointer to string descriptors -char const* string_desc_arr [] = -{ - (const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409) - "TinyUSB", // 1: Manufacturer - "TinyUSB Device", // 2: Product - "123456", // 3: Serials, should use chip ID - "Keyboard Interface", // 4: Interface 1 String - "Mouse Interface", // 5: Interface 2 String -}; - -static uint16_t _desc_str[32]; - -// Invoked when received GET STRING DESCRIPTOR request -// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete -uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) -{ - (void) langid; - - uint8_t chr_count; - - if ( index == 0) - { - memcpy(&_desc_str[1], string_desc_arr[0], 2); - chr_count = 1; - }else - { - // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors. - // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors - - if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) return NULL; - - const char* str = string_desc_arr[index]; - - // Cap at max char - chr_count = strlen(str); - if ( chr_count > 31 ) chr_count = 31; - - // Convert ASCII string into UTF-16 - for(uint8_t i=0; i Date: Fri, 9 Oct 2020 13:57:23 +0700 Subject: clean up example --- examples/device/hid_multiple_interface/src/main.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/device/hid_multiple_interface/src/main.c b/examples/device/hid_multiple_interface/src/main.c index b1957b9fc..3599683c5 100644 --- a/examples/device/hid_multiple_interface/src/main.c +++ b/examples/device/hid_multiple_interface/src/main.c @@ -34,6 +34,12 @@ // MACRO CONSTANT TYPEDEF PROTYPES //--------------------------------------------------------------------+ +// Interface index depends on the order in configuration descriptor +enum { + ITF_KEYBOARD = 0, + ITF_MOUSE = 1 +}; + /* Blink pattern * - 250 ms : device not mounted * - 1000 ms : device mounted @@ -104,10 +110,6 @@ void tud_resume_cb(void) void hid_task(void) { - //Set up interfaces - const uint8_t keyboard_interface = 0; - const uint8_t mouse_interface = 1; - // Poll every 10ms const uint32_t interval_ms = 10; static uint32_t start_ms = 0; @@ -126,7 +128,7 @@ void hid_task(void) } /*------------- Keyboard -------------*/ - if ( tud_hid_n_ready(keyboard_interface) ) + if ( tud_hid_n_ready(ITF_KEYBOARD) ) { // use to avoid send multiple consecutive zero report for keyboard static bool has_key = false; @@ -136,29 +138,26 @@ void hid_task(void) uint8_t keycode[6] = { 0 }; keycode[0] = HID_KEY_A; - tud_hid_n_keyboard_report(keyboard_interface, 0, 0, keycode); + tud_hid_n_keyboard_report(ITF_KEYBOARD, 0, 0, keycode); has_key = true; }else { // send empty key report if previously has key pressed - if (has_key) tud_hid_n_keyboard_report(keyboard_interface, 0, 0, NULL); + if (has_key) tud_hid_n_keyboard_report(ITF_KEYBOARD, 0, 0, NULL); has_key = false; } } /*------------- Mouse -------------*/ - if ( tud_hid_n_ready(mouse_interface) ) + if ( tud_hid_n_ready(ITF_MOUSE) ) { if ( btn ) { int8_t const delta = 5; // no button, right + down, no scroll pan - tud_hid_n_mouse_report(mouse_interface, 0, 0x00, delta, delta, 0, 0); - - // delay a bit before attempt to send keyboard report - board_delay(10); + tud_hid_n_mouse_report(ITF_MOUSE, 0, 0x00, delta, delta, 0, 0); } } } -- cgit v1.3.1 From 13abcb953fcd3d51983e9768619adde776af257e Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 9 Oct 2020 20:24:10 +0700 Subject: rename multiple hid callback --- examples/device/hid_multiple_interface/src/main.c | 4 +-- .../hid_multiple_interface/src/usb_descriptors.c | 2 +- src/class/hid/hid_device.c | 8 +++--- src/class/hid/hid_device.h | 32 ++++++++++++---------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/examples/device/hid_multiple_interface/src/main.c b/examples/device/hid_multiple_interface/src/main.c index 3599683c5..7cb1d75a7 100644 --- a/examples/device/hid_multiple_interface/src/main.c +++ b/examples/device/hid_multiple_interface/src/main.c @@ -166,7 +166,7 @@ void hid_task(void) // Invoked when received GET_REPORT control request // Application must fill buffer report's content and return its length. // Return zero will cause the stack to STALL request -uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) +uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) { // TODO not Implemented (void) itf; @@ -180,7 +180,7 @@ uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type // Invoked when received SET_REPORT control request or // received data on OUT endpoint ( Report ID = 0, Type = 0 ) -void tud_hid_n_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) +void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) { // TODO set LED based on CAPLOCK, NUMLOCK etc... (void) itf; diff --git a/examples/device/hid_multiple_interface/src/usb_descriptors.c b/examples/device/hid_multiple_interface/src/usb_descriptors.c index dd8ef7120..0d67d499a 100644 --- a/examples/device/hid_multiple_interface/src/usb_descriptors.c +++ b/examples/device/hid_multiple_interface/src/usb_descriptors.c @@ -83,7 +83,7 @@ uint8_t const desc_hid_report2[] = // Invoked when received GET HID REPORT DESCRIPTOR // Application return pointer to descriptor // Descriptor contents must exist long enough for transfer to complete -uint8_t const * tud_hid_n_descriptor_report_cb(uint8_t itf) +uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf) { if (itf == 0) { diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index 45b6aaaca..b1a4bb8de 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -250,7 +250,7 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request else if (request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT) { #if CFG_TUD_HID>1 - uint8_t const * desc_report = tud_hid_n_descriptor_report_cb(hid_itf); + uint8_t const * desc_report = tud_hid_descriptor_report_cb(hid_itf); #else uint8_t const * desc_report = tud_hid_descriptor_report_cb(); #endif @@ -273,7 +273,7 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request uint8_t const report_id = tu_u16_low(request->wValue); #if CFG_TUD_HID>1 - uint16_t xferlen = tud_hid_n_get_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength); + uint16_t xferlen = tud_hid_get_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength); #else uint16_t xferlen = tud_hid_get_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength); #endif @@ -347,7 +347,7 @@ bool hidd_control_complete(uint8_t rhport, tusb_control_request_t const * p_requ #if CFG_TUD_HID>1 uint8_t const hid_itf = get_hid_index_by_itfnum((uint8_t)p_request->wIndex); TU_VERIFY(hid_itf<0xFF); - tud_hid_n_set_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength); + tud_hid_set_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength); #else tud_hid_set_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength); #endif @@ -373,7 +373,7 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_ if (ep_addr == p_hid->ep_out) { #if CFG_TUD_HID>1 - tud_hid_n_set_report_cb(itf, 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes); + tud_hid_set_report_cb(itf, 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes); #else tud_hid_set_report_cb(0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes); #endif diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h index 4b8cb17d5..fc060f0ce 100644 --- a/src/class/hid/hid_device.h +++ b/src/class/hid/hid_device.h @@ -84,30 +84,20 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8 // Callbacks (Weak is optional) //--------------------------------------------------------------------+ +#if CFG_TUD_HID > 1 + // Invoked when received GET HID REPORT DESCRIPTOR request // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete -#if CFG_TUD_HID>1 -uint8_t const * tud_hid_n_descriptor_report_cb(uint8_t itf); -#else -uint8_t const * tud_hid_descriptor_report_cb(void); -#endif +uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf); // Invoked when received GET_REPORT control request // Application must fill buffer report's content and return its length. // Return zero will cause the stack to STALL request -#if CFG_TUD_HID>1 -uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen); -#else -uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen); -#endif +uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen); // Invoked when received SET_REPORT control request or // received data on OUT endpoint ( Report ID = 0, Type = 0 ) -#if CFG_TUD_HID>1 -void tud_hid_n_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize); -#else -void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize); -#endif +void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize); // Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report ) TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode); @@ -117,6 +107,18 @@ TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode); // - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms). TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate); +#else + +uint8_t const * tud_hid_descriptor_report_cb(void); +uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen); +void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize); + +TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode); +TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate); + +#endif + + //--------------------------------------------------------------------+ // Inline Functions //--------------------------------------------------------------------+ -- cgit v1.3.1 From 8ba0c362ccb72a04ec101610f4b7f9c8577a26da Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 9 Oct 2020 20:51:20 +0700 Subject: update tud_hid_boot_mode_cb/tud_hid_set_idle_cb support mul interfaces also clean up code --- src/class/hid/hid_device.c | 90 ++++++++++++++++++++++++---------------------- src/class/hid/hid_device.h | 5 +-- 2 files changed, 50 insertions(+), 45 deletions(-) diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index b1a4bb8de..11da5f220 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -57,17 +57,7 @@ typedef struct CFG_TUSB_MEM_SECTION static hidd_interface_t _hidd_itf[CFG_TUD_HID]; /*------------- Helpers -------------*/ -static inline hidd_interface_t* get_interface_by_itfnum(uint8_t itf_num) -{ - for (uint8_t i=0; i < CFG_TUD_HID; i++ ) - { - if ( itf_num == _hidd_itf[i].itf_num ) return &_hidd_itf[i]; - } - - return NULL; -} - -static inline uint8_t get_hid_index_by_itfnum(uint8_t itf_num) +static inline uint8_t get_index_by_itfnum(uint8_t itf_num) { for (uint8_t i=0; i < CFG_TUD_HID; i++ ) { @@ -227,13 +217,10 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request { TU_VERIFY(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE); - hidd_interface_t* p_hid = get_interface_by_itfnum( (uint8_t) request->wIndex ); - TU_ASSERT(p_hid); + uint8_t const hid_itf = get_index_by_itfnum((uint8_t) request->wIndex); + TU_VERIFY(hid_itf < CFG_TUD_HID); - #if CFG_TUD_HID>1 - uint8_t const hid_itf = get_hid_index_by_itfnum((uint8_t) request->wIndex); - TU_VERIFY(hid_itf<0xFF); - #endif + hidd_interface_t* p_hid = &_hidd_itf[hid_itf]; if (request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD) { @@ -249,11 +236,11 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request } else if (request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT) { - #if CFG_TUD_HID>1 - uint8_t const * desc_report = tud_hid_descriptor_report_cb(hid_itf); - #else - uint8_t const * desc_report = tud_hid_descriptor_report_cb(); - #endif + uint8_t const * desc_report = tud_hid_descriptor_report_cb( + #if CFG_TUD_HID > 1 + hid_itf // TODO for backward compatible callback, remove later when appropriate + #endif + ); tud_control_xfer(rhport, request, (void*) desc_report, p_hid->report_desc_len); } else @@ -272,11 +259,12 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request uint8_t const report_type = tu_u16_high(request->wValue); uint8_t const report_id = tu_u16_low(request->wValue); - #if CFG_TUD_HID>1 - uint16_t xferlen = tud_hid_get_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength); - #else - uint16_t xferlen = tud_hid_get_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength); - #endif + uint16_t xferlen = tud_hid_get_report_cb( + #if CFG_TUD_HID > 1 + hid_itf, // TODO for backward compatible callback, remove later when appropriate + #endif + report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength + ); TU_ASSERT( xferlen > 0 ); tud_control_xfer(rhport, request, p_hid->epin_buf, xferlen); @@ -293,7 +281,12 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request if ( tud_hid_set_idle_cb ) { // stall request if callback return false - if ( !tud_hid_set_idle_cb(p_hid->idle_rate) ) return false; + TU_VERIFY( tud_hid_set_idle_cb( + #if CFG_TUD_HID > 1 + hid_itf, // TODO for backward compatible callback, remove later when appropriate + #endif + p_hid->idle_rate) + ); } tud_control_status(rhport, request); @@ -314,7 +307,15 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request case HID_REQ_CONTROL_SET_PROTOCOL: p_hid->boot_mode = 1 - request->wValue; // 0 is Boot, 1 is Report protocol - if (tud_hid_boot_mode_cb) tud_hid_boot_mode_cb(p_hid->boot_mode); + if (tud_hid_boot_mode_cb) + { + tud_hid_boot_mode_cb( + #if CFG_TUD_HID > 1 + hid_itf, // TODO for backward compatible callback, remove later when appropriate + #endif + p_hid->boot_mode + ); + } tud_control_status(rhport, request); break; @@ -334,8 +335,11 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request bool hidd_control_complete(uint8_t rhport, tusb_control_request_t const * p_request) { (void) rhport; - hidd_interface_t* p_hid = get_interface_by_itfnum( (uint8_t) p_request->wIndex ); - TU_ASSERT(p_hid); + + uint8_t const hid_itf = get_index_by_itfnum((uint8_t) p_request->wIndex); + TU_VERIFY(hid_itf < CFG_TUD_HID); + + hidd_interface_t* p_hid = &_hidd_itf[hid_itf]; if (p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS && p_request->bRequest == HID_REQ_CONTROL_SET_REPORT) @@ -344,13 +348,12 @@ bool hidd_control_complete(uint8_t rhport, tusb_control_request_t const * p_requ uint8_t const report_type = tu_u16_high(p_request->wValue); uint8_t const report_id = tu_u16_low(p_request->wValue); - #if CFG_TUD_HID>1 - uint8_t const hid_itf = get_hid_index_by_itfnum((uint8_t)p_request->wIndex); - TU_VERIFY(hid_itf<0xFF); - tud_hid_set_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength); - #else - tud_hid_set_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength); - #endif + tud_hid_set_report_cb( + #if CFG_TUD_HID > 1 + hid_itf, // TODO for backward compatible callback, remove later when appropriate + #endif + report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength + ); } return true; @@ -372,11 +375,12 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_ if (ep_addr == p_hid->ep_out) { - #if CFG_TUD_HID>1 - tud_hid_set_report_cb(itf, 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes); - #else - tud_hid_set_report_cb(0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes); - #endif + tud_hid_set_report_cb( + #if CFG_TUD_HID > 1 + itf, // TODO for backward compatible callback, remove later when appropriate + #endif + 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes + ); TU_ASSERT(usbd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf))); } diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h index fc060f0ce..d5b5b7296 100644 --- a/src/class/hid/hid_device.h +++ b/src/class/hid/hid_device.h @@ -100,15 +100,16 @@ uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize); // Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report ) -TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode); +TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t itf, uint8_t boot_mode); // Invoked when received SET_IDLE request. return false will stall the request // - Idle Rate = 0 : only send report if there is changes, i.e skip duplication // - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms). -TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate); +TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t itf, uint8_t idle_rate); #else +// TODO for backward compatible callback, remove later when appropriate uint8_t const * tud_hid_descriptor_report_cb(void); uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen); void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize); -- cgit v1.3.1 From 8cf1ed6e4ee385dbfb7ef7dd1446c52eab67f503 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 9 Oct 2020 21:01:52 +0700 Subject: try GITHUB_PATH for ci --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd48eef1b..227593e8a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,14 +66,14 @@ jobs: npm install --global xpm xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@latest - echo "::add-path::`echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin`" - echo "::add-path::`echo $HOME/opt/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin`" + echo `$HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH + echo `echo $HOME/opt/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin` >> $GITHUB_PATH # TI MSP430 GCC mkdir -p /tmp/dl/ [ -f "/tmp/dl/msp430-gcc.tar.bz2" ] || wget --progress=dot:mega $MSP430GCC_URL -O /tmp/dl/msp430-gcc.tar.bz2 tar -C $HOME -xaf /tmp/dl/msp430-gcc.tar.bz2 - echo "::add-path::`echo $HOME/msp430-gcc-*_linux64/bin`" + echo `echo $HOME/msp430-gcc-*_linux64/bin` >> $GITHUB_PATH - name: Checkout TinyUSB uses: actions/checkout@v2 -- cgit v1.3.1 From 3fd38ddf0493f84eb3124aacf9ccd7c76643a2c9 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 9 Oct 2020 21:10:59 +0700 Subject: fix ci build --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 227593e8a..8bb382a8d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,7 +66,7 @@ jobs: npm install --global xpm xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@latest - echo `$HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH + echo `echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH echo `echo $HOME/opt/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin` >> $GITHUB_PATH # TI MSP430 GCC -- cgit v1.3.1