Procházet zdrojové kódy

Merge branch 'master' of https://github.com/hathach/tinyusb into bsp_412

Mengsk před 3 roky
rodič
revize
9d3d8fd5b0
100 změnil soubory, kde provedl 1005 přidání a 681 odebrání
  1. 13 4
      .github/ISSUE_TEMPLATE/bug_report.yml
  2. 4 0
      .github/ISSUE_TEMPLATE/config.yml
  3. 0 14
      .github/ISSUE_TEMPLATE/feature_request.md
  4. 49 0
      .github/ISSUE_TEMPLATE/feature_request.yml
  5. 9 4
      .github/workflows/build_aarch64.yml
  6. 108 47
      .github/workflows/build_arm.yml
  7. 11 7
      .github/workflows/build_esp.yml
  8. 10 6
      .github/workflows/build_msp430.yml
  9. 12 6
      .github/workflows/build_renesas.yml
  10. 12 6
      .github/workflows/build_riscv.yml
  11. 4 2
      .github/workflows/trigger.yml
  12. 2 0
      .gitignore
  13. 21 0
      .gitmodules
  14. 16 3
      CONTRIBUTORS.rst
  15. 15 11
      README.rst
  16. 0 1
      docs/conf.py
  17. 97 0
      docs/info/changelog.rst
  18. 12 4
      docs/reference/getting_started.rst
  19. 2 2
      docs/reference/index.rst
  20. 138 120
      docs/reference/supported.rst
  21. 1 1
      docs/requirements.txt
  22. 0 0
      examples/device/audio_4_channel_mic/.skip.MCU_SAMD11
  23. 0 0
      examples/device/audio_4_channel_mic/.skip.MCU_SAME5X
  24. 0 0
      examples/device/audio_4_channel_mic/.skip.MCU_SAMG
  25. 3 0
      examples/device/audio_4_channel_mic/skip.txt
  26. 3 2
      examples/device/audio_4_channel_mic/src/main.c
  27. 37 26
      examples/device/audio_4_channel_mic/src/tusb_config.h
  28. 2 2
      examples/device/audio_4_channel_mic/src/usb_descriptors.c
  29. 0 0
      examples/device/audio_test/.skip.MCU_SAMD11
  30. 0 0
      examples/device/audio_test/.skip.MCU_SAME5X
  31. 0 0
      examples/device/audio_test/.skip.MCU_SAMG
  32. 3 0
      examples/device/audio_test/skip.txt
  33. 3 2
      examples/device/audio_test/src/main.c
  34. 21 7
      examples/device/audio_test/src/tusb_config.h
  35. 2 2
      examples/device/audio_test/src/usb_descriptors.c
  36. 3 16
      examples/device/board_test/src/tusb_config.h
  37. 6 3
      examples/device/cdc_dual_ports/src/main.c
  38. 23 27
      examples/device/cdc_dual_ports/src/tusb_config.h
  39. 2 2
      examples/device/cdc_dual_ports/src/usb_descriptors.c
  40. 0 0
      examples/device/cdc_msc/.skip.MCU_SAMD11
  41. 1 0
      examples/device/cdc_msc/skip.txt
  42. 3 1
      examples/device/cdc_msc/src/main.c
  43. 1 5
      examples/device/cdc_msc/src/msc_disk.c
  44. 25 30
      examples/device/cdc_msc/src/tusb_config.h
  45. 11 1
      examples/device/cdc_msc/src/usb_descriptors.c
  46. 0 0
      examples/device/cdc_msc_freertos/.skip.MCU_BCM2711
  47. 0 0
      examples/device/cdc_msc_freertos/.skip.MCU_CXD56
  48. 0 0
      examples/device/cdc_msc_freertos/.skip.MCU_GD32VF103
  49. 0 0
      examples/device/cdc_msc_freertos/.skip.MCU_MKL25ZXX
  50. 0 0
      examples/device/cdc_msc_freertos/.skip.MCU_MSP430x5xx
  51. 0 0
      examples/device/cdc_msc_freertos/.skip.MCU_RP2040
  52. 0 0
      examples/device/cdc_msc_freertos/.skip.MCU_SAMD11
  53. 0 0
      examples/device/cdc_msc_freertos/.skip.MCU_SAMX7X
  54. 0 0
      examples/device/cdc_msc_freertos/.skip.MCU_VALENTYUSB_EPTRI
  55. 1 1
      examples/device/cdc_msc_freertos/Makefile
  56. 11 0
      examples/device/cdc_msc_freertos/skip.txt
  57. 4 0
      examples/device/cdc_msc_freertos/src/CMakeLists.txt
  58. 1 0
      examples/device/cdc_msc_freertos/src/FreeRTOSConfig/FreeRTOSConfig.h
  59. 17 14
      examples/device/cdc_msc_freertos/src/main.c
  60. 0 5
      examples/device/cdc_msc_freertos/src/msc_disk.c
  61. 25 30
      examples/device/cdc_msc_freertos/src/tusb_config.h
  62. 2 2
      examples/device/cdc_msc_freertos/src/usb_descriptors.c
  63. 0 4
      examples/device/dfu/.skip.MCU_TM4C123
  64. 1 1
      examples/device/dfu/CMakeLists.txt
  65. 2 0
      examples/device/dfu/skip.txt
  66. 2 1
      examples/device/dfu/src/main.c
  67. 27 31
      examples/device/dfu/src/tusb_config.h
  68. 1 1
      examples/device/dfu/src/usb_descriptors.c
  69. 2 1
      examples/device/dfu_runtime/src/main.c
  70. 24 28
      examples/device/dfu_runtime/src/tusb_config.h
  71. 2 2
      examples/device/dfu_runtime/src/usb_descriptors.c
  72. 0 0
      examples/device/dynamic_configuration/.skip.MCU_SAMD11
  73. 1 0
      examples/device/dynamic_configuration/skip.txt
  74. 4 2
      examples/device/dynamic_configuration/src/main.c
  75. 3 8
      examples/device/dynamic_configuration/src/msc_disk.c
  76. 25 29
      examples/device/dynamic_configuration/src/tusb_config.h
  77. 3 3
      examples/device/dynamic_configuration/src/usb_descriptors.c
  78. 4 2
      examples/device/hid_boot_interface/src/main.c
  79. 25 29
      examples/device/hid_boot_interface/src/tusb_config.h
  80. 2 2
      examples/device/hid_boot_interface/src/usb_descriptors.c
  81. 5 3
      examples/device/hid_composite/src/main.c
  82. 24 28
      examples/device/hid_composite/src/tusb_config.h
  83. 2 2
      examples/device/hid_composite/src/usb_descriptors.c
  84. 0 0
      examples/device/hid_composite_freertos/.skip.MCU_BCM2711
  85. 0 0
      examples/device/hid_composite_freertos/.skip.MCU_CXD56
  86. 0 0
      examples/device/hid_composite_freertos/.skip.MCU_GD32VF103
  87. 0 0
      examples/device/hid_composite_freertos/.skip.MCU_MSP430x5xx
  88. 0 0
      examples/device/hid_composite_freertos/.skip.MCU_RP2040
  89. 0 0
      examples/device/hid_composite_freertos/.skip.MCU_SAMD11
  90. 0 0
      examples/device/hid_composite_freertos/.skip.MCU_SAMX7X
  91. 0 0
      examples/device/hid_composite_freertos/.skip.MCU_VALENTYUSB_EPTRI
  92. 1 1
      examples/device/hid_composite_freertos/Makefile
  93. 11 0
      examples/device/hid_composite_freertos/skip.txt
  94. 5 1
      examples/device/hid_composite_freertos/src/CMakeLists.txt
  95. 13 10
      examples/device/hid_composite_freertos/src/main.c
  96. 24 29
      examples/device/hid_composite_freertos/src/tusb_config.h
  97. 2 2
      examples/device/hid_composite_freertos/src/usb_descriptors.c
  98. 17 15
      examples/device/hid_generic_inout/hid_test.py
  99. 2 1
      examples/device/hid_generic_inout/src/main.c
  100. 25 29
      examples/device/hid_generic_inout/src/tusb_config.h

+ 13 - 4
.github/ISSUE_TEMPLATE/bug_report.yml

@@ -60,11 +60,12 @@ body:
 
   - type: textarea
     attributes:
-      label: Debug Log
+      label: Debug Log as txt file
       placeholder: |
-        TinyUSB debug log where the issue occurred as attached txt file, best with comments to explain the actual events.
-
-        Note: To enable logging, add `LOG=3` to to the make command if building with stock examples or set `CFG_TUSB_DEBUG=3` in your tusb_config.h. 
+        Attach your debug log txt file here, where the issue occurred, best with comments to explain the actual events.
+        
+        Note1: Please DO NOT paste your lengthy log contents here since it hurts the readibility.
+        Note2: To enable logging, add `LOG=3` to to the make command if building with stock examples or set `CFG_TUSB_DEBUG=3` in your tusb_config.h. 
         More information can be found at [example's readme](https://github.com/hathach/tinyusb/blob/master/docs/getting_started.md)
     validations:
       required: false
@@ -75,3 +76,11 @@ body:
       description: If applicable, add screenshots to help explain your problem.
     validations:
       required: false
+
+  - type: checkboxes
+    attributes:
+      label: I have checked existing issues, dicussion and documentation
+      description: You agree to check all the resources above before opening a new issue.
+      options:
+        - label: I confirm I have checked existing issues, dicussion and documentation.
+          required: true

+ 4 - 0
.github/ISSUE_TEMPLATE/config.yml

@@ -1,4 +1,8 @@
+blank_issues_enabled: false
 contact_links:
   - name: TinyUSB Discussion
     url: https://github.com/hathach/tinyusb/discussions
     about: If you have other questions or need help, post it here.
+  - name: TinyUSB Docs
+    url: https://docs.tinyusb.org/
+    about: Online documentation

+ 0 - 14
.github/ISSUE_TEMPLATE/feature_request.md

@@ -1,14 +0,0 @@
----
-name: Feature Request
-about: Suggest an idea for this project
-title: ''
-labels: Feature 💡
-assignees: ''
-
----
-
-**Is your feature request related to a problem? Please describe.**
-A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.

+ 49 - 0
.github/ISSUE_TEMPLATE/feature_request.yml

@@ -0,0 +1,49 @@
+name: Feature Request
+description: Suggest an idea for this project
+labels: 'Feature 💡'
+body:
+  - type: markdown
+    attributes:
+      value: |
+        Thanks for taking the time to fill out this request!
+        It's okay to leave some blank if it doesn't apply to your request.
+
+  - type: input
+    attributes:
+      label: Related area
+      description: Please briefly explain the area of your Feature Request.
+      placeholder: eg. new port support, device stack, class driver ...
+    validations:
+      required: true
+
+  - type: input
+    attributes:
+      label: Hardware specification
+      description: Please provide if your proposal depends on specific Hardware.
+      placeholder: eg. rp2040, samd51 ...
+    validations:
+      required: true
+
+  - type: textarea
+    attributes:
+      label: Is your feature request related to a problem?
+      description: Please provide a clear and concise description of what the problem is. Add relevant issue link.
+      placeholder: ex. I'm facing the issue/missing function...
+    validations:
+      required: true
+
+  - type: textarea
+    attributes:
+      label: Describe the solution you'd like
+      description: Please provide a clear and concise description of what you want to happen.
+      placeholder: ex. When using this function...
+    validations:
+      required: true
+
+  - type: checkboxes
+    attributes:
+      label: I have checked existing issues, dicussion and documentation
+      description: You agree to check all the resources above before opening a new issue.
+      options:
+        - label: I confirm I have checked existing issues, dicussion and documentation.
+          required: true

+ 9 - 4
.github/workflows/build_aarch64.yml

@@ -18,19 +18,21 @@ jobs:
       matrix:
         family:
         # Alphabetical order
-        - 'raspberrypi4'
+        - 'broadcom_64bit'
     steps:
     - name: Setup Python
-      uses: actions/setup-python@v2
+      uses: actions/setup-python@v4
+      with:
+        python-version: '3.x'
 
     - name: Checkout TinyUSB
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Checkout common submodules in lib
       run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel
 
     - name: Checkout hathach/linkermap
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
          repository: hathach/linkermap
          path: linkermap
@@ -55,6 +57,9 @@ jobs:
     - name: Set Toolchain Path
       run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
 
+    - name: Get Dependencies
+      run: python3 tools/get_dependencies.py ${{ matrix.family }}
+
     - name: Build
       run: python3 tools/build_family.py ${{ matrix.family }}
 

+ 108 - 47
.github/workflows/build_arm.yml

@@ -15,12 +15,12 @@ jobs:
     runs-on: ubuntu-latest
     steps:
     - name: Setup Ruby
-      uses: actions/setup-ruby@v1
+      uses: ruby/setup-ruby@v1
       with:
         ruby-version: '2.7'
 
     - name: Checkout TinyUSB
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Unit Tests
       run: |
@@ -39,6 +39,7 @@ jobs:
       matrix:
         family:
         # Alphabetical order
+        - 'broadcom_32bit'
         - 'imxrt'
         - 'lpc15'
         - 'lpc18'
@@ -56,51 +57,43 @@ jobs:
         - 'stm32f1'
         - 'stm32f4'
         - 'stm32f7'
+        - 'stm32g4'
         - 'stm32h7'
         - 'stm32l4'
+        - 'stm32wb'
         - 'tm4c123'
         - 'xmc4000'
     steps:
     - name: Setup Python
-      uses: actions/setup-python@v2
+      uses: actions/setup-python@v4
+      with:
+        python-version: '3.x'
+
+    - name: Install ARM GCC
+      uses: carlosperate/arm-none-eabi-gcc-action@v1
+      with:
+        release: '11.2-2022.02'
 
     - name: Checkout TinyUSB
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Checkout common submodules in lib
       run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel
 
     - name: Checkout hathach/linkermap
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
          repository: hathach/linkermap
          path: linkermap
 
-    - name: Checkout pico-sdk
+    - name: Checkout pico-sdk for rp2040
       if: matrix.family == 'rp2040'
       run: |
         git clone --depth 1 -b develop https://github.com/raspberrypi/pico-sdk ~/pico-sdk
         echo >> $GITHUB_ENV PICO_SDK_PATH=~/pico-sdk
 
-    - name: Set Toolchain URL
-      run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-linux-x64.tar.gz
-
-    - name: Cache Toolchain
-      uses: actions/cache@v2
-      id: cache-toolchain
-      with:
-        path: ~/cache/
-        key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }}
-
-    - name: Install Toolchain
-      if: steps.cache-toolchain.outputs.cache-hit != 'true'
-      run: |
-        mkdir -p ~/cache/toolchain
-        wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz
-        tar -C ~/cache/toolchain -xaf toolchain.tar.gz
-
-    - name: Set Toolchain Path
-      run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
+    - name: Get Dependencies
+      run: python3 tools/get_dependencies.py ${{ matrix.family }}
 
     - name: Build
       run: python3 tools/build_family.py ${{ matrix.family }}
