Merge branch 'master' into port-ft90x

This commit is contained in:
Gordon McNab
2021-12-08 08:36:43 +00:00
318 changed files with 31702 additions and 3551 deletions
+5 -2
View File
@@ -33,8 +33,10 @@ body:
attributes: attributes:
label: Firmware label: Firmware
placeholder: | placeholder: |
e.g examples/device/cdc_msc. e.g examples/device/cdc_msc. If it is custom firmware, it is preferably compiled like one in example folder and reviewable for people to comment on. The easiest way is
If it is custom firmware, please provide links to your minimal sources or as attached files. - Fork this repo, checkout a new branch
- Add your-own-example based on stock one
- Push and post it here.
validations: validations:
required: true required: true
@@ -49,6 +51,7 @@ body:
attributes: attributes:
label: How to reproduce ? label: How to reproduce ?
placeholder: | placeholder: |
Exact steps in chronological order, details should be specific e.g if you use a command/script to test with, please post it as well.
1. Go to '...' 1. Go to '...'
2. Click on '....' 2. Click on '....'
3. See error 3. See error
+67
View File
@@ -0,0 +1,67 @@
name: Build AArch64
on:
pull_request:
push:
release:
types:
- created
jobs:
# ---------------------------------------
# Build AARCH64 family
# ---------------------------------------
build-arm:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
family:
# Alphabetical order
- 'raspberrypi4'
steps:
- name: Setup Python
uses: actions/setup-python@v2
- name: Checkout TinyUSB
uses: actions/checkout@v2
- 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
with:
repository: hathach/linkermap
path: linkermap
- name: Set Toolchain URL
run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
- name: Cache Toolchain
uses: actions/cache@v2
id: cache-toolchain
with:
path: ~/cache/
key: ${{ runner.os }}-21-11-02-${{ 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: 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::"'; \
done
@@ -44,6 +44,8 @@ jobs:
- 'lpc18' - 'lpc18'
- 'lpc54' - 'lpc54'
- 'lpc55' - 'lpc55'
- 'mm32'
- 'msp432e4'
- 'nrf' - 'nrf'
- 'rp2040' - 'rp2040'
- 'samd11' - 'samd11'
@@ -55,6 +57,9 @@ jobs:
- 'stm32f4' - 'stm32f4'
- 'stm32f7' - 'stm32f7'
- 'stm32h7' - 'stm32h7'
- 'stm32l4'
- 'tm4c123'
- 'xmc4000'
steps: steps:
- name: Setup Python - name: Setup Python
uses: actions/setup-python@v2 uses: actions/setup-python@v2
@@ -65,6 +70,12 @@ jobs:
- name: Checkout common submodules in lib - name: Checkout common submodules in lib
run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel
- name: Checkout hathach/linkermap
uses: actions/checkout@v2
with:
repository: hathach/linkermap
path: linkermap
- name: Checkout pico-sdk - name: Checkout pico-sdk
if: matrix.family == 'rp2040' if: matrix.family == 'rp2040'
run: | run: |
@@ -94,6 +105,14 @@ jobs:
- name: Build - name: Build
run: python3 tools/build_family.py ${{ matrix.family }} 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::"'; \
done
# --------------------------------------- # ---------------------------------------
# Build all no-family (opharned) boards # Build all no-family (opharned) boards
# --------------------------------------- # ---------------------------------------
+15 -1
View File
@@ -18,8 +18,8 @@ jobs:
# ESP32-S2 # ESP32-S2
- 'espressif_saola_1' - 'espressif_saola_1'
# ESP32-S3 # ESP32-S3
# latest IDF does not define USB0 in linker
#- 'espressif_addax_1' #- 'espressif_addax_1'
# S3 compile error with "dangerous relocation: call8: call target out of range: memcpy"
steps: steps:
- name: Setup Python - name: Setup Python
@@ -31,5 +31,19 @@ jobs:
- name: Checkout TinyUSB - name: Checkout TinyUSB
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Checkout hathach/linkermap
uses: actions/checkout@v2
with:
repository: hathach/linkermap
path: linkermap
- name: Build - name: Build
run: docker run --rm -v $PWD:/project -w /project espressif/idf:latest python3 tools/build_esp32sx.py ${{ matrix.board }} run: docker run --rm -v $PWD:/project -w /project espressif/idf:latest python3 tools/build_esp32sx.py ${{ matrix.board }}
- 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::"'; \
done
+14
View File
@@ -26,6 +26,12 @@ jobs:
- name: Checkout common submodules in lib - name: Checkout common submodules in lib
run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
- name: Checkout hathach/linkermap
uses: actions/checkout@v2
with:
repository: hathach/linkermap
path: linkermap
- name: Set Toolchain URL - name: Set Toolchain URL
run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2 run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2
@@ -48,3 +54,11 @@ jobs:
- name: Build - name: Build
run: python3 tools/build_family.py ${{ matrix.family }} 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::"'; \
done
+14
View File
@@ -26,6 +26,12 @@ jobs:
- name: Checkout common submodules in lib - name: Checkout common submodules in lib
run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
- name: Checkout hathach/linkermap
uses: actions/checkout@v2
with:
repository: hathach/linkermap
path: linkermap
- name: Set Toolchain URL - name: Set Toolchain URL
run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run
@@ -49,3 +55,11 @@ jobs:
- name: Build - name: Build
run: python3 tools/build_family.py ${{ matrix.family }} 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::"'; \
done
+14
View File
@@ -27,6 +27,12 @@ jobs:
- name: Checkout common submodules in lib - name: Checkout common submodules in lib
run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
- name: Checkout hathach/linkermap
uses: actions/checkout@v2
with:
repository: hathach/linkermap
path: linkermap
- name: Set Toolchain URL - name: Set Toolchain URL
run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz
@@ -49,3 +55,11 @@ jobs:
- name: Build - name: Build
run: python3 tools/build_family.py ${{ matrix.family }} 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::"'; \
done
+10 -3
View File
@@ -121,12 +121,19 @@
[submodule "hw/mcu/nxp/nxp_sdk"] [submodule "hw/mcu/nxp/nxp_sdk"]
path = hw/mcu/nxp/nxp_sdk path = hw/mcu/nxp/nxp_sdk
url = https://github.com/hathach/nxp_sdk.git url = https://github.com/hathach/nxp_sdk.git
[submodule "hw/mcu/mindmotion/mm32sdk"]
path = hw/mcu/mindmotion/mm32sdk
url = https://github.com/zhangslice/mm32sdk.git
[submodule "hw/mcu/gd/nuclei-sdk"] [submodule "hw/mcu/gd/nuclei-sdk"]
path = hw/mcu/gd/nuclei-sdk path = hw/mcu/gd/nuclei-sdk
url = https://github.com/Nuclei-Software/nuclei-sdk.git url = https://github.com/Nuclei-Software/nuclei-sdk.git
[submodule "hw/mcu/bridgetek/ft9xx/ft90x-sdk"] [submodule "hw/mcu/bridgetek/ft9xx/ft90x-sdk"]
path = hw/mcu/bridgetek/ft9xx/ft90x-sdk path = hw/mcu/bridgetek/ft9xx/ft90x-sdk
url = https://github.com/BRTSG-FOSS/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
[submodule "hw/mcu/broadcom"]
path = hw/mcu/broadcom
url = https://github.com/adafruit/broadcom-peripherals.git
branch = main-build
[submodule "hw/mcu/infineon/mtb-xmclib-cat3"]
path = hw/mcu/infineon/mtb-xmclib-cat3
url = https://github.com/Infineon/mtb-xmclib-cat3.git
+17 -14
View File
@@ -31,6 +31,12 @@ Notable contributors
- Improve ESP32s2 DCD - Improve ESP32s2 DCD
`Jacob Berg Potter <https://github.com/j4cbo>`__
------------------------------------------------
- Add new class driver for network CDC-NCM
`Jan Dümpelmann <https://github.com/duempel>`__ `Jan Dümpelmann <https://github.com/duempel>`__
----------------------------------------------- -----------------------------------------------
@@ -76,7 +82,8 @@ Notable contributors
----------------------------------------------- -----------------------------------------------
- Add new DCD port for NXP Kinetis KL25 - Add new DCD port for NXP Kinetis KL25
- Add new DCD port for Renesas RX63n with GR-CITRUS board - Add new DCD port for Renesas RX family (RX600, RX700 ..) with GR-CITRUS, RX65n target board
- Add new class driver for USB Video Class (UVC 1.5)
`Nathan Conrad <https://github.com/pigrew>`__ `Nathan Conrad <https://github.com/pigrew>`__
@@ -93,9 +100,9 @@ Notable contributors
------------------------------------------------ ------------------------------------------------
- Add new DCD port for Nuvoton NUC 120, 121, 125, 126, 505 - Add new DCD port for Nuvoton NUC 120, 121, 125, 126, 505
- Add new class driver for USBNET RNDIS, CDC-ECM - Add new class driver for network RNDIS, CDC-ECM
- Add *net\_lwip\_webserver* example for demonstration of usbnet with - Enhance CDC-NCM network driver to compatible with RNDIS/ECM
lwip - Add *net\_lwip\_webserver* example for demonstration of usbnet with lwip
- Board support for NuTiny NUC120, NUC121s, NUC125s, NUC126V, NUC505 - Board support for NuTiny NUC120, NUC121s, NUC125s, NUC126V, NUC505
- Improve multiple cdc interfaces API & add cdc\_dual\_ports example - Improve multiple cdc interfaces API & add cdc\_dual\_ports example
@@ -103,7 +110,7 @@ Notable contributors
`Rafael Silva <https://github.com/perigoso>`__ `Rafael Silva <https://github.com/perigoso>`__
---------------------------------------------- ----------------------------------------------
- Add new DCD port for Silabs EFM32GG12 with SLTB009A board - Port DCD Synopsys to support Silabs EFM32GG12 with SLTB009A board
- Rewrite documentation in rst and setup for readthedocs - Rewrite documentation in rst and setup for readthedocs
@@ -118,10 +125,8 @@ Notable contributors
------------------------------------------------ ------------------------------------------------
- Add new class driver for USB Audio Class 2.0 (UAC2) - Add new class driver for USB Audio Class 2.0 (UAC2)
- Rework tu\_fifo with unmasked pointer, add DMA support, and constant - Rework tu\_fifo with unmasked pointer, add DMA support, and constant address support
address support - Add new DCD/USBD edpt\_xfer\_fifo() API for optimizing endpoint transfer
- Add new DCD/USBD edpt\_xfer\_fifo() API for optimizing endpoint
transfer
- Add and greatly improve Isochronous transfer - Add and greatly improve Isochronous transfer
- Add new audio examples: audio\_test and audio\_4\_channel\_mic - Add new audio examples: audio\_test and audio\_4\_channel\_mic
@@ -130,8 +135,7 @@ Notable contributors
------------------------------------------------ ------------------------------------------------
- Add new DCD port for SAMD21 and SAMD51 - Add new DCD port for SAMD21 and SAMD51
- Add new class driver for Musical Instrument Digital Interface - Add new class driver for Musical Instrument Digital Interface (MIDI)
(MIDI)
- Improve USBD control transfer, MSC, CDC class driver - Improve USBD control transfer, MSC, CDC class driver
- Board support for Metro M0 & M4 express - Board support for Metro M0 & M4 express
- Write the excellent porting.md documentation - Write the excellent porting.md documentation
@@ -173,12 +177,11 @@ Notable contributors
- Add new DCD port for Synopsys DesignWare for STM32 L4, F2, F4, - Add new DCD port for Synopsys DesignWare for STM32 L4, F2, F4,
F7, H7 etc ... F7, H7 etc ...
- Add new DCD port for TI MSP430 - Add new DCD port for TI MSP430
- Board support for STM32F407 Discovery, STM32H743 Nucleo, pyboard - Board support for STM32F407 Discovery, STM32H743 Nucleo, pyboard v1.1, msp\_exp430f5529lp etc ...
v1.1, msp\_exp430f5529lp etc ...
`Zixun Li <https://github.com/HiFiPhile>`__ `Zixun Li <https://github.com/HiFiPhile>`__
----------------------------------------------- -------------------------------------------
- Add new DCD port for Microchip SAMx7x - Add new DCD port for Microchip SAMx7x
- Add IAR compiler support - Add IAR compiler support
+12 -8
View File
@@ -32,23 +32,26 @@ Supported MCUs
The stack supports the following MCUs: The stack supports the following MCUs:
- **Broadcom:** BCM2837, BCM2711
- **Dialog:** DA1469x - **Dialog:** DA1469x
- **Espressif:** ESP32-S2, ESP32-S3 - **Espressif:** ESP32-S2, ESP32-S3
- **GigaDevice:** GD32VF103
- **Infineon:** XMC4500
- **MicroChip:** SAMD11, SAMD21, SAMD51, SAME5x, SAMG55, SAML21, SAML22, SAME7x - **MicroChip:** SAMD11, SAMD21, SAMD51, SAME5x, SAMG55, SAML21, SAML22, SAME7x
- **NordicSemi:** nRF52833, nRF52840 - **NordicSemi:** nRF52833, nRF52840, nRF5340
- **Nuvoton:** NUC120, NUC121/NUC125, NUC126, NUC505 - **Nuvoton:** NUC120, NUC121/NUC125, NUC126, NUC505
- **NXP:** - **NXP:**
- iMX RT Series: RT1011, RT1015, RT1021, RT1052, RT1062, RT1064 - iMX RT Series: RT1011, RT1015, RT1021, RT1052, RT1062, RT1064
- Kinetis: KL25, K32L2Bxx - Kinetis: KL25, K32L2
- LPC Series: 11u, 13, 15, 17, 18, 40, 43, 51u, 54, 55 - LPC Series: 11u, 13, 15, 17, 18, 40, 43, 51u, 54, 55
- **Raspberry Pi:** RP2040 - **Raspberry Pi:** RP2040
- **Renesas:** RX63N, RX65N - **Renesas:** RX63N, RX65N, RX72N
- **Silabs:** EFM32GG12 - **Silabs:** EFM32GG
- **Sony:** CXD56 - **Sony:** CXD56
- **ST:** STM32 series: L0, L1, F0, F1, F2, F3, F4, F7, H7 both FullSpeed and HighSpeed - **ST:** STM32 series: F0, F1, F2, F3, F4, F7, H7, L0, L1, L4, L4+
- **TI:** MSP430 - **TI:** MSP430, MSP432E4, TM4C123
- **ValentyUSB:** eptri - **ValentyUSB:** eptri
Here is the list of `Supported Devices`_ that can be used with provided examples. Here is the list of `Supported Devices`_ that can be used with provided examples.
@@ -65,8 +68,9 @@ Supports multiple device configurations by dynamically changing USB descriptors,
- Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ... - Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
- Mass Storage Class (MSC): with multiple LUNs - Mass Storage Class (MSC): with multiple LUNs
- Musical Instrument Digital Interface (MIDI) - Musical Instrument Digital Interface (MIDI)
- Network with RNDIS, CDC-ECM (work in progress) - Network with RNDIS, Ethernet Control Model (ECM), Network Control Model (NCM)
- USB Test and Measurement Class (USBTMC) - Test and Measurement Class (USBTMC)
- Video class 1.5 (UVC): work in progress
- 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. - 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 - `WebUSB <https://github.com/WICG/webusb>`__ with vendor-specific class
-1
View File
@@ -21,7 +21,6 @@ extensions = [
'sphinx.ext.intersphinx', 'sphinx.ext.intersphinx',
'sphinx.ext.todo', 'sphinx.ext.todo',
'sphinx_autodoc_typehints', 'sphinx_autodoc_typehints',
'sphinxemoji.sphinxemoji',
] ]
templates_path = ['_templates'] templates_path = ['_templates']
+32 -1
View File
@@ -2,6 +2,37 @@
Changelog Changelog
********* *********
0.12.0
======
- add CFG_TUSB_OS_INC_PATH for os include path
Device Controller Driver (DCD)
------------------------------
- Getting device stack to pass USB Compliance Verification test (chapter9, HID, MSC). Ports are tested:
nRF, SAMD 21/51, rp2040, stm32f4, Renesas RX, iMXRT, ESP32-S2/3, Kinetic KL25/32, DA146xx
- Added dcd_edpt_close_all() for switching configuration
- [Transdimension] Support dcd_edpt_xfer_fifo() with auto wrap over if fifo buffer is 4K aligned and size is multiple of 4K.
- [DA146xx] Improve vbus, reset, suspend, resume detection, and remote wakeup.
Device Stack
------------
- Add new network driver Network Control Model (CDC-NCM), update net_lwip_webserver to work with NCM (need re-configure example)
- Add new USB Video Class UVC 1.5 driver and video_capture example ((work in progress)
- Fix potential buffer overflow for HID, bluetooth drivers
Host Controller Driver (HCD)
----------------------------
No notable changes
Host Stack
----------
No notable changes
0.11.0 (2021-08-29) 0.11.0 (2021-08-29)
=================== ===================
@@ -26,7 +57,7 @@ Synopsys
^^^^^^^^ ^^^^^^^^
- Fix Synopsys set address bug which could cause re-enumeration failed - Fix Synopsys set address bug which could cause re-enumeration failed
- Fix for dcd_synopsys driver integer overflow in HS mode (issue #968) - Fix dcd_synopsys driver integer overflow in HS mode (issue #968)
nRF5x nRF5x
^^^^^ ^^^^^
+46 -1
View File
@@ -89,6 +89,15 @@ A MCU can support multiple operational speed. By default, the example build syst
$ make BOARD=stm32f746disco SPEED=full all $ make BOARD=stm32f746disco SPEED=full all
Size Analysis
~~~~~~~~~~~~~
First install `linkermap tool <https://github.com/hathach/linkermap>`_ then ``linkermap`` target can be used to analyze code size. You may want to compile with ``NO_LTO=1`` since -flto merges code across .o files and make it difficult to analyze.
.. code-block::
$ make BOARD=feather_nrf52840_express NO_LTO=1 all linkermap
Debug Debug
^^^^^ ^^^^^
@@ -113,7 +122,7 @@ Logger
By default log message is printed via on-board UART which is slow and take lots of CPU time comparing to USB speed. If your board support on-board/external debugger, it would be more efficient to use it for logging. There are 2 protocols: By default log message is printed via on-board UART which is slow and take lots of CPU time comparing to USB speed. If your board support on-board/external debugger, it would be more efficient to use it for logging. There are 2 protocols:
* `LOGGER=rtt`: use [Segger RTT protocol](https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/) * `LOGGER=rtt`: use `Segger RTT protocol <https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/>`_
* Cons: requires jlink as the debugger. * Cons: requires jlink as the debugger.
* Pros: work with most if not all MCUs * Pros: work with most if not all MCUs
@@ -151,3 +160,39 @@ Some board use uf2 bootloader for drag & drop in to mass storage device, uf2 can
.. code-block:: .. code-block::
$ make BOARD=feather_nrf52840_express all uf2 $ make BOARD=feather_nrf52840_express all uf2
IAR Support
^^^^^^^^^^^
IAR Project Connection files are provided to import TinyUSB stack into your project.
* A buldable project of your MCU need to be created in advance.
* Take example of STM32F0:
- You need `stm32l0xx.h`, `startup_stm32f0xx.s`, `system_stm32f0xx.c`.
- `STM32L0xx_HAL_Driver` is only needed to run examples, TinyUSB stack itself doesn't rely on MCU's SDKs.
* Open `Tools -> Configure Custom Argument Variables` (Switch to `Global` tab if you want to do it for all your projects)
Click `New Group ...`, name it to `TUSB`, Click `Add Variable ...`, name it to `TUSB_DIR`, change it's value to the path of your TinyUSB stack,
for example `C:\\tinyusb`
Import stack only
~~~~~~~~~~~~~~~~~
1. Open `Project -> Add project Connection ...`, click `OK`, choose `tinyusb\\tools\\iar_template.ipcf`.
Run examples
~~~~~~~~~~~~
1. (Python3 is needed) Run `iar_gen.py` to generate .ipcf files of examples:
.. code-block::
cd C:\tinyusb\tools
python iar_gen.py
2. Open `Project -> Add project Connection ...`, click `OK`, choose `tinyusb\\examples\\(.ipcf of example)`.
For example `C:\\tinyusb\\examples\\device\\cdc_msc\\iar_cdc_msc.ipcf`
+164 -119
View File
@@ -2,126 +2,114 @@
Supported Devices Supported Devices
***************** *****************
Supported MCUs Supported MCUs
============== ==============
.. admonition:: Warning +--------------+-----------------------+--------+------+-----------+-------------------+--------------+
:class: warning | 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 | |
| +---------+-------------+--------+------+-----------+-------------------+--------------+
| | 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 | |
+--------------+-----------------------+--------+------+-----------+-------------------+--------------+
| 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 | |
| +-----------------------+--------+------+-----------+-------------------+--------------+
| | L0, L1 | ✔ | ✖ | ✖ | stm32_fsdev | |
| +----+------------------+--------+------+-----------+-------------------+--------------+
| | L4 | 4x2, 4x3 | ✔ | ✖ | ✖ | stm32_fsdev | |
| | +------------------+--------+------+-----------+-------------------+--------------+
| | | 4x5, 4x6 | ✔ | | | dwc2 | |
| +----+------------------+--------+------+-----------+-------------------+--------------+
| | L4+ | ✔ | | | dwc2 | |
| +-----------------------+--------+------+-----------+-------------------+--------------+
| | U5 | ⚠ | | | dwc2 | |
+--------------+-----------------------+--------+------+-----------+-------------------+--------------+
| TI | MSP430 | ✔ | ✖ | ✖ | msp430x5xx | |
| +-----------------------+--------+------+-----------+-------------------+--------------+
| | MSP432E4 | ✔ | | ✖ | musb | |
| +-----------------------+--------+------+-----------+-------------------+--------------+
| | TM4C123 | ✔ | | ✖ | musb | |
+--------------+-----------------------+--------+------+-----------+-------------------+--------------+
| ValentyUSB | eptri | ✔ | ✖ | ✖ | eptri | |
+--------------+-----------------------+--------+------+-----------+-------------------+--------------+
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 | | | | | |
| +--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
| | RX65N | | | | | |
+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
| Silabs | EFM32GG12 | |:green_square:| | |:x:| | |:green_square:| | |:x:| | #750 |
+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
| 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:| | | |
+--------------+--------------------+-------------------+--------------------+-------------------+-------------------+--------------+
Table Legend Table Legend
------------ ------------
================= =================== = ===================
|:x:| Not available ✔ Supported
|:red_square:| Not supported ⚠ WIP/partial support
|:yellow_square:| WIP/partial support ✖ Not supported
|:green_square:| Supported = ===================
================= ===================
Supported Boards Supported Boards
================ ================
@@ -134,6 +122,11 @@ The board support code is only used for self-contained examples and testing. It
The following boards are supported (sorted alphabetically): The following boards are supported (sorted alphabetically):
Broadcom
--------
- `Raspberry Pi CM4 <https://www.raspberrypi.com/products/compute-module-4>`__
Dialog DA146xx Dialog DA146xx
-------------- --------------
@@ -143,12 +136,25 @@ Dialog DA146xx
Espressif ESP32-S2 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 Magtag 2.9" E-Ink WiFi Display <https://www.adafruit.com/product/4800>`__
- `Adafruit Metro ESP32-S2 <https://www.adafruit.com/product/4775>`__ - `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-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>`__ - `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
---------
XMC4000
^^^^^^^
- `XMC4500 Relax (Lite) Kit <https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc45_relax_lite_v1/>`__
MicroChip MicroChip
--------- ---------
@@ -175,6 +181,12 @@ SAMD51 & SAME54
- `D5035-01 <https://github.com/RudolphRiedel/USB_CAN-FD>`__ - `D5035-01 <https://github.com/RudolphRiedel/USB_CAN-FD>`__
- `Microchip SAME54 Xplained Pro <https://www.microchip.com/developmenttools/productdetails/atsame54-xpro>`__ - `Microchip SAME54 Xplained Pro <https://www.microchip.com/developmenttools/productdetails/atsame54-xpro>`__
SAME7x
^^^^^^
- `Microchip SAME70 Xplained <https://www.microchip.com/en-us/development-tool/ATSAME70-XPLD>`_
- `QMTECH ATSAME70N19 <https://www.aliexpress.com/item/1005003173783268.html>`_
SAMG SAMG
^^^^ ^^^^
@@ -229,7 +241,8 @@ iMX RT
Kinetis 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>`__
LPC 11-13-15 LPC 11-13-15
^^^^^^^^^^^^ ^^^^^^^^^^^^
@@ -299,28 +312,58 @@ Sony
ST STM32 ST STM32
-------- --------
- `Adafruit Feather STM32F405 <https://www.adafruit.com/product/4382>`__ F0
- `Micro Python PyBoard v1.1 <https://store.micropython.org/product/PYBv1.1>`__ ^^
- `STLink-V3 Mini <https://www.st.com/en/development-tools/stlink-v3mini.html>`__
- `STM32 L035c8 Discovery <https://www.st.com/en/evaluation-tools/32l0538discovery.html>`__
- `STM32 L4R5zi Nucleo <https://www.st.com/en/evaluation-tools/nucleo-l4r5zi.html>`__
- `STM32 F070rb Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f070rb.html>`__ - `STM32 F070rb Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f070rb.html>`__
- `STM32 F072 Evaluation <https://www.st.com/en/evaluation-tools/stm32072b-eval.html>`__ - `STM32 F072 Evaluation <https://www.st.com/en/evaluation-tools/stm32072b-eval.html>`__
- `STM32 F072rb Discovery <https://www.st.com/en/evaluation-tools/32f072bdiscovery.html>`__ - `STM32 F072rb Discovery <https://www.st.com/en/evaluation-tools/32f072bdiscovery.html>`__
F1
^^
- `STM32 F103c8 Blue Pill <https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill>`__ - `STM32 F103c8 Blue Pill <https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill>`__
- `STM32 F103rc Mini v2.0 <https://stm32-base.org/boards/STM32F103RCT6-STM32-Mini-V2.0>`__ - `STM32 F103rc Mini v2.0 <https://stm32-base.org/boards/STM32F103RCT6-STM32-Mini-V2.0>`__
F2
^^
- `STM32 F207zg Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f207zg.html>`__ - `STM32 F207zg Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f207zg.html>`__
F3
^^
- `STM32 F303vc Discovery <https://www.st.com/en/evaluation-tools/stm32f3discovery.html>`__ - `STM32 F303vc Discovery <https://www.st.com/en/evaluation-tools/stm32f3discovery.html>`__
F4
^^
- `Adafruit Feather STM32F405 <https://www.adafruit.com/product/4382>`__
- `Micro Python PyBoard v1.1 <https://store.micropython.org/product/PYBv1.1>`__
- `STM32 F401cc Black Pill <https://stm32-base.org/boards/STM32F401CCU6-WeAct-Black-Pill-V1.2>`__ - `STM32 F401cc Black Pill <https://stm32-base.org/boards/STM32F401CCU6-WeAct-Black-Pill-V1.2>`__
- `STM32 F407vg Discovery <https://www.st.com/en/evaluation-tools/stm32f4discovery.html>`__ - `STM32 F407vg Discovery <https://www.st.com/en/evaluation-tools/stm32f4discovery.html>`__
- `STM32 F411ce Black Pill <https://www.adafruit.com/product/4877>`__ - `STM32 F411ce Black Pill <https://www.adafruit.com/product/4877>`__
- `STM32 F411ve Discovery <https://www.st.com/en/evaluation-tools/32f411ediscovery.html>`__ - `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 Discovery <https://www.st.com/en/evaluation-tools/32f412gdiscovery.html>`__
- `STM32 F412zg Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f412zg.html>`__
F7
^^
- `STLink-V3 Mini <https://www.st.com/en/development-tools/stlink-v3mini.html>`__
- `STM32 F723e Discovery <https://www.st.com/en/evaluation-tools/32f723ediscovery.html>`__ - `STM32 F723e Discovery <https://www.st.com/en/evaluation-tools/32f723ediscovery.html>`__
- `STM32 F746zg Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f746zg.html>`__ - `STM32 F746zg Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f746zg.html>`__
- `STM32 F746g Discovery <https://www.st.com/en/evaluation-tools/32f746gdiscovery.html>`__ - `STM32 F746g Discovery <https://www.st.com/en/evaluation-tools/32f746gdiscovery.html>`__
- `STM32 F767zi Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f767zi.html>`__ - `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>`__ - `STM32 F769i Discovery <https://www.st.com/en/evaluation-tools/32f769idiscovery.html>`__
L0
^^
- `STM32 L035c8 Discovery <https://www.st.com/en/evaluation-tools/32l0538discovery.html>`__
L4
^^
- `STM32 L476vg Discovery <https://www.st.com/en/evaluation-tools/32l476gdiscovery.html>`__
- `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
^^
- `STM32 H743zi Nucleo <https://www.st.com/en/evaluation-tools/nucleo-h743zi.html>`__ - `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 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>`__ - `STM32 H745i Discovery <https://www.st.com/en/evaluation-tools/stm32h745i-disco.html>`__
@@ -330,6 +373,8 @@ TI
-- --
- `MSP430F5529 USB LaunchPad Evaluation Kit <http://www.ti.com/tool/MSP-EXP430F5529LP>`__ - `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 Tomu
---- ----
-1
View File
@@ -1,4 +1,3 @@
sphinx~=3.0 sphinx~=3.0
furo>=2020.12.30.b24 furo>=2020.12.30.b24
sphinxemoji>=0.1.8
sphinx-autodoc-typehints>=1.10 sphinx-autodoc-typehints>=1.10
+7
View File
@@ -12,3 +12,10 @@ ATTRS{idVendor}=="cafe", MODE="0666", GROUP="dialout"
# Rule to blacklist TinyUSB example from being manipulated by ModemManager. # Rule to blacklist TinyUSB example from being manipulated by ModemManager.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="cafe", ENV{ID_MM_DEVICE_IGNORE}="1" SUBSYSTEMS=="usb", ATTRS{idVendor}=="cafe", ENV{ID_MM_DEVICE_IGNORE}="1"
# Xplained Pro SamG55 Device
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE="0666", GROUP="users", ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEMS=="tty", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE="0666", GROUP="users", ENV{ID_MM_DEVICE_IGNORE}="1"
# TI Stellaris/Tiva-C Launchpad ICDI
SUBSYSTEM=="usb", ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00fd", MODE="0666"
+1
View File
@@ -24,4 +24,5 @@ family_add_subdirectory(msc_dual_lun)
family_add_subdirectory(net_lwip_webserver) family_add_subdirectory(net_lwip_webserver)
family_add_subdirectory(uac2_headset) family_add_subdirectory(uac2_headset)
family_add_subdirectory(usbtmc) family_add_subdirectory(usbtmc)
family_add_subdirectory(video_capture)
family_add_subdirectory(webusb_serial) family_add_subdirectory(webusb_serial)
@@ -141,7 +141,7 @@ void tud_resume_cb(void)
void audio_task(void) void audio_task(void)
{ {
// Yet to be filled - e.g. put meas data into TX FIFOs etc. // Yet to be filled - e.g. put meas data into TX FIFOs etc.
asm("nop"); // asm("nop");
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -81,10 +81,15 @@ enum
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + CFG_TUD_AUDIO * TUD_AUDIO_MIC_FOUR_CH_DESC_LEN) #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + CFG_TUD_AUDIO * TUD_AUDIO_MIC_FOUR_CH_DESC_LEN)
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX #if TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ... // 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ...
#define EPNUM_AUDIO 0x03 #define EPNUM_AUDIO 0x03
#elif TU_CHECK_MCU(OPT_MCU_NRF5X)
// nRF5x ISO can only be endpoint 8
#define EPNUM_AUDIO 0x08
#else #else
#define EPNUM_AUDIO 0x01 #define EPNUM_AUDIO 0x01
#endif #endif
@@ -92,7 +97,7 @@ enum
uint8_t const desc_configuration[] = uint8_t const desc_configuration[] =
{ {
// Interface count, string index, total length, attribute, power in mA // Interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_AUDIO_MIC_FOUR_CH_DESCRIPTOR(/*_itfnum*/ ITF_NUM_AUDIO_CONTROL, /*_stridx*/ 0, /*_nBytesPerSample*/ CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX, /*_nBitsUsedPerSample*/ CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX*8, /*_epin*/ 0x80 | EPNUM_AUDIO, /*_epsize*/ CFG_TUD_AUDIO_EP_SZ_IN) TUD_AUDIO_MIC_FOUR_CH_DESCRIPTOR(/*_itfnum*/ ITF_NUM_AUDIO_CONTROL, /*_stridx*/ 0, /*_nBytesPerSample*/ CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX, /*_nBitsUsedPerSample*/ CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX*8, /*_epin*/ 0x80 | EPNUM_AUDIO, /*_epsize*/ CFG_TUD_AUDIO_EP_SZ_IN)
+1 -1
View File
@@ -142,7 +142,7 @@ void tud_resume_cb(void)
void audio_task(void) void audio_task(void)
{ {
// Yet to be filled - e.g. put meas data into TX FIFOs etc. // Yet to be filled - e.g. put meas data into TX FIFOs etc.
asm("nop"); // asm("nop");
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -85,6 +85,11 @@ enum
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ... // 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ...
#define EPNUM_AUDIO 0x03 #define EPNUM_AUDIO 0x03
#elif TU_CHECK_MCU(OPT_MCU_NRF5X)
// nRF5x ISO can only be endpoint 8
#define EPNUM_AUDIO 0x08
#else #else
#define EPNUM_AUDIO 0x01 #define EPNUM_AUDIO 0x01
#endif #endif
@@ -92,7 +97,7 @@ enum
uint8_t const desc_configuration[] = uint8_t const desc_configuration[] =
{ {
// Interface count, string index, total length, attribute, power in mA // Interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_AUDIO_MIC_ONE_CH_DESCRIPTOR(/*_itfnum*/ ITF_NUM_AUDIO_CONTROL, /*_stridx*/ 0, /*_nBytesPerSample*/ CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX, /*_nBitsUsedPerSample*/ CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX*8, /*_epin*/ 0x80 | EPNUM_AUDIO, /*_epsize*/ CFG_TUD_AUDIO_EP_SZ_IN) TUD_AUDIO_MIC_ONE_CH_DESCRIPTOR(/*_itfnum*/ ITF_NUM_AUDIO_CONTROL, /*_stridx*/ 0, /*_nBytesPerSample*/ CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX, /*_nBitsUsedPerSample*/ CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX*8, /*_epin*/ 0x80 | EPNUM_AUDIO, /*_epsize*/ CFG_TUD_AUDIO_EP_SZ_IN)
+1
View File
@@ -47,6 +47,7 @@ enum {
int main(void) int main(void)
{ {
board_init(); board_init();
board_led_write(true);
uint32_t start_ms = 0; uint32_t start_ms = 0;
bool led_state = false; bool led_state = false;
@@ -35,6 +35,9 @@
#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ #define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) ) _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) )
#define USB_VID 0xCafe
#define USB_BCD 0x0200
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Device Descriptors // Device Descriptors
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -42,7 +45,7 @@ tusb_desc_device_t const desc_device =
{ {
.bLength = sizeof(tusb_desc_device_t), .bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE, .bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200, .bcdUSB = USB_BCD,
// Use Interface Association Descriptor (IAD) for CDC // Use Interface Association Descriptor (IAD) for CDC
// As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1) // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
@@ -51,7 +54,7 @@ tusb_desc_device_t const desc_device =
.bDeviceProtocol = MISC_PROTOCOL_IAD, .bDeviceProtocol = MISC_PROTOCOL_IAD,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe, .idVendor = USB_VID,
.idProduct = USB_PID, .idProduct = USB_PID,
.bcdDevice = 0x0100, .bcdDevice = 0x0100,
@@ -118,7 +121,7 @@ enum
uint8_t const desc_fs_configuration[] = uint8_t const desc_fs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size. // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_0, 4, EPNUM_CDC_0_NOTIF, 8, EPNUM_CDC_0_OUT, EPNUM_CDC_0_IN, 64), TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_0, 4, EPNUM_CDC_0_NOTIF, 8, EPNUM_CDC_0_OUT, EPNUM_CDC_0_IN, 64),
@@ -128,10 +131,12 @@ uint8_t const desc_fs_configuration[] =
}; };
#if TUD_OPT_HIGH_SPEED #if TUD_OPT_HIGH_SPEED
// Per USB specs: high speed capable device must report device_qualifier and other_speed_configuration
uint8_t const desc_hs_configuration[] = uint8_t const desc_hs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size. // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_0, 4, EPNUM_CDC_0_NOTIF, 8, EPNUM_CDC_0_OUT, EPNUM_CDC_0_IN, 512), TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_0, 4, EPNUM_CDC_0_NOTIF, 8, EPNUM_CDC_0_OUT, EPNUM_CDC_0_IN, 512),
@@ -139,7 +144,44 @@ uint8_t const desc_hs_configuration[] =
// 2nd CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size. // 2nd CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_1, 4, EPNUM_CDC_1_NOTIF, 8, EPNUM_CDC_1_OUT, EPNUM_CDC_1_IN, 512), TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_1, 4, EPNUM_CDC_1_NOTIF, 8, EPNUM_CDC_1_OUT, EPNUM_CDC_1_IN, 512),
}; };
#endif
// device qualifier is mostly similar to device descriptor since we don't change configuration based on speed
tusb_desc_device_qualifier_t const desc_device_qualifier =
{
.bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = USB_BCD,
.bDeviceClass = TUSB_CLASS_MISC,
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
.bDeviceProtocol = MISC_PROTOCOL_IAD,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.bNumConfigurations = 0x01,
.bReserved = 0x00
};
// Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
// device_qualifier descriptor describes information about a high-speed capable device that would
// change if the device were operating at the other speed. If not highspeed capable stall this request.
uint8_t const* tud_descriptor_device_qualifier_cb(void)
{
return (uint8_t const*) &desc_device_qualifier;
}
// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index)
{
(void) index; // for multiple configurations
// if link speed is high return fullspeed config, and vice versa
return (tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration;
}
#endif // highspeed
// Invoked when received GET CONFIGURATION DESCRIPTOR // Invoked when received GET CONFIGURATION DESCRIPTOR
// Application return pointer to descriptor // Application return pointer to descriptor
+22 -5
View File
@@ -188,10 +188,24 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
{ {
(void) lun; (void) lun;
// out of ramdisk
if ( lba >= DISK_BLOCK_NUM ) return -1;
uint8_t const* addr = msc_disk[lba] + offset; uint8_t const* addr = msc_disk[lba] + offset;
memcpy(buffer, addr, bufsize); memcpy(buffer, addr, bufsize);
return bufsize; return (int32_t) bufsize;
}
bool tud_msc_is_writable_cb (uint8_t lun)
{
(void) lun;
#ifdef CFG_EXAMPLE_MSC_READONLY
return false;
#else
return true;
#endif
} }
// Callback invoked when received WRITE10 command. // Callback invoked when received WRITE10 command.
@@ -200,6 +214,9 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
{ {
(void) lun; (void) lun;
// out of ramdisk
if ( lba >= DISK_BLOCK_NUM ) return -1;
#ifndef CFG_EXAMPLE_MSC_READONLY #ifndef CFG_EXAMPLE_MSC_READONLY
uint8_t* addr = msc_disk[lba] + offset; uint8_t* addr = msc_disk[lba] + offset;
memcpy(addr, buffer, bufsize); memcpy(addr, buffer, bufsize);
@@ -207,7 +224,7 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
(void) lba; (void) offset; (void) buffer; (void) lba; (void) offset; (void) buffer;
#endif #endif
return bufsize; return (int32_t) bufsize;
} }
// Callback invoked when received an SCSI command not in built-in list below // Callback invoked when received an SCSI command not in built-in list below
@@ -218,7 +235,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
// read10 & write10 has their own callback and MUST not be handled here // read10 & write10 has their own callback and MUST not be handled here
void const* response = NULL; void const* response = NULL;
uint16_t resplen = 0; int32_t resplen = 0;
// most scsi handled is input // most scsi handled is input
bool in_xfer = true; bool in_xfer = true;
@@ -246,14 +263,14 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
{ {
if(in_xfer) if(in_xfer)
{ {
memcpy(buffer, response, resplen); memcpy(buffer, response, (size_t) resplen);
}else }else
{ {
// SCSI output // SCSI output
} }
} }
return resplen; return (int32_t) resplen;
} }
#endif #endif
+3 -3
View File
@@ -47,9 +47,9 @@
// RHPort max operational speed can defined by board.mk // RHPort max operational speed can defined by board.mk
// Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed // Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed
#ifndef BOARD_DEVICE_RHPORT_SPEED #ifndef BOARD_DEVICE_RHPORT_SPEED
#if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \ #if TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX, OPT_MCU_MIMXRT10XX, OPT_MCU_NUC505) ||\
CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56 || CFG_TUSB_MCU == OPT_MCU_SAMX7X || \ TU_CHECK_MCU(OPT_MCU_CXD56, OPT_MCU_SAMX7X, OPT_MCU_BCM2711) ||\
CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X ) TU_CHECK_MCU(OPT_MCU_FT90X, OPT_MCU_FT93X)
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED
#else #else
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
+63 -9
View File
@@ -35,6 +35,9 @@
#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ #define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) ) _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) )
#define USB_VID 0xCafe
#define USB_BCD 0x0200
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Device Descriptors // Device Descriptors
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -42,7 +45,7 @@ tusb_desc_device_t const desc_device =
{ {
.bLength = sizeof(tusb_desc_device_t), .bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE, .bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200, .bcdUSB = USB_BCD,
// Use Interface Association Descriptor (IAD) for CDC // Use Interface Association Descriptor (IAD) for CDC
// As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1) // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
@@ -52,7 +55,7 @@ tusb_desc_device_t const desc_device =
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe, .idVendor = USB_VID,
.idProduct = USB_PID, .idProduct = USB_PID,
.bcdDevice = 0x0100, .bcdDevice = 0x0100,
@@ -82,8 +85,6 @@ enum
ITF_NUM_TOTAL ITF_NUM_TOTAL
}; };
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN)
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX #if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In, 5 Bulk etc ... // 0 control, 1 In, 2 Bulk, 3 Iso, 4 In, 5 Bulk etc ...
@@ -136,10 +137,13 @@ enum
#endif #endif
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN)
// full speed configuration
uint8_t const desc_fs_configuration[] = uint8_t const desc_fs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP notification address and size, EP data address (out, in) and size. // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64), TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64),
@@ -149,10 +153,13 @@ uint8_t const desc_fs_configuration[] =
}; };
#if TUD_OPT_HIGH_SPEED #if TUD_OPT_HIGH_SPEED
// Per USB specs: high speed capable device must report device_qualifier and other_speed_configuration
// high speed configuration
uint8_t const desc_hs_configuration[] = uint8_t const desc_hs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP notification address and size, EP data address (out, in) and size. // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 512), TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 512),
@@ -160,7 +167,54 @@ uint8_t const desc_hs_configuration[] =
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, 512), TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, 512),
}; };
#endif
// other speed configuration
uint8_t desc_other_speed_config[CONFIG_TOTAL_LEN];
// device qualifier is mostly similar to device descriptor since we don't change configuration based on speed
tusb_desc_device_qualifier_t const desc_device_qualifier =
{
.bLength = sizeof(tusb_desc_device_qualifier_t),
.bDescriptorType = TUSB_DESC_DEVICE_QUALIFIER,
.bcdUSB = USB_BCD,
.bDeviceClass = TUSB_CLASS_MISC,
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
.bDeviceProtocol = MISC_PROTOCOL_IAD,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.bNumConfigurations = 0x01,
.bReserved = 0x00
};
// Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
// device_qualifier descriptor describes information about a high-speed capable device that would
// change if the device were operating at the other speed. If not highspeed capable stall this request.
uint8_t const* tud_descriptor_device_qualifier_cb(void)
{
return (uint8_t const*) &desc_device_qualifier;
}
// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index)
{
(void) index; // for multiple configurations
// if link speed is high return fullspeed config, and vice versa
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
memcpy(desc_other_speed_config,
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
CONFIG_TOTAL_LEN);
desc_other_speed_config[1] = TUSB_DESC_OTHER_SPEED_CONFIG;
return desc_other_speed_config;
}
#endif // highspeed
// Invoked when received GET CONFIGURATION DESCRIPTOR // Invoked when received GET CONFIGURATION DESCRIPTOR
@@ -188,7 +242,7 @@ char const* string_desc_arr [] =
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409) (const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer "TinyUSB", // 1: Manufacturer
"TinyUSB Device", // 2: Product "TinyUSB Device", // 2: Product
"123456", // 3: Serials, should use chip ID "123456789012", // 3: Serials, should use chip ID
"TinyUSB CDC", // 4: CDC Interface "TinyUSB CDC", // 4: CDC Interface
"TinyUSB MSC", // 5: MSC Interface "TinyUSB MSC", // 5: MSC Interface
}; };
@@ -217,7 +271,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
const char* str = string_desc_arr[index]; const char* str = string_desc_arr[index];
// Cap at max char // Cap at max char
chr_count = strlen(str); chr_count = (uint8_t) strlen(str);
if ( chr_count > 31 ) chr_count = 31; if ( chr_count > 31 ) chr_count = 31;
// Convert ASCII string into UTF-16 // Convert ASCII string into UTF-16
+10 -1
View File
@@ -7,12 +7,18 @@ FREERTOS_SRC = lib/FreeRTOS-Kernel
INC += \ INC += \
src \ src \
src/FreeRTOSConfig \
$(TOP)/hw \ $(TOP)/hw \
$(TOP)/$(FREERTOS_SRC)/include \ $(TOP)/$(FREERTOS_SRC)/include \
$(TOP)/$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT) $(TOP)/$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)
# Example source # Example source
EXAMPLE_SOURCE += $(wildcard src/*.c) EXAMPLE_SOURCE = \
src/freertos_hook.c \
src/main.c \
src/msc_disk.c \
src/usb_descriptors.c
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE)) SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
# FreeRTOS source, all files in port folder # FreeRTOS source, all files in port folder
@@ -23,6 +29,9 @@ SRC_C += \
$(FREERTOS_SRC)/timers.c \ $(FREERTOS_SRC)/timers.c \
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c)) $(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c))
# Suppress FreeRTOS warnings
CFLAGS += -Wno-error=cast-qual
# FreeRTOS (lto + Os) linker issue # FreeRTOS (lto + Os) linker issue
LDFLAGS += -Wl,--undefined=vTaskSwitchContext LDFLAGS += -Wl,--undefined=vTaskSwitchContext
@@ -8,9 +8,7 @@ if(EXISTS ${board_cmake})
include(${board_cmake}) include(${board_cmake})
endif() endif()
idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
target_include_directories(${COMPONENT_TARGET} PUBLIC target_include_directories(${COMPONENT_TARGET} PUBLIC
"${FREERTOS_ORIG_INCLUDE_PATH}"
"${TOP}/hw" "${TOP}/hw"
"${TOP}/src" "${TOP}/src"
) )
@@ -25,8 +23,9 @@ target_sources(${COMPONENT_TARGET} PUBLIC
"${TOP}/src/class/hid/hid_device.c" "${TOP}/src/class/hid/hid_device.c"
"${TOP}/src/class/midi/midi_device.c" "${TOP}/src/class/midi/midi_device.c"
"${TOP}/src/class/msc/msc_device.c" "${TOP}/src/class/msc/msc_device.c"
"${TOP}/src/class/net/net_device.c" "${TOP}/src/class/net/ecm_rndis_device.c"
"${TOP}/src/class/net/ncm_device.c"
"${TOP}/src/class/usbtmc/usbtmc_device.c" "${TOP}/src/class/usbtmc/usbtmc_device.c"
"${TOP}/src/class/vendor/vendor_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"
) )
@@ -45,7 +45,16 @@
// Include MCU header // Include MCU header
#include "bsp/board_mcu.h" #include "bsp/board_mcu.h"
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3
#error "ESP32-Sx should use IDF's FreeRTOSConfig.h"
#endif
// TODO fix later
#if CFG_TUSB_MCU == OPT_MCU_MM32F327X
extern u32 SystemCoreClock;
#else
extern uint32_t SystemCoreClock; extern uint32_t SystemCoreClock;
#endif
/* Cortex M23/M33 port configuration. */ /* Cortex M23/M33 port configuration. */
#define configENABLE_MPU 0 #define configENABLE_MPU 0
+24 -16
View File
@@ -27,15 +27,30 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "queue.h"
#include "semphr.h"
#include "bsp/board.h" #include "bsp/board.h"
#include "tusb.h" #include "tusb.h"
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
// ESP-IDF need "freertos/" prefix in include path.
// CFG_TUSB_OS_INC_PATH should be defined accordingly.
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#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
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTYPES // MACRO CONSTANT TYPEDEF PROTYPES
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -55,14 +70,7 @@ enum {
StaticTimer_t blinky_tmdef; StaticTimer_t blinky_tmdef;
TimerHandle_t blinky_tm; TimerHandle_t blinky_tm;
// static task for usbd // static task
// 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
StackType_t usb_device_stack[USBD_STACK_SIZE]; StackType_t usb_device_stack[USBD_STACK_SIZE];
StaticTask_t usb_device_taskdef; StaticTask_t usb_device_taskdef;
@@ -95,14 +103,14 @@ int main(void)
(void) xTaskCreateStatic( cdc_task, "cdc", CDC_STACK_SZIE, NULL, configMAX_PRIORITIES-2, cdc_stack, &cdc_taskdef); (void) xTaskCreateStatic( cdc_task, "cdc", CDC_STACK_SZIE, NULL, configMAX_PRIORITIES-2, cdc_stack, &cdc_taskdef);
// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3 // skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
#if CFG_TUSB_MCU != OPT_MCU_ESP32S2 && CFG_TUSB_MCU != OPT_MCU_ESP32S3 #if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
vTaskStartScheduler(); vTaskStartScheduler();
#endif #endif
return 0; return 0;
} }
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3 #if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
void app_main(void) void app_main(void)
{ {
main(); main();
@@ -178,6 +178,9 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
{ {
(void) lun; (void) lun;
// out of ramdisk
if ( lba >= DISK_BLOCK_NUM ) return -1;
uint8_t const* addr = msc_disk[lba] + offset; uint8_t const* addr = msc_disk[lba] + offset;
memcpy(buffer, addr, bufsize); memcpy(buffer, addr, bufsize);
@@ -190,6 +193,9 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
{ {
(void) lun; (void) lun;
// out of ramdisk
if ( lba >= DISK_BLOCK_NUM ) return -1;
#ifndef CFG_EXAMPLE_MSC_READONLY #ifndef CFG_EXAMPLE_MSC_READONLY
uint8_t* addr = msc_disk[lba] + offset; uint8_t* addr = msc_disk[lba] + offset;
memcpy(addr, buffer, bufsize); memcpy(addr, buffer, bufsize);
@@ -208,7 +214,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
// read10 & write10 has their own callback and MUST not be handled here // read10 & write10 has their own callback and MUST not be handled here
void const* response = NULL; void const* response = NULL;
uint16_t resplen = 0; int32_t resplen = 0;
// most scsi handled is input // most scsi handled is input
bool in_xfer = true; bool in_xfer = true;
@@ -67,6 +67,11 @@
// This examples use FreeRTOS // 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/
#endif
// can be defined by compiler in DEBUG build // can be defined by compiler in DEBUG build
#ifndef CFG_TUSB_DEBUG #ifndef CFG_TUSB_DEBUG
#define CFG_TUSB_DEBUG 0 #define CFG_TUSB_DEBUG 0
@@ -35,6 +35,9 @@
#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ #define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) ) _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) )
#define USB_VID 0xCafe
#define USB_BCD 0x0200
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Device Descriptors // Device Descriptors
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -42,7 +45,7 @@ tusb_desc_device_t const desc_device =
{ {
.bLength = sizeof(tusb_desc_device_t), .bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE, .bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200, .bcdUSB = USB_BCD,
// Use Interface Association Descriptor (IAD) for CDC // Use Interface Association Descriptor (IAD) for CDC
// As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1) // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
@@ -52,7 +55,7 @@ tusb_desc_device_t const desc_device =
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe, .idVendor = USB_VID,
.idProduct = USB_PID, .idProduct = USB_PID,
.bcdDevice = 0x0100, .bcdDevice = 0x0100,
@@ -82,8 +85,6 @@ enum
ITF_NUM_TOTAL ITF_NUM_TOTAL
}; };
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN)
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX #if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In, 5 Bulk etc ... // 0 control, 1 In, 2 Bulk, 3 Iso, 4 In, 5 Bulk etc ...
@@ -114,10 +115,12 @@ enum
#endif #endif
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN)
uint8_t const desc_fs_configuration[] = uint8_t const desc_fs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP notification address and size, EP data address (out, in) and size. // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64), TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64),
@@ -127,10 +130,13 @@ uint8_t const desc_fs_configuration[] =
}; };
#if TUD_OPT_HIGH_SPEED #if TUD_OPT_HIGH_SPEED
// Per USB specs: high speed capable device must report device_qualifier and other_speed_configuration
// high speed configuration
uint8_t const desc_hs_configuration[] = uint8_t const desc_hs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP notification address and size, EP data address (out, in) and size. // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 512), TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 512),
@@ -138,7 +144,54 @@ uint8_t const desc_hs_configuration[] =
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, 512), TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, 512),
}; };
#endif
// other speed configuration
uint8_t desc_other_speed_config[CONFIG_TOTAL_LEN];
// device qualifier is mostly similar to device descriptor since we don't change configuration based on speed
tusb_desc_device_qualifier_t const desc_device_qualifier =
{
.bLength = sizeof(tusb_desc_device_qualifier_t),
.bDescriptorType = TUSB_DESC_DEVICE_QUALIFIER,
.bcdUSB = USB_BCD,
.bDeviceClass = TUSB_CLASS_MISC,
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
.bDeviceProtocol = MISC_PROTOCOL_IAD,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.bNumConfigurations = 0x01,
.bReserved = 0x00
};
// Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
// device_qualifier descriptor describes information about a high-speed capable device that would
// change if the device were operating at the other speed. If not highspeed capable stall this request.
uint8_t const* tud_descriptor_device_qualifier_cb(void)
{
return (uint8_t const*) &desc_device_qualifier;
}
// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index)
{
(void) index; // for multiple configurations
// if link speed is high return fullspeed config, and vice versa
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
memcpy(desc_other_speed_config,
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
CONFIG_TOTAL_LEN);
desc_other_speed_config[1] = TUSB_DESC_OTHER_SPEED_CONFIG;
return desc_other_speed_config;
}
#endif // highspeed
// Invoked when received GET CONFIGURATION DESCRIPTOR // Invoked when received GET CONFIGURATION DESCRIPTOR
// Application return pointer to descriptor // Application return pointer to descriptor
@@ -165,7 +218,7 @@ char const* string_desc_arr [] =
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409) (const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer "TinyUSB", // 1: Manufacturer
"TinyUSB Device", // 2: Product "TinyUSB Device", // 2: Product
"123456", // 3: Serials, should use chip ID "123456789012", // 3: Serials, should use chip ID
"TinyUSB CDC", // 4: CDC Interface "TinyUSB CDC", // 4: CDC Interface
"TinyUSB MSC", // 5: MSC Interface "TinyUSB MSC", // 5: MSC Interface
}; };
+4
View File
@@ -0,0 +1,4 @@
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
View File
@@ -80,7 +80,7 @@
#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 // DFU buffer size, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR
#define CFG_TUD_DFU_XFER_BUFSIZE 512 #define CFG_TUD_DFU_XFER_BUFSIZE ( OPT_MODE_HIGH_SPEED ? 512 : 64 )
#ifdef __cplusplus #ifdef __cplusplus
} }
+1 -1
View File
@@ -97,7 +97,7 @@ enum
uint8_t const desc_configuration[] = uint8_t const desc_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, Alternate count, starting string index, attributes, detach timeout, transfer size // Interface number, Alternate count, starting string index, attributes, detach timeout, transfer size
TUD_DFU_DESCRIPTOR(ITF_NUM_DFU_MODE, ALT_COUNT, 4, FUNC_ATTRS, 1000, CFG_TUD_DFU_XFER_BUFSIZE), TUD_DFU_DESCRIPTOR(ITF_NUM_DFU_MODE, ALT_COUNT, 4, FUNC_ATTRS, 1000, CFG_TUD_DFU_XFER_BUFSIZE),
@@ -92,7 +92,7 @@ enum
uint8_t const desc_configuration[] = uint8_t const desc_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, attributes, detach timeout, transfer size */ // Interface number, string index, attributes, detach timeout, transfer size */
TUD_DFU_RT_DESCRIPTOR(ITF_NUM_DFU_RT, 4, 0x0d, 1000, 4096), TUD_DFU_RT_DESCRIPTOR(ITF_NUM_DFU_RT, 4, 0x0d, 1000, 4096),
@@ -178,6 +178,9 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
{ {
(void) lun; (void) lun;
// out of ramdisk
if ( lba >= DISK_BLOCK_NUM ) return -1;
uint8_t const* addr = msc_disk[lba] + offset; uint8_t const* addr = msc_disk[lba] + offset;
memcpy(buffer, addr, bufsize); memcpy(buffer, addr, bufsize);
@@ -190,6 +193,9 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
{ {
(void) lun; (void) lun;
// out of ramdisk
if ( lba >= DISK_BLOCK_NUM ) return -1;
#ifndef CFG_EXAMPLE_MSC_READONLY #ifndef CFG_EXAMPLE_MSC_READONLY
uint8_t* addr = msc_disk[lba] + offset; uint8_t* addr = msc_disk[lba] + offset;
memcpy(addr, buffer, bufsize); memcpy(addr, buffer, bufsize);
@@ -208,7 +214,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
// read10 & write10 has their own callback and MUST not be handled here // read10 & write10 has their own callback and MUST not be handled here
void const* response = NULL; void const* response = NULL;
uint16_t resplen = 0; int32_t resplen = 0;
// most scsi handled is input // most scsi handled is input
bool in_xfer = true; bool in_xfer = true;
@@ -160,7 +160,7 @@ enum
uint8_t const desc_configuration_0[] = uint8_t const desc_configuration_0[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_0_NUM_TOTAL, 0, CONFIG_0_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), 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. // 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, 64),
@@ -173,7 +173,7 @@ uint8_t const desc_configuration_0[] =
uint8_t const desc_configuraiton_1[] = uint8_t const desc_configuraiton_1[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_1_NUM_TOTAL, 0, CONFIG_1_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_1_NUM_TOTAL, 0, CONFIG_1_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_MSC_DESCRIPTOR(ITF_1_NUM_MSC, 0, EPNUM_1_MSC_OUT, EPNUM_1_MSC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64), TUD_MSC_DESCRIPTOR(ITF_1_NUM_MSC, 0, EPNUM_1_MSC_OUT, EPNUM_1_MSC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64),
+1 -1
View File
@@ -6,7 +6,7 @@ INC += \
$(TOP)/hw \ $(TOP)/hw \
# Example source # Example source
EXAMPLE_SOURCE += \ EXAMPLE_SOURCE = \
src/main.c \ src/main.c \
src/usb_descriptors.c src/usb_descriptors.c
@@ -47,8 +47,8 @@
// RHPort max operational speed can defined by board.mk // RHPort max operational speed can defined by board.mk
// Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed // Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed
#ifndef BOARD_DEVICE_RHPORT_SPEED #ifndef BOARD_DEVICE_RHPORT_SPEED
#if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \ #if TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX, OPT_MCU_MIMXRT10XX, OPT_MCU_NUC505) ||\
CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56 || CFG_TUSB_MCU == OPT_MCU_SAMX7X) TU_CHECK_MCU(OPT_MCU_CXD56, OPT_MCU_SAMX7X, OPT_MCU_BCM2711)
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED
#else #else
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
@@ -36,6 +36,9 @@
#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ #define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) ) _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) )
#define USB_VID 0xCafe
#define USB_BCD 0x0200
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Device Descriptors // Device Descriptors
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -43,13 +46,13 @@ tusb_desc_device_t const desc_device =
{ {
.bLength = sizeof(tusb_desc_device_t), .bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE, .bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200, .bcdUSB = USB_BCD,
.bDeviceClass = 0x00, .bDeviceClass = 0x00,
.bDeviceSubClass = 0x00, .bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00, .bDeviceProtocol = 0x00,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe, .idVendor = USB_VID,
.idProduct = USB_PID, .idProduct = USB_PID,
.bcdDevice = 0x0100, .bcdDevice = 0x0100,
@@ -111,12 +114,62 @@ uint8_t const desc_configuration[] =
TUD_HID_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 5) TUD_HID_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 5)
}; };
#if TUD_OPT_HIGH_SPEED
// Per USB specs: high speed capable device must report device_qualifier and other_speed_configuration
// other speed configuration
uint8_t desc_other_speed_config[CONFIG_TOTAL_LEN];
// device qualifier is mostly similar to device descriptor since we don't change configuration based on speed
tusb_desc_device_qualifier_t const desc_device_qualifier =
{
.bLength = sizeof(tusb_desc_device_qualifier_t),
.bDescriptorType = TUSB_DESC_DEVICE_QUALIFIER,
.bcdUSB = USB_BCD,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.bNumConfigurations = 0x01,
.bReserved = 0x00
};
// Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
// device_qualifier descriptor describes information about a high-speed capable device that would
// change if the device were operating at the other speed. If not highspeed capable stall this request.
uint8_t const* tud_descriptor_device_qualifier_cb(void)
{
return (uint8_t const*) &desc_device_qualifier;
}
// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index)
{
(void) index; // for multiple configurations
// other speed config is basically configuration with type = OHER_SPEED_CONFIG
memcpy(desc_other_speed_config, desc_configuration, CONFIG_TOTAL_LEN);
desc_other_speed_config[1] = TUSB_DESC_OTHER_SPEED_CONFIG;
// this example use the same configuration for both high and full speed mode
return desc_other_speed_config;
}
#endif // highspeed
// Invoked when received GET CONFIGURATION DESCRIPTOR // Invoked when received GET CONFIGURATION DESCRIPTOR
// Application return pointer to descriptor // Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete // Descriptor contents must exist long enough for transfer to complete
uint8_t const * tud_descriptor_configuration_cb(uint8_t index) uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
{ {
(void) index; // for multiple configurations (void) index; // for multiple configurations
// This example use the same configuration for both high and full speed mode
return desc_configuration; return desc_configuration;
} }
@@ -7,12 +7,17 @@ FREERTOS_SRC = lib/FreeRTOS-Kernel
INC += \ INC += \
src \ src \
src/FreeRTOSConfig \
$(TOP)/hw \ $(TOP)/hw \
$(TOP)/$(FREERTOS_SRC)/include \ $(TOP)/$(FREERTOS_SRC)/include \
$(TOP)/$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT) $(TOP)/$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)
# Example source # Example source
EXAMPLE_SOURCE += $(wildcard src/*.c) EXAMPLE_SOURCE = \
src/freertos_hook.c \
src/main.c \
src/usb_descriptors.c
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE)) SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
# FreeRTOS source, all files in port folder # FreeRTOS source, all files in port folder
@@ -23,6 +28,9 @@ SRC_C += \
$(FREERTOS_SRC)/timers.c \ $(FREERTOS_SRC)/timers.c \
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c)) $(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c))
# Suppress FreeRTOS warnings
CFLAGS += -Wno-error=cast-qual
# FreeRTOS (lto + Os) linker issue # FreeRTOS (lto + Os) linker issue
LDFLAGS += -Wl,--undefined=vTaskSwitchContext LDFLAGS += -Wl,--undefined=vTaskSwitchContext
@@ -8,9 +8,7 @@ if(EXISTS ${board_cmake})
include(${board_cmake}) include(${board_cmake})
endif() endif()
idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
target_include_directories(${COMPONENT_TARGET} PUBLIC target_include_directories(${COMPONENT_TARGET} PUBLIC
"${FREERTOS_ORIG_INCLUDE_PATH}"
"${TOP}/hw" "${TOP}/hw"
"${TOP}/src" "${TOP}/src"
) )
@@ -25,7 +23,8 @@ target_sources(${COMPONENT_TARGET} PUBLIC
"${TOP}/src/class/hid/hid_device.c" "${TOP}/src/class/hid/hid_device.c"
"${TOP}/src/class/midi/midi_device.c" "${TOP}/src/class/midi/midi_device.c"
"${TOP}/src/class/msc/msc_device.c" "${TOP}/src/class/msc/msc_device.c"
"${TOP}/src/class/net/net_device.c" "${TOP}/src/class/net/ecm_rndis_device.c"
"${TOP}/src/class/net/ncm_device.c"
"${TOP}/src/class/usbtmc/usbtmc_device.c" "${TOP}/src/class/usbtmc/usbtmc_device.c"
"${TOP}/src/class/vendor/vendor_device.c" "${TOP}/src/class/vendor/vendor_device.c"
"${TOP}/src/portable/espressif/esp32sx/dcd_esp32sx.c" "${TOP}/src/portable/espressif/esp32sx/dcd_esp32sx.c"
@@ -45,7 +45,16 @@
// Include MCU header // Include MCU header
#include "bsp/board_mcu.h" #include "bsp/board_mcu.h"
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3
#error "ESP32-Sx should use IDF's FreeRTOSConfig.h"
#endif
#if CFG_TUSB_MCU == OPT_MCU_MM32F327X
// TODO fix/remove later
extern u32 SystemCoreClock;
#else
extern uint32_t SystemCoreClock; extern uint32_t SystemCoreClock;
#endif
/* Cortex M23/M33 port configuration. */ /* Cortex M23/M33 port configuration. */
#define configENABLE_MPU 0 #define configENABLE_MPU 0
@@ -27,17 +27,32 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "queue.h"
#include "semphr.h"
#include "bsp/board.h" #include "bsp/board.h"
#include "tusb.h" #include "tusb.h"
#include "usb_descriptors.h" #include "usb_descriptors.h"
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
// ESP-IDF need "freertos/" prefix in include path.
// CFG_TUSB_OS_INC_PATH should be defined accordingly.
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#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
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTYPES // MACRO CONSTANT TYPEDEF PROTYPES
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -57,13 +72,7 @@ enum {
StaticTimer_t blinky_tmdef; StaticTimer_t blinky_tmdef;
TimerHandle_t blinky_tm; TimerHandle_t blinky_tm;
// static task for usbd // static task
#if CFG_TUSB_DEBUG
#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE)
#else
#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2)
#endif
StackType_t usb_device_stack[USBD_STACK_SIZE]; StackType_t usb_device_stack[USBD_STACK_SIZE];
StaticTask_t usb_device_taskdef; StaticTask_t usb_device_taskdef;
@@ -96,14 +105,14 @@ int main(void)
(void) xTaskCreateStatic( hid_task, "hid", HID_STACK_SZIE, NULL, configMAX_PRIORITIES-2, hid_stack, &hid_taskdef); (void) xTaskCreateStatic( hid_task, "hid", HID_STACK_SZIE, NULL, configMAX_PRIORITIES-2, hid_stack, &hid_taskdef);
// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3 // skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
#if CFG_TUSB_MCU != OPT_MCU_ESP32S2 && CFG_TUSB_MCU != OPT_MCU_ESP32S3 #if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
vTaskStartScheduler(); vTaskStartScheduler();
#endif #endif
return 0; return 0;
} }
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3 #if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
void app_main(void) void app_main(void)
{ {
main(); main();
@@ -67,8 +67,15 @@
// This examples use FreeRTOS // This examples use FreeRTOS
#define CFG_TUSB_OS OPT_OS_FREERTOS #define CFG_TUSB_OS OPT_OS_FREERTOS
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build // Espressif IDF requires "freertos/" prefix in include path
// #define CFG_TUSB_DEBUG 0 #if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#define CFG_TUSB_OS_INC_PATH freertos/
#endif
#ifndef CFG_TUSB_DEBUG
#define CFG_TUSB_DEBUG 0
#endif
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. /* 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 * Tinyusb use follows macros to declare transferring memory so that they can be put
@@ -36,6 +36,9 @@
#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ #define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) ) _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) )
#define USB_VID 0xCafe
#define USB_BCD 0x0200
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Device Descriptors // Device Descriptors
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -43,13 +46,13 @@ tusb_desc_device_t const desc_device =
{ {
.bLength = sizeof(tusb_desc_device_t), .bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE, .bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200, .bcdUSB = USB_BCD,
.bDeviceClass = 0x00, .bDeviceClass = 0x00,
.bDeviceSubClass = 0x00, .bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00, .bDeviceProtocol = 0x00,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe, .idVendor = USB_VID,
.idProduct = USB_PID, .idProduct = USB_PID,
.bcdDevice = 0x0100, .bcdDevice = 0x0100,
@@ -111,6 +114,54 @@ uint8_t const desc_configuration[] =
TUD_HID_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 5) TUD_HID_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 5)
}; };
#if TUD_OPT_HIGH_SPEED
// Per USB specs: high speed capable device must report device_qualifier and other_speed_configuration
// other speed configuration
uint8_t desc_other_speed_config[CONFIG_TOTAL_LEN];
// device qualifier is mostly similar to device descriptor since we don't change configuration based on speed
tusb_desc_device_qualifier_t const desc_device_qualifier =
{
.bLength = sizeof(tusb_desc_device_qualifier_t),
.bDescriptorType = TUSB_DESC_DEVICE_QUALIFIER,
.bcdUSB = USB_BCD,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.bNumConfigurations = 0x01,
.bReserved = 0x00
};
// Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
// device_qualifier descriptor describes information about a high-speed capable device that would
// change if the device were operating at the other speed. If not highspeed capable stall this request.
uint8_t const* tud_descriptor_device_qualifier_cb(void)
{
return (uint8_t const*) &desc_device_qualifier;
}
// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index)
{
(void) index; // for multiple configurations
// other speed config is basically configuration with type = OHER_SPEED_CONFIG
memcpy(desc_other_speed_config, desc_configuration, CONFIG_TOTAL_LEN);
desc_other_speed_config[1] = TUSB_DESC_OTHER_SPEED_CONFIG;
// this example use the same configuration for both high and full speed mode
return desc_other_speed_config;
}
#endif // highspeed
// Invoked when received GET CONFIGURATION DESCRIPTOR // Invoked when received GET CONFIGURATION DESCRIPTOR
// Application return pointer to descriptor // Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete // Descriptor contents must exist long enough for transfer to complete
@@ -101,7 +101,7 @@ enum
uint8_t const desc_configuration[] = uint8_t const desc_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval // Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, 0x80 | EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10) TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, 0x80 | EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10)
@@ -91,7 +91,7 @@ enum
uint8_t const desc_fs_configuration[] = uint8_t const desc_fs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_MIDI_DESCRIPTOR(ITF_NUM_MIDI, 0, EPNUM_MIDI, 0x80 | EPNUM_MIDI, 64) TUD_MIDI_DESCRIPTOR(ITF_NUM_MIDI, 0, EPNUM_MIDI, 0x80 | EPNUM_MIDI, 64)
@@ -101,7 +101,7 @@ uint8_t const desc_fs_configuration[] =
uint8_t const desc_hs_configuration[] = uint8_t const desc_hs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_MIDI_DESCRIPTOR(ITF_NUM_MIDI, 0, EPNUM_MIDI, 0x80 | EPNUM_MIDI, 512) TUD_MIDI_DESCRIPTOR(ITF_NUM_MIDI, 0, EPNUM_MIDI, 0x80 | EPNUM_MIDI, 512)
@@ -268,16 +268,33 @@ bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes. // Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
{ {
// out of ramdisk
if ( lba >= DISK_BLOCK_NUM ) return -1;
uint8_t const* addr = (lun ? msc_disk1[lba] : msc_disk0[lba]) + offset; uint8_t const* addr = (lun ? msc_disk1[lba] : msc_disk0[lba]) + offset;
memcpy(buffer, addr, bufsize); memcpy(buffer, addr, bufsize);
return bufsize; return bufsize;
} }
bool tud_msc_is_writable_cb (uint8_t lun)
{
(void) lun;
#ifdef CFG_EXAMPLE_MSC_READONLY
return false;
#else
return true;
#endif
}
// Callback invoked when received WRITE10 command. // Callback invoked when received WRITE10 command.
// Process data in buffer to disk's storage and return number of written bytes // Process data in buffer to disk's storage and return number of written bytes
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
{ {
// out of ramdisk
if ( lba >= DISK_BLOCK_NUM ) return -1;
#ifndef CFG_EXAMPLE_MSC_READONLY #ifndef CFG_EXAMPLE_MSC_READONLY
uint8_t* addr = (lun ? msc_disk1[lba] : msc_disk0[lba]) + offset; uint8_t* addr = (lun ? msc_disk1[lba] : msc_disk0[lba]) + offset;
memcpy(addr, buffer, bufsize); memcpy(addr, buffer, bufsize);
@@ -296,7 +313,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
// read10 & write10 has their own callback and MUST not be handled here // read10 & write10 has their own callback and MUST not be handled here
void const* response = NULL; void const* response = NULL;
uint16_t resplen = 0; int32_t resplen = 0;
// most scsi handled is input // most scsi handled is input
bool in_xfer = true; bool in_xfer = true;
@@ -99,7 +99,7 @@ enum
uint8_t const desc_fs_configuration[] = uint8_t const desc_fs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 0, EPNUM_MSC_OUT, EPNUM_MSC_IN, 64), TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 0, EPNUM_MSC_OUT, EPNUM_MSC_IN, 64),
@@ -109,7 +109,7 @@ uint8_t const desc_fs_configuration[] =
uint8_t const desc_hs_configuration[] = uint8_t const desc_hs_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 0, EPNUM_MSC_OUT, EPNUM_MSC_IN, 512), TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 0, EPNUM_MSC_OUT, EPNUM_MSC_IN, 512),
@@ -141,7 +141,7 @@ char const* string_desc_arr [] =
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409) (const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer "TinyUSB", // 1: Manufacturer
"TinyUSB Device", // 2: Product "TinyUSB Device", // 2: Product
"123456", // 3: Serials, should use chip ID "123456789012", // 3: Serials, should use chip ID
}; };
static uint16_t _desc_str[32]; static uint16_t _desc_str[32];
@@ -0,0 +1 @@
tinyusb/lib/lwip/src/include/lwip/arch.h:202:13: error: conflicting types for 'ssize_t'
+13 -3
View File
@@ -3,10 +3,11 @@ DEPS_SUBMODULES += lib/lwip
include ../../../tools/top.mk include ../../../tools/top.mk
include ../../make.mk include ../../make.mk
# suppress warning caused by lwip
CFLAGS += \ CFLAGS += \
-DPBUF_POOL_SIZE=2 \ -Wno-error=null-dereference \
-DTCP_WND=2*TCP_MSS \ -Wno-error=unused-parameter \
-DHTTPD_USE_CUSTOM_FSDATA=0 -Wno-error=unused-variable
INC += \ INC += \
src \ src \
@@ -50,6 +51,15 @@ SRC_C += \
lib/lwip/src/core/ipv4/ip4.c \ lib/lwip/src/core/ipv4/ip4.c \
lib/lwip/src/core/ipv4/ip4_addr.c \ lib/lwip/src/core/ipv4/ip4_addr.c \
lib/lwip/src/core/ipv4/ip4_frag.c \ lib/lwip/src/core/ipv4/ip4_frag.c \
lib/lwip/src/core/ipv6/dhcp6.c \
lib/lwip/src/core/ipv6/ethip6.c \
lib/lwip/src/core/ipv6/icmp6.c \
lib/lwip/src/core/ipv6/inet6.c \
lib/lwip/src/core/ipv6/ip6.c \
lib/lwip/src/core/ipv6/ip6_addr.c \
lib/lwip/src/core/ipv6/ip6_frag.c \
lib/lwip/src/core/ipv6/mld6.c \
lib/lwip/src/core/ipv6/nd6.c \
lib/lwip/src/netif/ethernet.c \ lib/lwip/src/netif/ethernet.c \
lib/lwip/src/netif/slipif.c \ lib/lwip/src/netif/slipif.c \
lib/lwip/src/apps/http/httpd.c \ lib/lwip/src/apps/http/httpd.c \
@@ -42,11 +42,14 @@
#define LWIP_ICMP 1 #define LWIP_ICMP 1
#define LWIP_UDP 1 #define LWIP_UDP 1
#define LWIP_TCP 1 #define LWIP_TCP 1
#define LWIP_IPV4 1
#define LWIP_IPV6 0
#define ETH_PAD_SIZE 0 #define ETH_PAD_SIZE 0
#define LWIP_IP_ACCEPT_UDP_PORT(p) ((p) == PP_NTOHS(67)) #define LWIP_IP_ACCEPT_UDP_PORT(p) ((p) == PP_NTOHS(67))
#define TCP_MSS (1500 /*mtu*/ - 20 /*iphdr*/ - 20 /*tcphhr*/) #define TCP_MSS (1500 /*mtu*/ - 20 /*iphdr*/ - 20 /*tcphhr*/)
#define TCP_SND_BUF (2 * TCP_MSS) #define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_WND (TCP_MSS)
#define ETHARP_SUPPORT_STATIC_ENTRIES 1 #define ETHARP_SUPPORT_STATIC_ENTRIES 1
@@ -56,4 +59,13 @@
#define LWIP_SINGLE_NETIF 1 #define LWIP_SINGLE_NETIF 1
#define PBUF_POOL_SIZE 2
#define HTTPD_USE_CUSTOM_FSDATA 0
#define LWIP_MULTICAST_PING 1
#define LWIP_BROADCAST_PING 1
#define LWIP_IPV6_MLD 0
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 0
#endif /* __LWIPOPTS_H__ */ #endif /* __LWIPOPTS_H__ */
+29 -13
View File
@@ -50,8 +50,11 @@ try changing the first byte of tud_network_mac_address[] below from 0x02 to 0x00
#include "dnserver.h" #include "dnserver.h"
#include "lwip/init.h" #include "lwip/init.h"
#include "lwip/timeouts.h" #include "lwip/timeouts.h"
#include "lwip/ethip6.h"
#include "httpd.h" #include "httpd.h"
#define INIT_IP4(a,b,c,d) { PP_HTONL(LWIP_MAKEU32(a,b,c,d)) }
/* lwip context */ /* lwip context */
static struct netif netif_data; static struct netif netif_data;
@@ -64,24 +67,24 @@ static struct pbuf *received_frame;
const uint8_t tud_network_mac_address[6] = {0x02,0x02,0x84,0x6A,0x96,0x00}; const uint8_t tud_network_mac_address[6] = {0x02,0x02,0x84,0x6A,0x96,0x00};
/* network parameters of this MCU */ /* network parameters of this MCU */
static const ip_addr_t ipaddr = IPADDR4_INIT_BYTES(192, 168, 7, 1); static const ip4_addr_t ipaddr = INIT_IP4(192, 168, 7, 1);
static const ip_addr_t netmask = IPADDR4_INIT_BYTES(255, 255, 255, 0); static const ip4_addr_t netmask = INIT_IP4(255, 255, 255, 0);
static const ip_addr_t gateway = IPADDR4_INIT_BYTES(0, 0, 0, 0); static const ip4_addr_t gateway = INIT_IP4(0, 0, 0, 0);
/* database IP addresses that can be offered to the host; this must be in RAM to store assigned MAC addresses */ /* database IP addresses that can be offered to the host; this must be in RAM to store assigned MAC addresses */
static dhcp_entry_t entries[] = static dhcp_entry_t entries[] =
{ {
/* mac ip address lease time */ /* mac ip address lease time */
{ {0}, IPADDR4_INIT_BYTES(192, 168, 7, 2), 24 * 60 * 60 }, { {0}, INIT_IP4(192, 168, 7, 2), 24 * 60 * 60 },
{ {0}, IPADDR4_INIT_BYTES(192, 168, 7, 3), 24 * 60 * 60 }, { {0}, INIT_IP4(192, 168, 7, 3), 24 * 60 * 60 },
{ {0}, IPADDR4_INIT_BYTES(192, 168, 7, 4), 24 * 60 * 60 }, { {0}, INIT_IP4(192, 168, 7, 4), 24 * 60 * 60 },
}; };
static const dhcp_config_t dhcp_config = static const dhcp_config_t dhcp_config =
{ {
.router = IPADDR4_INIT_BYTES(0, 0, 0, 0), /* router address (if any) */ .router = INIT_IP4(0, 0, 0, 0), /* router address (if any) */
.port = 67, /* listen port */ .port = 67, /* listen port */
.dns = IPADDR4_INIT_BYTES(192, 168, 7, 1), /* dns server (if any) */ .dns = INIT_IP4(192, 168, 7, 1), /* dns server (if any) */
"usb", /* dns suffix */ "usb", /* dns suffix */
TU_ARRAY_SIZE(entries), /* num entry */ TU_ARRAY_SIZE(entries), /* num entry */
entries /* entries */ entries /* entries */
@@ -97,7 +100,7 @@ static err_t linkoutput_fn(struct netif *netif, struct pbuf *p)
return ERR_USE; return ERR_USE;
/* if the network driver can accept another packet, we make it happen */ /* if the network driver can accept another packet, we make it happen */
if (tud_network_can_xmit()) if (tud_network_can_xmit(p->tot_len))
{ {
tud_network_xmit(p, 0 /* unused for this example */); tud_network_xmit(p, 0 /* unused for this example */);
return ERR_OK; return ERR_OK;
@@ -108,11 +111,18 @@ static err_t linkoutput_fn(struct netif *netif, struct pbuf *p)
} }
} }
static err_t output_fn(struct netif *netif, struct pbuf *p, const ip_addr_t *addr) static err_t ip4_output_fn(struct netif *netif, struct pbuf *p, const ip4_addr_t *addr)
{ {
return etharp_output(netif, p, addr); return etharp_output(netif, p, addr);
} }
#if LWIP_IPV6
static err_t ip6_output_fn(struct netif *netif, struct pbuf *p, const ip6_addr_t *addr)
{
return ethip6_output(netif, p, addr);
}
#endif
static err_t netif_init_cb(struct netif *netif) static err_t netif_init_cb(struct netif *netif)
{ {
LWIP_ASSERT("netif != NULL", (netif != NULL)); LWIP_ASSERT("netif != NULL", (netif != NULL));
@@ -122,7 +132,10 @@ static err_t netif_init_cb(struct netif *netif)
netif->name[0] = 'E'; netif->name[0] = 'E';
netif->name[1] = 'X'; netif->name[1] = 'X';
netif->linkoutput = linkoutput_fn; netif->linkoutput = linkoutput_fn;
netif->output = output_fn; netif->output = ip4_output_fn;
#if LWIP_IPV6
netif->output_ip6 = ip6_output_fn;
#endif
return ERR_OK; return ERR_OK;
} }
@@ -138,11 +151,14 @@ static void init_lwip(void)
netif->hwaddr[5] ^= 0x01; netif->hwaddr[5] ^= 0x01;
netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, netif_init_cb, ip_input); netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, netif_init_cb, ip_input);
#if LWIP_IPV6
netif_create_ip6_linklocal_address(netif, 1);
#endif
netif_set_default(netif); netif_set_default(netif);
} }
/* handle any DNS requests from dns-server */ /* handle any DNS requests from dns-server */
bool dns_query_proc(const char *name, ip_addr_t *addr) bool dns_query_proc(const char *name, ip4_addr_t *addr)
{ {
if (0 == strcmp(name, "tiny.usb")) if (0 == strcmp(name, "tiny.usb"))
{ {
@@ -218,7 +234,7 @@ int main(void)
init_lwip(); init_lwip();
while (!netif_is_up(&netif_data)); while (!netif_is_up(&netif_data));
while (dhserv_init(&dhcp_config) != ERR_OK); while (dhserv_init(&dhcp_config) != ERR_OK);
while (dnserv_init(&ipaddr, 53, dns_query_proc) != ERR_OK); while (dnserv_init(IP_ADDR_ANY, 53, dns_query_proc) != ERR_OK);
httpd_init(); httpd_init();
while (1) while (1)
@@ -95,12 +95,11 @@
#endif #endif
//------------- CLASS -------------// //------------- CLASS -------------//
#define CFG_TUD_CDC 0
#define CFG_TUD_MSC 0 // Network class has 2 drivers: ECM/RNDIS and NCM.
#define CFG_TUD_HID 0 // Only one of the drivers can be enabled
#define CFG_TUD_MIDI 0 #define CFG_TUD_ECM_RNDIS 1
#define CFG_TUD_VENDOR 0 #define CFG_TUD_NCM (1-CFG_TUD_ECM_RNDIS)
#define CFG_TUD_NET 1
#ifdef __cplusplus #ifdef __cplusplus
} }
@@ -33,7 +33,7 @@
*/ */
#define _PID_MAP(itf, n) ( (CFG_TUD_##itf) << (n) ) #define _PID_MAP(itf, n) ( (CFG_TUD_##itf) << (n) )
#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ #define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) | _PID_MAP(NET, 5) ) _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) | _PID_MAP(ECM_RNDIS, 5) | _PID_MAP(NCM, 5) )
// String Descriptor Index // String Descriptor Index
enum enum
@@ -55,8 +55,12 @@ enum
enum enum
{ {
#if CFG_TUD_ECM_RNDIS
CONFIG_ID_RNDIS = 0, CONFIG_ID_RNDIS = 0,
CONFIG_ID_ECM = 1, CONFIG_ID_ECM = 1,
#else
CONFIG_ID_NCM = 0,
#endif
CONFIG_ID_COUNT CONFIG_ID_COUNT
}; };
@@ -99,6 +103,7 @@ uint8_t const * tud_descriptor_device_cb(void)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define MAIN_CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_RNDIS_DESC_LEN) #define MAIN_CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_RNDIS_DESC_LEN)
#define ALT_CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_ECM_DESC_LEN) #define ALT_CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_ECM_DESC_LEN)
#define NCM_CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_NCM_DESC_LEN)
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX #if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
@@ -120,6 +125,8 @@ uint8_t const * tud_descriptor_device_cb(void)
#define EPNUM_NET_IN 0x82 #define EPNUM_NET_IN 0x82
#endif #endif
#if CFG_TUD_ECM_RNDIS
static uint8_t const rndis_configuration[] = static uint8_t const rndis_configuration[] =
{ {
// Config number (index+1), interface count, string index, total length, attribute, power in mA // Config number (index+1), interface count, string index, total length, attribute, power in mA
@@ -138,14 +145,31 @@ static uint8_t const ecm_configuration[] =
TUD_CDC_ECM_DESCRIPTOR(ITF_NUM_CDC, STRID_INTERFACE, STRID_MAC, EPNUM_NET_NOTIF, 64, EPNUM_NET_OUT, EPNUM_NET_IN, CFG_TUD_NET_ENDPOINT_SIZE, CFG_TUD_NET_MTU), TUD_CDC_ECM_DESCRIPTOR(ITF_NUM_CDC, STRID_INTERFACE, STRID_MAC, EPNUM_NET_NOTIF, 64, EPNUM_NET_OUT, EPNUM_NET_IN, CFG_TUD_NET_ENDPOINT_SIZE, CFG_TUD_NET_MTU),
}; };
#else
static uint8_t const ncm_configuration[] =
{
// Config number (index+1), interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(CONFIG_ID_NCM+1, ITF_NUM_TOTAL, 0, NCM_CONFIG_TOTAL_LEN, 0, 100),
// Interface number, description string index, MAC address string index, EP notification address and size, EP data address (out, in), and size, max segment size.
TUD_CDC_NCM_DESCRIPTOR(ITF_NUM_CDC, STRID_INTERFACE, STRID_MAC, EPNUM_NET_NOTIF, 64, EPNUM_NET_OUT, EPNUM_NET_IN, CFG_TUD_NET_ENDPOINT_SIZE, CFG_TUD_NET_MTU),
};
#endif
// Configuration array: RNDIS and CDC-ECM // Configuration array: RNDIS and CDC-ECM
// - Windows only works with RNDIS // - Windows only works with RNDIS
// - MacOS only works with CDC-ECM // - MacOS only works with CDC-ECM
// - Linux will work on both // - Linux will work on both
static uint8_t const * const configuration_arr[2] = static uint8_t const * const configuration_arr[2] =
{ {
#if CFG_TUD_ECM_RNDIS
[CONFIG_ID_RNDIS] = rndis_configuration, [CONFIG_ID_RNDIS] = rndis_configuration,
[CONFIG_ID_ECM ] = ecm_configuration [CONFIG_ID_ECM ] = ecm_configuration
#else
[CONFIG_ID_NCM ] = ncm_configuration
#endif
}; };
// Invoked when received GET CONFIGURATION DESCRIPTOR // Invoked when received GET CONFIGURATION DESCRIPTOR
+4 -3
View File
@@ -40,6 +40,7 @@ const uint32_t sample_rates[] = {44100, 48000};
#else #else
const uint32_t sample_rates[] = {44100, 48000, 88200, 96000}; const uint32_t sample_rates[] = {44100, 48000, 88200, 96000};
#endif #endif
uint32_t current_sample_rate = 44100; uint32_t current_sample_rate = 44100;
#define N_SAMPLE_RATES TU_ARRAY_SIZE(sample_rates) #define N_SAMPLE_RATES TU_ARRAY_SIZE(sample_rates)
@@ -202,7 +203,7 @@ static bool tud_audio_clock_set_request(uint8_t rhport, audio_control_request_t
{ {
TU_VERIFY(request->wLength == sizeof(audio_control_cur_4_t)); TU_VERIFY(request->wLength == sizeof(audio_control_cur_4_t));
current_sample_rate = ((audio_control_cur_4_t *)buf)->bCur; current_sample_rate = ((audio_control_cur_4_t const *)buf)->bCur;
TU_LOG1("Clock set current freq: %d\r\n", current_sample_rate); TU_LOG1("Clock set current freq: %d\r\n", current_sample_rate);
@@ -264,7 +265,7 @@ static bool tud_audio_feature_unit_set_request(uint8_t rhport, audio_control_req
{ {
TU_VERIFY(request->wLength == sizeof(audio_control_cur_1_t)); TU_VERIFY(request->wLength == sizeof(audio_control_cur_1_t));
mute[request->bChannelNumber] = ((audio_control_cur_1_t *)buf)->bCur; mute[request->bChannelNumber] = ((audio_control_cur_1_t const *)buf)->bCur;
TU_LOG1("Set channel %d Mute: %d\r\n", request->bChannelNumber, mute[request->bChannelNumber]); TU_LOG1("Set channel %d Mute: %d\r\n", request->bChannelNumber, mute[request->bChannelNumber]);
@@ -295,7 +296,7 @@ static bool tud_audio_feature_unit_set_request(uint8_t rhport, audio_control_req
// Invoked when audio class specific get request received for an entity // Invoked when audio class specific get request received for an entity
bool tud_audio_get_req_entity_cb(uint8_t rhport, tusb_control_request_t const *p_request) bool tud_audio_get_req_entity_cb(uint8_t rhport, tusb_control_request_t const *p_request)
{ {
audio_control_request_t *request = (audio_control_request_t *)p_request; audio_control_request_t const *request = (audio_control_request_t const *)p_request;
if (request->bEntityID == UAC2_ENTITY_CLOCK) if (request->bEntityID == UAC2_ENTITY_CLOCK)
return tud_audio_clock_get_request(rhport, request); return tud_audio_clock_get_request(rhport, request);
@@ -81,15 +81,18 @@ uint8_t const * tud_descriptor_device_cb(void)
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ... // 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ...
#define EPNUM_AUDIO_IN 0x03 #define EPNUM_AUDIO_IN 0x03
#define EPNUM_AUDIO_OUT 0x03 #define EPNUM_AUDIO_OUT 0x03
#elif CFG_TUSB_MCU == OPT_MCU_NRF5X #elif CFG_TUSB_MCU == OPT_MCU_NRF5X
// ISO endpoints for NRF5x are fixed to 0x08 (0x88) // ISO endpoints for NRF5x are fixed to 0x08 (0x88)
#define EPNUM_AUDIO_IN 0x08 #define EPNUM_AUDIO_IN 0x08
#define EPNUM_AUDIO_OUT 0x08 #define EPNUM_AUDIO_OUT 0x08
#elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X #elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X
// SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT // SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT
// e.g EP1 OUT & EP1 IN cannot exist together // e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_AUDIO_IN 0x01 #define EPNUM_AUDIO_IN 0x01
#define EPNUM_AUDIO_OUT 0x02 #define EPNUM_AUDIO_OUT 0x02
#else #else
#define EPNUM_AUDIO_IN 0x01 #define EPNUM_AUDIO_IN 0x01
#define EPNUM_AUDIO_OUT 0x01 #define EPNUM_AUDIO_OUT 0x01
@@ -98,7 +101,7 @@ uint8_t const * tud_descriptor_device_cb(void)
uint8_t const desc_configuration[] = uint8_t const desc_configuration[] =
{ {
// Interface count, string index, total length, attribute, power in mA // Interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP Out & EP In address, EP size // Interface number, string index, EP Out & EP In address, EP size
TUD_AUDIO_HEADSET_STEREO_DESCRIPTOR(2, EPNUM_AUDIO_OUT, EPNUM_AUDIO_IN | 0x80) TUD_AUDIO_HEADSET_STEREO_DESCRIPTOR(2, EPNUM_AUDIO_OUT, EPNUM_AUDIO_IN | 0x80)
+1 -1
View File
@@ -122,7 +122,7 @@ enum
uint8_t const desc_configuration[] = uint8_t const desc_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
TUD_USBTMC_DESC(ITF_NUM_USBTMC), TUD_USBTMC_DESC(ITF_NUM_USBTMC),
}; };
@@ -0,0 +1 @@
too many warnings for 16-bit integer overflow
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.5)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
project(${PROJECT})
# Checks this example is valid for the family and initializes the project
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
add_executable(${PROJECT})
# Example source
target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
)
# Example include
target_include_directories(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# 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})
+12
View File
@@ -0,0 +1,12 @@
include ../../../tools/top.mk
include ../../make.mk
INC += \
src \
$(TOP)/hw \
# Example source
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
include ../../rules.mk
File diff suppressed because it is too large Load Diff
+222
View File
@@ -0,0 +1,222 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "bsp/board.h"
#include "tusb.h"
#include "usb_descriptors.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTYPES
//--------------------------------------------------------------------+
/* Blink pattern
* - 250 ms : device not mounted
* - 1000 ms : device mounted
* - 2500 ms : device is suspended
*/
enum {
BLINK_NOT_MOUNTED = 250,
BLINK_MOUNTED = 1000,
BLINK_SUSPENDED = 2500,
};
static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;
void led_blinking_task(void);
void video_task(void);
/*------------- MAIN -------------*/
int main(void)
{
board_init();
tusb_init();
while (1)
{
tud_task(); // tinyusb device task
led_blinking_task();
video_task();
}
return 0;
}
//--------------------------------------------------------------------+
// Device callbacks
//--------------------------------------------------------------------+
// Invoked when device is mounted
void tud_mount_cb(void)
{
blink_interval_ms = BLINK_MOUNTED;
}
// Invoked when device is unmounted
void tud_umount_cb(void)
{
blink_interval_ms = BLINK_NOT_MOUNTED;
}
// Invoked when usb bus is suspended
// remote_wakeup_en : if host allow us to perform remote wakeup
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
void tud_suspend_cb(bool remote_wakeup_en)
{
(void) remote_wakeup_en;
blink_interval_ms = BLINK_SUSPENDED;
}
// Invoked when usb bus is resumed
void tud_resume_cb(void)
{
blink_interval_ms = BLINK_MOUNTED;
}
//--------------------------------------------------------------------+
// USB Video
//--------------------------------------------------------------------+
static unsigned frame_num = 0;
static unsigned tx_busy = 0;
static unsigned interval_ms = 1000 / FRAME_RATE;
/* YUY2 frame buffer */
#ifdef CFG_EXAMPLE_VIDEO_READONLY
#include "images.h"
#else
static uint8_t frame_buffer[FRAME_WIDTH * FRAME_HEIGHT * 16 / 8];
static void fill_color_bar(uint8_t *buffer, unsigned start_position)
{
/* EBU color bars
* See also https://stackoverflow.com/questions/6939422 */
static uint8_t const bar_color[8][4] = {
/* Y, U, Y, V */
{ 235, 128, 235, 128}, /* 100% White */
{ 219, 16, 219, 138}, /* Yellow */
{ 188, 154, 188, 16}, /* Cyan */
{ 173, 42, 173, 26}, /* Green */
{ 78, 214, 78, 230}, /* Magenta */
{ 63, 102, 63, 240}, /* Red */
{ 32, 240, 32, 118}, /* Blue */
{ 16, 128, 16, 128}, /* Black */
};
uint8_t *p;
/* Generate the 1st line */
uint8_t *end = &buffer[FRAME_WIDTH * 2];
unsigned idx = (FRAME_WIDTH / 2 - 1) - (start_position % (FRAME_WIDTH / 2));
p = &buffer[idx * 4];
for (unsigned i = 0; i < 8; ++i) {
for (int j = 0; j < FRAME_WIDTH / (2 * 8); ++j) {
memcpy(p, &bar_color[i], 4);
p += 4;
if (end <= p) {
p = buffer;
}
}
}
/* Duplicate the 1st line to the others */
p = &buffer[FRAME_WIDTH * 2];
for (unsigned i = 1; i < FRAME_HEIGHT; ++i) {
memcpy(p, buffer, FRAME_WIDTH * 2);
p += FRAME_WIDTH * 2;
}
}
#endif
void video_task(void)
{
static unsigned start_ms = 0;
static unsigned already_sent = 0;
if (!tud_video_n_streaming(0, 0)) {
already_sent = 0;
frame_num = 0;
return;
}
if (!already_sent) {
already_sent = 1;
start_ms = board_millis();
#ifdef CFG_EXAMPLE_VIDEO_READONLY
tud_video_n_frame_xfer(0, 0, (void*)(uintptr_t) &frame_buffer[(frame_num % (FRAME_WIDTH / 2)) * 4],
FRAME_WIDTH * FRAME_HEIGHT * 16/8);
#else
fill_color_bar(frame_buffer, frame_num);
tud_video_n_frame_xfer(0, 0, (void*)frame_buffer, FRAME_WIDTH * FRAME_HEIGHT * 16/8);
#endif
}
unsigned cur = board_millis();
if (cur - start_ms < interval_ms) return; // not enough time
if (tx_busy) return;
start_ms += interval_ms;
#ifdef CFG_EXAMPLE_VIDEO_READONLY
tud_video_n_frame_xfer(0, 0, (void*)(uintptr_t) &frame_buffer[(frame_num % (FRAME_WIDTH / 2)) * 4],
FRAME_WIDTH * FRAME_HEIGHT * 16/8);
#else
fill_color_bar(frame_buffer, frame_num);
tud_video_n_frame_xfer(0, 0, (void*)frame_buffer, FRAME_WIDTH * FRAME_HEIGHT * 16/8);
#endif
}
void tud_video_frame_xfer_complete_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx)
{
(void)ctl_idx; (void)stm_idx;
tx_busy = 0;
/* flip buffer */
++frame_num;
}
int tud_video_commit_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx,
video_probe_and_commit_control_t const *parameters)
{
(void)ctl_idx; (void)stm_idx;
/* convert unit to ms from 100 ns */
interval_ms = parameters->dwFrameInterval / 10000;
return VIDEO_ERROR_NONE;
}
//--------------------------------------------------------------------+
// BLINKING TASK
//--------------------------------------------------------------------+
void led_blinking_task(void)
{
static uint32_t start_ms = 0;
static bool led_state = false;
// Blink every interval ms
if ( board_millis() - start_ms < blink_interval_ms) return; // not enough time
start_ms += blink_interval_ms;
board_led_write(led_state);
led_state = 1 - led_state; // toggle
}
@@ -0,0 +1,107 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#ifndef _TUSB_CONFIG_H_
#define _TUSB_CONFIG_H_
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------
// COMMON CONFIGURATION
//--------------------------------------------------------------------
// RHPort number used for device can be defined by board.mk, default to port 0
#ifndef BOARD_DEVICE_RHPORT_NUM
#define BOARD_DEVICE_RHPORT_NUM 0
#endif
// RHPort max operational speed can defined by board.mk
// Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed
#ifndef BOARD_DEVICE_RHPORT_SPEED
#if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \
CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56)
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED
#else
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
#endif
#endif
// Device mode with rhport and speed defined by board.mk
#if BOARD_DEVICE_RHPORT_NUM == 0
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
#elif BOARD_DEVICE_RHPORT_NUM == 1
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
#else
#error "Incorrect RHPort configuration"
#endif
// This example doesn't use an RTOS
#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_NONE
#endif
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
// #define CFG_TUSB_DEBUG 0
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
* Tinyusb use follows macros to declare transferring memory so that they can be put
* into those specific section.
* e.g
* - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
* - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
*/
#ifndef CFG_TUSB_MEM_SECTION
#define CFG_TUSB_MEM_SECTION
#endif
#ifndef CFG_TUSB_MEM_ALIGN
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
#endif
//--------------------------------------------------------------------
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
#ifndef CFG_TUD_ENDPOINT0_SIZE
#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
// The number of video control interfaces
#define CFG_TUD_VIDEO 1
// The number of video streaming interfaces
#define CFG_TUD_VIDEO_STREAMING 1
// video streaming endpoint size
#define CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE 256
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_CONFIG_H_ */
@@ -0,0 +1,166 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include "tusb.h"
#include "usb_descriptors.h"
/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
* Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
*
* Auto ProductID layout's Bitmap:
* [MSB] VIDEO | AUDIO | MIDI | HID | MSC | CDC [LSB]
*/
#define _PID_MAP(itf, n) ( (CFG_TUD_##itf) << (n) )
#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) | _PID_MAP(AUDIO, 4) | _PID_MAP(VIDEO, 5) | _PID_MAP(VENDOR, 6) )
//--------------------------------------------------------------------+
// Device Descriptors
//--------------------------------------------------------------------+
tusb_desc_device_t const desc_device =
{
.bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200,
// Use Interface Association Descriptor (IAD) for Video
// As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
.bDeviceClass = TUSB_CLASS_MISC,
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
.bDeviceProtocol = MISC_PROTOCOL_IAD,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
.bcdDevice = 0x0100,
.iManufacturer = 0x01,
.iProduct = 0x02,
.iSerialNumber = 0x03,
.bNumConfigurations = 0x01
};
// Invoked when received GET DEVICE DESCRIPTOR
// Application return pointer to descriptor
uint8_t const * tud_descriptor_device_cb(void)
{
return (uint8_t const *) &desc_device;
}
//--------------------------------------------------------------------+
// Configuration Descriptor
//--------------------------------------------------------------------+
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_VIDEO_CAPTURE_DESC_LEN)
#if TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In, 5 Bulk etc ...
#define EPNUM_VIDEO_IN 0x83
#elif TU_CHECK_MCU(OPT_MCU_NRF5X)
// nRF5x ISO can only be endpoint 8
#define EPNUM_VIDEO_IN 0x88
#else
#define EPNUM_VIDEO_IN 0x81
#endif
uint8_t const desc_fs_configuration[] =
{
// Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0, 500),
// IAD for Video Control
TUD_VIDEO_CAPTURE_DESCRIPTOR(4, EPNUM_VIDEO_IN,
FRAME_WIDTH, FRAME_HEIGHT, FRAME_RATE,
CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE)
};
// Invoked when received GET CONFIGURATION DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
{
(void) index; // for multiple configurations
return desc_fs_configuration;
}
//--------------------------------------------------------------------+
// String Descriptors
//--------------------------------------------------------------------+
// array of pointer to string descriptors
char const* string_desc_arr [] =
{
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer
"TinyUSB Device", // 2: Product
"123456", // 3: Serials, should use chip ID
"TinyUSB UVC", // 4: UVC Interface
};
static uint16_t _desc_str[32];
// Invoked when received GET STRING DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
{
(void) langid;
uint8_t chr_count;
if ( index == 0)
{
memcpy(&_desc_str[1], string_desc_arr[0], 2);
chr_count = 1;
}else
{
// Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors
if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) return NULL;
const char* str = string_desc_arr[index];
// Cap at max char
chr_count = strlen(str);
if ( chr_count > 31 ) chr_count = 31;
// Convert ASCII string into UTF-16
for(uint8_t i=0; i<chr_count; i++)
{
_desc_str[1+i] = str[i];
}
}
// first byte is length (including header), second byte is string type
_desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
return _desc_str;
}
@@ -0,0 +1,113 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Jerzy Kasenbreg
* Copyright (c) 2021 Koji KITAYAMA
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#ifndef _USB_DESCRIPTORS_H_
#define _USB_DESCRIPTORS_H_
/* Time stamp base clock. It is a deprecated parameter. */
#define UVC_CLOCK_FREQUENCY 27000000
/* video capture path */
#define UVC_ENTITY_CAP_INPUT_TERMINAL 0x01
#define UVC_ENTITY_CAP_OUTPUT_TERMINAL 0x02
#define FRAME_WIDTH 128
#define FRAME_HEIGHT 96
#define FRAME_RATE 10
enum {
ITF_NUM_VIDEO_CONTROL = 0,
ITF_NUM_VIDEO_STREAMING,
ITF_NUM_TOTAL
};
#define TUD_VIDEO_CAPTURE_DESC_LEN (\
TUD_VIDEO_DESC_IAD_LEN\
/* control */\
+ TUD_VIDEO_DESC_STD_VC_LEN\
+ (TUD_VIDEO_DESC_CS_VC_LEN + 1/*bInCollection*/)\
+ TUD_VIDEO_DESC_CAMERA_TERM_LEN\
+ TUD_VIDEO_DESC_OUTPUT_TERM_LEN\
/* Interface 1, Alternate 0 */\
+ TUD_VIDEO_DESC_STD_VS_LEN\
+ (TUD_VIDEO_DESC_CS_VS_IN_LEN + 1/*bNumFormats x bControlSize*/)\
+ TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR_LEN\
+ TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_CONT_LEN\
+ TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING_LEN\
/* Interface 1, Alternate 1 */\
+ TUD_VIDEO_DESC_STD_VS_LEN\
+ 7/* Endpoint */\
)
/* Windows support YUY2 and NV12
* https://docs.microsoft.com/en-us/windows-hardware/drivers/stream/usb-video-class-driver-overview */
#define TUD_VIDEO_DESC_CS_VS_FMT_YUY2(_fmtidx, _numfmtdesc, _frmidx, _asrx, _asry, _interlace, _cp) \
TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR(_fmtidx, _numfmtdesc, TUD_VIDEO_GUID_YUY2, 16, _frmidx, _asrx, _asry, _interlace, _cp)
#define TUD_VIDEO_DESC_CS_VS_FMT_NV12(_fmtidx, _numfmtdesc, _frmidx, _asrx, _asry, _interlace, _cp) \
TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR(_fmtidx, _numfmtdesc, TUD_VIDEO_GUID_NV12, 12, _frmidx, _asrx, _asry, _interlace, _cp)
#define TUD_VIDEO_DESC_CS_VS_FMT_M420(_fmtidx, _numfmtdesc, _frmidx, _asrx, _asry, _interlace, _cp) \
TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR(_fmtidx, _numfmtdesc, TUD_VIDEO_GUID_M420, 12, _frmidx, _asrx, _asry, _interlace, _cp)
#define TUD_VIDEO_DESC_CS_VS_FMT_I420(_fmtidx, _numfmtdesc, _frmidx, _asrx, _asry, _interlace, _cp) \
TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR(_fmtidx, _numfmtdesc, TUD_VIDEO_GUID_I420, 12, _frmidx, _asrx, _asry, _interlace, _cp)
#define TUD_VIDEO_CAPTURE_DESCRIPTOR(_stridx, _epin, _width, _height, _fps, _epsize) \
TUD_VIDEO_DESC_IAD(ITF_NUM_VIDEO_CONTROL, ITF_NUM_TOTAL, _stridx), \
/* Video control 0 */ \
TUD_VIDEO_DESC_STD_VC(ITF_NUM_VIDEO_CONTROL, 0, _stridx), \
TUD_VIDEO_DESC_CS_VC( /* UVC 1.5*/ 0x0150, \
/* wTotalLength - bLength */ \
TUD_VIDEO_DESC_CAMERA_TERM_LEN + TUD_VIDEO_DESC_OUTPUT_TERM_LEN, \
UVC_CLOCK_FREQUENCY, 1), \
TUD_VIDEO_DESC_CAMERA_TERM(UVC_ENTITY_CAP_INPUT_TERMINAL, 0, 0,\
/*wObjectiveFocalLengthMin*/0, /*wObjectiveFocalLengthMax*/0,\
/*wObjectiveFocalLength*/0, /*bmControls*/0), \
TUD_VIDEO_DESC_OUTPUT_TERM(UVC_ENTITY_CAP_OUTPUT_TERMINAL, VIDEO_TT_STREAMING, 0, 1, 0), \
/* Video stream alt. 0 */ \
TUD_VIDEO_DESC_STD_VS( 1, 0, 0, 0), \
/* Video stream header for without still image capture */ \
TUD_VIDEO_DESC_CS_VS_INPUT( /*bNumFormats*/1, \
/*wTotalLength - bLength */\
TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR_LEN\
+ TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_CONT_LEN\
+ TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING_LEN,\
_epin, /*bmInfo*/0, /*bTerminalLink*/UVC_ENTITY_CAP_OUTPUT_TERMINAL, \
/*bStillCaptureMethod*/0, /*bTriggerSupport*/0, /*bTriggerUsage*/0, \
/*bmaControls(1)*/0), \
/* Video stream format */ \
TUD_VIDEO_DESC_CS_VS_FMT_YUY2(/*bFormatIndex*/1, /*bNumFrameDescriptors*/1, \
/*bDefaultFrameIndex*/1, 0, 0, 0, /*bCopyProtect*/0), \
/* Video stream frame format */ \
TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_CONT(/*bFrameIndex */1, 0, _width, _height, \
_width * _height * 16, _width * _height * 16 * _fps, \
_width * _height * 16, \
(10000000/_fps), (10000000/_fps), 10000000, 100000), \
TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING(VIDEO_COLOR_PRIMARIES_BT709, VIDEO_COLOR_XFER_CH_BT709, VIDEO_COLOR_COEF_SMPTE170M), \
/* VS alt 1 */\
TUD_VIDEO_DESC_STD_VS(1, 1, 1, 0), \
/* EP */ \
TUD_VIDEO_DESC_EP_ISO(_epin, _epsize, 1)
#endif
+2 -2
View File
@@ -179,7 +179,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
case VENDOR_REQUEST_WEBUSB: case VENDOR_REQUEST_WEBUSB:
// match vendor request in BOS descriptor // match vendor request in BOS descriptor
// Get landing page url // Get landing page url
return tud_control_xfer(rhport, request, (void*) &desc_url, desc_url.bLength); return tud_control_xfer(rhport, request, (void*)(uintptr_t) &desc_url, desc_url.bLength);
case VENDOR_REQUEST_MICROSOFT: case VENDOR_REQUEST_MICROSOFT:
if ( request->wIndex == 7 ) if ( request->wIndex == 7 )
@@ -188,7 +188,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
uint16_t total_len; uint16_t total_len;
memcpy(&total_len, desc_ms_os_20+8, 2); memcpy(&total_len, desc_ms_os_20+8, 2);
return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len); return tud_control_xfer(rhport, request, (void*)(uintptr_t) desc_ms_os_20, total_len);
}else }else
{ {
return false; return false;
@@ -107,7 +107,7 @@ enum
uint8_t const desc_configuration[] = uint8_t const desc_configuration[] =
{ {
// Config number, interface count, string index, total length, attribute, power in mA // Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP notification address and size, EP data address (out, in) and size. // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, 0x81, 8, EPNUM_CDC_OUT, 0x80 | EPNUM_CDC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64), TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, 0x81, 8, EPNUM_CDC_OUT, 0x80 | EPNUM_CDC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64),
+1
View File
@@ -7,3 +7,4 @@ family_initialize_project(tinyusb_host_examples ${CMAKE_CURRENT_LIST_DIR})
# family_add_subdirectory will filter what to actually add based on selected FAMILY # family_add_subdirectory will filter what to actually add based on selected FAMILY
family_add_subdirectory(cdc_msc_hid) family_add_subdirectory(cdc_msc_hid)
family_add_subdirectory(hid_controller)
+2 -3
View File
@@ -9,7 +9,8 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c) EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE)) SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
CFLAGS += -Wno-error=cast-align # TODO: suppress warning caused by host stack
CFLAGS += -Wno-error=cast-align -Wno-error=null-dereference
# TinyUSB Host Stack source # TinyUSB Host Stack source
SRC_C += \ SRC_C += \
@@ -19,9 +20,7 @@ SRC_C += \
src/host/hub.c \ src/host/hub.c \
src/host/usbh.c \ src/host/usbh.c \
src/host/usbh_control.c \ src/host/usbh_control.c \
src/portable/ehci/ehci.c \
src/portable/ohci/ohci.c \ src/portable/ohci/ohci.c \
src/portable/nxp/transdimension/hcd_transdimension.c \
src/portable/nxp/lpc17_40/hcd_lpc17_40.c src/portable/nxp/lpc17_40/hcd_lpc17_40.c
include ../../rules.mk include ../../rules.mk
+2 -3
View File
@@ -12,7 +12,8 @@ EXAMPLE_SOURCE += \
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE)) SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
CFLAGS += -Wno-error=cast-align # TODO: suppress warning caused by host stack
CFLAGS += -Wno-error=cast-align -Wno-error=null-dereference
# TinyUSB Host Stack source # TinyUSB Host Stack source
SRC_C += \ SRC_C += \
@@ -22,9 +23,7 @@ SRC_C += \
src/host/hub.c \ src/host/hub.c \
src/host/usbh.c \ src/host/usbh.c \
src/host/usbh_control.c \ src/host/usbh_control.c \
src/portable/ehci/ehci.c \
src/portable/ohci/ohci.c \ src/portable/ohci/ohci.c \
src/portable/nxp/transdimension/hcd_transdimension.c \
src/portable/nxp/lpc17_40/hcd_lpc17_40.c src/portable/nxp/lpc17_40/hcd_lpc17_40.c
include ../../rules.mk include ../../rules.mk
+7 -1
View File
@@ -111,7 +111,11 @@ static inline bool is_sony_ds4(uint8_t dev_addr)
uint16_t vid, pid; uint16_t vid, pid;
tuh_vid_pid_get(dev_addr, &vid, &pid); tuh_vid_pid_get(dev_addr, &vid, &pid);
return (vid == 0x054c && pid == 0x09cc); return ( (vid == 0x054c && (pid == 0x09cc || pid == 0x05c4)) // Sony DualShock4
|| (vid == 0x0f0d && pid == 0x005e) // Hori FC4
|| (vid == 0x0f0d && pid == 0x00ee) // Hori PS4 Mini (PS4-099U)
|| (vid == 0x1f4f && pid == 0x1002) // ASW GG xrd controller
);
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -134,6 +138,8 @@ void hid_app_task(void)
// therefore report_desc = NULL, desc_len = 0 // therefore report_desc = NULL, desc_len = 0
void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len) void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len)
{ {
(void)desc_report;
(void)desc_len;
uint16_t vid, pid; uint16_t vid, pid;
tuh_vid_pid_get(dev_addr, &vid, &pid); tuh_vid_pid_get(dev_addr, &vid, &pid);
+1
View File
@@ -49,6 +49,7 @@ int main(void)
board_init(); board_init();
printf("TinyUSB Host HID Controller Example\r\n"); printf("TinyUSB Host HID Controller Example\r\n");
printf("Note: Events only displayed for explictly supported controllers\r\n");
tusb_init(); tusb_init();
+5 -1
View File
@@ -65,10 +65,12 @@ MKDIR = mkdir
ifeq ($(CMDEXE),1) ifeq ($(CMDEXE),1)
CP = copy CP = copy
RM = del RM = del
PYTHON = python
else else
SED = sed SED = sed
CP = cp CP = cp
RM = rm RM = rm
PYTHON = python3
endif endif
#-------------- Source files and compiler flags -------------- #-------------- Source files and compiler flags --------------
@@ -102,7 +104,9 @@ CFLAGS += \
-Wmissing-format-attribute \ -Wmissing-format-attribute \
-Wunreachable-code \ -Wunreachable-code \
-Wcast-align \ -Wcast-align \
-Wcast-function-type -Wcast-function-type \
-Wcast-qual \
-Wnull-dereference
# Debugging/Optimization # Debugging/Optimization
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
+32 -14
View File
@@ -5,12 +5,11 @@
# Set all as default goal # Set all as default goal
.DEFAULT_GOAL := all .DEFAULT_GOAL := all
# ESP32-SX and RP2040 has its own CMake build system # ESP32-Sx and RP2040 has its own CMake build system
ifneq ($(FAMILY),esp32s2) ifeq (,$(findstring $(FAMILY),esp32s2 esp32s3 rp2040))
ifneq ($(FAMILY),esp32s3)
ifneq ($(FAMILY),rp2040)
# --------------------------------------- # ---------------------------------------
# GNU Make build system # Compiler Flags
# --------------------------------------- # ---------------------------------------
# libc # libc
@@ -33,8 +32,10 @@ SRC_C += \
src/class/hid/hid_device.c \ src/class/hid/hid_device.c \
src/class/midi/midi_device.c \ src/class/midi/midi_device.c \
src/class/msc/msc_device.c \ src/class/msc/msc_device.c \
src/class/net/net_device.c \ src/class/net/ecm_rndis_device.c \
src/class/net/ncm_device.c \
src/class/usbtmc/usbtmc_device.c \ src/class/usbtmc/usbtmc_device.c \
src/class/video/video_device.c \
src/class/vendor/vendor_device.c src/class/vendor/vendor_device.c
# TinyUSB stack include # TinyUSB stack include
@@ -42,6 +43,12 @@ INC += $(TOP)/src
CFLAGS += $(addprefix -I,$(INC)) CFLAGS += $(addprefix -I,$(INC))
# LTO makes it difficult to analyze map file for optimizing size purpose
# We will run this option in ci
ifeq ($(NO_LTO),1)
CFLAGS := $(filter-out -flto,$(CFLAGS))
endif
LDFLAGS += $(CFLAGS) -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections LDFLAGS += $(CFLAGS) -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections
ifneq ($(SKIP_NANOLIB), 1) ifneq ($(SKIP_NANOLIB), 1)
LDFLAGS += -specs=nosys.specs -specs=nano.specs LDFLAGS += -specs=nosys.specs -specs=nano.specs
@@ -65,6 +72,10 @@ $(info LDFLAGS $(LDFLAGS)) $(info )
$(info ASFLAGS $(ASFLAGS)) $(info ) $(info ASFLAGS $(ASFLAGS)) $(info )
endif endif
# ---------------------------------------
# Rules
# ---------------------------------------
all: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex size all: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex size
uf2: $(BUILD)/$(PROJECT).uf2 uf2: $(BUILD)/$(PROJECT).uf2
@@ -124,11 +135,17 @@ $(BUILD)/obj/%_asm.o: %.S
@echo AS $(notdir $@) @echo AS $(notdir $@)
@$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< @$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
endif # GNU Make
size: $(BUILD)/$(PROJECT).elf size: $(BUILD)/$(PROJECT).elf
-@echo '' -@echo ''
@$(SIZE) $< @$(SIZE) $<
-@echo '' -@echo ''
# linkermap must be install previously at https://github.com/hathach/linkermap
linkermap: $(BUILD)/$(PROJECT).elf
@linkermap -v $<.map
.PHONY: clean .PHONY: clean
clean: clean:
ifeq ($(CMDEXE),1) ifeq ($(CMDEXE),1)
@@ -137,21 +154,18 @@ else
$(RM) -rf $(BUILD) $(RM) -rf $(BUILD)
endif endif
endif
endif
endif # GNU Make
# --------------------------------------- # ---------------------------------------
# Flash Targets # Flash Targets
# --------------------------------------- # ---------------------------------------
# Flash binary using Jlink # Jlink binary
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
JLINKEXE = JLink.exe JLINKEXE = JLink.exe
else else
JLINKEXE = JLinkExe JLINKEXE = JLinkExe
endif endif
# Jlink Interface
JLINK_IF ?= swd JLINK_IF ?= swd
# Flash using jlink # Flash using jlink
@@ -164,18 +178,22 @@ flash-jlink: $(BUILD)/$(PROJECT).hex
@echo exit >> $(BUILD)/$(BOARD).jlink @echo exit >> $(BUILD)/$(BOARD).jlink
$(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -JTAGConf -1,-1 -speed auto -CommandFile $(BUILD)/$(BOARD).jlink $(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -JTAGConf -1,-1 -speed auto -CommandFile $(BUILD)/$(BOARD).jlink
# flash STM32 MCU using stlink with STM32 Cube Programmer CLI # Flash STM32 MCU using stlink with STM32 Cube Programmer CLI
flash-stlink: $(BUILD)/$(PROJECT).elf flash-stlink: $(BUILD)/$(PROJECT).elf
STM32_Programmer_CLI --connect port=swd --write $< --go STM32_Programmer_CLI --connect port=swd --write $< --go
# flash with pyocd # Flash using pyocd
PYOCD_OPTION ?= PYOCD_OPTION ?=
flash-pyocd: $(BUILD)/$(PROJECT).hex flash-pyocd: $(BUILD)/$(PROJECT).hex
pyocd flash -t $(PYOCD_TARGET) $(PYOCD_OPTION) $< pyocd flash -t $(PYOCD_TARGET) $(PYOCD_OPTION) $<
pyocd reset -t $(PYOCD_TARGET) pyocd reset -t $(PYOCD_TARGET)
# flash with Black Magic Probe # Flash using openocd
OPENOCD_OPTION ?=
flash-openocd: $(BUILD)/$(PROJECT).elf
openocd $(OPENOCD_OPTION) -c "program $< verify reset exit"
# flash with Black Magic Probe
# This symlink is created by https://github.com/blacksphere/blackmagic/blob/master/driver/99-blackmagic.rules # This symlink is created by https://github.com/blacksphere/blackmagic/blob/master/driver/99-blackmagic.rules
BMP ?= /dev/ttyBmpGdb BMP ?= /dev/ttyBmpGdb
+5 -3
View File
@@ -96,7 +96,7 @@ void board_led_task(void)
TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count) TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
{ {
(void) fhdl; (void) fhdl;
SEGGER_RTT_Write(0, (char*) buf, (int) count); SEGGER_RTT_Write(0, (const char*) buf, (int) count);
return count; return count;
} }
@@ -126,6 +126,8 @@ TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
{ {
(void) fhdl; (void) fhdl;
(void) buf;
(void) count;
return 0; return 0;
} }
@@ -135,13 +137,13 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count) TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
{ {
(void) fhdl; (void) fhdl;
return board_uart_write(buf, count); return board_uart_write(buf, (int) count);
} }
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
{ {
(void) fhdl; (void) fhdl;
return board_uart_read((uint8_t*) buf, count); return board_uart_read((uint8_t*) buf, (int) count);
} }
#endif #endif
+13 -1
View File
@@ -98,6 +98,9 @@
#elif CFG_TUSB_MCU == OPT_MCU_MSP430x5xx #elif CFG_TUSB_MCU == OPT_MCU_MSP430x5xx
#include "msp430.h" #include "msp430.h"
#elif CFG_TUSB_MCU == OPT_MCU_MSP432E4
#include "msp.h"
#elif CFG_TUSB_MCU == OPT_MCU_VALENTYUSB_EPTRI #elif CFG_TUSB_MCU == OPT_MCU_VALENTYUSB_EPTRI
// no header needed // no header needed
@@ -125,7 +128,7 @@
#elif CFG_TUSB_MCU == OPT_MCU_RP2040 #elif CFG_TUSB_MCU == OPT_MCU_RP2040
#include "pico.h" #include "pico.h"
#elif CFG_TUSB_MCU == OPT_MCU_EFM32GG || CFG_TUSB_MCU == OPT_MCU_EFM32GG11 || CFG_TUSB_MCU == OPT_MCU_EFM32GG12 #elif CFG_TUSB_MCU == OPT_MCU_EFM32GG
#include "em_device.h" #include "em_device.h"
#elif CFG_TUSB_MCU == OPT_MCU_RX63X || CFG_TUSB_MCU == OPT_MCU_RX65X #elif CFG_TUSB_MCU == OPT_MCU_RX63X || CFG_TUSB_MCU == OPT_MCU_RX65X
@@ -134,6 +137,15 @@
#elif CFG_TUSB_MCU == OPT_MCU_GD32VF103 #elif CFG_TUSB_MCU == OPT_MCU_GD32VF103
#include "gd32vf103.h" #include "gd32vf103.h"
#elif CFG_TUSB_MCU == OPT_MCU_MM32F327X
#include "mm32_device.h"
#elif CFG_TUSB_MCU == OPT_MCU_XMC4000
#include "xmc_device.h"
#elif CFG_TUSB_MCU == OPT_MCU_TM4C123
#include "TM4C123.h"
#else #else
#error "Missing MCU header" #error "Missing MCU header"
#endif #endif
+3
View File
@@ -18,6 +18,9 @@ CFLAGS += \
-DSVC_Handler=SVCall_Handler \ -DSVC_Handler=SVCall_Handler \
-DHWREV=$(HWREV) -DHWREV=$(HWREV)
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=cast-qual
# All source paths should be relative to the top level. # All source paths should be relative to the top level.
LD_FILE = hw/bsp/$(BOARD)/same51j19a_flash.ld LD_FILE = hw/bsp/$(BOARD)/same51j19a_flash.ld
+11 -4
View File
@@ -53,6 +53,9 @@ void UnhandledIRQ(void)
while(1); while(1);
} }
// DA146xx driver function that must be called whenever VBUS changes.
extern void tusb_vbus_changed(bool present);
void board_init(void) void board_init(void)
{ {
// LED // LED
@@ -65,12 +68,15 @@ void board_init(void)
hal_gpio_init_out(5, 0); hal_gpio_init_out(5, 0);
// Button // Button
hal_gpio_init_in(BUTTON_PIN, HAL_GPIO_PULL_NONE); hal_gpio_init_in(BUTTON_PIN, HAL_GPIO_PULL_DOWN);
// 1ms tick timer // 1ms tick timer
SysTick_Config(SystemCoreClock / 1000); SysTick_Config(SystemCoreClock / 1000);
NVIC_SetPriority(USB_IRQn, 2); #if TUSB_OPT_DEVICE_ENABLED
// This board is USB powered there is no need to monitor
// VBUS line. Notify driver that VBUS is present.
tusb_vbus_changed(true);
/* Setup USB IRQ */ /* Setup USB IRQ */
NVIC_SetPriority(USB_IRQn, 2); NVIC_SetPriority(USB_IRQn, 2);
@@ -81,6 +87,7 @@ void board_init(void)
mcu_gpio_set_pin_function(14, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB); mcu_gpio_set_pin_function(14, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB);
mcu_gpio_set_pin_function(15, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB); mcu_gpio_set_pin_function(15, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB);
#endif
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -94,8 +101,8 @@ void board_led_write(bool state)
uint32_t board_button_read(void) uint32_t board_button_read(void)
{ {
// button is active LOW // button is active HIGH
return hal_gpio_read(BUTTON_PIN) ^ 1; return hal_gpio_read(BUTTON_PIN);
} }
int board_uart_read(uint8_t* buf, int len) int board_uart_read(uint8_t* buf, int len)
+26 -2
View File
@@ -36,6 +36,21 @@ void USB_IRQHandler(void)
tud_int_handler(0); tud_int_handler(0);
} }
#if TUSB_OPT_DEVICE_ENABLED
// DA146xx driver function that must be called whenever VBUS changes
extern void tusb_vbus_changed(bool present);
// VBUS change interrupt handler
void VBUS_IRQHandler(void)
{
bool present = (CRG_TOP->ANA_STATUS_REG & CRG_TOP_ANA_STATUS_REG_VBUS_AVAILABLE_Msk) != 0;
// Clear VBUS interrupt
CRG_TOP->VBUS_IRQ_CLEAR_REG = 1;
tusb_vbus_changed(present);
}
#endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM // MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@@ -65,12 +80,20 @@ void board_init(void)
hal_gpio_init_out(5, 0); hal_gpio_init_out(5, 0);
// Button // Button
hal_gpio_init_in(BUTTON_PIN, HAL_GPIO_PULL_NONE); hal_gpio_init_in(BUTTON_PIN, HAL_GPIO_PULL_UP);
// 1ms tick timer // 1ms tick timer
SysTick_Config(SystemCoreClock / 1000); SysTick_Config(SystemCoreClock / 1000);
NVIC_SetPriority(USB_IRQn, 2); #if TUSB_OPT_DEVICE_ENABLED
// Setup interrupt for both connect and disconnect
CRG_TOP->VBUS_IRQ_MASK_REG = CRG_TOP_VBUS_IRQ_MASK_REG_VBUS_IRQ_EN_FALL_Msk |
CRG_TOP_VBUS_IRQ_MASK_REG_VBUS_IRQ_EN_RISE_Msk;
NVIC_SetPriority(VBUS_IRQn, 2);
// Trigger interrupt at the start to inform driver about VBUS state at start
// otherwise it could go unnoticed.
NVIC_SetPendingIRQ(VBUS_IRQn);
NVIC_EnableIRQ(VBUS_IRQn);
/* Setup USB IRQ */ /* Setup USB IRQ */
NVIC_SetPriority(USB_IRQn, 2); NVIC_SetPriority(USB_IRQn, 2);
@@ -81,6 +104,7 @@ void board_init(void)
mcu_gpio_set_pin_function(14, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB); mcu_gpio_set_pin_function(14, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB);
mcu_gpio_set_pin_function(15, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB); mcu_gpio_set_pin_function(15, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB);
#endif
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
+1 -1
View File
@@ -14,7 +14,7 @@ CFLAGS += \
-DCFG_TUSB_MCU=OPT_MCU_LPC40XX -DCFG_TUSB_MCU=OPT_MCU_LPC40XX
# mcu driver cause following warnings # mcu driver cause following warnings
CFLAGS += -Wno-error=strict-prototypes -Wno-error=unused-parameter CFLAGS += -Wno-error=strict-prototypes -Wno-error=unused-parameter -Wno-error=cast-qual
MCU_DIR = hw/mcu/nxp/lpcopen/lpc40xx/lpc_chip_40xx MCU_DIR = hw/mcu/nxp/lpcopen/lpc40xx/lpc_chip_40xx
+4 -2
View File
@@ -13,7 +13,7 @@ CFLAGS += \
-DCFG_TUSB_MCU=OPT_MCU_LPC43XX -DCFG_TUSB_MCU=OPT_MCU_LPC43XX
# mcu driver cause following warnings # mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes -Wno-error=cast-qual
MCU_DIR = hw/mcu/nxp/lpcopen/lpc43xx/lpc_chip_43xx MCU_DIR = hw/mcu/nxp/lpcopen/lpc43xx/lpc_chip_43xx
@@ -21,7 +21,9 @@ MCU_DIR = hw/mcu/nxp/lpcopen/lpc43xx/lpc_chip_43xx
LD_FILE = hw/bsp/$(BOARD)/lpc4357.ld LD_FILE = hw/bsp/$(BOARD)/lpc4357.ld
SRC_C += \ SRC_C += \
src/portable/nxp/transdimension/dcd_transdimension.c \ src/portable/chipidea/ci_hs/dcd_ci_hs.c \
src/portable/chipidea/ci_hs/hcd_ci_hs.c \
src/portable/ehci/ehci.c \
$(MCU_DIR)/../gcc/cr_startup_lpc43xx.c \ $(MCU_DIR)/../gcc/cr_startup_lpc43xx.c \
$(MCU_DIR)/src/chip_18xx_43xx.c \ $(MCU_DIR)/src/chip_18xx_43xx.c \
$(MCU_DIR)/src/clock_18xx_43xx.c \ $(MCU_DIR)/src/clock_18xx_43xx.c \
-2
View File
@@ -6,9 +6,7 @@ idf_component_register(SRCS esp32s2.c
# Apply board specific content # Apply board specific content
include("${BOARD}/board.cmake") include("${BOARD}/board.cmake")
idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
target_include_directories(${COMPONENT_TARGET} PUBLIC target_include_directories(${COMPONENT_TARGET} PUBLIC
"${FREERTOS_ORIG_INCLUDE_PATH}"
"${TOP}/hw" "${TOP}/hw"
"${TOP}/src" "${TOP}/src"
) )
+1 -4
View File
@@ -7,14 +7,11 @@ all:
build: all build: all
clean:
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) clean
fullclean: fullclean:
if test -f sdkconfig; then $(RM) -f sdkconfig ; fi if test -f sdkconfig; then $(RM) -f sdkconfig ; fi
if test -d $(BUILD); then $(RM) -rf $(BUILD) ; fi if test -d $(BUILD); then $(RM) -rf $(BUILD) ; fi
flash bootloader-flash app-flash erase monitor dfu-flash dfu: clean flash bootloader-flash app-flash erase monitor dfu-flash dfu size size-components size-files:
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) $@ idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) $@
uf2: $(BUILD)/$(PROJECT).uf2 uf2: $(BUILD)/$(PROJECT).uf2
+6 -1
View File
@@ -101,9 +101,14 @@ int board_uart_read(uint8_t* buf, int len)
int board_uart_write(void const * buf, int len) int board_uart_write(void const * buf, int len)
{ {
int32_t offset = 0; int32_t offset = 0;
uint8_t const* buf8 = (uint8_t const*) buf;
for (offset = 0; offset < len; offset++) for (offset = 0; offset < len; offset++)
{
if (!(messible_status_read() & CSR_MESSIBLE_STATUS_FULL_OFFSET)) if (!(messible_status_read() & CSR_MESSIBLE_STATUS_FULL_OFFSET))
messible_in_write(((uint8_t *)buf)[offset]); {
messible_in_write(buf8[offset]);
}
}
return len; return len;
} }
+1 -1
View File
@@ -122,7 +122,7 @@ int board_uart_read(uint8_t* buf, int len)
int board_uart_write(void const * buf, int len) int board_uart_write(void const * buf, int len)
{ {
LPUART_WriteBlocking(UART_PORT, (uint8_t*)buf, len); LPUART_WriteBlocking(UART_PORT, (uint8_t const*) buf, len);
return len; return len;
} }
+7 -2
View File
@@ -6,10 +6,15 @@ CFLAGS += \
-mabi=aapcs \ -mabi=aapcs \
-mcpu=cortex-m0plus \ -mcpu=cortex-m0plus \
-DCPU_MKL25Z128VLK4 \ -DCPU_MKL25Z128VLK4 \
-DCFG_TUSB_MCU=OPT_MCU_MKL25ZXX -DCFG_TUSB_MCU=OPT_MCU_MKL25ZXX \
-DCFG_EXAMPLE_VIDEO_READONLY
LDFLAGS += \
-Wl,--defsym,__stack_size__=0x400 \
-Wl,--defsym,__heap_size__=0
# mcu driver cause following warnings # mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter CFLAGS += -Wno-error=unused-parameter -Wno-error=format
MCU_DIR = $(SDK_DIR)/devices/MKL25Z4 MCU_DIR = $(SDK_DIR)/devices/MKL25Z4
+25 -2
View File
@@ -54,6 +54,14 @@ void USB0_IRQHandler(void)
#define LED_PIN_FUNCTION kPORT_MuxAsGpio #define LED_PIN_FUNCTION kPORT_MuxAsGpio
#define LED_STATE_ON 0 #define LED_STATE_ON 0
// Button
#define BUTTON_PORT GPIOC
#define BUTTON_PIN_CLOCK kCLOCK_PortC
#define BUTTON_PIN_PORT PORTC
#define BUTTON_PIN 9U
#define BUTTON_PIN_FUNCTION kPORT_MuxAsGpio
#define BUTTON_STATE_ACTIVE 0
// UART // UART
#define UART_PORT UART0 #define UART_PORT UART0
#define UART_PIN_CLOCK kCLOCK_PortA #define UART_PIN_CLOCK kCLOCK_PortA
@@ -84,7 +92,19 @@ void board_init(void)
PORT_SetPinMux(LED_PIN_PORT, LED_PIN, LED_PIN_FUNCTION); PORT_SetPinMux(LED_PIN_PORT, LED_PIN, LED_PIN_FUNCTION);
gpio_pin_config_t led_config = { kGPIO_DigitalOutput, 0 }; gpio_pin_config_t led_config = { kGPIO_DigitalOutput, 0 };
GPIO_PinInit(LED_PORT, LED_PIN, &led_config); GPIO_PinInit(LED_PORT, LED_PIN, &led_config);
board_led_write(true); board_led_write(false);
#if defined(BUTTON_PORT) && defined(BUTTON_PIN)
// Button
CLOCK_EnableClock(BUTTON_PIN_CLOCK);
port_pin_config_t button_port = {
.pullSelect = kPORT_PullUp,
.mux = BUTTON_PIN_FUNCTION,
};
PORT_SetPinConfig(BUTTON_PIN_PORT, BUTTON_PIN, &button_port);
gpio_pin_config_t button_config = { kGPIO_DigitalInput, 0 };
GPIO_PinInit(BUTTON_PORT, BUTTON_PIN, &button_config);
#endif
// UART // UART
CLOCK_EnableClock(UART_PIN_CLOCK); CLOCK_EnableClock(UART_PIN_CLOCK);
@@ -119,6 +139,9 @@ void board_led_write(bool state)
uint32_t board_button_read(void) uint32_t board_button_read(void)
{ {
#if defined(BUTTON_PORT) && defined(BUTTON_PIN)
return BUTTON_STATE_ACTIVE == GPIO_ReadPinInput(BUTTON_PORT, BUTTON_PIN);
#endif
return 0; return 0;
} }
@@ -130,7 +153,7 @@ int board_uart_read(uint8_t* buf, int len)
int board_uart_write(void const * buf, int len) int board_uart_write(void const * buf, int len)
{ {
LPSCI_WriteBlocking(UART_PORT, (uint8_t*)buf, len); LPSCI_WriteBlocking(UART_PORT, (uint8_t const*) buf, len);
return len; return len;
} }
+1 -1
View File
@@ -158,7 +158,7 @@ int board_uart_write(void const* buf, int len) {
#if defined(UART_DEV) #if defined(UART_DEV)
int txsize = len; int txsize = len;
while (txsize--) { while (txsize--) {
usart_write(UART_DEV, *(uint8_t*)buf); usart_write(UART_DEV, *(uint8_t const*)buf);
buf++; buf++;
} }
return len; return len;
+2 -3
View File
@@ -28,14 +28,13 @@ CFLAGS += \
-mstrict-align \ -mstrict-align \
-nostdlib -nostartfiles \ -nostdlib -nostartfiles \
-DCFG_TUSB_MCU=OPT_MCU_GD32VF103 \ -DCFG_TUSB_MCU=OPT_MCU_GD32VF103 \
-DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP \ -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP
-DGD32VF103
# mcu driver cause following warnings # mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter CFLAGS += -Wno-error=unused-parameter
SRC_C += \ SRC_C += \
src/portable/st/synopsys/dcd_synopsys.c \ src/portable/synopsys/dwc2/dcd_dwc2.c \
$(GD32VF103_SDK_DRIVER)/gd32vf103_rcu.c \ $(GD32VF103_SDK_DRIVER)/gd32vf103_rcu.c \
$(GD32VF103_SDK_DRIVER)/gd32vf103_gpio.c \ $(GD32VF103_SDK_DRIVER)/gd32vf103_gpio.c \
$(GD32VF103_SDK_DRIVER)/Usb/gd32vf103_usb_hw.c \ $(GD32VF103_SDK_DRIVER)/Usb/gd32vf103_usb_hw.c \
+1 -1
View File
@@ -1,4 +1,4 @@
CFLAGS += -DCPU_MIMXRT1011DAE5A CFLAGS += -DCPU_MIMXRT1011DAE5A -DCFG_EXAMPLE_VIDEO_READONLY
MCU_VARIANT = MIMXRT1011 MCU_VARIANT = MIMXRT1011
# For flash-jlink target # For flash-jlink target
+1 -1
View File
@@ -1,4 +1,4 @@
CFLAGS += -DCPU_MIMXRT1015DAF5A CFLAGS += -DCPU_MIMXRT1015DAF5A -DCFG_EXAMPLE_VIDEO_READONLY
MCU_VARIANT = MIMXRT1015 MCU_VARIANT = MIMXRT1015
# For flash-jlink target # For flash-jlink target

Some files were not shown because too many files have changed in this diff Show More