mirror of
https://github.com/hathach/tinyusb.git
synced 2026-03-06 15:44:38 +00:00
Merge remote-tracking branch 'upstream/master' into uac1
Signed-off-by: HiFiPhile <admin@hifiphile.com>
This commit is contained in:
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -161,8 +161,8 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
west build -b pca10056 -d examples/device/cdc_msc/build examples/device/cdc_msc -- -DRTOS=zephyr
|
||||
west build -b pca10056 -d examples/device/msc_dual_lun/build examples/device/msc_dual_lun -- -DRTOS=zephyr
|
||||
west build -b nrf52840dk -d examples/device/cdc_msc/build examples/device/cdc_msc -- -DRTOS=zephyr
|
||||
west build -b nrf52840dk -d examples/device/msc_dual_lun/build examples/device/msc_dual_lun -- -DRTOS=zephyr
|
||||
|
||||
# ---------------------------------------
|
||||
# Hardware in the loop (HIL)
|
||||
|
||||
4
.github/workflows/ci_set_matrix.py
vendored
4
.github/workflows/ci_set_matrix.py
vendored
@ -31,11 +31,11 @@ family_list = {
|
||||
"msp430": ["msp430-gcc"],
|
||||
"msp432e4 tm4c": ["arm-gcc"],
|
||||
"nrf": ["arm-gcc", "arm-clang"],
|
||||
"nuc100_120 nuc121_125 nuc126 nuc505": ["arm-gcc"],
|
||||
"ra": ["arm-gcc"],
|
||||
"rp2040": ["arm-gcc"],
|
||||
"rx": ["rx-gcc"],
|
||||
"samd11 saml2x": ["arm-gcc", "arm-clang"],
|
||||
"samd21": ["arm-gcc", "arm-clang"],
|
||||
"samd11 samd2x_l2x": ["arm-gcc", "arm-clang"],
|
||||
"samd5x_e5x samg": ["arm-gcc", "arm-clang"],
|
||||
"stm32c0 stm32f0 stm32f1 stm32f2 stm32f3": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||
"stm32f4": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,6 +20,7 @@ latex
|
||||
*.ewt
|
||||
*.ewd
|
||||
*.hex
|
||||
.venv/
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
settings/
|
||||
|
||||
13
.idea/debugServers/lpc1769.xml
generated
Normal file
13
.idea/debugServers/lpc1769.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="DebugServers">
|
||||
<jlink-debug-target name="lpc1769" uniqueID="8f746157-a0c3-435f-b417-10f26c3b2699">
|
||||
<debugger version="1">
|
||||
<debugger kind="GDB" isBundled="true" />
|
||||
<env />
|
||||
</debugger>
|
||||
<gdbserver exe="/usr/bin/JLinkGDBServerCLExe" />
|
||||
<console port="19021" />
|
||||
<target device="LPC1769" reset-before="false" frequency="12000" />
|
||||
<connection extended-remote="false" port="4444" warmup-ms="500" />
|
||||
<swo />
|
||||
</jlink-debug-target>
|
||||
</component>
|
||||
13
.idea/debugServers/lpc55s69.xml
generated
Normal file
13
.idea/debugServers/lpc55s69.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="DebugServers">
|
||||
<jlink-debug-target name="lpc55s69" uniqueID="7de47452-94f1-4f1d-b03c-0f4ad3556d01">
|
||||
<debugger version="1">
|
||||
<debugger kind="GDB" isBundled="true" />
|
||||
<env />
|
||||
</debugger>
|
||||
<gdbserver exe="/usr/bin/JLinkGDBServerCLExe" />
|
||||
<console port="19021" />
|
||||
<target device="LPC55S69_M33_0" reset-before="false" frequency="12000" />
|
||||
<connection extended-remote="false" port="4444" warmup-ms="500" />
|
||||
<swo />
|
||||
</jlink-debug-target>
|
||||
</component>
|
||||
13
.idea/debugServers/nrf52833.xml
generated
Normal file
13
.idea/debugServers/nrf52833.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="DebugServers">
|
||||
<jlink-debug-target name="nrf52833" uniqueID="19eede9f-2096-4b30-9390-14d415964264">
|
||||
<debugger version="1">
|
||||
<debugger kind="GDB" isBundled="true" />
|
||||
<env />
|
||||
</debugger>
|
||||
<gdbserver exe="/usr/bin/JLinkGDBServerCLExe" />
|
||||
<console port="19021" />
|
||||
<target device="nRF52833_xxAA" reset-before="false" frequency="12000" />
|
||||
<connection extended-remote="false" port="4444" warmup-ms="500" />
|
||||
<swo />
|
||||
</jlink-debug-target>
|
||||
</component>
|
||||
13
.idea/debugServers/nrf5340.xml
generated
Normal file
13
.idea/debugServers/nrf5340.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="DebugServers">
|
||||
<jlink-debug-target name="nrf5340" uniqueID="d82e668b-1307-4266-8a5c-3752be6795c9" selected="true">
|
||||
<debugger version="1">
|
||||
<debugger kind="GDB" isBundled="true" />
|
||||
<env />
|
||||
</debugger>
|
||||
<gdbserver exe="/usr/bin/JLinkGDBServerCLExe" />
|
||||
<console port="19021" />
|
||||
<target device="nRF5340_xxAA_APP" reset-before="false" frequency="12000" />
|
||||
<connection extended-remote="false" port="4444" warmup-ms="500" />
|
||||
<swo />
|
||||
</jlink-debug-target>
|
||||
</component>
|
||||
13
.idea/debugServers/stm32f411.xml
generated
Normal file
13
.idea/debugServers/stm32f411.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="DebugServers">
|
||||
<jlink-debug-target name="stm32f411" uniqueID="c48950a7-634c-49b6-b136-204ed0b71718">
|
||||
<debugger version="1">
|
||||
<debugger kind="GDB" isBundled="true" />
|
||||
<env />
|
||||
</debugger>
|
||||
<gdbserver exe="/usr/bin/JLinkGDBServerCLExe" />
|
||||
<console port="19021" />
|
||||
<target device="STM32F411VE" reset-before="false" frequency="12000" />
|
||||
<connection extended-remote="false" port="4444" warmup-ms="500" />
|
||||
<swo />
|
||||
</jlink-debug-target>
|
||||
</component>
|
||||
@ -241,6 +241,15 @@ Table Legend
|
||||
\[empty\] Unknown
|
||||
========= =========================
|
||||
|
||||
Development Tools
|
||||
=================
|
||||
|
||||
The following tools are provided freely to support the development of the TinyUSB project:
|
||||
|
||||
- `IAR Build Tools (CX) <https://iar.com>`_ Professional IDE and compiler for embedded development.
|
||||
- `JetBrains CLion <https://www.jetbrains.com/clion/>`_ Cross-platform IDE for C and C++ development.
|
||||
- `PVS-Studio <https://pvs-studio.com/en/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source>`_ static analyzer for C, C++, C#, and Java code.
|
||||
|
||||
|
||||
.. |Build Status| image:: https://github.com/hathach/tinyusb/actions/workflows/build.yml/badge.svg
|
||||
:target: https://github.com/hathach/tinyusb/actions
|
||||
|
||||
@ -202,10 +202,11 @@ circuitplayground_bluefruit Adafruit Circuit Playground Bluefruit nrf ht
|
||||
feather_nrf52840_express Adafruit Feather nRF52840 Express nrf https://www.adafruit.com/product/4062
|
||||
feather_nrf52840_sense Adafruit Feather nRF52840 Sense nrf https://www.adafruit.com/product/4516
|
||||
itsybitsy_nrf52840 Adafruit ItsyBitsy nRF52840 Express nrf https://www.adafruit.com/product/4481
|
||||
pca10056 Nordic nRF52840DK nrf https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK
|
||||
pca10059 Nordic nRF52840 Dongle nrf https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle
|
||||
pca10095 Nordic nRF5340 DK nrf https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF5340-DK
|
||||
pca10100 Nordic nRF52833 DK nrf https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52833-DK
|
||||
nrf52833dk Nordic nRF52833 DK nrf https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52833-DK
|
||||
nrf52840dk Nordic nRF52840DK nrf https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK
|
||||
nrf52840dongle Nordic nRF52840 Dongle nrf https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle
|
||||
nrf5340dk Nordic nRF5340 DK nrf https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF5340-DK
|
||||
nrf54h20dk Nordic nRF54H20 DK nrf https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF5340-DK
|
||||
=========================== ===================================== ======== ============================================================================== ======
|
||||
|
||||
Raspberry Pi
|
||||
@ -298,8 +299,8 @@ stm32l4p5nucleo STM32 L4P5 Nucleo stm32l4 https://www.s
|
||||
stm32l4r5nucleo STM32 L4R5 Nucleo stm32l4 https://www.st.com/en/evaluation-tools/nucleo-l4r5zi.html
|
||||
stm32n6570dk STM32 N6570-DK stm32n6 https://www.st.com/en/evaluation-tools/stm32n6570-dk.html
|
||||
stm32n657nucleo STM32 N657X0-Q Nucleo stm32n6 https://www.st.com/en/evaluation-tools/nucleo-n657x0-q.html
|
||||
stm32u083cdk STM32U083C-DK Discovery Kit stm32u0 https://www.st.com/en/evaluation-tools/stm32u083c-dk.html
|
||||
b_u585i_iot2a STM32 B-U585i IOT2A Discovery kit stm32u5 https://www.st.com/en/evaluation-tools/b-u585i-iot02a.html
|
||||
stm32u083cdk STM32 U083C Discovery Kit stm32u0 https://www.st.com/en/evaluation-tools/stm32u083c-dk.html
|
||||
stm32u545nucleo STM32 U545 Nucleo stm32u5 https://www.st.com/en/evaluation-tools/nucleo-u545re-q.html
|
||||
stm32u575eval STM32 U575 Eval stm32u5 https://www.st.com/en/evaluation-tools/stm32u575i-ev.html
|
||||
stm32u575nucleo STM32 U575 Nucleo stm32u5 https://www.st.com/en/evaluation-tools/nucleo-u575zi-q.html
|
||||
|
||||
@ -22,7 +22,7 @@ hw/mcu/gd/nuclei-sdk https://github.com/Nuclei-Software/nuc
|
||||
hw/mcu/infineon/mtb-xmclib-cat3 https://github.com/Infineon/mtb-xmclib-cat3.git daf5500d03cba23e68c2f241c30af79cd9d63880 xmc4000
|
||||
hw/mcu/microchip https://github.com/hathach/microchip_driver.git 9e8b37e307d8404033bb881623a113931e1edf27 sam3x samd11 samd21 samd51 samd5x_e5x same5x same7x saml2x samg
|
||||
hw/mcu/mindmotion/mm32sdk https://github.com/hathach/mm32sdk.git b93e856211060ae825216c6a1d6aa347ec758843 mm32
|
||||
hw/mcu/nordic/nrfx https://github.com/NordicSemiconductor/nrfx.git 7c47cc0a56ce44658e6da2458e86cd8783ccc4a2 nrf
|
||||
hw/mcu/nordic/nrfx https://github.com/NordicSemiconductor/nrfx.git 11f57e578c7feea13f21c79ea0efab2630ac68c7 nrf
|
||||
hw/mcu/nuvoton https://github.com/majbthrd/nuc_driver.git 2204191ec76283371419fbcec207da02e1bc22fa nuc
|
||||
hw/mcu/nxp/lpcopen https://github.com/hathach/nxp_lpcopen.git b41cf930e65c734d8ec6de04f1d57d46787c76ae lpc11 lpc13 lpc15 lpc17 lpc18 lpc40 lpc43
|
||||
hw/mcu/nxp/mcux-sdk https://github.com/nxp-mcuxpresso/mcux-sdk a1bdae309a14ec95a4f64a96d3315a4f89c397c6 kinetis_k kinetis_k32l2 kinetis_kl lpc51 lpc54 lpc55 mcx imxrt
|
||||
|
||||
@ -7,6 +7,8 @@ if (NOT DEFINED CMAKE_CXX_COMPILER)
|
||||
endif ()
|
||||
|
||||
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
|
||||
set(TOOLCHAIN_ASM_FLAGS "-x assembler-with-cpp")
|
||||
|
||||
find_program(CMAKE_SIZE llvm-size)
|
||||
find_program(CMAKE_OBJCOPY llvm-objcopy)
|
||||
find_program(CMAKE_OBJDUMP llvm-objdump)
|
||||
|
||||
@ -20,11 +20,11 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_CPU}.cmake)
|
||||
# ----------------------------------------------------------------------------
|
||||
# Compile flags
|
||||
# ----------------------------------------------------------------------------
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
if (TOOLCHAIN STREQUAL "gcc" OR TOOLCHAIN STREQUAL "clang")
|
||||
list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
-fdata-sections
|
||||
-ffunction-sections
|
||||
-fsingle-precision-constant
|
||||
# -fsingle-precision-constant # not supported by clang
|
||||
-fno-strict-aliasing
|
||||
)
|
||||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
@ -32,24 +32,10 @@ if (TOOLCHAIN STREQUAL "gcc")
|
||||
-Wl,--gc-sections
|
||||
-Wl,--cref
|
||||
)
|
||||
|
||||
elseif (TOOLCHAIN STREQUAL "iar")
|
||||
#list(APPEND TOOLCHAIN_COMMON_FLAGS)
|
||||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
--diag_suppress=Li065
|
||||
)
|
||||
|
||||
elseif (TOOLCHAIN STREQUAL "clang")
|
||||
list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
-fdata-sections
|
||||
-ffunction-sections
|
||||
-fno-strict-aliasing
|
||||
)
|
||||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
-Wl,--print-memory-usage
|
||||
-Wl,--gc-sections
|
||||
-Wl,--cref
|
||||
)
|
||||
endif ()
|
||||
|
||||
# join the toolchain flags into a single string
|
||||
@ -61,5 +47,10 @@ foreach (LANG IN ITEMS C CXX ASM)
|
||||
#set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0")
|
||||
endforeach ()
|
||||
|
||||
# Assembler
|
||||
if (DEFINED TOOLCHAIN_ASM_FLAGS)
|
||||
set(CMAKE_ASM_FLAGS_INIT "${CMAKE_ASM_FLAGS_INIT} ${TOOLCHAIN_ASM_FLAGS}")
|
||||
endif ()
|
||||
|
||||
# Linker
|
||||
list(JOIN TOOLCHAIN_EXE_LINKER_FLAGS " " CMAKE_EXE_LINKER_FLAGS_INIT)
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += \
|
||||
src/main.c \
|
||||
src/usb_descriptors.c \
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
RTOS = freertos
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE = \
|
||||
src/main.c \
|
||||
src/usb_descriptors.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -17,3 +17,4 @@ board:lpcxpresso11u37
|
||||
board:lpcxpresso1347
|
||||
family:broadcom_32bit
|
||||
family:broadcom_64bit
|
||||
family:nuc121_125
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
RTOS = freertos
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE = \
|
||||
src/main.c \
|
||||
src/usb_descriptors.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -15,3 +15,4 @@ mcu:RAXXX
|
||||
family:broadcom_32bit
|
||||
family:broadcom_64bit
|
||||
board:stm32l0538disco
|
||||
family:nuc121_125
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -66,12 +66,12 @@ int main(void) {
|
||||
printf(HELLO_STR);
|
||||
|
||||
#ifndef LOGGER_UART
|
||||
board_uart_write(HELLO_STR, strlen(HELLO_STR));
|
||||
board_uart_write(HELLO_STR, sizeof(HELLO_STR)-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
board_led_write(led_state);
|
||||
led_state = 1 - led_state; // toggle
|
||||
led_state = !led_state; // toggle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += \
|
||||
@ -10,6 +10,6 @@ EXAMPLE_SOURCE += \
|
||||
src/msc_disk.c \
|
||||
src/usb_descriptors.c \
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -126,9 +126,9 @@ uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t *inquiry_resp, uin
|
||||
const char pid[] = "Mass Storage";
|
||||
const char rev[] = "1.0";
|
||||
|
||||
memcpy(inquiry_resp->vendor_id, vid, strlen(vid));
|
||||
memcpy(inquiry_resp->product_id, pid, strlen(pid));
|
||||
memcpy(inquiry_resp->product_rev, rev, strlen(rev));
|
||||
strncpy((char*) inquiry_resp->vendor_id, vid, 8);
|
||||
strncpy((char*) inquiry_resp->product_id, pid, 16);
|
||||
strncpy((char*) inquiry_resp->product_rev, rev, 4);
|
||||
|
||||
return sizeof(scsi_inquiry_resp_t); // 36 bytes
|
||||
}
|
||||
@ -242,6 +242,8 @@ int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void *buffer, u
|
||||
// negative means error -> tinyusb could stall and/or response with failed status
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
RTOS = freertos
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE = \
|
||||
@ -11,6 +11,6 @@ EXAMPLE_SOURCE = \
|
||||
src/msc_disk.c \
|
||||
src/usb_descriptors.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -15,3 +15,4 @@ mcu:RAXXX
|
||||
mcu:STM32L0
|
||||
family:broadcom_32bit
|
||||
family:broadcom_64bit
|
||||
family:nuc121_125
|
||||
|
||||
@ -198,9 +198,9 @@ uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp, uin
|
||||
const char pid[] = "Mass Storage";
|
||||
const char rev[] = "1.0";
|
||||
|
||||
memcpy(inquiry_resp->vendor_id, vid, strlen(vid));
|
||||
memcpy(inquiry_resp->product_id, pid, strlen(pid));
|
||||
memcpy(inquiry_resp->product_rev, rev, strlen(rev));
|
||||
strncpy((char*) inquiry_resp->vendor_id, vid, 8);
|
||||
strncpy((char*) inquiry_resp->product_id, pid, 16);
|
||||
strncpy((char*) inquiry_resp->product_rev, rev, 4);
|
||||
|
||||
return sizeof(scsi_inquiry_resp_t); // 36 bytes
|
||||
}
|
||||
@ -299,13 +299,11 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
|
||||
return TUD_MSC_RET_ERROR;
|
||||
}
|
||||
|
||||
#ifdef CFG_EXAMPLE_MSC_READONLY
|
||||
#ifdef CFG_EXAMPLE_MSC_READONLY
|
||||
(void) lun;
|
||||
(void) buffer;
|
||||
return bufsize;
|
||||
#endif
|
||||
|
||||
#if CFG_EXAMPLE_MSC_ASYNC_IO
|
||||
#elif CFG_EXAMPLE_MSC_ASYNC_IO
|
||||
io_ops_t io_ops = {.is_read = false, .lun = lun, .lba = lba, .offset = offset, .buffer = buffer, .bufsize = bufsize};
|
||||
|
||||
// Send IO operation to IO task
|
||||
@ -318,7 +316,7 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
|
||||
tusb_time_delay_ms_api(CFG_EXAMPLE_MSC_IO_DELAY_MS);
|
||||
|
||||
return bufsize;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// Callback invoked when received an SCSI command not in built-in list below
|
||||
@ -326,12 +324,8 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
|
||||
// - READ10 and WRITE10 has their own callbacks
|
||||
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
|
||||
// read10 & write10 has their own callback and MUST not be handled here
|
||||
|
||||
void const *response = NULL;
|
||||
int32_t resplen = 0;
|
||||
|
||||
// most scsi handled is input
|
||||
bool in_xfer = true;
|
||||
(void) buffer;
|
||||
(void) bufsize;
|
||||
|
||||
switch (scsi_cmd[0]) {
|
||||
default:
|
||||
@ -339,22 +333,10 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
|
||||
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||
|
||||
// negative means error -> tinyusb could stall and/or response with failed status
|
||||
resplen = -1;
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// return resplen must not larger than bufsize
|
||||
if (resplen > bufsize) { resplen = bufsize; }
|
||||
|
||||
if (response && (resplen > 0)) {
|
||||
if (in_xfer) {
|
||||
memcpy(buffer, response, (size_t) resplen);
|
||||
} else {
|
||||
// SCSI output
|
||||
}
|
||||
}
|
||||
|
||||
return (int32_t) resplen;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += \
|
||||
@ -11,6 +11,6 @@ EXAMPLE_SOURCE += \
|
||||
src/uac2_app.c \
|
||||
src/usb_descriptors.c \
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -31,4 +31,7 @@ enum
|
||||
VOLUME_CTRL_SILENCE = 0x8000,
|
||||
};
|
||||
|
||||
void led_blinking_task(void);
|
||||
void audio_task(void);
|
||||
|
||||
#endif
|
||||
|
||||
@ -38,9 +38,6 @@ extern uint32_t blink_interval_ms;
|
||||
#include "pico/stdlib.h"
|
||||
#endif
|
||||
|
||||
void led_blinking_task(void);
|
||||
void audio_task(void);
|
||||
|
||||
/*------------- MAIN -------------*/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE = \
|
||||
src/main.c \
|
||||
src/usb_descriptors.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -126,9 +126,9 @@ uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t *inquiry_resp, uin
|
||||
const char pid[] = "Mass Storage";
|
||||
const char rev[] = "1.0";
|
||||
|
||||
memcpy(inquiry_resp->vendor_id, vid, strlen(vid));
|
||||
memcpy(inquiry_resp->product_id, pid, strlen(pid));
|
||||
memcpy(inquiry_resp->product_rev, rev, strlen(rev));
|
||||
strncpy((char*) inquiry_resp->vendor_id, vid, 8);
|
||||
strncpy((char*) inquiry_resp->product_id, pid, 16);
|
||||
strncpy((char*) inquiry_resp->product_rev, rev, 4);
|
||||
|
||||
return sizeof(scsi_inquiry_resp_t); // 36 bytes
|
||||
}
|
||||
@ -211,42 +211,21 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
|
||||
// Callback invoked when received an SCSI command not in built-in list below
|
||||
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
|
||||
// - READ10 and WRITE10 has their own callbacks
|
||||
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize)
|
||||
{
|
||||
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
|
||||
// read10 & write10 has their own callback and MUST not be handled here
|
||||
(void) buffer;
|
||||
(void) bufsize;
|
||||
|
||||
void const* response = NULL;
|
||||
int32_t resplen = 0;
|
||||
|
||||
// most scsi handled is input
|
||||
bool in_xfer = true;
|
||||
|
||||
switch (scsi_cmd[0])
|
||||
{
|
||||
switch (scsi_cmd[0]) {
|
||||
default:
|
||||
// Set Sense = Invalid Command Operation
|
||||
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||
|
||||
// negative means error -> tinyusb could stall and/or response with failed status
|
||||
resplen = -1;
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// return resplen must not larger than bufsize
|
||||
if ( resplen > bufsize ) resplen = bufsize;
|
||||
|
||||
if ( response && (resplen > 0) )
|
||||
{
|
||||
if(in_xfer)
|
||||
{
|
||||
memcpy(buffer, response, (size_t) resplen);
|
||||
}else
|
||||
{
|
||||
// SCSI output
|
||||
}
|
||||
}
|
||||
|
||||
return resplen;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE = \
|
||||
src/main.c \
|
||||
src/usb_descriptors.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
RTOS = freertos
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE = \
|
||||
src/main.c \
|
||||
src/usb_descriptors.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
RTOS = freertos
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += \
|
||||
src/main.c \
|
||||
src/usb_descriptors.c \
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -217,9 +217,9 @@ uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t *inquiry_resp, uin
|
||||
const char pid[] = "Mass Storage";
|
||||
const char rev[] = "1.0";
|
||||
|
||||
memcpy(inquiry_resp->vendor_id, vid, strlen(vid));
|
||||
memcpy(inquiry_resp->product_id, pid, strlen(pid));
|
||||
memcpy(inquiry_resp->product_rev, rev, strlen(rev));
|
||||
strncpy((char*) inquiry_resp->vendor_id, vid, 8);
|
||||
strncpy((char*) inquiry_resp->product_id, pid, 16);
|
||||
strncpy((char*) inquiry_resp->product_rev, rev, 4);
|
||||
|
||||
return sizeof(scsi_inquiry_resp_t); // 36 bytes
|
||||
}
|
||||
@ -227,9 +227,7 @@ uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t *inquiry_resp, uin
|
||||
// Invoked when received Test Unit Ready command.
|
||||
// return true allowing host to read/write this LUN e.g SD card inserted
|
||||
bool tud_msc_test_unit_ready_cb(uint8_t lun) {
|
||||
if ( lun == 1 && board_button_read() ) return false;
|
||||
|
||||
return true; // RAM disk is always ready
|
||||
return ( lun == 1 && board_button_read() ) ? false : true;
|
||||
}
|
||||
|
||||
// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
# suppress warning caused by lwip
|
||||
CFLAGS_GCC += \
|
||||
@ -8,7 +8,6 @@ CFLAGS_GCC += \
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
$(TOP)/lib/lwip/src/include \
|
||||
$(TOP)/lib/lwip/src/include/ipv4 \
|
||||
$(TOP)/lib/lwip/src/include/lwip/apps \
|
||||
@ -16,7 +15,7 @@ INC += \
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
# lwip sources
|
||||
SRC_C += \
|
||||
@ -66,4 +65,4 @@ SRC_C += \
|
||||
lib/networking/dnserver.c \
|
||||
lib/networking/rndis_reports.c
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -20,3 +20,5 @@ board:curiosity_nano
|
||||
board:frdm_kl25z
|
||||
# lpc55 has weird error 'ncm_interface' causes a section type conflict with 'ntb_parameters'
|
||||
family:lpc55
|
||||
family:nuc126
|
||||
family:nuc100_120
|
||||
|
||||
@ -58,6 +58,7 @@ try changing the first byte of tud_network_mac_address[] below from 0x02 to 0x00
|
||||
#include "lwip/ethip6.h"
|
||||
#include "lwip/init.h"
|
||||
#include "lwip/timeouts.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#ifdef INCLUDE_IPERF
|
||||
#include "lwip/apps/lwiperf.h"
|
||||
@ -172,7 +173,7 @@ static void init_lwip(void) {
|
||||
}
|
||||
|
||||
/* handle any DNS requests from dns-server */
|
||||
bool dns_query_proc(const char *name, ip4_addr_t *addr) {
|
||||
static bool dns_query_proc(const char *name, ip4_addr_t *addr) {
|
||||
if (0 == strcmp(name, "tiny.usb")) {
|
||||
*addr = ipaddr;
|
||||
return true;
|
||||
|
||||
@ -88,7 +88,7 @@ extern "C" {
|
||||
#ifndef USE_ECM
|
||||
#if TU_CHECK_MCU(OPT_MCU_LPC15XX, OPT_MCU_LPC40XX, OPT_MCU_LPC51UXX, OPT_MCU_LPC54)
|
||||
#define USE_ECM 1
|
||||
#elif TU_CHECK_MCU(OPT_MCU_SAMD21, OPT_MCU_SAML21, OPT_MCU_SAML22)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_SAMD21, OPT_MCU_SAML2X)
|
||||
#define USE_ECM 1
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F0, OPT_MCU_STM32F1)
|
||||
#define USE_ECM 1
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -87,9 +87,9 @@ uint8_t const * tud_descriptor_device_cb(void)
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_CXD56
|
||||
// CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
|
||||
// 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
|
||||
// #define EPNUM_AUDIO_IN 0x01
|
||||
// #define EPNUM_AUDIO_OUT 0x02
|
||||
// #define EPNUM_AUDIO_INT 0x03
|
||||
#define EPNUM_AUDIO_IN 0x01
|
||||
#define EPNUM_AUDIO_OUT 0x02
|
||||
#define EPNUM_AUDIO_INT 0x03
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_NRF5X
|
||||
// ISO endpoints for NRF5x are fixed to 0x08 (0x88)
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -322,7 +322,7 @@ static bool audio20_clock_get_request(uint8_t rhport, audio20_control_request_t
|
||||
|
||||
if (request->bControlSelector == AUDIO20_CS_CTRL_SAM_FREQ) {
|
||||
if (request->bRequest == AUDIO20_CS_REQ_CUR) {
|
||||
TU_LOG1("Clock get current freq %lu\r\n", current_sample_rate);
|
||||
TU_LOG1("Clock get current freq %" PRIu32 "\r\n", current_sample_rate);
|
||||
|
||||
audio20_control_cur_4_t curf = {(int32_t) tu_htole32(current_sample_rate)};
|
||||
return tud_audio_buffer_and_schedule_control_xfer(rhport, (tusb_control_request_t const *) request, &curf, sizeof(curf));
|
||||
@ -360,7 +360,7 @@ static bool audio20_clock_set_request(audio20_control_request_t const *request,
|
||||
|
||||
current_sample_rate = (uint32_t) ((audio20_control_cur_4_t const *) buf)->bCur;
|
||||
|
||||
TU_LOG1("Clock set current freq: %ld\r\n", current_sample_rate);
|
||||
TU_LOG1("Clock set current freq: %" PRIu32 "\r\n", current_sample_rate);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
#include "main.h"
|
||||
#include "usbtmc_app.h"
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "tusb.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "main.h"
|
||||
#include "usbtmc_app.h"
|
||||
|
||||
#if (CFG_TUD_USBTMC_ENABLE_488)
|
||||
static usbtmc_response_capabilities_488_t const
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
ifeq ($(DISABLE_MJPEG),1)
|
||||
CFLAGS += -DCFG_EXAMPLE_VIDEO_DISABLE_MJPEG
|
||||
@ -9,10 +9,10 @@ endif
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
ifeq ($(DISABLE_MJPEG),1)
|
||||
CFLAGS += -DCFG_EXAMPLE_VIDEO_DISABLE_MJPEG
|
||||
@ -9,10 +9,10 @@ endif
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -180,7 +180,7 @@ static void fill_color_bar(uint8_t* buffer, unsigned start_position) {
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t get_framebuf(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, size_t fnum, void **fb) {
|
||||
static size_t get_framebuf(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, size_t fnum, void **fb) {
|
||||
uint32_t idx = ctl_idx + stm_idx;
|
||||
|
||||
if (idx == 0) {
|
||||
@ -205,8 +205,7 @@ size_t get_framebuf(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, size_t fnum, voi
|
||||
//--------------------------------------------------------------------+
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
void video_send_frame(uint_fast8_t ctl_idx, uint_fast8_t stm_idx) {
|
||||
static void video_send_frame(uint_fast8_t ctl_idx, uint_fast8_t stm_idx) {
|
||||
static unsigned start_ms[CFG_TUD_VIDEO_STREAMING] = {0, };
|
||||
static unsigned already_sent = 0;
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -107,7 +107,7 @@ int main(void) {
|
||||
}
|
||||
|
||||
// send characters to both CDC and WebUSB
|
||||
void echo_all(const uint8_t buf[], uint32_t count) {
|
||||
static void echo_all(const uint8_t buf[], uint32_t count) {
|
||||
// echo to web serial
|
||||
if (web_serial_connected) {
|
||||
tud_vendor_write(buf, count);
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
CFLAGS_GCC += -Wno-error=cast-align -Wno-error=null-dereference
|
||||
|
||||
@ -15,4 +15,4 @@ SRC_C += \
|
||||
src/host/hub.c \
|
||||
src/host/usbh.c
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
CFLAGS_GCC += -Wno-error=cast-align -Wno-error=null-dereference
|
||||
|
||||
@ -14,4 +14,4 @@ SRC_C += \
|
||||
src/host/hub.c \
|
||||
src/host/usbh.c
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -218,9 +218,7 @@ static void print_device_info(uint8_t daddr, const tusb_desc_device_t* desc_devi
|
||||
cdc_printf("\r\n");
|
||||
|
||||
cdc_printf(" iSerialNumber %u " , desc_device->iSerialNumber);
|
||||
cdc_printf((char*)serial); // serial is already to UTF-8
|
||||
cdc_printf("\r\n");
|
||||
|
||||
cdc_printf("%s \r\n", (char*)serial); // serial is already to UTF-8
|
||||
cdc_printf(" bNumConfigurations %u\r\n" , desc_device->bNumConfigurations);
|
||||
}
|
||||
|
||||
@ -310,5 +308,5 @@ static void print_utf16(uint16_t *temp_buf, size_t buf_len) {
|
||||
_convert_utf16le_to_utf8(temp_buf + 1, utf16_len, (uint8_t *) temp_buf, sizeof(uint16_t) * buf_len);
|
||||
((uint8_t*) temp_buf)[utf8_len] = '\0';
|
||||
|
||||
cdc_printf((char*) temp_buf);
|
||||
cdc_printf("%s", (char*) temp_buf);
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += \
|
||||
src/main.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE = \
|
||||
@ -11,6 +11,6 @@ EXAMPLE_SOURCE = \
|
||||
src/main.c \
|
||||
src/msc_app.c \
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
32
examples/host/cdc_msc_hid/src/app.h
Normal file
32
examples/host/cdc_msc_hid/src/app.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2025 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
#ifndef TUSB_TINYUSB_EXAMPLES_APP_H
|
||||
#define TUSB_TINYUSB_EXAMPLES_APP_H
|
||||
|
||||
void cdc_app_task(void);
|
||||
void hid_app_task(void);
|
||||
|
||||
#endif
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
#include "tusb.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "app.h"
|
||||
|
||||
static size_t get_console_inputs(uint8_t* buf, size_t bufsize) {
|
||||
size_t count = 0;
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
#include "app.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||
|
||||
@ -29,13 +29,12 @@
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
#include "app.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF PROTOTYPES
|
||||
//--------------------------------------------------------------------+
|
||||
void led_blinking_task(void);
|
||||
extern void cdc_app_task(void);
|
||||
extern void hid_app_task(void);
|
||||
|
||||
/*------------- MAIN -------------*/
|
||||
int main(void) {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
RTOS = freertos
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE = \
|
||||
@ -12,6 +12,6 @@ EXAMPLE_SOURCE = \
|
||||
src/main.c \
|
||||
src/msc_app.c \
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
33
examples/host/cdc_msc_hid_freertos/src/app.h
Normal file
33
examples/host/cdc_msc_hid_freertos/src/app.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2025 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
#ifndef TUSB_TINYUSB_EXAMPLES_APP_H
|
||||
#define TUSB_TINYUSB_EXAMPLES_APP_H
|
||||
|
||||
void cdc_app_init(void);
|
||||
void hid_app_init(void);
|
||||
void msc_app_init(void);
|
||||
|
||||
#endif
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
#include "tusb.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "app.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#define CDC_STACK_SZIE 2048
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
#include "app.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||
@ -160,7 +161,7 @@ static void process_kbd_report(hid_keyboard_report_t const *report) {
|
||||
// Mouse
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
void cursor_movement(int8_t x, int8_t y, int8_t wheel) {
|
||||
static void cursor_movement(int8_t x, int8_t y, int8_t wheel) {
|
||||
#if USE_ANSI_ESCAPE
|
||||
// Move X using ansi escape
|
||||
if ( x < 0) {
|
||||
@ -210,6 +211,7 @@ static void process_mouse_report(hid_mouse_report_t const *report) {
|
||||
//--------------------------------------------------------------------+
|
||||
static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t const *report, uint16_t len) {
|
||||
(void) dev_addr;
|
||||
(void) len;
|
||||
|
||||
uint8_t const rpt_count = hid_info[instance].report_count;
|
||||
tuh_hid_report_info_t *rpt_info_arr = hid_info[instance].report_info;
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
#include "app.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#define USBH_STACK_SIZE 4096
|
||||
@ -65,9 +66,6 @@ TimerHandle_t blinky_tm;
|
||||
static void led_blinky_cb(TimerHandle_t xTimer);
|
||||
static void usb_host_task(void* param);
|
||||
|
||||
extern void cdc_app_init(void);
|
||||
extern void hid_app_init(void);
|
||||
extern void msc_app_init(void);
|
||||
|
||||
/*------------- MAIN -------------*/
|
||||
int main(void) {
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include "tusb.h"
|
||||
#include "app.h"
|
||||
|
||||
// define the buffer to be place in USB/DMA memory with correct alignment/cache line size
|
||||
CFG_TUH_MEM_SECTION static struct {
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += \
|
||||
src/main.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -171,9 +171,7 @@ void tuh_mount_cb(uint8_t daddr) {
|
||||
printf("\r\n");
|
||||
|
||||
printf(" iSerialNumber %u ", desc.device.iSerialNumber);
|
||||
printf((char*)desc.serial); // serial is already to UTF-8
|
||||
printf("\r\n");
|
||||
|
||||
printf("%s\r\n", (char*)desc.serial); // serial is already to UTF-8
|
||||
printf(" bNumConfigurations %u\r\n", desc.device.bNumConfigurations);
|
||||
}
|
||||
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += \
|
||||
src/hid_app.c \
|
||||
src/main.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
31
examples/host/hid_controller/src/app.h
Normal file
31
examples/host/hid_controller/src/app.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2025 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
#ifndef TUSB_TINYUSB_EXAMPLES_APP_H
|
||||
#define TUSB_TINYUSB_EXAMPLES_APP_H
|
||||
|
||||
void hid_app_task(void);
|
||||
|
||||
#endif
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
#include "app.h"
|
||||
|
||||
/* From https://www.kernel.org/doc/html/latest/input/gamepad.html
|
||||
____________________________ __
|
||||
|
||||
@ -34,18 +34,15 @@
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
#include "app.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
||||
//--------------------------------------------------------------------+
|
||||
void led_blinking_task(void);
|
||||
|
||||
extern void cdc_task(void);
|
||||
extern void hid_app_task(void);
|
||||
|
||||
/*------------- MAIN -------------*/
|
||||
int main(void)
|
||||
{
|
||||
int main(void) {
|
||||
board_init();
|
||||
|
||||
printf("TinyUSB Host HID Controller Example\r\n");
|
||||
@ -60,19 +57,11 @@ int main(void)
|
||||
|
||||
board_init_after_tusb();
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
// tinyusb host task
|
||||
tuh_task();
|
||||
led_blinking_task();
|
||||
|
||||
#if CFG_TUH_CDC
|
||||
cdc_task();
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_HID
|
||||
hid_app_task();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,8 +72,7 @@ int main(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// Blinking Task
|
||||
//--------------------------------------------------------------------+
|
||||
void led_blinking_task(void)
|
||||
{
|
||||
void led_blinking_task(void) {
|
||||
const uint32_t interval_ms = 1000;
|
||||
static uint32_t start_ms = 0;
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += \
|
||||
src/main.c
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -27,10 +27,8 @@ target_sources(${PROJECT} PUBLIC
|
||||
)
|
||||
|
||||
# Suppress warnings on fatfs
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
set_source_files_properties(
|
||||
${TOP}/lib/fatfs/source/ff.c
|
||||
PROPERTIES
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set_source_files_properties(${TOP}/lib/fatfs/source/ff.c PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual"
|
||||
)
|
||||
endif ()
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
FATFS_PATH = lib/fatfs/source
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
$(TOP)/$(FATFS_PATH) \
|
||||
$(TOP)/lib/embedded-cli \
|
||||
|
||||
@ -13,7 +12,7 @@ EXAMPLE_SOURCE = \
|
||||
src/main.c \
|
||||
src/msc_app.c \
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
# FatFS source
|
||||
SRC_C += \
|
||||
@ -24,4 +23,4 @@ SRC_C += \
|
||||
# suppress warning caused by fatfs
|
||||
CFLAGS_GCC += -Wno-error=cast-qual
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
include ../../build_system/make/make.mk
|
||||
include ../../../hw/bsp/family_support.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
EXAMPLE_SOURCE += \
|
||||
src/main.c
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../../hw/bsp/family_rules.mk
|
||||
|
||||
@ -48,6 +48,12 @@ void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
|
||||
void OTGFS1_IRQHandler(void);
|
||||
void OTGHS_IRQHandler(void);
|
||||
void OTGFS1_WKUP_IRQHandler(void);
|
||||
void OTGHS_WKUP_IRQHandler(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "at32f402_405_clock.h"
|
||||
#include "at32f402_405_int.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "board.h"
|
||||
|
||||
@ -40,20 +41,16 @@ void usb_gpio_config(void);
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void OTGFS1_IRQHandler(void)
|
||||
{
|
||||
void OTGFS1_IRQHandler(void) {
|
||||
tusb_int_handler(0, true);
|
||||
}
|
||||
void OTGHS_IRQHandler(void)
|
||||
{
|
||||
void OTGHS_IRQHandler(void) {
|
||||
tusb_int_handler(1, true);
|
||||
}
|
||||
void OTGFS1_WKUP_IRQHandler(void)
|
||||
{
|
||||
void OTGFS1_WKUP_IRQHandler(void) {
|
||||
tusb_int_handler(0, true);
|
||||
}
|
||||
void OTGHS_WKUP_IRQHandler(void)
|
||||
{
|
||||
void OTGHS_WKUP_IRQHandler(void) {
|
||||
tusb_int_handler(1, true);
|
||||
}
|
||||
|
||||
@ -278,6 +275,7 @@ void HardFault_Handler(void) {
|
||||
|
||||
// Required by __libc_init_array in startup code if we are compiling using
|
||||
// -nostdlib/-nostartfiles.
|
||||
void _init(void);
|
||||
void _init(void) {
|
||||
}
|
||||
|
||||
|
||||
@ -31,26 +31,22 @@ if (NOT DEFINED RHPORT_HOST_SPEED)
|
||||
list(GET RHPORT_SPEED ${RHPORT_HOST} RHPORT_HOST_SPEED)
|
||||
endif ()
|
||||
|
||||
#------------------------------------
|
||||
# Startup & Linker script
|
||||
#------------------------------------
|
||||
set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
|
||||
|
||||
#------------------------------------
|
||||
# BOARD_TARGET
|
||||
#------------------------------------
|
||||
# only need to be built ONCE for all examples
|
||||
function(add_board_target BOARD_TARGET)
|
||||
if (TARGET ${BOARD_TARGET})
|
||||
return()
|
||||
endif ()
|
||||
|
||||
# Startup & Linker script
|
||||
set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
|
||||
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
|
||||
|
||||
function(family_add_board BOARD_TARGET)
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
|
||||
@ -58,7 +54,6 @@ function(add_board_target BOARD_TARGET)
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_acc.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
@ -74,59 +69,49 @@ function(add_board_target BOARD_TARGET)
|
||||
)
|
||||
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# Functions
|
||||
#------------------------------------
|
||||
function(family_configure_example TARGET RTOS)
|
||||
family_configure_common(${TARGET} ${RTOS})
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
|
||||
|
||||
# Board target
|
||||
add_board_target(board_${BOARD})
|
||||
|
||||
#---------- Port Specific ----------
|
||||
# These files are built for each example since it depends on example's tusb_config.h
|
||||
target_sources(${TARGET} PUBLIC
|
||||
# BSP
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
|
||||
${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
|
||||
${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
|
||||
${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${TARGET} PUBLIC
|
||||
# family, hw, board
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
|
||||
)
|
||||
|
||||
# Add TinyUSB target and port source
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
|
||||
target_sources(${TARGET} PUBLIC
|
||||
${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
|
||||
${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
|
||||
${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
|
||||
)
|
||||
target_link_libraries(${TARGET} PUBLIC board_${BOARD})
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
||||
set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES SKIP_LINTING ON)
|
||||
# Flashing
|
||||
family_add_bin_hex(${TARGET})
|
||||
family_flash_jlink(${TARGET})
|
||||
|
||||
@ -48,6 +48,12 @@ void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
|
||||
void USBFS_H_CAN1_TX_IRQHandler(void);
|
||||
void USBFS_L_CAN1_RX0_IRQHandler(void);
|
||||
void USBFS_MAPH_IRQHandler(void);
|
||||
void USBFS_MAPL_IRQHandler(void);
|
||||
void USBFSWakeUp_IRQHandler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "at32f403a_407_clock.h"
|
||||
#include "at32f403a_407_int.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "board.h"
|
||||
|
||||
@ -266,6 +267,7 @@ void HardFault_Handler(void) {
|
||||
|
||||
// Required by __libc_init_array in startup code if we are compiling using
|
||||
// -nostdlib/-nostartfiles.
|
||||
void _init(void);
|
||||
void _init(void) {
|
||||
}
|
||||
|
||||
|
||||
@ -14,26 +14,22 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
|
||||
|
||||
set(FAMILY_MCUS ${AT32_FAMILY_UPPER} CACHE INTERNAL "")
|
||||
|
||||
#------------------------------------
|
||||
# Startup & Linker script
|
||||
#------------------------------------
|
||||
set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
|
||||
|
||||
#------------------------------------
|
||||
# BOARD_TARGET
|
||||
#------------------------------------
|
||||
# only need to be built ONCE for all examples
|
||||
function(add_board_target BOARD_TARGET)
|
||||
if (TARGET ${BOARD_TARGET})
|
||||
return()
|
||||
endif ()
|
||||
|
||||
# Startup & Linker script
|
||||
set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
|
||||
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
|
||||
|
||||
function(family_add_board BOARD_TARGET)
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
|
||||
@ -41,7 +37,6 @@ function(add_board_target BOARD_TARGET)
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_acc.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
@ -51,57 +46,46 @@ function(add_board_target BOARD_TARGET)
|
||||
)
|
||||
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# Functions
|
||||
#------------------------------------
|
||||
function(family_configure_example TARGET RTOS)
|
||||
family_configure_common(${TARGET} ${RTOS})
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
|
||||
|
||||
# Board target
|
||||
add_board_target(board_${BOARD})
|
||||
|
||||
#---------- Port Specific ----------
|
||||
# These files are built for each example since it depends on example's tusb_config.h
|
||||
target_sources(${TARGET} PUBLIC
|
||||
# BSP
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
|
||||
${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${TARGET} PUBLIC
|
||||
# family, hw, board
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
|
||||
)
|
||||
|
||||
# Add TinyUSB target and port source
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
|
||||
target_sources(${TARGET} PUBLIC
|
||||
${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
|
||||
)
|
||||
target_link_libraries(${TARGET} PUBLIC board_${BOARD})
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES SKIP_LINTING ON)
|
||||
# Flashing
|
||||
family_add_bin_hex(${TARGET})
|
||||
family_flash_jlink(${TARGET})
|
||||
|
||||
@ -48,6 +48,12 @@ void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
|
||||
void USBFS_H_CAN1_TX_IRQHandler(void);
|
||||
void USBFS_L_CAN1_RX0_IRQHandler(void);
|
||||
void USBFS_MAPH_IRQHandler(void);
|
||||
void USBFS_MAPL_IRQHandler(void);
|
||||
void USBFSWakeUp_IRQHandler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "at32f413_clock.h"
|
||||
#include "at32f413_int.h"
|
||||
#include "board.h"
|
||||
#include "bsp/board_api.h"
|
||||
|
||||
@ -266,6 +267,7 @@ void HardFault_Handler(void) {
|
||||
|
||||
// Required by __libc_init_array in startup code if we are compiling using
|
||||
// -nostdlib/-nostartfiles.
|
||||
void _init(void);
|
||||
void _init(void) {
|
||||
}
|
||||
|
||||
|
||||
@ -14,26 +14,22 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
|
||||
|
||||
set(FAMILY_MCUS ${AT32_FAMILY_UPPER} CACHE INTERNAL "")
|
||||
|
||||
#------------------------------------
|
||||
# Startup & Linker script
|
||||
#------------------------------------
|
||||
set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
|
||||
|
||||
#------------------------------------
|
||||
# BOARD_TARGET
|
||||
#------------------------------------
|
||||
# only need to be built ONCE for all examples
|
||||
function(add_board_target BOARD_TARGET)
|
||||
if (TARGET ${BOARD_TARGET})
|
||||
return()
|
||||
endif ()
|
||||
|
||||
# Startup & Linker script
|
||||
set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
|
||||
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
|
||||
|
||||
function(family_add_board BOARD_TARGET)
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
|
||||
@ -41,7 +37,6 @@ function(add_board_target BOARD_TARGET)
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_acc.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
@ -51,56 +46,46 @@ function(add_board_target BOARD_TARGET)
|
||||
)
|
||||
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# Functions
|
||||
#------------------------------------
|
||||
function(family_configure_example TARGET RTOS)
|
||||
family_configure_common(${TARGET} ${RTOS})
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
|
||||
|
||||
# Board target
|
||||
add_board_target(board_${BOARD})
|
||||
|
||||
#---------- Port Specific ----------
|
||||
# These files are built for each example since it depends on example's tusb_config.h
|
||||
target_sources(${TARGET} PUBLIC
|
||||
# BSP
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
|
||||
${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${TARGET} PUBLIC
|
||||
# family, hw, board
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
|
||||
)
|
||||
|
||||
# Add TinyUSB target and port source
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
|
||||
target_sources(${TARGET} PUBLIC
|
||||
${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
|
||||
)
|
||||
target_link_libraries(${TARGET} PUBLIC board_${BOARD})
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES SKIP_LINTING ON)
|
||||
|
||||
# Flashing
|
||||
family_add_bin_hex(${TARGET})
|
||||
|
||||
@ -48,6 +48,9 @@ void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
|
||||
void OTGFS1_IRQHandler(void);
|
||||
void OTGFS1_WKUP_IRQHandler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "at32f415_clock.h"
|
||||
#include "at32f415_int.h"
|
||||
#include "board.h"
|
||||
#include "bsp/board_api.h"
|
||||
|
||||
@ -262,6 +263,7 @@ void HardFault_Handler(void) {
|
||||
|
||||
// Required by __libc_init_array in startup code if we are compiling using
|
||||
// -nostdlib/-nostartfiles.
|
||||
void _init(void);
|
||||
void _init(void) {
|
||||
}
|
||||
|
||||
|
||||
@ -14,33 +14,28 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
|
||||
|
||||
set(FAMILY_MCUS ${AT32_FAMILY_UPPER} CACHE INTERNAL "")
|
||||
|
||||
#------------------------------------
|
||||
# Startup & Linker script
|
||||
#------------------------------------
|
||||
set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
|
||||
|
||||
#------------------------------------
|
||||
# BOARD_TARGET
|
||||
#------------------------------------
|
||||
# only need to be built ONCE for all examples
|
||||
function(add_board_target BOARD_TARGET)
|
||||
if (TARGET ${BOARD_TARGET})
|
||||
return()
|
||||
endif ()
|
||||
|
||||
# Startup & Linker script
|
||||
set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
|
||||
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
|
||||
|
||||
function(family_add_board BOARD_TARGET)
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_misc.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
|
||||
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
@ -49,58 +44,48 @@ function(add_board_target BOARD_TARGET)
|
||||
${AT32_SDK_LIB}/drivers/inc
|
||||
)
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# Functions
|
||||
#------------------------------------
|
||||
function(family_configure_example TARGET RTOS)
|
||||
family_configure_common(${TARGET} ${RTOS})
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
|
||||
|
||||
# Board target
|
||||
add_board_target(board_${BOARD})
|
||||
|
||||
#---------- Port Specific ----------
|
||||
# These files are built for each example since it depends on example's tusb_config.h
|
||||
target_sources(${TARGET} PUBLIC
|
||||
# BSP
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
|
||||
${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
|
||||
${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
|
||||
${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${TARGET} PUBLIC
|
||||
# family, hw, board
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
|
||||
)
|
||||
|
||||
# Add TinyUSB target and port source
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
|
||||
target_sources(${TARGET} PUBLIC
|
||||
${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
|
||||
${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
|
||||
${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
|
||||
)
|
||||
target_link_libraries(${TARGET} PUBLIC board_${BOARD})
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES SKIP_LINTING ON)
|
||||
|
||||
# Flashing
|
||||
family_add_bin_hex(${TARGET})
|
||||
|
||||
@ -39,7 +39,7 @@ extern "C" {
|
||||
/* exported functions ------------------------------------------------------- */
|
||||
|
||||
void NMI_Handler(void);
|
||||
//void HardFault_Handler(void);
|
||||
void HardFault_Handler(void);
|
||||
void MemManage_Handler(void);
|
||||
void BusFault_Handler(void);
|
||||
void UsageFault_Handler(void);
|
||||
@ -48,6 +48,9 @@ void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
|
||||
void OTGFS1_IRQHandler(void);
|
||||
void OTGFS1_WKUP_IRQHandler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "at32f423_clock.h"
|
||||
#include "at32f423_int.h"
|
||||
#include "board.h"
|
||||
#include "bsp/board_api.h"
|
||||
|
||||
@ -266,6 +267,7 @@ void HardFault_Handler(void) {
|
||||
|
||||
// Required by __libc_init_array in startup code if we are compiling using
|
||||
// -nostdlib/-nostartfiles.
|
||||
void _init(void);
|
||||
void _init(void) {
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user