@@ -108,13 +101,28 @@ jobs:
     - name: Linker Map
       run: |
         pip install linkermap/
-        for ex in `ls -d examples/device/*/`; do \
-          find ${ex} -name *.map -print -quit | \
-          xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \
+        # find -quit to only print linkermap of 1 board per example
+        for ex in `ls -d examples/*/*/`
+        do
+          find ${ex} -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'
         done
 
+    # Following steps are for Hardware Test with self-hosted
+
+    - name: Prepare Artifacts
+      if: matrix.family == 'rp2040' && github.repository_owner == 'hathach'
+      run: find examples/ -name "*.elf" -exec mv {} . \;
+
+    - name: Upload Artifacts for Hardware Test
+      if: matrix.family == 'rp2040' && github.repository_owner == 'hathach'
+      uses: actions/upload-artifact@v3
+      with:
+        name: ${{ matrix.family }}
+        path: |
+          *.elf
+
   # ---------------------------------------
-  # Build all no-family (opharned) boards
+  # Build all no-family (orphaned) boards
   # ---------------------------------------
   build-board:
     runs-on: ubuntu-latest
@@ -131,33 +139,86 @@ jobs:
 
     steps:
     - name: Setup Python
-      uses: actions/setup-python@v2
+      uses: actions/setup-python@v4
+      with:
+        python-version: '3.x'
+
+    - name: Install ARM GCC
+      uses: carlosperate/arm-none-eabi-gcc-action@v1
+      with:
+        release: '11.2-2022.02'
 
     - name: Checkout TinyUSB
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Checkout common submodules in lib
       run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
 
-    - name: Set Toolchain URL
-      run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-linux-x64.tar.gz
+    - name: Build
+      run: python3 tools/build_board.py ${{ matrix.example }}
+
+  # ---------------------------------------
+  # Hardware in the loop (HIL)
+  # Current self-hosted instance is running on an RPI4 with
+  # - pico + pico-probe connected via USB
+  # - pico-probe is /dev/ttyACM0
+  # ---------------------------------------
+  hw-test:
+    # Limit the run to only hathach due to limited resource on RPI4
+    if: github.repository_owner == 'hathach'
+    needs: build-arm
+    runs-on: [self-hosted, Linux, ARM64]
 
-    - name: Cache Toolchain
-      uses: actions/cache@v2
-      id: cache-toolchain
+    steps:
+    - name: Clean workspace
+      run: |
+        echo "Cleaning up previous run"
+        rm -rf "${{ github.workspace }}"
+        mkdir -p "${{ github.workspace }}"
+
+    - name: Download rp2040 Artifacts
+      uses: actions/download-artifact@v3
       with:
-        path: ~/cache/
-        key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }}
+        name: rp2040
 
-    - name: Install Toolchain
-      if: steps.cache-toolchain.outputs.cache-hit != 'true'
+    - name: Create flash.sh
       run: |
-        mkdir -p ~/cache/toolchain
-        wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz
-        tar -C ~/cache/toolchain -xaf toolchain.tar.gz
+        touch flash.sh
+        chmod +x flash.sh
+        echo > flash.sh 'openocd -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -c "program $1 reset exit"'
 
-    - name: Set Toolchain Path
-      run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
+    - name: Test cdc_dual_ports
+      run: |
+        ./flash.sh cdc_dual_ports.elf
+        while (! ([ -e /dev/ttyACM1 ] && [ -e /dev/ttyACM2 ])) && [ $SECONDS -le 5 ]; do :; done
+        test -e /dev/ttyACM1 && echo "ttyACM1 exists"
+        test -e /dev/ttyACM2 && echo "ttyACM2 exists"
+
+    - name: Test cdc_msc
+      run: |
+        ./flash.sh cdc_msc.elf
+        readme='/media/pi/TinyUSB MSC/README.TXT'
+        while (! ([ -e /dev/ttyACM1 ] && [ -f "$readme" ])) && [ $SECONDS -le 5 ]; do :; done
+        test -e /dev/ttyACM1 && echo "ttyACM1 exists"
+        test -f "$readme" && echo "$readme exists"
+        cat "$readme"
+
+    - name: Test dfu
+      run: |
+        ./flash.sh dfu.elf
+        while (! (dfu-util -l | grep "Found DFU")) && [ $SECONDS -le 5 ]; do :; done
+        dfu-util -d cafe -a 0 -U dfu0
+        dfu-util -d cafe -a 1 -U dfu1
+        grep "TinyUSB DFU! - Partition 0" dfu0
+        grep "TinyUSB DFU! - Partition 1" dfu1
+
+    - name: Test dfu_runtime
+      run: |
+        ./flash.sh dfu_runtime.elf
+        while (! (dfu-util -l | grep "Found Runtime")) && [ $SECONDS -le 5 ]; do :; done
+
+#    - name: Test hid_boot_interface
+#      run: |
+#        ./flash.sh hid_boot_interface.elf
+#        while (! (dfu-util -l | grep "Found Runtime")) && [ $SECONDS -le 5 ]; do :; done
 
-    - name: Build
-      run: python3 tools/build_board.py ${{ matrix.example }}

+ 11 - 7
.github/workflows/build_esp.yml

@@ -18,20 +18,23 @@ jobs:
         # ESP32-S2
         - 'espressif_saola_1'
         # ESP32-S3
-        - 'espressif_addax_1'
+        #- 'espressif_s3_devkitm'
+        # S3 compile error with "dangerous relocation: call8: call target out of range: memcpy"
 
     steps:
     - name: Setup Python
-      uses: actions/setup-python@v2
+      uses: actions/setup-python@v4
+      with:
+        python-version: '3.x'
 
     - name: Pull ESP-IDF docker
       run: docker pull espressif/idf:latest
 
     - name: Checkout TinyUSB
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Checkout hathach/linkermap
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
          repository: hathach/linkermap
          path: linkermap
@@ -42,7 +45,8 @@ jobs:
     - name: Linker Map
       run: |
         pip install linkermap/
-        for ex in `ls -d examples/device/*/`; do \
-          find ${ex} -maxdepth 3 -name *.map -print -quit | \
-          xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \
+        # find -quit to only print linkermap of 1 board per example
+        for ex in `ls -d examples/device/*/`
+        do
+          find ${ex} -maxdepth 3 -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'
         done

+ 10 - 6
.github/workflows/build_msp430.yml

@@ -18,16 +18,16 @@ jobs:
         - 'msp430'
     steps:
     - name: Setup Python
-      uses: actions/setup-python@v2
+      uses: actions/setup-python@v4
 
     - name: Checkout TinyUSB
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Checkout common submodules in lib
       run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
 
     - name: Checkout hathach/linkermap
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
          repository: hathach/linkermap
          path: linkermap
@@ -52,13 +52,17 @@ jobs:
     - name: Set Toolchain Path
       run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
 
+    - name: Get Dependencies
+      run: python3 tools/get_dependencies.py ${{ matrix.family }}
+
     - name: Build
       run: python3 tools/build_family.py ${{ matrix.family }}
 
     - name: Linker Map
       run: |
         pip install linkermap/
-        for ex in `ls -d examples/device/*/`; do \
-          find ${ex} -name *.map -print -quit | \
-          xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \
+        # find -quit to only print linkermap of 1 board per example
+        for ex in `ls -d examples/device/*/`
+        do
+          find ${ex} -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'
         done

+ 12 - 6
.github/workflows/build_renesas.yml

@@ -18,16 +18,18 @@ jobs:
         - 'rx'
     steps:
     - name: Setup Python
-      uses: actions/setup-python@v2
+      uses: actions/setup-python@v4
+      with:
+        python-version: '3.x'
 
     - name: Checkout TinyUSB
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Checkout common submodules in lib
       run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
 
     - name: Checkout hathach/linkermap
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
          repository: hathach/linkermap
          path: linkermap
@@ -53,13 +55,17 @@ jobs:
     - name: Set Toolchain Path
       run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
 
+    - name: Get Dependencies
+      run: python3 tools/get_dependencies.py ${{ matrix.family }}
+
     - name: Build
       run: python3 tools/build_family.py ${{ matrix.family }}
 
     - name: Linker Map
       run: |
         pip install linkermap/
-        for ex in `ls -d examples/device/*/`; do \
-          find ${ex} -name *.map -print -quit | \
-          xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \
+        # find -quit to only print linkermap of 1 board per example
+        for ex in `ls -d examples/device/*/`
+        do
+          find ${ex} -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'
         done

+ 12 - 6
.github/workflows/build_riscv.yml

@@ -19,16 +19,18 @@ jobs:
         - 'gd32vf103'
     steps:
     - name: Setup Python
-      uses: actions/setup-python@v2
+      uses: actions/setup-python@v4
+      with:
+        python-version: '3.x'
 
     - name: Checkout TinyUSB
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Checkout common submodules in lib
       run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
 
     - name: Checkout hathach/linkermap
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
          repository: hathach/linkermap
          path: linkermap
@@ -53,13 +55,17 @@ jobs:
     - name: Set Toolchain Path
       run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
 
+    - name: Get Dependencies
+      run: python3 tools/get_dependencies.py ${{ matrix.family }}
+
     - name: Build
       run: python3 tools/build_family.py ${{ matrix.family }}
 
     - name: Linker Map
       run: |
         pip install linkermap/
-        for ex in `ls -d examples/device/*/`; do \
-          find ${ex} -name *.map -print -quit | \
-          xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \
+        # find -quit to only print linkermap of 1 board per example
+        for ex in `ls -d examples/device/*/`
+        do
+          find ${ex} -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'
         done

+ 4 - 2
.github/workflows/trigger.yml

@@ -22,7 +22,7 @@ jobs:
     runs-on: ubuntu-latest
     steps:
     - name: Checkout code
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Push to tinyusb_src
       run: |
@@ -55,4 +55,6 @@ jobs:
         git push origin ${{ github.event.release.tag_name }}
         
         # Send POST reqwuest to release https://docs.github.com/en/rest/reference/repos#create-a-release
-        curl -X POST -H "Authorization: token ${{ secrets.API_TOKEN_GITHUB }}" -H "Accept: application/vnd.github.v3+json" --data '{"tag_name": "${{ github.event.release.tag_name }}", "name": "${{ github.event.release.name }}", "body": "${{ github.event.release.body }}", "draft": ${{ github.event.release.draft }}, "prerelease": ${{ github.event.release.prerelease }}}' https://api.github.com/repos/hathach/tinyusb_src/releases
+        bb={{ github.event.release.body }}
+        bb=${bb//\n/\\\n}
+        curl -X POST -H "Authorization: token ${{ secrets.API_TOKEN_GITHUB }}" -H "Accept: application/vnd.github.v3+json" --data '{"tag_name": "${{ github.event.release.tag_name }}", "name": "${{ github.event.release.name }}", "body": "$bb", "draft": ${{ github.event.release.draft }}, "prerelease": ${{ github.event.release.prerelease }}}' https://api.github.com/repos/hathach/tinyusb_src/releases

+ 2 - 0
.gitignore

@@ -26,3 +26,5 @@ cov-int
 # cppcheck build directories
 *-build-dir
 /_bin/
+__pycache__
+

+ 21 - 0
.gitmodules

@@ -97,6 +97,12 @@
 [submodule "hw/mcu/st/stm32l5xx_hal_driver"]
 	path = hw/mcu/st/stm32l5xx_hal_driver
 	url = https://github.com/STMicroelectronics/stm32l5xx_hal_driver.git
+[submodule "hw/mcu/st/cmsis_device_wb"]
+	path = hw/mcu/st/cmsis_device_wb
+	url = https://github.com/STMicroelectronics/cmsis_device_wb.git
+[submodule "hw/mcu/st/stm32wbxx_hal_driver"]
+	path = hw/mcu/st/stm32wbxx_hal_driver
+	url = https://github.com/STMicroelectronics/stm32wbxx_hal_driver.git
 [submodule "lib/sct_neopixel"]
 	path = lib/sct_neopixel
 	url = https://github.com/gsteiert/sct_neopixel
@@ -124,6 +130,9 @@
 [submodule "hw/mcu/gd/nuclei-sdk"]
 	path = hw/mcu/gd/nuclei-sdk
 	url = https://github.com/Nuclei-Software/nuclei-sdk.git
+[submodule "hw/mcu/bridgetek/ft9xx/ft90x-sdk"]
+	path = hw/mcu/bridgetek/ft9xx/ft90x-sdk
+	url = https://github.com/BRTSG-FOSS/ft90x-sdk
 [submodule "hw/mcu/mindmotion/mm32sdk"]
 	path = hw/mcu/mindmotion/mm32sdk
 	url = https://github.com/hathach/mm32sdk.git
@@ -134,3 +143,15 @@
 [submodule "hw/mcu/infineon/mtb-xmclib-cat3"]
 	path = hw/mcu/infineon/mtb-xmclib-cat3
 	url = https://github.com/Infineon/mtb-xmclib-cat3.git
+[submodule "hw/mcu/allwinner"]
+	path = hw/mcu/allwinner
+	url = https://github.com/hathach/allwinner_driver.git
+[submodule "hw/mcu/raspberry_pi/Pico-PIO-USB"]
+	path = hw/mcu/raspberry_pi/Pico-PIO-USB
+	url = https://github.com/sekigon-gonnoc/Pico-PIO-USB.git
+[submodule "hw/mcu/st/cmsis_device_u5"]
+	path = hw/mcu/st/cmsis_device_u5
+	url = https://github.com/STMicroelectronics/cmsis_device_u5
+[submodule "hw/mcu/st/stm32u5xx_hal_driver"]
+	path = hw/mcu/st/stm32u5xx_hal_driver
+	url = https://github.com/STMicroelectronics/stm32u5xx_hal_driver

+ 16 - 3
CONTRIBUTORS.rst

@@ -18,6 +18,12 @@ Notable contributors
 -  Design the project logo
 
 
+`Gordon McNab <https://github.com/ftdigdm>`__
+---------------------------------------------
+
+-  Add new DCD port for Bridgetek FT90x and FT93x
+
+
 `Ha Thach <https://github.com/hathach>`__
 -----------------------------------------
 
@@ -53,6 +59,7 @@ Notable contributors
 -----------------------------------------------
 
 -  Add new DCD port for Dialog DA1469x
+-  Add new DCD port for PIC32MZ
 -  Add new class driver for Bluetooth HCI
 -  Add ISO transfer for STM32 Synopsys, Nordic nRF, Dialog DA1469x
 -  Improve Audio driver and add uac2\_headset example
@@ -81,11 +88,11 @@ Notable contributors
 `Koji KITAYAMA <https://github.com/kkitayam>`__
 -----------------------------------------------
 
--  Add new DCD port for NXP Kinetis KL25
--  Add new DCD port for Renesas RX family (RX600, RX700 ..) with GR-CITRUS, RX65n target board
+-  Add new DCD and HCD port for NXP Kinetis KL25
+-  Add new DCD and HCD port for Renesas RX family (RX600, RX700 ..) with GR-CITRUS, RX65n target board
+-  Add new DCD and HCD port for Mentor musb with MSP432E4
 -  Add new class driver for USB Video Class (UVC 1.5)
 
-
 `Nathan Conrad <https://github.com/pigrew>`__
 ---------------------------------------------
 
@@ -153,6 +160,12 @@ Notable contributors
 -  Add new class driver for DFU Runtime
 
 
+`Tian Yunhao <https://github.com/t123yh>`__
+-------------------------------------------
+
+-  Add new DCD port for Allwinner F1C100S/F1C200S
+-  Add support for osal_rtx4
+
 `Timon Skerutsch <https://github.com/PTS93>`__
 ----------------------------------------------
 

+ 15 - 11
README.rst

@@ -32,24 +32,27 @@ Supported MCUs
 
 The stack supports the following MCUs:
 
+- **Allwinner:** F1C100s/F1C200s
+- **Broadcom:** BCM2837, BCM2711
 - **Dialog:** DA1469x
 - **Espressif:** ESP32-S2, ESP32-S3
+- **GigaDevice:** GD32VF103
 - **Infineon:** XMC4500
 - **MicroChip:** SAMD11, SAMD21, SAMD51, SAME5x, SAMG55, SAML21, SAML22, SAME7x
 - **NordicSemi:** nRF52833, nRF52840, nRF5340
 - **Nuvoton:** NUC120, NUC121/NUC125, NUC126, NUC505
 - **NXP:**
 
-  - iMX RT Series: RT1011, RT1015, RT1021, RT1052, RT1062, RT1064
-  - Kinetis: KL25, K32L2Bxx
+  - iMX RT Series: RT10xx, RT11xx
+  - Kinetis: KL25, K32L2
   - LPC Series: 11u, 13, 15, 17, 18, 40, 43, 51u, 54, 55
 
 - **Raspberry Pi:** RP2040
-- **Renesas:** RX63N, RX65N
+- **Renesas:** RX63N, RX65N, RX72N
 - **Silabs:** EFM32GG
 - **Sony:** CXD56
-- **ST:** STM32 series: L0, L1, L4, L4+, F0, F1, F2, F3, F4, F7, H7
-- **TI:** MSP430
+- **ST:** STM32 series: F0, F1, F2, F3, F4, F7, H7, G4, L0, L1, L4, L4+, WB
+- **TI:** MSP430, MSP432E4, TM4C123
 - **ValentyUSB:** eptri
 
 Here is the list of `Supported Devices`_ that can be used with provided examples.
@@ -62,7 +65,7 @@ Supports multiple device configurations by dynamically changing USB descriptors,
 -  Audio Class 2.0 (UAC2)
 -  Bluetooth Host Controller Interface (BTH HCI)
 -  Communication Device Class (CDC)
--  Device Firmware Update (DFU): DFU mode (WIP) and Runtinme
+-  Device Firmware Update (DFU): DFU mode (WIP) and Runtime
 -  Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
 -  Mass Storage Class (MSC): with multiple LUNs
 -  Musical Instrument Digital Interface (MIDI)
@@ -72,14 +75,14 @@ Supports multiple device configurations by dynamically changing USB descriptors,
 -  Vendor-specific class support with generic In & Out endpoints. Can be used with MS OS 2.0 compatible descriptor to load winUSB driver without INF file.
 -  `WebUSB <https://github.com/WICG/webusb>`__ with vendor-specific class
 
-If you have a special requirement, `usbd_app_driver_get_cb()` can be used to write your own class driver without modifying the stack. Here is how the RPi team added their reset interface [raspberrypi/pico-sdk#197](https://github.com/raspberrypi/pico-sdk/pull/197)
+If you have a special requirement, `usbd_app_driver_get_cb()` can be used to write your own class driver without modifying the stack. Here is how the RPi team added their reset interface `raspberrypi/pico-sdk#197 <https://github.com/raspberrypi/pico-sdk/pull/197>`_
 
 Host Stack
 ==========
 
 - Human Interface Device (HID): Keyboard, Mouse, Generic
 - Mass Storage Class (MSC)
-- Hub currently only supports 1 level of hub (due to my laziness)
+- Hub with multiple-level support
 
 OS Abstraction layer
 ====================
@@ -88,10 +91,11 @@ TinyUSB is completely thread-safe by pushing all Interrupt Service Request (ISR)
 
 - **No OS**
 - **FreeRTOS**
-- **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its [own repo](https://github.com/hathach/mynewt-tinyusb-example)
+- `RT-Thread <https://github.com/RT-Thread/rt-thread>`_: `repo <https://github.com/RT-Thread-packages/tinyusb>`_
+- **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its `own repo <https://github.com/hathach/mynewt-tinyusb-example>`_
 
-Local Docs
-==========
+Docs
+====
 
 - Info
 

+ 0 - 1
docs/conf.py

@@ -21,7 +21,6 @@ extensions = [
     'sphinx.ext.intersphinx',
     'sphinx.ext.todo',
     'sphinx_autodoc_typehints',
-    'sphinxemoji.sphinxemoji',
 ]
 
 templates_path = ['_templates']

+ 97 - 0
docs/info/changelog.rst

@@ -2,6 +2,103 @@
 Changelog
 *********
 
+0.14.0
+======
+
+- Improve compiler support for CCRX and IAR
+- Add timeout to osal_queue_receive()
+- Add tud_task_ext(timeout, in_isr) as generic version of tud_task(). Same as tuh_task_ext(), tuh_task()
+- Enable more warnings -Wnull-dereference -Wuninitialized -Wunused -Wredundant-decls -Wconversion
+- Add new examples 
+  - host/bare_api to demonstrate generic (app-level) enumeration and endpoint transfer
+  - dual/host_hid_to_device_cdc to run both device and host stack concurrently, get HID report from host and print out to device CDC. This example only work with multiple-controller MCUs and rp2040 with the help of pio-usb as added controller.
+
+Controller Driver (DCD & HCD)
+-----------------------------
+
+- Enhance rhports management to better support dual roles
+  - CFG_TUD_ENABLED/CFG_TUH_ENABLED, CFG_TUD_MAX_SPEED/CFG_TUH_MAX_SPEED can be used to replace CFG_TUSB_RHPORT0_MODE/CFG_TUSB_RHPORT1_MODE
+  - tud_init(rphort), tuh_init(rhport) can be used to init stack on specified roothub port (controller) instead of tusb_init(void)
+- Add dcd/hcd port specific defines TUP_ (stand for tinyusb port-specific)
+- [dwc2]
+  - Update to support stm32 h72x, h73x with only 1 otg controller
+  - Fix overwrite with grstctl when disable endpoint
+- [EHCI] Fix an issue with EHCI driver
+- [msp430] Fix for possible bug in msp430-elf-gcc 9.3.0
+- [nrf5x] Fix DMA access race condition using atomic function 
+- [pic32] Fix PIC32 santiy
+- [rp2040]
+  - Add PICO-PIO-USB as controller (device/host) support for rp2040
+  - Use shared IRQ handlers, so user can also hook the USB IRQ
+  - Fix resumed signal not reported to device stack
+- [stm32fsdev] Add support for stm32wb55 
+
+Device Stack
+------------
+
+- [Audio] Add support for feedback endpoint computation
+  - New API tud_audio_feedback_params_cb(), tud_audio_feedback_interval_isr().
+  - Supported computation method are: frequency with fixed/float or power of 2. Feedback with fifo count is not yet supported.
+  - Fix nitfs (should be 3) in TUD_AUDIO_HEADSET_STEREO_DESCRIPTOR
+  - Fix typo in audiod_rx_done_cb()
+- [DFU] Fix coexistence with other interfaces BTH, RNDIS
+- [MSC] Fix inquiry response additional length field
+- [Venndor] Improve write performance
+
+Host Stack
+----------
+
+- Add new API tuh_configure(rhport, cfg_id, cfg_param) for dynamnic port specific behavior configuration
+- [HID] Open OUT endpoint if available
+- [Hub] hub clear port and device interrupts
+- [USBH] Major improvement
+  - Rework usbh control transfer with complete callback. New API tuh_control_xfer() though still only carry 1 usbh (no queueing) at a time.
+  - Add generic endpoint transfer with tuh_edpt_open(), tuh_edpt_xfer(). Require `CFG_TUH_API_EDPT_XFER=1`
+  - Support app-level enumeration with new APIs
+    - tuh_descriptor_get(), tuh_descriptor_get_device(), tuh_descriptor_get_configuration(), tuh_descriptor_get_hid_report()
+    - tuh_descriptor_get_string(), tuh_descriptor_get_manufacturer_string(), tuh_descriptor_get_product_string(), tuh_descriptor_get_serial_string()
+    - Also add _sync() as sync/blocking version for above APIs
+
+0.13.0
+======
+
+- [tu_fifo] Fix locked mutex when full, and return type in peek_n()
+
+Controller Driver (DCD & HCD)
+-----------------------------
+
+- [DWC2] Generalize synopsys dwc2 with synopsys/dwc2 which support both FS and HS phy (UTMI and ULPI) for various MCUs.
+  - Broadcom 28/27xx on raspberrypi SBC
+  - Silicon Labs EFM32
+  - Espressif ESP32 Sx
+  - GigaDevice GD32
+  - ST STM32
+  - Infineon XMC
+- [KL25] Add new HCD for NXP KL25
+- [MUSB] Add new DCD and HCD for Mentor musb with TI MSP432E4
+- [F1C100s] Add new DCD for Allwinner F1C100s family
+- [PIC32MZ] Add new DCD for PIC32MZ
+- [nRF] Fix/Enhance varous race condtion with: EASY DMA, request HFXO, EPOUT
+- [ChipIdea] rename Transdimension to more popular ChipIdea Highspeed, 
+- [RP2040] various update/fix for hcd/dcd
+- [FT9XX] new DCD port for Bridgetek FT90x and FT93x devices
+- [DA1469X] Fix resume
+- [OHCI] Fix device array out of bound
+
+Note: legacy drivers such as st/synopsys, nxp/transdimension are still present in this release but won't recieve more update and could be removed in the future.
+
+Device Stack
+------------
+
+- [Audio] Support disabling feedback format correction (16.16 <-> 10.14 format)
+- [MSC] Add tud_msc_request_sense_cb() callback, change most default sense error to medium not present (0x02, 0x3A, 0x00)
+- [Video] Fix video_capture example fails enumeration when 8FPS
+
+Host Stack
+----------
+
+No notable changes
+
 0.12.0
 ======
 

+ 12 - 4
docs/reference/getting_started.rst

@@ -37,7 +37,7 @@ It is relatively simple to incorporate tinyusb to your (existing) project
 Examples
 --------
 
-For your convenience, TinyUSB contains a handful of examples for both host and device with/without RTOS to quickly test the functionality as well as demonstrate how API() should be used. Most examples will work on most of `the supported Boards <boards.md>`_. Firstly we need to ``git clone`` if not already
+For your convenience, TinyUSB contains a handful of examples for both host and device with/without RTOS to quickly test the functionality as well as demonstrate how API() should be used. Most examples will work on most of `the supported boards <supported.rst>`_. Firstly we need to ``git clone`` if not already
 
 .. code-block::
 
@@ -50,9 +50,7 @@ Some TinyUSB examples also requires external submodule libraries in ``/lib`` suc
 
    $ git submodule update --init lib
 
-In addition, MCU driver submodule is also needed to provide low-level MCU peripheral's driver. Luckily, it will be fetched if needed when you run the ``make`` to build your board.
-
-Note: some examples especially those that uses Vendor class (e.g webUSB) may requires udev permission on Linux (and/or macOS) to access usb device. It depends on your OS distro, typically copy ``/examples/device/99-tinyusb.rules`` file to /etc/udev/rules.d/ then run ``sudo udevadm control --reload-rules && sudo udevadm trigger`` is good enough.
+Some ports will also require a port-specific SDK (e.g. RP2040) or binary (e.g. Sony Spresense) to build examples. They are out of scope for tinyusb, you should download/install it first according to its manufacturer guide. 
 
 Build
 ^^^^^
@@ -63,6 +61,15 @@ To build example, first change directory to an example folder.
 
    $ cd examples/device/cdc_msc
 
+Before building, we need to download MCU driver submodule to provide low-level MCU peripheral's driver first. Run the ``get-deps`` target in one of the example folder as follow. You only need to do this once per mcu
+
+.. code-block::
+
+   $ make BOARD=feather_nrf52840_express get-deps
+
+
+Some modules (e.g. RP2040 and ESP32s2) require the project makefiles to be customized using CMake. If necessary apply any setup steps for the platform's SDK.
+
 Then compile with ``make BOARD=[board_name] all``\ , for example
 
 .. code-block::
@@ -70,6 +77,7 @@ Then compile with ``make BOARD=[board_name] all``\ , for example
    $ make BOARD=feather_nrf52840_express all
 
 Note: ``BOARD`` can be found as directory name in ``hw/bsp``\ , either in its family/boards or directly under bsp (no family).
+Note: some examples especially those that uses Vendor class (e.g webUSB) may requires udev permission on Linux (and/or macOS) to access usb device. It depends on your OS distro, typically copy ``/examples/device/99-tinyusb.rules`` file to /etc/udev/rules.d/ then run ``sudo udevadm control --reload-rules && sudo udevadm trigger`` is good enough.
 
 Port Selection
 ~~~~~~~~~~~~~~

+ 2 - 2
docs/reference/index.rst

@@ -25,7 +25,7 @@ Supports multiple device configurations by dynamically changing usb descriptors.
 -  Vendor-specific class support with generic In & Out endpoints. Can be used with MS OS 2.0 compatible descriptor to load winUSB driver without INF file.
 -  `WebUSB <https://github.com/WICG/webusb>`__ with vendor-specific class
 
-If you have special need, `usbd_app_driver_get_cb()` can be used to write your own class driver without modifying the stack. Here is how RPi team add their reset interface [raspberrypi/pico-sdk#197](https://github.com/raspberrypi/pico-sdk/pull/197)
+If you have special need, `usbd_app_driver_get_cb()` can be used to write your own class driver without modifying the stack. Here is how RPi team add their reset interface `raspberrypi/pico-sdk#197 <https://github.com/raspberrypi/pico-sdk/pull/197>`__
 
 Host Stack
 ==========
@@ -41,7 +41,7 @@ TinyUSB is completely thread-safe by pushing all ISR events into a central queue
 
 - **No OS**
 - **FreeRTOS**
-- **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its [own repo](https://github.com/hathach/mynewt-tinyusb-example)
+- **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its `own repo <https://github.com/hathach/mynewt-tinyusb-example>`__
 
 License
 =======

+ 138 - 120
docs/reference/supported.rst

@@ -2,126 +2,120 @@
 Supported Devices
 *****************
 
-
 Supported MCUs
 ==============
 
-.. admonition:: Warning
-   :class: warning
-
-   This table is a WIP! the data is not correct, tho if a device is listed, it likely works as a usb full speed device at the least.
-
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| Manufacturer | Family             | Device            | Host               | FS                | HS                | Known Issues |
-+==============+====================+===================+====================+===================+===================+==============+
-| Dialog       | DA1469x            | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| Espressif    | ESP32-S2           | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | ESP32-S3           | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| MicroChip    | SAMD11             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | SAMD21             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | SAMD51             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | SAME5x             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | SAMG55             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | SAML21             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | SAML22             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | SAME70,S70,V70,V71 | |:green_square:|  | |:red_square:|     | |:green_square:|  | |:green_square:|  |              |
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| NordicSemi   | nRF52833           | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | nRF52840           | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| Nuvoton      | NUC120             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | NUC121/NUC125      | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | NUC126             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | NUC505             | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-+--------------+-------+------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| NXP          | iMX   | RT1011     | |:green_square:|  | |:yellow_square:|  | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | RT1015     | |:green_square:|  | |:yellow_square:|  | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | RT1021     | |:green_square:|  | |:yellow_square:|  | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | RT1052     | |:green_square:|  | |:yellow_square:|  | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | RT1062     | |:green_square:|  | |:yellow_square:|  | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | RT1064     | |:green_square:|  | |:yellow_square:|  | |:green_square:|  | |:x:|             |              |
-|              +-------+------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | Kinetis KL25       | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              +-------+------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | LPC   | 11u        | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | 13         | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | 15         | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | 17         | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | 18         |                   | |:yellow_square:|  | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | 40         |                   | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | 43         | |:green_square:|  | |:yellow_square:|  | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | 51u        | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | 54         | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | 55         | |:green_square:|  | |:x:|              | |:green_square:|  |                   |              |
-+--------------+-------+------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| Raspberry Pi | RP2040             | |:green_square:|  | |:x:|              | |:green_square:|  |                   |              |
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| Renesas      | RX63N              | |:green_square:|  |                    | |:green_square:|  | |:x:|             |              |
-|              +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              | RX65N              | |:green_square:|  |                    | |:green_square:|  | |:x:|             |              |
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| Silabs       | EFM32GG12          | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| Sony         | CXD56              | |:green_square:|  | |:x:|              | |:green_square:|  | |:x:|             |              |
-+--------------+-------+------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| ST           | STM32 | L0         | |:green_square:|  |                    | |:green_square:|  |                   |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | F0         | |:green_square:|  |                    | |:green_square:|  |                   |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | F1         | |:green_square:|  |                    | |:green_square:|  |                   |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | F2         | |:green_square:|  |                    | |:green_square:|  |                   |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | F3         | |:green_square:|  |                    | |:green_square:|  |                   |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | F4         | |:green_square:|  |                    | |:green_square:|  |                   |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | F7         | |:green_square:|  |                    | |:green_square:|  |                   |              |
-|              |       +------------+-------------------+--------------------+-------------------+-------------------+--------------+
-|              |       | H7         | |:green_square:|  |                    | |:green_square:|  | |:green_square:|  |              |
-+--------------+-------+------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| TI           | MSP430             | |:green_square:|  |                    | |:green_square:|  |                   |              |
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
-| ValentyUSB   | eptri              | |:green_square:|  |                    | |:green_square:|  |                   |              |
-+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| Manufacturer | Family                | Device | Host | Highspeed | Driver            | Note         |
++==============+=======================+========+======+===========+===================+==============+
+| Broadcom     | BCM2711, BCM2837      | ✔      |      | ✔         | dwc2              |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| Dialog       | DA1469x               | ✔      | ✖    | ✖         | da146xx           |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| Espressif    | ESP32 S2, S3          | ✔      |      | ✖         | dwc2 or esp32sx   |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| GigaDevice   | GD32VF103             | ✔      |      | ✖         | dwc2              |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| Infineon     | XMC4500               | ✔      |      | ✖         | dwc2              |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| MicroChip    | SAM D11, D21          | ✔      |      | ✖         | samd              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | SAM D51, E5x          | ✔      |      | ✖         | samd              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | SAM G55               | ✔      |      | ✖         | samg              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | SAM L21, L22          | ✔      |      | ✖         | samd              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | SAM E70,S70,V70,V71   | ✔      |      | ✔         | samx7x            |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| NordicSemi   | nRF52833, nRF52840    | ✔      | ✖    | ✖         | nrf5x             |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | nRF5340               | ✔      | ✖    | ✖         | nrf5x             |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| Nuvoton      | NUC120                | ✔      | ✖    | ✖         |                   |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | NUC121/NUC125         | ✔      | ✖    | ✖         |                   |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | NUC126                | ✔      | ✖    | ✖         |                   |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | NUC505                | ✔      |      | ✔         |                   |              |
++--------------+---------+-------------+--------+------+-----------+-------------------+--------------+
+| NXP          | iMXRT   | RT10xx      | ✔      | ✔    | ✔         | ci_hs             |              |
+|              |         +-------------+--------+------+-----------+-------------------+--------------+
+|              |         | RT11xx      | ✔      | ✔    | ✔         | ci_hs             |              |
+|              +---------+-------------+--------+------+-----------+-------------------+--------------+
+|              | Kinetis | KL25        | ✔      | ⚠    | ✖         |                   |              |
+|              |         +-------------+--------+------+-----------+-------------------+--------------+
+|              |         | K32L2       | ✔      |      | ✖         |                   |              |
+|              +---------+-------------+--------+------+-----------+-------------------+--------------+
+|              | LPC     | 11u, 13, 15 | ✔      | ✖    | ✖         | lpc_ip3511        |              |
+|              |         +-------------+--------+------+-----------+-------------------+--------------+
+|              |         | 17, 40      | ✔      | ⚠    | ✖         | lpc17_40          |              |
+|              |         +-------------+--------+------+-----------+-------------------+--------------+
+|              |         | 18, 43      | ✔      | ✔    | ✔         | ci_hs             |              |
+|              |         +-------------+--------+------+-----------+-------------------+--------------+
+|              |         | 51u         | ✔      | ✖    | ✖         | lpc_ip3511        |              |
+|              |         +-------------+--------+------+-----------+-------------------+--------------+
+|              |         | 54          | ✔      |      | ✔         | lpc_ip3511        |              |
+|              |         +-------------+--------+------+-----------+-------------------+--------------+
+|              |         | 55          | ✔      |      | ✔         | lpc_ip3511        |              |
++--------------+---------+-------------+--------+------+-----------+-------------------+--------------+
+| Raspberry Pi | RP2040                | ✔      | ✔    | ✖         | rp2040, pio_usb   |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| Renesas      | RX 63N, 65N, 72N      | ✔      | ✔    | ✖         | usba              |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| Silabs       | EFM32GG12             | ✔      |      | ✖         | dwc2              |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| Sony         | CXD56                 | ✔      | ✖    | ✔         | cxd56             |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| ST STM32     | F0                    | ✔      | ✖    | ✖         | stm32_fsdev       |              |
+|              +----+------------------+--------+------+-----------+-------------------+--------------+
+|              | F1 | 102, 103         | ✔      | ✖    | ✖         | stm32_fsdev       |              |
+|              |    +------------------+--------+------+-----------+-------------------+--------------+
+|              |    | 105, 107         | ✔      |      | ✖         | dwc2              |              |
+|              +----+------------------+--------+------+-----------+-------------------+--------------+
+|              | F2                    | ✔      |      | ✔         | dwc2              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | F3                    | ✔      | ✖    | ✖         | stm32_fsdev       |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | F4                    | ✔      |      | ✔         | dwc2              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | F7                    | ✔      |      | ✔         | dwc2              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | H7                    | ✔      |      | ✔         | dwc2              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | G4                    | ✔      | ✖    | ✖         | stm32_fsdev       |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | L0, L1                | ✔      | ✖    | ✖         | stm32_fsdev       |              |
+|              +----+------------------+--------+------+-----------+-------------------+--------------+
+|              | L4 | 4x2, 4x3         | ✔      | ✖    | ✖         | stm32_fsdev       |              |
+|              |    +------------------+--------+------+-----------+-------------------+--------------+
+|              |    | 4x5, 4x6         | ✔      |      |           | dwc2              |              |
+|              +----+------------------+--------+------+-----------+-------------------+--------------+
+|              | L4+                   | ✔      |      |           | dwc2              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | U5                    | ⚠      |      |           | dwc2              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | WBx5                  | ✔      |      |           | stm32_fsdev       |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| TI           | MSP430                | ✔      | ✖    | ✖         | msp430x5xx        |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | MSP432E4              | ✔      |      | ✖         | musb              |              |
+|              +-----------------------+--------+------+-----------+-------------------+--------------+
+|              | TM4C123               | ✔      |      | ✖         | musb              |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+| ValentyUSB   | eptri                 | ✔      | ✖    | ✖         | eptri             |              |
++--------------+-----------------------+--------+------+-----------+-------------------+--------------+
+
 
 Table Legend
 ------------
 
-================= ===================
-|:x:|             Not available
-|:red_square:|    Not supported
-|:yellow_square:| WIP/partial support
-|:green_square:|  Supported
-================= ===================
+= ===================
+✔ Supported
+⚠ WIP/partial support
+✖ Not supported
+= ===================
 
 Supported Boards
 ================
@@ -134,6 +128,11 @@ The board support code is only used for self-contained examples and testing. It
 
 The following boards are supported (sorted alphabetically):
 
+Broadcom
+--------
+
+-  `Raspberry Pi CM4 <https://www.raspberrypi.com/products/compute-module-4>`__
+
 Dialog DA146xx
 --------------
 
@@ -143,12 +142,17 @@ Dialog DA146xx
 Espressif ESP32-S2
 ------------------
 
--  Adafruit Feather ESP32-S2
+-  `Adafruit Feather ESP32-S2 <https://www.adafruit.com/product/5000>`__
 -  `Adafruit Magtag 2.9" E-Ink WiFi Display <https://www.adafruit.com/product/4800>`__
 -  `Adafruit Metro ESP32-S2 <https://www.adafruit.com/product/4775>`__
 -  `ESP32-S2-Kaluga-1 <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit.html>`__
 -  `ESP32-S2-Saola-1 <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html>`__
 
+GigaDevice
+----------
+
+-  `Sipeed Longan Nano <https://longan.sipeed.com/en/>`__
+
 Infineon
 ---------
 
@@ -239,11 +243,14 @@ iMX RT
 -  `MIMX RT1060 Evaluation Kit <https://www.nxp.com/design/development-boards/i.mx-evaluation-and-development-boards/mimxrt1060-evk-i.mx-rt1060-evaluation-kit:MIMXRT1060-EVK>`__
 -  `MIMX RT1064 Evaluation Kit <https://www.nxp.com/design/development-boards/i.mx-evaluation-and-development-boards/mimxrt1064-evk-i.mx-rt1064-evaluation-kit:MIMXRT1064-EVK>`__
 -  `Teensy 4.0 Development Board <https://www.pjrc.com/store/teensy40.html>`__
+-  `Teensy 4.1 Development Board <https://www.pjrc.com/store/teensy41.html>`__
 
 Kinetis
 ^^^^^^^
 
--  `FRDM-KL25Z <https://www.nxp.com/design/development-boards/freedom-development-boards/mcu-boards/freedom-development-platform-for-kinetis-kl14-kl15-kl24-kl25-mcus:FRDM-KL25Z>`__
+-  `Freedom FRDM-KL25Z <https://www.nxp.com/design/development-boards/freedom-development-boards/mcu-boards/freedom-development-platform-for-kinetis-kl14-kl15-kl24-kl25-mcus:FRDM-KL25Z>`__
+-  `Freedom FRDM-K32L2B3 <https://www.nxp.com/design/development-boards/freedom-development-boards/mcu-boards/nxp-freedom-development-platform-for-k32-l2b-mcus:FRDM-K32L2B3>`__
+-  `KUIIC <https://github.com/nxf58843/kuiic>`__
 
 LPC 11-13-15
 ^^^^^^^^^^^^
@@ -342,6 +349,7 @@ F4
 -  `STM32 F411ve Discovery <https://www.st.com/en/evaluation-tools/32f411ediscovery.html>`__
 -  `STM32 F412zg Discovery <https://www.st.com/en/evaluation-tools/32f412gdiscovery.html>`__
 -  `STM32 F412zg Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f412zg.html>`__
+-  `STM32 F439zi Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f439zi.html>`__
 
 F7
 ^^
@@ -353,6 +361,17 @@ F7
 -  `STM32 F767zi Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f767zi.html>`__
 -  `STM32 F769i Discovery <https://www.st.com/en/evaluation-tools/32f769idiscovery.html>`__
 
+H7
+^^
+-  `STM32 H743zi Nucleo <https://www.st.com/en/evaluation-tools/nucleo-h743zi.html>`__
+-  `STM32 H743i Evaluation <https://www.st.com/en/evaluation-tools/stm32h743i-eval.html>`__
+-  `STM32 H745i Discovery <https://www.st.com/en/evaluation-tools/stm32h745i-disco.html>`__
+-  `Waveshare OpenH743I-C <https://www.waveshare.com/openh743i-c-standard.htm>`__
+
+G4
+^^
+-  `STM32 G474RE Nucleo <https://www.st.com/en/evaluation-tools/nucleo-g474re.html>`__
+
 L0
 ^^
 -  `STM32 L035c8 Discovery <https://www.st.com/en/evaluation-tools/32l0538discovery.html>`__
@@ -363,17 +382,16 @@ L4
 -  `STM32 L4P5zg Nucleo <https://www.st.com/en/evaluation-tools/nucleo-l4p5zg.html>`__
 -  `STM32 L4R5zi Nucleo <https://www.st.com/en/evaluation-tools/nucleo-l4r5zi.html>`__
 
-H7
+WB
 ^^
--  `STM32 H743zi Nucleo <https://www.st.com/en/evaluation-tools/nucleo-h743zi.html>`__
--  `STM32 H743i Evaluation <https://www.st.com/en/evaluation-tools/stm32h743i-eval.html>`__
--  `STM32 H745i Discovery <https://www.st.com/en/evaluation-tools/stm32h745i-disco.html>`__
--  `Waveshare OpenH743I-C <https://www.waveshare.com/openh743i-c-standard.htm>`__
+-  `STM32 WB55 Nucleo <https://www.st.com/en/evaluation-tools/p-nucleo-wb55.html>`__
 
 TI
 --
 
 -  `MSP430F5529 USB LaunchPad Evaluation Kit <http://www.ti.com/tool/MSP-EXP430F5529LP>`__
+-  `MSP-EXP432E401Y LaunchPad Evaluation Kit <https://www.ti.com/tool/MSP-EXP432E401Y>`__
+-  `TM4C123GXL LaunchPad Evaluation Kit <https://www.ti.com/tool/EK-TM4C123GXL>`__
 
 Tomu
 ----

+ 1 - 1
docs/requirements.txt

@@ -1,4 +1,4 @@
 sphinx~=3.0
 furo>=2020.12.30.b24
-sphinxemoji>=0.1.8
 sphinx-autodoc-typehints>=1.10
+jinja2==3.0.3

+ 0 - 0
examples/device/audio_4_channel_mic/.skip.MCU_SAMD11


+ 0 - 0
examples/device/audio_4_channel_mic/.skip.MCU_SAME5X


+ 0 - 0
examples/device/audio_4_channel_mic/.skip.MCU_SAMG


+ 3 - 0
examples/device/audio_4_channel_mic/skip.txt

@@ -0,0 +1,3 @@
+mcu:SAMD11
+mcu:SAME5X
+mcu:SAMG

+ 3 - 2
examples/device/audio_4_channel_mic/src/main.c

@@ -81,7 +81,8 @@ int main(void)
 {
   board_init();
 
-  tusb_init();
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   // Init values
   sampFreq = AUDIO_SAMPLE_RATE;
@@ -220,7 +221,7 @@ bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
         // Request uses format layout 2
         TU_VERIFY(p_request->wLength == sizeof(audio_control_cur_2_t));
 
-        volume[channelNum] = ((audio_control_cur_2_t*) pBuff)->bCur;
+        volume[channelNum] = (uint16_t) ((audio_control_cur_2_t*) pBuff)->bCur;
 
         TU_LOG2("    Set Volume: %d dB of channel: %u\r\n", volume[channelNum], channelNum);
       return true;

+ 37 - 26
examples/device/audio_4_channel_mic/src/tusb_config.h

@@ -30,6 +30,20 @@
 extern "C" {
 #endif
 
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
+
+// RHPort number used for device can be defined by board.mk, default to port 0
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      0
+#endif
+
+// RHPort max operational speed can defined by board.mk
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
+#endif
+
 //--------------------------------------------------------------------
 // COMMON CONFIGURATION
 //--------------------------------------------------------------------
@@ -39,22 +53,19 @@ extern "C" {
 #error CFG_TUSB_MCU must be defined
 #endif
 
-#if CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX
-#define CFG_TUSB_RHPORT0_MODE       (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
-#else
-#define CFG_TUSB_RHPORT0_MODE       OPT_MODE_DEVICE
-#endif
-
 #ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS                 OPT_OS_NONE
+#define CFG_TUSB_OS               OPT_OS_NONE
 #endif
 
 #ifndef CFG_TUSB_DEBUG
-#define CFG_TUSB_DEBUG              0
+#define CFG_TUSB_DEBUG            0
 #endif
 
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG           0
+// Enable Device stack
+#define CFG_TUD_ENABLED           1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED         BOARD_TUD_MAX_SPEED
 
 /* 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
@@ -68,7 +79,7 @@ extern "C" {
 #endif
 
 #ifndef CFG_TUSB_MEM_ALIGN
-#define CFG_TUSB_MEM_ALIGN          __attribute__ ((aligned(4)))
+#define CFG_TUSB_MEM_ALIGN        __attribute__ ((aligned(4)))
 #endif
 
 //--------------------------------------------------------------------
@@ -80,11 +91,11 @@ extern "C" {
 #endif
 
 //------------- CLASS -------------//
+#define CFG_TUD_AUDIO             1
 #define CFG_TUD_CDC               0
 #define CFG_TUD_MSC               0
 #define CFG_TUD_HID               0
 #define CFG_TUD_MIDI              0
-#define CFG_TUD_AUDIO             1
 #define CFG_TUD_VENDOR            0
 
 //--------------------------------------------------------------------
@@ -93,23 +104,23 @@ extern "C" {
 
 // Have a look into audio_device.h for all configurations
 
-#define CFG_TUD_AUDIO_FUNC_1_DESC_LEN                                 TUD_AUDIO_MIC_FOUR_CH_DESC_LEN
+#define CFG_TUD_AUDIO_FUNC_1_DESC_LEN                 TUD_AUDIO_MIC_FOUR_CH_DESC_LEN
 
-#define CFG_TUD_AUDIO_FUNC_1_N_AS_INT                                 1
-#define CFG_TUD_AUDIO_FUNC_1_CTRL_BUF_SZ                              64
+#define CFG_TUD_AUDIO_FUNC_1_N_AS_INT                 1
+#define CFG_TUD_AUDIO_FUNC_1_CTRL_BUF_SZ              64
 
-#define CFG_TUD_AUDIO_ENABLE_EP_IN                                    1
-#define CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX                    2         // This value is not required by the driver, it parses this information from the descriptor once the alternate interface is set by the host - we use it for the setup
-#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX                            4         // This value is not required by the driver, it parses this information from the descriptor once the alternate interface is set by the host - we use it for the setup
-#define CFG_TUD_AUDIO_EP_SZ_IN                                        (48 + 1) * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX      // 48 Samples (48 kHz) x 2 Bytes/Sample x CFG_TUD_AUDIO_N_CHANNELS_TX Channels - the Windows driver always needs an extra sample per channel of space more, otherwise it complains... found by trial and error
-#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX                             CFG_TUD_AUDIO_EP_SZ_IN
-#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ                          CFG_TUD_AUDIO_EP_SZ_IN
+#define CFG_TUD_AUDIO_ENABLE_EP_IN                    1
+#define CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX    2         // This value is not required by the driver, it parses this information from the descriptor once the alternate interface is set by the host - we use it for the setup
+#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX            4         // This value is not required by the driver, it parses this information from the descriptor once the alternate interface is set by the host - we use it for the setup
+#define CFG_TUD_AUDIO_EP_SZ_IN                        (48 + 1) * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX      // 48 Samples (48 kHz) x 2 Bytes/Sample x CFG_TUD_AUDIO_N_CHANNELS_TX Channels - the Windows driver always needs an extra sample per channel of space more, otherwise it complains... found by trial and error
+#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX             CFG_TUD_AUDIO_EP_SZ_IN
+#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ          CFG_TUD_AUDIO_EP_SZ_IN
 
-#define CFG_TUD_AUDIO_ENABLE_ENCODING                                 1
-#define CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING                          1
-#define CFG_TUD_AUDIO_FUNC_1_CHANNEL_PER_FIFO_TX                      2         // One I2S stream contains two channels, each stream is saved within one support FIFO - this value is currently fixed, the driver does not support a changing value
-#define CFG_TUD_AUDIO_FUNC_1_N_TX_SUPP_SW_FIFO                        (CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX / CFG_TUD_AUDIO_FUNC_1_CHANNEL_PER_FIFO_TX)
-#define CFG_TUD_AUDIO_FUNC_1_TX_SUPP_SW_FIFO_SZ                       (CFG_TUD_AUDIO_EP_SZ_IN / CFG_TUD_AUDIO_FUNC_1_N_TX_SUPP_SW_FIFO)
+#define CFG_TUD_AUDIO_ENABLE_ENCODING                 1
+#define CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING          1
+#define CFG_TUD_AUDIO_FUNC_1_CHANNEL_PER_FIFO_TX      2         // One I2S stream contains two channels, each stream is saved within one support FIFO - this value is currently fixed, the driver does not support a changing value
+#define CFG_TUD_AUDIO_FUNC_1_N_TX_SUPP_SW_FIFO        (CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX / CFG_TUD_AUDIO_FUNC_1_CHANNEL_PER_FIFO_TX)
+#define CFG_TUD_AUDIO_FUNC_1_TX_SUPP_SW_FIFO_SZ       (CFG_TUD_AUDIO_EP_SZ_IN / CFG_TUD_AUDIO_FUNC_1_N_TX_SUPP_SW_FIFO)
 
 #ifdef __cplusplus
 }

+ 2 - 2
examples/device/audio_4_channel_mic/src/usb_descriptors.c

@@ -149,7 +149,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     for(uint8_t i=0; i<chr_count; i++)
@@ -159,7 +159,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 0 - 0
examples/device/audio_test/.skip.MCU_SAMD11


+ 0 - 0
examples/device/audio_test/.skip.MCU_SAME5X


+ 0 - 0
examples/device/audio_test/.skip.MCU_SAMG


+ 3 - 0
examples/device/audio_test/skip.txt

@@ -0,0 +1,3 @@
+mcu:SAMD11
+mcu:SAME5X
+mcu:SAMG

+ 3 - 2
examples/device/audio_test/src/main.c

@@ -82,7 +82,8 @@ int main(void)
 {
   board_init();
 
-  tusb_init();
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   // Init values
   sampFreq = AUDIO_SAMPLE_RATE;
@@ -221,7 +222,7 @@ bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
         // Request uses format layout 2
         TU_VERIFY(p_request->wLength == sizeof(audio_control_cur_2_t));
 
-        volume[channelNum] = ((audio_control_cur_2_t*) pBuff)->bCur;
+        volume[channelNum] = (uint16_t) ((audio_control_cur_2_t*) pBuff)->bCur;
 
         TU_LOG2("    Set Volume: %d dB of channel: %u\r\n", volume[channelNum], channelNum);
       return true;

+ 21 - 7
examples/device/audio_test/src/tusb_config.h

@@ -30,6 +30,20 @@
 extern "C" {
 #endif
 
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
+
+// RHPort number used for device can be defined by board.mk, default to port 0
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      0
+#endif
+
+// RHPort max operational speed can defined by board.mk
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
+#endif
+
 //--------------------------------------------------------------------
 // COMMON CONFIGURATION
 //--------------------------------------------------------------------
@@ -39,12 +53,6 @@ extern "C" {
 #error CFG_TUSB_MCU must be defined
 #endif
 
-#if CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX
-#define CFG_TUSB_RHPORT0_MODE       (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
-#else
-#define CFG_TUSB_RHPORT0_MODE       OPT_MODE_DEVICE
-#endif
-
 #ifndef CFG_TUSB_OS
 #define CFG_TUSB_OS                 OPT_OS_NONE
 #endif
@@ -53,6 +61,12 @@ extern "C" {
 #define CFG_TUSB_DEBUG              0
 #endif
 
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
+
 // CFG_TUSB_DEBUG is defined by compiler in DEBUG build
 // #define CFG_TUSB_DEBUG           0
 
@@ -80,11 +94,11 @@ extern "C" {
 #endif
 
 //------------- CLASS -------------//
+#define CFG_TUD_AUDIO             1
 #define CFG_TUD_CDC               0
 #define CFG_TUD_MSC               0
 #define CFG_TUD_HID               0
 #define CFG_TUD_MIDI              0
-#define CFG_TUD_AUDIO             1
 #define CFG_TUD_VENDOR            0
 
 //--------------------------------------------------------------------

+ 2 - 2
examples/device/audio_test/src/usb_descriptors.c

@@ -149,7 +149,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     for(uint8_t i=0; i<chr_count; i++)
@@ -159,7 +159,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 16
examples/device/board_test/src/tusb_config.h

@@ -43,7 +43,9 @@
   #define CFG_TUSB_OS               OPT_OS_NONE
 #endif
 
-#define CFG_TUSB_RHPORT0_MODE       OPT_MODE_NONE
+// This example only test LED & GPIO, disable both device and host stack
+#define CFG_TUD_ENABLED   0
+#define CFG_TUH_ENABLED   0
 
 // CFG_TUSB_DEBUG is defined by compiler in DEBUG build
 // #define CFG_TUSB_DEBUG           0
@@ -63,21 +65,6 @@
 #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_CDC             0
-#define CFG_TUD_MSC             0
-#define CFG_TUD_HID             0
-#define CFG_TUD_MIDI            0
-#define CFG_TUD_VENDOR          0
-
 #ifdef __cplusplus
  }
 #endif

+ 6 - 3
examples/device/cdc_dual_ports/src/main.c

@@ -39,7 +39,8 @@ int main(void)
 {
   board_init();
 
-  tusb_init();
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   while (1)
   {
@@ -54,17 +55,19 @@ int main(void)
 // with Serial0 as all lower case, Serial1 as all upper case
 static void echo_serial_port(uint8_t itf, uint8_t buf[], uint32_t count)
 {
+  uint8_t const case_diff = 'a' - 'A';
+
   for(uint32_t i=0; i<count; i++)
   {
     if (itf == 0)
     {
       // echo back 1st port as lower case
-      if (isupper(buf[i])) buf[i] += 'a' - 'A';
+      if (isupper(buf[i])) buf[i] += case_diff;
     }
     else
     {
       // echo back 2nd port as upper case
-      if (islower(buf[i])) buf[i] -= 'a' - 'A';
+      if (islower(buf[i])) buf[i] -= case_diff;
     }
 
     tud_cdc_n_write_char(itf, buf[i]);

+ 23 - 27
examples/device/cdc_dual_ports/src/tusb_config.h

@@ -30,46 +30,42 @@
  extern "C" {
 #endif
 
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
+
+// RHPort number used for device can be defined by board.mk, default to port 0
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      0
+#endif
+
+// RHPort max operational speed can defined by board.mk
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
+#endif
+
 //--------------------------------------------------------------------
 // COMMON CONFIGURATION
 //--------------------------------------------------------------------
 
 // defined by board.mk
 #ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
+#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 || CFG_TUSB_MCU == OPT_MCU_SAMX7X)
-    #define BOARD_DEVICE_RHPORT_SPEED   OPT_MODE_HIGH_SPEED
-  #else
-    #define BOARD_DEVICE_RHPORT_SPEED   OPT_MODE_FULL_SPEED
-  #endif
+#ifndef CFG_TUSB_OS
+#define CFG_TUSB_OS           OPT_OS_NONE
 #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"
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG        0
 #endif
 
-#ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS                 OPT_OS_NONE
-#endif
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
 
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG           0
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
 
 /* 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

+ 2 - 2
examples/device/cdc_dual_ports/src/usb_descriptors.c

@@ -236,7 +236,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -247,7 +247,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 0 - 0
examples/device/cdc_msc/.skip.MCU_SAMD11


+ 1 - 0
examples/device/cdc_msc/skip.txt

@@ -0,0 +1 @@
+mcu:SAMD11

+ 3 - 1
examples/device/cdc_msc/src/main.c

@@ -54,7 +54,9 @@ void cdc_task(void);
 int main(void)
 {
   board_init();
-  tusb_init();
+
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   while (1)
   {

+ 1 - 5
examples/device/cdc_msc/src/msc_disk.c

@@ -142,6 +142,7 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun)
 
   // RAM disk is ready until ejected
   if (ejected) {
+    // Additional Sense 3A-00 is NOT_FOUND
     tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, 0x3a, 0x00);
     return false;
   }
@@ -242,11 +243,6 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
 
   switch (scsi_cmd[0])
   {
-    case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
-      // Host is about to read/write etc ... better not to disconnect disk
-      resplen = 0;
-    break;
-
     default:
       // Set Sense = Invalid Command Operation
       tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);

+ 25 - 30
examples/device/cdc_msc/src/tusb_config.h

@@ -30,47 +30,42 @@
  extern "C" {
 #endif
 
-//--------------------------------------------------------------------
-// COMMON CONFIGURATION
-//--------------------------------------------------------------------
-
-// defined by board.mk
-#ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
-#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
 
 // 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
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      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 TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX, OPT_MCU_MIMXRT10XX, OPT_MCU_NUC505) ||\
-      TU_CHECK_MCU(OPT_MCU_CXD56, OPT_MCU_SAMX7X, OPT_MCU_BCM2711)
-    #define BOARD_DEVICE_RHPORT_SPEED   OPT_MODE_HIGH_SPEED
-  #else
-    #define BOARD_DEVICE_RHPORT_SPEED   OPT_MODE_FULL_SPEED
-  #endif
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
 #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"
+//--------------------------------------------------------------------
+// Common Configuration
+//--------------------------------------------------------------------
+
+// defined by compiler flags for flexibility
+#ifndef CFG_TUSB_MCU
+#error CFG_TUSB_MCU must be defined
 #endif
 
-// This example doesn't use an RTOS
 #ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS               OPT_OS_NONE
+#define CFG_TUSB_OS           OPT_OS_NONE
 #endif
 
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG           0
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG        0
+#endif
+
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
 
 /* 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
@@ -84,7 +79,7 @@
 #endif
 
 #ifndef CFG_TUSB_MEM_ALIGN
-#define CFG_TUSB_MEM_ALIGN          __attribute__ ((aligned(4)))
+#define CFG_TUSB_MEM_ALIGN    __attribute__ ((aligned(4)))
 #endif
 
 //--------------------------------------------------------------------

+ 11 - 1
examples/device/cdc_msc/src/usb_descriptors.c

@@ -117,6 +117,16 @@ enum
   #define EPNUM_MSC_OUT     0x05
   #define EPNUM_MSC_IN      0x84
 
+#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
+  // FT9XX doesn't support a same endpoint number with different direction IN and OUT
+  //    e.g EP1 OUT & EP1 IN cannot exist together
+  #define EPNUM_CDC_NOTIF   0x81
+  #define EPNUM_CDC_OUT     0x02
+  #define EPNUM_CDC_IN      0x83
+
+  #define EPNUM_MSC_OUT     0x04
+  #define EPNUM_MSC_IN      0x85
+
 #else
   #define EPNUM_CDC_NOTIF   0x81
   #define EPNUM_CDC_OUT     0x02
@@ -272,7 +282,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 0 - 0
examples/device/cdc_msc_freertos/.skip.MCU_BCM2711


+ 0 - 0
examples/device/cdc_msc_freertos/.skip.MCU_CXD56


+ 0 - 0
examples/device/cdc_msc_freertos/.skip.MCU_GD32VF103


+ 0 - 0
examples/device/cdc_msc_freertos/.skip.MCU_MKL25ZXX


+ 0 - 0
examples/device/cdc_msc_freertos/.skip.MCU_MSP430x5xx


+ 0 - 0
examples/device/cdc_msc_freertos/.skip.MCU_RP2040


+ 0 - 0
examples/device/cdc_msc_freertos/.skip.MCU_SAMD11


+ 0 - 0
examples/device/cdc_msc_freertos/.skip.MCU_SAMX7X


+ 0 - 0
examples/device/cdc_msc_freertos/.skip.MCU_VALENTYUSB_EPTRI


+ 1 - 1
examples/device/cdc_msc_freertos/Makefile

@@ -30,7 +30,7 @@ SRC_C += \
 	$(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c))
 
 # Suppress FreeRTOS warnings
-CFLAGS += -Wno-error=cast-qual
+CFLAGS += -Wno-error=cast-qual -Wno-error=redundant-decls
 
 # FreeRTOS (lto + Os) linker issue
 LDFLAGS += -Wl,--undefined=vTaskSwitchContext

+ 11 - 0
examples/device/cdc_msc_freertos/skip.txt

@@ -0,0 +1,11 @@
+mcu:CXD56
+mcu:F1C100S
+mcu:GD32VF103
+mcu:MKL25ZXX
+mcu:MSP430x5xx
+mcu:RP2040
+mcu:SAMD11
+mcu:SAMX7X
+mcu:VALENTYUSB_EPTRI
+family:broadcom_32bit
+family:broadcom_64bit

+ 4 - 0
examples/device/cdc_msc_freertos/src/CMakeLists.txt

@@ -13,6 +13,10 @@ target_include_directories(${COMPONENT_TARGET} PUBLIC
   "${TOP}/src"
 )
 
+target_compile_definitions(${COMPONENT_TARGET} PUBLIC
+  ESP_PLATFORM
+)
+
 target_sources(${COMPONENT_TARGET} PUBLIC
   "${TOP}/src/tusb.c"
   "${TOP}/src/common/tusb_fifo.c"

+ 1 - 0
examples/device/cdc_msc_freertos/src/FreeRTOSConfig/FreeRTOSConfig.h

@@ -53,6 +53,7 @@
 #if CFG_TUSB_MCU == OPT_MCU_MM32F327X
   extern u32 SystemCoreClock;
 #else
+  // FIXME cause redundant-decls warnings
   extern uint32_t SystemCoreClock;
 #endif
 

+ 17 - 14
examples/device/cdc_msc_freertos/src/main.c

@@ -38,12 +38,17 @@
   #include "freertos/queue.h"
   #include "freertos/task.h"
   #include "freertos/timers.h"
+
+  #define USBD_STACK_SIZE     4096
 #else
   #include "FreeRTOS.h"
   #include "semphr.h"
   #include "queue.h"
   #include "task.h"
   #include "timers.h"
+
+  // Increase stack size when debug log is enabled
+  #define USBD_STACK_SIZE    (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1)
 #endif
 
 //--------------------------------------------------------------------+
@@ -65,14 +70,7 @@ enum  {
 StaticTimer_t blinky_tmdef;
 TimerHandle_t blinky_tm;
 
-// static task for usbd
-// Increase stack size when debug log is enabled
-#if CFG_TUSB_DEBUG
-  #define USBD_STACK_SIZE     (3*configMINIMAL_STACK_SIZE)
-#else
-  #define USBD_STACK_SIZE     (3*configMINIMAL_STACK_SIZE/2)
-#endif
-
+// static task
 StackType_t  usb_device_stack[USBD_STACK_SIZE];
 StaticTask_t usb_device_taskdef;
 
@@ -125,15 +123,19 @@ void usb_device_task(void* param)
 {
   (void) param;
 
+  // init device stack on configured roothub port
   // This should be called after scheduler/kernel is started.
   // Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
-  tusb_init();
+  tud_init(BOARD_TUD_RHPORT);
 
   // RTOS forever loop
   while (1)
   {
-    // tinyusb device task
+    // put this thread to waiting state until there is new events
     tud_task();
+
+    // following code only run if tud_task() process at least 1 event
+    tud_cdc_write_flush();
   }
 }
 
@@ -183,7 +185,7 @@ void cdc_task(void* params)
     // if ( tud_cdc_connected() )
     {
       // There are data available
-      if ( tud_cdc_available() )
+      while ( tud_cdc_available() )
       {
         uint8_t buf[64];
 
@@ -196,12 +198,13 @@ void cdc_task(void* params)
         // for throughput test e.g
         //    $ dd if=/dev/zero of=/dev/ttyACM0 count=10000
         tud_cdc_write(buf, count);
-        tud_cdc_write_flush();
       }
+
+      tud_cdc_write_flush();
     }
 
-    // For ESP32-S2 this delay is essential to allow idle how to run and reset wdt
-    vTaskDelay(pdMS_TO_TICKS(10));
+    // For ESP32-Sx this delay is essential to allow idle how to run and reset watchdog
+    vTaskDelay(1);
   }
 }
 

+ 0 - 5
examples/device/cdc_msc_freertos/src/msc_disk.c

@@ -221,11 +221,6 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
 
   switch (scsi_cmd[0])
   {
-    case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
-      // Host is about to read/write etc ... better not to disconnect disk
-      resplen = 0;
-    break;
-
     default:
       // Set Sense = Invalid Command Operation
       tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);

+ 25 - 30
examples/device/cdc_msc_freertos/src/tusb_config.h

@@ -30,53 +30,48 @@
  extern "C" {
 #endif
 
-//--------------------------------------------------------------------
-// COMMON CONFIGURATION
-//--------------------------------------------------------------------
-
-// defined by board.mk
-#ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
-#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
 
 // 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
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT     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
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
 #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"
+//--------------------------------------------------------------------
+// COMMON CONFIGURATION
+//--------------------------------------------------------------------
+
+// defined by board.mk
+#ifndef CFG_TUSB_MCU
+#error CFG_TUSB_MCU must be defined
 #endif
 
 // This examples use FreeRTOS
-#define CFG_TUSB_OS               OPT_OS_FREERTOS
+#define CFG_TUSB_OS           OPT_OS_FREERTOS
 
 // Espressif IDF requires "freertos/" prefix in include path
 #if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
-  #define CFG_TUSB_OS_INC_PATH    freertos/
+#define CFG_TUSB_OS_INC_PATH  freertos/
 #endif
 
 // can be defined by compiler in DEBUG build
 #ifndef CFG_TUSB_DEBUG
-  #define CFG_TUSB_DEBUG           0
+#define CFG_TUSB_DEBUG        0
 #endif
 
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
+
 /* 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.
@@ -89,7 +84,7 @@
 #endif
 
 #ifndef CFG_TUSB_MEM_ALIGN
-#define CFG_TUSB_MEM_ALIGN          __attribute__ ((aligned(4)))
+#define CFG_TUSB_MEM_ALIGN    __attribute__ ((aligned(4)))
 #endif
 
 //--------------------------------------------------------------------
@@ -97,7 +92,7 @@
 //--------------------------------------------------------------------
 
 #ifndef CFG_TUD_ENDPOINT0_SIZE
-#define CFG_TUD_ENDPOINT0_SIZE    64
+#define CFG_TUD_ENDPOINT0_SIZE   64
 #endif
 
 //------------- CLASS -------------//

+ 2 - 2
examples/device/cdc_msc_freertos/src/usb_descriptors.c

@@ -247,7 +247,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -258,7 +258,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 0 - 4
examples/device/dfu/.skip.MCU_TM4C123

@@ -1,4 +0,0 @@
-LINK _build/ek-tm4c123gxl/dfu.elf
-/home/runner/cache/toolchain/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: section .ARM.exidx.text._close LMA [0000000000002980,0000000000002987] overlaps section .data LMA [0000000000002980,0000000000002a03]
-collect2: error: ld returned 1 exit status
-make: *** [../../rules.mk:94: _build/ek-tm4c123gxl/dfu.elf] Error 1

+ 1 - 1
examples/device/dfu/CMakeLists.txt

@@ -25,4 +25,4 @@ target_include_directories(${PROJECT} PUBLIC
 
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
-family_configure_device_example(${PROJECT})
+family_configure_device_example(${PROJECT})

+ 2 - 0
examples/device/dfu/skip.txt

@@ -0,0 +1,2 @@
+mcu:TM4C123
+mcu:BCM2835

+ 2 - 1
examples/device/dfu/src/main.c

@@ -74,7 +74,8 @@ int main(void)
 {
   board_init();
 
-  tusb_init();
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   while (1)
   {

+ 27 - 31
examples/device/dfu/src/tusb_config.h

@@ -12,46 +12,42 @@
  extern "C" {
 #endif
 
-//--------------------------------------------------------------------
-// COMMON CONFIGURATION
-//--------------------------------------------------------------------
-
-// defined by board.mk
-#ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
-#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
 
 // 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
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      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
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
 #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"
+//--------------------------------------------------------------------
+// COMMON CONFIGURATION
+//--------------------------------------------------------------------
+
+// defined by compiler flags for flexibility
+#ifndef CFG_TUSB_MCU
+#error CFG_TUSB_MCU must be defined
 #endif
 
 #ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS               OPT_OS_NONE
+#define CFG_TUSB_OS           OPT_OS_NONE
 #endif
 
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG           0
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG        0
+#endif
+
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
 
 /* 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
@@ -65,7 +61,7 @@
 #endif
 
 #ifndef CFG_TUSB_MEM_ALIGN
-#define CFG_TUSB_MEM_ALIGN          __attribute__ ((aligned(4)))
+#define CFG_TUSB_MEM_ALIGN        __attribute__ ((aligned(4)))
 #endif
 
 //--------------------------------------------------------------------
@@ -77,10 +73,10 @@
 #endif
 
 //------------- CLASS -------------//
-#define CFG_TUD_DFU    1
+#define CFG_TUD_DFU               1
 
 // DFU buffer size, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR
-#define CFG_TUD_DFU_XFER_BUFSIZE    ( OPT_MODE_HIGH_SPEED ? 512 : 64 )
+#define CFG_TUD_DFU_XFER_BUFSIZE  (TUD_OPT_HIGH_SPEED ? 512 : 64)
 
 #ifdef __cplusplus
  }

+ 1 - 1
examples/device/dfu/src/usb_descriptors.c

@@ -152,7 +152,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) {
       chr_count = 31;
     }

+ 2 - 1
examples/device/dfu_runtime/src/main.c

@@ -69,7 +69,8 @@ int main(void)
 {
   board_init();
 
-  tusb_init();
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   while (1)
   {

+ 24 - 28
examples/device/dfu_runtime/src/tusb_config.h

@@ -12,46 +12,42 @@
  extern "C" {
 #endif
 
-//--------------------------------------------------------------------
-// COMMON CONFIGURATION
-//--------------------------------------------------------------------
-
-// defined by board.mk
-#ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
-#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
 
 // 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
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      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
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
 #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"
+//--------------------------------------------------------------------
+// COMMON CONFIGURATION
+//--------------------------------------------------------------------
+
+// defined by compiler flags for flexibility
+#ifndef CFG_TUSB_MCU
+#error CFG_TUSB_MCU must be defined
 #endif
 
 #ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS               OPT_OS_NONE
+#define CFG_TUSB_OS           OPT_OS_NONE
 #endif
 
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG           0
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG        0
+#endif
+
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
 
 /* 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

+ 2 - 2
examples/device/dfu_runtime/src/usb_descriptors.c

@@ -147,7 +147,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) {
       chr_count = 31;
     }
@@ -160,7 +160,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (uint16_t)((((uint16_t)TUSB_DESC_STRING) << 8 ) | (2u*chr_count + 2u));
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 0 - 0
examples/device/dynamic_configuration/.skip.MCU_SAMD11


+ 1 - 0
examples/device/dynamic_configuration/skip.txt

@@ -0,0 +1 @@
+mcu:SAMD11

+ 4 - 2
examples/device/dynamic_configuration/src/main.c

@@ -55,7 +55,9 @@ void midi_task(void);
 int main(void)
 {
   board_init();
-  tusb_init();
+
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   while (1)
   {
@@ -179,7 +181,7 @@ void midi_task(void)
   start_ms += 286;
 
   // Previous positions in the note sequence.
-  int previous = note_pos - 1;
+  int previous = (int) (note_pos - 1);
 
   // If we currently are at position 0, set the
   // previous position to the last note in the sequence.

+ 3 - 8
examples/device/dynamic_configuration/src/msc_disk.c

@@ -184,7 +184,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
   uint8_t const* addr = msc_disk[lba] + offset;
   memcpy(buffer, addr, bufsize);
 
-  return bufsize;
+  return (int32_t) bufsize;
 }
 
 // Callback invoked when received WRITE10 command.
@@ -203,7 +203,7 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
   (void) lba; (void) offset; (void) buffer;
 #endif
 
-  return bufsize;
+  return (int32_t) bufsize;
 }
 
 // Callback invoked when received an SCSI command not in built-in list below
@@ -221,11 +221,6 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
 
   switch (scsi_cmd[0])
   {
-    case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
-      // Host is about to read/write etc ... better not to disconnect disk
-      resplen = 0;
-    break;
-
     default:
       // Set Sense = Invalid Command Operation
       tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
@@ -242,7 +237,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
   {
     if(in_xfer)
     {
-      memcpy(buffer, response, resplen);
+      memcpy(buffer, response, (size_t) resplen);
     }else
     {
       // SCSI output

+ 25 - 29
examples/device/dynamic_configuration/src/tusb_config.h

@@ -30,46 +30,42 @@
  extern "C" {
 #endif
 
-//--------------------------------------------------------------------
-// COMMON CONFIGURATION
-//--------------------------------------------------------------------
-
-// defined by board.mk
-#ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
-#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
 
 // 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
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      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
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
 #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"
+//--------------------------------------------------------------------
+// COMMON CONFIGURATION
+//--------------------------------------------------------------------
+
+// defined by compiler flags for flexibility
+#ifndef CFG_TUSB_MCU
+#error CFG_TUSB_MCU must be defined
 #endif
 
 #ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS               OPT_OS_NONE
+#define CFG_TUSB_OS           OPT_OS_NONE
 #endif
 
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG           0
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG        0
+#endif
+
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
 
 /* 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
@@ -83,7 +79,7 @@
 #endif
 
 #ifndef CFG_TUSB_MEM_ALIGN
-#define CFG_TUSB_MEM_ALIGN          __attribute__ ((aligned(4)))
+#define CFG_TUSB_MEM_ALIGN        __attribute__ ((aligned(4)))
 #endif
 
 //--------------------------------------------------------------------

+ 3 - 3
examples/device/dynamic_configuration/src/usb_descriptors.c

@@ -163,7 +163,7 @@ uint8_t const desc_configuration_0[] =
   TUD_CONFIG_DESCRIPTOR(1, ITF_0_NUM_TOTAL, 0, CONFIG_0_TOTAL_LEN, 0x00, 100),
 
   // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
-  TUD_CDC_DESCRIPTOR(ITF_0_NUM_CDC, 0, EPNUM_0_CDC_NOTIF, 8, EPNUM_0_CDC_OUT, EPNUM_0_CDC_IN, 64),
+  TUD_CDC_DESCRIPTOR(ITF_0_NUM_CDC, 0, EPNUM_0_CDC_NOTIF, 8, EPNUM_0_CDC_OUT, EPNUM_0_CDC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64),
 
   // Interface number, string index, EP Out & EP In address, EP size
   TUD_MIDI_DESCRIPTOR(ITF_0_NUM_MIDI, 0, EPNUM_0_MIDI_OUT, EPNUM_0_MIDI_IN, TUD_OPT_HIGH_SPEED ? 512 : 64),
@@ -226,7 +226,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -237,7 +237,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 4 - 2
examples/device/hid_boot_interface/src/main.c

@@ -55,7 +55,9 @@ void hid_task(void);
 int main(void)
 {
   board_init();
-  tusb_init();
+
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   while (1)
   {
@@ -179,7 +181,7 @@ void tud_hid_set_protocol_cb(uint8_t instance, uint8_t protocol)
 // Invoked when sent REPORT successfully to host
 // Application can use this to send the next report
 // Note: For composite reports, report[0] is report ID
-void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len)
+void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, /*uint16_t*/ uint8_t len)
 {
   (void) instance;
   (void) report;

+ 25 - 29
examples/device/hid_boot_interface/src/tusb_config.h

@@ -30,46 +30,42 @@
  extern "C" {
 #endif
 
-//--------------------------------------------------------------------
-// COMMON CONFIGURATION
-//--------------------------------------------------------------------
-
-// defined by board.mk
-#ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
-#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
 
 // 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
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      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 || CFG_TUSB_MCU == OPT_MCU_SAMX7X)
-    #define BOARD_DEVICE_RHPORT_SPEED   OPT_MODE_HIGH_SPEED
-  #else
-    #define BOARD_DEVICE_RHPORT_SPEED   OPT_MODE_FULL_SPEED
-  #endif
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
 #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"
+//--------------------------------------------------------------------
+// COMMON CONFIGURATION
+//--------------------------------------------------------------------
+
+// defined by compiler flags for flexibility
+#ifndef CFG_TUSB_MCU
+#error CFG_TUSB_MCU must be defined
 #endif
 
 #ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS               OPT_OS_NONE
+#define CFG_TUSB_OS           OPT_OS_NONE
 #endif
 
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG           0
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG        0
+#endif
+
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
 
 /* 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
@@ -83,7 +79,7 @@
 #endif
 
 #ifndef CFG_TUSB_MEM_ALIGN
-#define CFG_TUSB_MEM_ALIGN          __attribute__ ((aligned(4)))
+#define CFG_TUSB_MEM_ALIGN        __attribute__ ((aligned(4)))
 #endif
 
 //--------------------------------------------------------------------

+ 2 - 2
examples/device/hid_boot_interface/src/usb_descriptors.c

@@ -163,7 +163,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -174,7 +174,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 5 - 3
examples/device/hid_composite/src/main.c

@@ -56,7 +56,9 @@ void hid_task(void);
 int main(void)
 {
   board_init();
-  tusb_init();
+
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   while (1)
   {
@@ -223,12 +225,12 @@ void hid_task(void)
 // Invoked when sent REPORT successfully to host
 // Application can use this to send the next report
 // Note: For composite reports, report[0] is report ID
-void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len)
+void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, /*uint16_t*/ uint8_t len)
 {
   (void) instance;
   (void) len;
 
-  uint8_t next_report_id = report[0] + 1;
+  uint8_t next_report_id = report[0] + 1u;
 
   if (next_report_id < REPORT_ID_COUNT)
   {

+ 24 - 28
examples/device/hid_composite/src/tusb_config.h

@@ -30,46 +30,42 @@
  extern "C" {
 #endif
 
-//--------------------------------------------------------------------
-// COMMON CONFIGURATION
-//--------------------------------------------------------------------
-
-// defined by board.mk
-#ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
-#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
 
 // 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
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      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 TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX, OPT_MCU_MIMXRT10XX, OPT_MCU_NUC505) ||\
-      TU_CHECK_MCU(OPT_MCU_CXD56, OPT_MCU_SAMX7X, OPT_MCU_BCM2711)
-    #define BOARD_DEVICE_RHPORT_SPEED   OPT_MODE_HIGH_SPEED
-  #else
-    #define BOARD_DEVICE_RHPORT_SPEED   OPT_MODE_FULL_SPEED
-  #endif
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
 #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"
+//--------------------------------------------------------------------
+// COMMON CONFIGURATION
+//--------------------------------------------------------------------
+
+// defined by compiler flags for flexibility
+#ifndef CFG_TUSB_MCU
+#error CFG_TUSB_MCU must be defined
 #endif
 
 #ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS               OPT_OS_NONE
+#define CFG_TUSB_OS           OPT_OS_NONE
 #endif
 
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG           0
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG        0
+#endif
+
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
 
 /* 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

+ 2 - 2
examples/device/hid_composite/src/usb_descriptors.c

@@ -210,7 +210,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -221,7 +221,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 0 - 0
examples/device/hid_composite_freertos/.skip.MCU_BCM2711


+ 0 - 0
examples/device/hid_composite_freertos/.skip.MCU_CXD56


+ 0 - 0
examples/device/hid_composite_freertos/.skip.MCU_GD32VF103


+ 0 - 0
examples/device/hid_composite_freertos/.skip.MCU_MSP430x5xx


+ 0 - 0
examples/device/hid_composite_freertos/.skip.MCU_RP2040


+ 0 - 0
examples/device/hid_composite_freertos/.skip.MCU_SAMD11


+ 0 - 0
examples/device/hid_composite_freertos/.skip.MCU_SAMX7X


+ 0 - 0
examples/device/hid_composite_freertos/.skip.MCU_VALENTYUSB_EPTRI


+ 1 - 1
examples/device/hid_composite_freertos/Makefile

@@ -29,7 +29,7 @@ SRC_C += \
 	$(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c))
 
 # Suppress FreeRTOS warnings
-CFLAGS += -Wno-error=cast-qual
+CFLAGS += -Wno-error=cast-qual -Wno-error=redundant-decls
 
 # FreeRTOS (lto + Os) linker issue
 LDFLAGS += -Wl,--undefined=vTaskSwitchContext

+ 11 - 0
examples/device/hid_composite_freertos/skip.txt

@@ -0,0 +1,11 @@
+mcu:CXD56
+mcu:F1C100S
+mcu:GD32VF103
+mcu:MKL25ZXX
+mcu:MSP430x5xx
+mcu:RP2040
+mcu:SAMD11
+mcu:SAMX7X
+mcu:VALENTYUSB_EPTRI
+family:broadcom_32bit
+family:broadcom_64bit

+ 5 - 1
examples/device/hid_composite_freertos/src/CMakeLists.txt

@@ -13,6 +13,10 @@ target_include_directories(${COMPONENT_TARGET} PUBLIC
   "${TOP}/src"
 )
 
+target_compile_definitions(${COMPONENT_TARGET} PUBLIC
+  ESP_PLATFORM
+)
+
 target_sources(${COMPONENT_TARGET} PUBLIC
   "${TOP}/src/tusb.c"
   "${TOP}/src/common/tusb_fifo.c"
@@ -27,5 +31,5 @@ target_sources(${COMPONENT_TARGET} PUBLIC
   "${TOP}/src/class/net/ncm_device.c"
   "${TOP}/src/class/usbtmc/usbtmc_device.c"
   "${TOP}/src/class/vendor/vendor_device.c"
-  "${TOP}/src/portable/espressif/esp32sx/dcd_esp32sx.c"
+  "${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c"
 )

+ 13 - 10
examples/device/hid_composite_freertos/src/main.c

@@ -39,12 +39,18 @@
   #include "freertos/queue.h"
   #include "freertos/task.h"
   #include "freertos/timers.h"
+
+  #define USBD_STACK_SIZE     4096
+
 #else
   #include "FreeRTOS.h"
   #include "semphr.h"
   #include "queue.h"
   #include "task.h"
   #include "timers.h"
+
+  // Increase stack size when debug log is enabled
+  #define USBD_STACK_SIZE    (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1)
 #endif
 
 //--------------------------------------------------------------------+
@@ -66,13 +72,7 @@ enum  {
 StaticTimer_t blinky_tmdef;
 TimerHandle_t blinky_tm;
 
-// static task for usbd
-#if CFG_TUSB_DEBUG
-  #define USBD_STACK_SIZE     (3*configMINIMAL_STACK_SIZE)
-#else
-  #define USBD_STACK_SIZE     (3*configMINIMAL_STACK_SIZE/2)
-#endif
-
+// static task
 StackType_t  usb_device_stack[USBD_STACK_SIZE];
 StaticTask_t usb_device_taskdef;
 
@@ -125,15 +125,18 @@ void usb_device_task(void* param)
 {
   (void) param;
 
+  // init device stack on configured roothub port
   // This should be called after scheduler/kernel is started.
   // Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
-  tusb_init();
+  tud_init(BOARD_TUD_RHPORT);
 
   // RTOS forever loop
   while (1)
   {
-    // tinyusb device task
+    // put this thread to waiting state until there is new events
     tud_task();
+
+    // following code only run if tud_task() process at least 1 event
   }
 }
 
@@ -291,7 +294,7 @@ void hid_task(void* param)
 // Invoked when sent REPORT successfully to host
 // Application can use this to send the next report
 // Note: For composite reports, report[0] is report ID
-void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len)
+void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, /*uint16_t*/ uint8_t len)
 {
   (void) instance;
   (void) len;

+ 24 - 29
examples/device/hid_composite_freertos/src/tusb_config.h

@@ -30,53 +30,48 @@
  extern "C" {
 #endif
 
-//--------------------------------------------------------------------
-// COMMON CONFIGURATION
-//--------------------------------------------------------------------
-
-// defined by board.mk
-#ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
-#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
 
 // 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
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT     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
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
 #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"
+//--------------------------------------------------------------------
+// COMMON CONFIGURATION
+//--------------------------------------------------------------------
+
+// defined by board.mk
+#ifndef CFG_TUSB_MCU
+#error CFG_TUSB_MCU must be defined
 #endif
 
 // This examples use FreeRTOS
-#define CFG_TUSB_OS               OPT_OS_FREERTOS
+#define CFG_TUSB_OS           OPT_OS_FREERTOS
 
 // Espressif IDF requires "freertos/" prefix in include path
 #if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
-  #define CFG_TUSB_OS_INC_PATH    freertos/
+#define CFG_TUSB_OS_INC_PATH  freertos/
 #endif
 
-
+// can be defined by compiler in DEBUG build
 #ifndef CFG_TUSB_DEBUG
-#define CFG_TUSB_DEBUG           0
+#define CFG_TUSB_DEBUG        0
 #endif
 
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
+
 /* 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.

+ 2 - 2
examples/device/hid_composite_freertos/src/usb_descriptors.c

@@ -208,7 +208,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -219,7 +219,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 17 - 15
examples/device/hid_generic_inout/hid_test.py

@@ -1,20 +1,22 @@
 # Install python3 HID package https://pypi.org/project/hid/
 import hid
 
-USB_VID = 0xcafe
+# default is TinyUSB (0xcafe), Adafruit (0x239a), RaspberryPi (0x2e8a), Espressif (0x303a) VID
+USB_VID = (0xcafe, 0x239a, 0x2e8a, 0x303a)
 
-print("Openning HID device with VID = 0x%X" % USB_VID)
+print("VID list: " + ", ".join('%02x' % v for v in USB_VID))
 
-for dict in hid.enumerate(USB_VID):
-    print(dict)
-    dev = hid.Device(dict['vendor_id'], dict['product_id'])
-    if dev:
-        while True:
-            # Get input from console and encode to UTF8 for array of chars.
-            # hid generic inout is single report therefore by HIDAPI requirement
-            # it must be preceeded with 0x00 as dummy reportID
-            str_out = b'\x00'
-            str_out += input("Send text to HID Device : ").encode('utf-8')
-            dev.write(str_out)
-            str_in = dev.read(64)
-            print("Received from HID Device:", str_in, '\n')
+for vid in  USB_VID:
+    for dict in hid.enumerate(vid):
+        print(dict)
+        dev = hid.Device(dict['vendor_id'], dict['product_id'])
+        if dev:
+            while True:
+                # Get input from console and encode to UTF8 for array of chars.
+                # hid generic inout is single report therefore by HIDAPI requirement
+                # it must be preceeded with 0x00 as dummy reportID
+                str_out = b'\x00'
+                str_out += input("Send text to HID Device : ").encode('utf-8')
+                dev.write(str_out)
+                str_in = dev.read(64)
+                print("Received from HID Device:", str_in, '\n')

+ 2 - 1
examples/device/hid_generic_inout/src/main.c

@@ -80,7 +80,8 @@ int main(void)
 {
   board_init();
 
-  tusb_init();
+  // init device stack on configured roothub port
+  tud_init(BOARD_TUD_RHPORT);
 
   while (1)
   {

+ 25 - 29
examples/device/hid_generic_inout/src/tusb_config.h

@@ -30,46 +30,42 @@
  extern "C" {
 #endif
 
-//--------------------------------------------------------------------
-// COMMON CONFIGURATION
-//--------------------------------------------------------------------
-
-// defined by board.mk
-#ifndef CFG_TUSB_MCU
-  #error CFG_TUSB_MCU must be defined
-#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
 
 // 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
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT      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
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED   OPT_MODE_DEFAULT_SPEED
 #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"
+//--------------------------------------------------------------------
+// COMMON CONFIGURATION
+//--------------------------------------------------------------------
+
+// defined by compiler flags for flexibility
+#ifndef CFG_TUSB_MCU
+#error CFG_TUSB_MCU must be defined
 #endif
 
 #ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS               OPT_OS_NONE
+#define CFG_TUSB_OS           OPT_OS_NONE
 #endif
 
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG           0
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG        0
+#endif
+
+// Enable Device stack
+#define CFG_TUD_ENABLED       1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED     BOARD_TUD_MAX_SPEED
 
 /* 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
@@ -83,7 +79,7 @@
 #endif
 
 #ifndef CFG_TUSB_MEM_ALIGN
-#define CFG_TUSB_MEM_ALIGN          __attribute__ ((aligned(4)))
+#define CFG_TUSB_MEM_ALIGN        __attribute__ ((aligned(4)))
 #endif
 
 //--------------------------------------------------------------------

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů