mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
Merge pull request #2836 from hathach/more-tusb_init()
change tusb_init() to use init struct
This commit is contained in:
commit
933ac29d77
2
.github/workflows/pre-commit.yml
vendored
2
.github/workflows/pre-commit.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
|||||||
#ceedling test:all
|
#ceedling test:all
|
||||||
|
|
||||||
- name: Run pre-commit
|
- name: Run pre-commit
|
||||||
uses: pre-commit/action@v3.0.0
|
uses: pre-commit/action@v3.0.1
|
||||||
|
|
||||||
- name: Build Fuzzer
|
- name: Build Fuzzer
|
||||||
run: |
|
run: |
|
||||||
|
13
.idea/cmake.xml
generated
13
.idea/cmake.xml
generated
@ -2,6 +2,9 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CMakeSharedSettings">
|
<component name="CMakeSharedSettings">
|
||||||
<configurations>
|
<configurations>
|
||||||
|
<configuration PROFILE_NAME="raspberrypi_zero" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberrypi_zero -DLOG=1" />
|
||||||
|
<configuration PROFILE_NAME="raspberrypi_zero2" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberrypi_zero2 -DLOG=1" />
|
||||||
|
<configuration PROFILE_NAME="raspberrypi_cm4" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberrypi_cm4 -DLOG=1" />
|
||||||
<configuration PROFILE_NAME="raspberry_pi_pico" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico -DLOG=1" />
|
<configuration PROFILE_NAME="raspberry_pi_pico" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico -DLOG=1" />
|
||||||
<configuration PROFILE_NAME="raspberry_pi_pico2" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico2 -DLOG=1" />
|
<configuration PROFILE_NAME="raspberry_pi_pico2" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico2 -DLOG=1" />
|
||||||
<configuration PROFILE_NAME="raspberry_pi_pico2_riscv" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico2_riscv -DLOG=1" />
|
<configuration PROFILE_NAME="raspberry_pi_pico2_riscv" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico2_riscv -DLOG=1" />
|
||||||
@ -80,7 +83,7 @@
|
|||||||
<configuration PROFILE_NAME="metro m7 1011 sd" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=metro_m7_1011_sd -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1" />
|
<configuration PROFILE_NAME="metro m7 1011 sd" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=metro_m7_1011_sd -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1" />
|
||||||
<configuration PROFILE_NAME="metro_m7_1011" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=metro_m7_1011 -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="metro_m7_1011" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=metro_m7_1011 -DLOG=1 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="rt1010 evk" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=mimxrt1010_evk -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="rt1010 evk" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=mimxrt1010_evk -DLOG=1 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="rt1060 evk" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=mimxrt1060_evk -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="mimxrt1060_evk" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=mimxrt1060_evk -DLOG=1 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="rt1170 evkb" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=mimxrt1170_evkb -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1" />
|
<configuration PROFILE_NAME="rt1170 evkb" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=mimxrt1170_evkb -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1" />
|
||||||
<configuration PROFILE_NAME="stm32f072disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f072disco -DLOG=0 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="stm32f072disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f072disco -DLOG=0 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="stm32f103_mini_2" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f103_mini_2 -DLOG=1 -DLOGGGER=RTT" />
|
<configuration PROFILE_NAME="stm32f103_mini_2" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f103_mini_2 -DLOG=1 -DLOGGGER=RTT" />
|
||||||
@ -94,11 +97,11 @@
|
|||||||
<configuration PROFILE_NAME="stm32g474nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32g474nucleo" />
|
<configuration PROFILE_NAME="stm32g474nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32g474nucleo" />
|
||||||
<configuration PROFILE_NAME="b_g474e_dpow1" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=b_g474e_dpow1 -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="b_g474e_dpow1" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=b_g474e_dpow1 -DLOG=1 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="stm32h563nucleo" ENABLED="false" GENERATION_OPTIONS="-DBOARD=stm32h563nucleo -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1" />
|
<configuration PROFILE_NAME="stm32h563nucleo" ENABLED="false" GENERATION_OPTIONS="-DBOARD=stm32h563nucleo -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1" />
|
||||||
<configuration PROFILE_NAME="stm32h743eval" ENABLED="true" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32h743eval -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1" />
|
<configuration PROFILE_NAME="stm32h743eval" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32h743eval -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1" />
|
||||||
<configuration PROFILE_NAME="stm32h743eval_dma" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32h743eval -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1 -DCFLAGS_CLI="-DCFG_TUD_DWC2_DMA=1"" />
|
<configuration PROFILE_NAME="stm32h743eval_dma" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32h743eval -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1 -DCFLAGS_CLI="-DCFG_TUD_DWC2_DMA=1"" />
|
||||||
<configuration PROFILE_NAME="stm32h743nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32h743nucleo -DLOG=1" />
|
<configuration PROFILE_NAME="stm32h743nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32h743nucleo -DLOG=1" />
|
||||||
<configuration PROFILE_NAME="stm32l0538disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32l0538disco -DLOG=0 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="stm32l0538disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32l0538disco -DLOG=0 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="stm32l476disco" ENABLED="true" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32l476disco -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="stm32l476disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32l476disco -DLOG=1 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="stm32u575nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32u575nucleo -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="stm32u575nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32u575nucleo -DLOG=1 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="stm32u5a5nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32u5a5nucleo -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="stm32u5a5nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32u5a5nucleo -DLOG=1 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="stm32wb55nucleo" ENABLED="false" GENERATION_OPTIONS="-DBOARD=stm32wb55nucleo" />
|
<configuration PROFILE_NAME="stm32wb55nucleo" ENABLED="false" GENERATION_OPTIONS="-DBOARD=stm32wb55nucleo" />
|
||||||
@ -109,9 +112,6 @@
|
|||||||
<configuration PROFILE_NAME="ra6m5_ek PORT0" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=ra6m5_ek -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1 -DPORT=0" />
|
<configuration PROFILE_NAME="ra6m5_ek PORT0" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=ra6m5_ek -DLOG=1 -DLOGGER=RTT -DTRACE_ETM=1 -DPORT=0" />
|
||||||
<configuration PROFILE_NAME="uno_r4" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=uno_r4 -DLOG=4 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="uno_r4" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=uno_r4 -DLOG=4 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="portenta_c33" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=portenta_c33 -DLOG=1" />
|
<configuration PROFILE_NAME="portenta_c33" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=portenta_c33 -DLOG=1" />
|
||||||
<configuration PROFILE_NAME="raspberrypi_zero" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberrypi_zero -DLOG=1" />
|
|
||||||
<configuration PROFILE_NAME="raspberrypi_zero2" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberrypi_zero2 -DLOG=1" />
|
|
||||||
<configuration PROFILE_NAME="raspberrypi_cm4" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberrypi_cm4 -DLOG=1" />
|
|
||||||
<configuration PROFILE_NAME="lpcxpresso11u37" ENABLED="false" GENERATION_OPTIONS="-DBOARD=lpcxpresso11u37" />
|
<configuration PROFILE_NAME="lpcxpresso11u37" ENABLED="false" GENERATION_OPTIONS="-DBOARD=lpcxpresso11u37" />
|
||||||
<configuration PROFILE_NAME="lpcxpresso11u68" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=lpcxpresso11u68 -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="lpcxpresso11u68" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=lpcxpresso11u68 -DLOG=1 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="lpcxpresso1347" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=lpcxpresso1347 -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="lpcxpresso1347" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=lpcxpresso1347 -DLOG=1 -DLOGGER=RTT" />
|
||||||
@ -148,6 +148,7 @@
|
|||||||
<configuration PROFILE_NAME="max32650fthr" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=max32650fthr -DLOG=0 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="max32650fthr" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=max32650fthr -DLOG=0 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="max32666fthr" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=max32666fthr -DLOG=0 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="max32666fthr" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=max32666fthr -DLOG=0 -DLOGGER=RTT" />
|
||||||
<configuration PROFILE_NAME="max32690evkit" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=max32690evkit -DLOG=1 -DLOGGER=RTT" />
|
<configuration PROFILE_NAME="max32690evkit" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=max32690evkit -DLOG=1 -DLOGGER=RTT" />
|
||||||
|
<configuration PROFILE_NAME="mimxrt1064_evk" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=mimxrt1064_evk" />
|
||||||
</configurations>
|
</configurations>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -42,3 +42,18 @@ repos:
|
|||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
types_or: [c, header]
|
types_or: [c, header]
|
||||||
language: system
|
language: system
|
||||||
|
|
||||||
|
# - id: build-fuzzer
|
||||||
|
# name: build-fuzzer
|
||||||
|
# files: ^(src/|test/fuzz/)
|
||||||
|
# language: system
|
||||||
|
# types_or: [c, header]
|
||||||
|
# entry: |
|
||||||
|
# bash -c 'export CC=clang
|
||||||
|
# export CXX=clang++
|
||||||
|
# fuzz_harness=$(ls -d test/fuzz/device/*/)
|
||||||
|
# for h in $fuzz_harness
|
||||||
|
# do
|
||||||
|
# make -C $h get-deps
|
||||||
|
# make -C $h all
|
||||||
|
# done'
|
||||||
|
@ -86,7 +86,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -209,7 +209,11 @@ void usb_device_task(void* param)
|
|||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
// This should be called after scheduler/kernel is started.
|
// This should be called after scheduler/kernel is started.
|
||||||
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -79,7 +79,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -156,7 +156,11 @@ void usb_device_task(void* param)
|
|||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
// This should be called after scheduler/kernel is started.
|
// This should be called after scheduler/kernel is started.
|
||||||
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -97,7 +97,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -52,7 +52,11 @@ int main(void) {
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -51,7 +51,11 @@ int main(void) {
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -132,7 +132,11 @@ static void usb_device_task(void *param) {
|
|||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
// This should be called after scheduler/kernel is started.
|
// This should be called after scheduler/kernel is started.
|
||||||
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -46,7 +46,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
#if (CFG_TUSB_MCU == OPT_MCU_RP2040)
|
#if (CFG_TUSB_MCU == OPT_MCU_RP2040)
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
@ -75,7 +75,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -70,7 +70,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -57,7 +57,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -57,7 +57,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -58,7 +58,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -136,7 +136,11 @@ void usb_device_task(void* param)
|
|||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
// This should be called after scheduler/kernel is started.
|
// This should be called after scheduler/kernel is started.
|
||||||
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -81,7 +81,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -62,7 +62,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -63,7 +63,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -54,7 +54,11 @@ int main(void) {
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -216,7 +216,11 @@ int main(void) {
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -100,7 +100,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -106,7 +106,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -55,7 +55,11 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -68,7 +68,11 @@ int main(void) {
|
|||||||
freertos_init_task();
|
freertos_init_task();
|
||||||
#else
|
#else
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
@ -319,7 +323,11 @@ void usb_device_task(void *param) {
|
|||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
// This should be called after scheduler/kernel is started.
|
// This should be called after scheduler/kernel is started.
|
||||||
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -68,7 +68,11 @@ int main(void) {
|
|||||||
freertos_init_task();
|
freertos_init_task();
|
||||||
#else
|
#else
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
@ -327,7 +331,11 @@ void usb_device_task(void *param) {
|
|||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
// This should be called after scheduler/kernel is started.
|
// This should be called after scheduler/kernel is started.
|
||||||
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -91,7 +91,11 @@ int main(void) {
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// init device stack on configured roothub port
|
// init device stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -79,8 +79,17 @@ int main(void) {
|
|||||||
printf("TinyUSB Host HID <-> Device CDC Example\r\n");
|
printf("TinyUSB Host HID <-> Device CDC Example\r\n");
|
||||||
|
|
||||||
// init device and host stack on configured roothub port
|
// init device and host stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
tusb_init(BOARD_TUH_RHPORT, TUSB_ROLE_HOST);
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
|
tusb_rhport_init_t host_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUH_RHPORT, &host_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -82,8 +82,17 @@ int main(void) {
|
|||||||
printf("TinyUSB Host Information -> Device CDC Example\r\n");
|
printf("TinyUSB Host Information -> Device CDC Example\r\n");
|
||||||
|
|
||||||
// init device and host stack on configured roothub port
|
// init device and host stack on configured roothub port
|
||||||
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
|
tusb_rhport_init_t dev_init = {
|
||||||
tusb_init(BOARD_TUH_RHPORT, TUSB_ROLE_HOST);
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
|
tusb_rhport_init_t host_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUH_RHPORT, &host_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -62,7 +62,11 @@ int main(void)
|
|||||||
printf("TinyUSB Bare API Example\r\n");
|
printf("TinyUSB Bare API Example\r\n");
|
||||||
|
|
||||||
// init host stack on configured roothub port
|
// init host stack on configured roothub port
|
||||||
tusb_init(BOARD_TUH_RHPORT, TUSB_ROLE_HOST);
|
tusb_rhport_init_t host_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUH_RHPORT, &host_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -50,7 +50,11 @@ int main(void) {
|
|||||||
printf("TinyUSB Host CDC MSC HID Example\r\n");
|
printf("TinyUSB Host CDC MSC HID Example\r\n");
|
||||||
|
|
||||||
// init host stack on configured roothub port
|
// init host stack on configured roothub port
|
||||||
tusb_init(BOARD_TUH_RHPORT, TUSB_ROLE_HOST);
|
tusb_rhport_init_t host_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUH_RHPORT, &host_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -126,7 +126,12 @@ static void usb_host_task(void *param) {
|
|||||||
(void) param;
|
(void) param;
|
||||||
|
|
||||||
// init host stack on configured roothub port
|
// init host stack on configured roothub port
|
||||||
if (!tusb_init(BOARD_TUH_RHPORT, TUSB_ROLE_HOST)) {
|
tusb_rhport_init_t host_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!tusb_init(BOARD_TUH_RHPORT, &host_init)) {
|
||||||
printf("Failed to init USB Host Stack\r\n");
|
printf("Failed to init USB Host Stack\r\n");
|
||||||
vTaskSuspend(NULL);
|
vTaskSuspend(NULL);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,11 @@ int main(void) {
|
|||||||
printf("TinyUSB Device Info Example\r\n");
|
printf("TinyUSB Device Info Example\r\n");
|
||||||
|
|
||||||
// init host stack on configured roothub port
|
// init host stack on configured roothub port
|
||||||
tusb_init(BOARD_TUH_RHPORT, TUSB_ROLE_HOST);
|
tusb_rhport_init_t host_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUH_RHPORT, &host_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -52,7 +52,11 @@ int main(void)
|
|||||||
printf("Note: Events only displayed for explicit supported controllers\r\n");
|
printf("Note: Events only displayed for explicit supported controllers\r\n");
|
||||||
|
|
||||||
// init host stack on configured roothub port
|
// init host stack on configured roothub port
|
||||||
tusb_init(BOARD_TUH_RHPORT, TUSB_ROLE_HOST);
|
tusb_rhport_init_t host_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUH_RHPORT, &host_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -78,7 +78,11 @@ int main(void) {
|
|||||||
printf("TinyUSB Host MassStorage Explorer Example\r\n");
|
printf("TinyUSB Host MassStorage Explorer Example\r\n");
|
||||||
|
|
||||||
// init host stack on configured roothub port
|
// init host stack on configured roothub port
|
||||||
tusb_init(BOARD_TUH_RHPORT, TUSB_ROLE_HOST);
|
tusb_rhport_init_t host_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
tusb_init(BOARD_TUH_RHPORT, &host_init);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
@ -707,7 +707,7 @@ static bool _open_vc_itf(uint8_t rhport, videod_interface_t *self, uint_fast8_t
|
|||||||
|
|
||||||
/* The first descriptor is a video control interface descriptor. */
|
/* The first descriptor is a video control interface descriptor. */
|
||||||
uint8_t const *cur = _find_desc_itf(beg, end, _desc_itfnum(beg), altnum);
|
uint8_t const *cur = _find_desc_itf(beg, end, _desc_itfnum(beg), altnum);
|
||||||
TU_LOG_DRV(" cur %d\r\n", cur - beg);
|
TU_LOG_DRV(" cur %" PRId32 "\r\n", (int32_t) (cur - beg));
|
||||||
TU_VERIFY(cur < end);
|
TU_VERIFY(cur < end);
|
||||||
|
|
||||||
tusb_desc_vc_itf_t const *vc = (tusb_desc_vc_itf_t const *)cur;
|
tusb_desc_vc_itf_t const *vc = (tusb_desc_vc_itf_t const *)cur;
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Optional API implemented by application if needed
|
// Optional API implemented by application if needed
|
||||||
// TODO move to a more ovious place/file
|
// TODO move to a more obvious place/file
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// flush data cache
|
// flush data cache
|
||||||
|
@ -118,6 +118,14 @@
|
|||||||
#define _TU_ARGS_APPLY_7(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7) _X(_a1) _s _TU_ARGS_APPLY_6(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7)
|
#define _TU_ARGS_APPLY_7(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7) _X(_a1) _s _TU_ARGS_APPLY_6(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7)
|
||||||
#define _TU_ARGS_APPLY_8(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) _X(_a1) _s _TU_ARGS_APPLY_7(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7, _a8)
|
#define _TU_ARGS_APPLY_8(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) _X(_a1) _s _TU_ARGS_APPLY_7(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7, _a8)
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Macro for function default arguments
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...) arg3
|
||||||
|
|
||||||
|
// function expand with number of arguments
|
||||||
|
#define TU_FUNC_OPTIONAL_ARG(func, ...) TU_XSTRCAT(func##_arg, TU_ARGS_NUM(__VA_ARGS__))(__VA_ARGS__)
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Compiler porting with Attribute and Endian
|
// Compiler porting with Attribute and Endian
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -50,6 +50,7 @@ typedef enum {
|
|||||||
TUSB_SPEED_FULL = 0,
|
TUSB_SPEED_FULL = 0,
|
||||||
TUSB_SPEED_LOW = 1,
|
TUSB_SPEED_LOW = 1,
|
||||||
TUSB_SPEED_HIGH = 2,
|
TUSB_SPEED_HIGH = 2,
|
||||||
|
TUSB_SPEED_AUTO = 0xaa,
|
||||||
TUSB_SPEED_INVALID = 0xff,
|
TUSB_SPEED_INVALID = 0xff,
|
||||||
} tusb_speed_t;
|
} tusb_speed_t;
|
||||||
|
|
||||||
@ -273,6 +274,14 @@ enum {
|
|||||||
TUSB_INDEX_INVALID_8 = 0xFFu
|
TUSB_INDEX_INVALID_8 = 0xFFu
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
typedef struct {
|
||||||
|
tusb_role_t role;
|
||||||
|
tusb_speed_t speed;
|
||||||
|
} tusb_rhport_init_t;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USB Descriptors
|
// USB Descriptors
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -93,9 +93,6 @@
|
|||||||
#define TU_BREAKPOINT() do {} while (0)
|
#define TU_BREAKPOINT() do {} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helper to implement optional parameter for TU_VERIFY Macro family
|
|
||||||
#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...) arg3
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* TU_VERIFY
|
/* TU_VERIFY
|
||||||
* - TU_VERIFY_1ARGS : return false if failed
|
* - TU_VERIFY_1ARGS : return false if failed
|
||||||
|
@ -108,7 +108,7 @@ void dcd_dcache_clean_invalidate(void const* addr, uint32_t data_size) TU_ATTR_W
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init(uint8_t rhport);
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
|
||||||
|
|
||||||
// Deinitialize controller, unset device mode.
|
// Deinitialize controller, unset device mode.
|
||||||
bool dcd_deinit(uint8_t rhport);
|
bool dcd_deinit(uint8_t rhport);
|
||||||
@ -194,38 +194,45 @@ extern void dcd_event_handler(dcd_event_t const * event, bool in_isr);
|
|||||||
|
|
||||||
// helper to send bus signal event
|
// helper to send bus signal event
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr) {
|
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr) {
|
||||||
dcd_event_t event = { .rhport = rhport, .event_id = eid };
|
dcd_event_t event;
|
||||||
|
event.rhport = rhport;
|
||||||
|
event.event_id = eid;
|
||||||
dcd_event_handler(&event, in_isr);
|
dcd_event_handler(&event, in_isr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper to send bus reset event
|
// helper to send bus reset event
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr) {
|
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr) {
|
||||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_BUS_RESET };
|
dcd_event_t event;
|
||||||
|
event.rhport = rhport;
|
||||||
|
event.event_id = DCD_EVENT_BUS_RESET;
|
||||||
event.bus_reset.speed = speed;
|
event.bus_reset.speed = speed;
|
||||||
dcd_event_handler(&event, in_isr);
|
dcd_event_handler(&event, in_isr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper to send setup received
|
// helper to send setup received
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr) {
|
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr) {
|
||||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_SETUP_RECEIVED };
|
dcd_event_t event;
|
||||||
|
event.rhport = rhport;
|
||||||
|
event.event_id = DCD_EVENT_SETUP_RECEIVED;
|
||||||
memcpy(&event.setup_received, setup, sizeof(tusb_control_request_t));
|
memcpy(&event.setup_received, setup, sizeof(tusb_control_request_t));
|
||||||
|
|
||||||
dcd_event_handler(&event, in_isr);
|
dcd_event_handler(&event, in_isr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper to send transfer complete event
|
// helper to send transfer complete event
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr) {
|
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr) {
|
||||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_XFER_COMPLETE };
|
dcd_event_t event;
|
||||||
|
event.rhport = rhport;
|
||||||
|
event.event_id = DCD_EVENT_XFER_COMPLETE;
|
||||||
event.xfer_complete.ep_addr = ep_addr;
|
event.xfer_complete.ep_addr = ep_addr;
|
||||||
event.xfer_complete.len = xferred_bytes;
|
event.xfer_complete.len = xferred_bytes;
|
||||||
event.xfer_complete.result = result;
|
event.xfer_complete.result = result;
|
||||||
|
|
||||||
dcd_event_handler(&event, in_isr);
|
dcd_event_handler(&event, in_isr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_sof(uint8_t rhport, uint32_t frame_count, bool in_isr) {
|
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_sof(uint8_t rhport, uint32_t frame_count, bool in_isr) {
|
||||||
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_SOF };
|
dcd_event_t event;
|
||||||
|
event.rhport = rhport;
|
||||||
|
event.event_id = DCD_EVENT_SOF;
|
||||||
event.sof.frame_count = frame_count;
|
event.sof.frame_count = frame_count;
|
||||||
dcd_event_handler(&event, in_isr);
|
dcd_event_handler(&event, in_isr);
|
||||||
}
|
}
|
||||||
|
@ -448,11 +448,14 @@ bool tud_inited(void) {
|
|||||||
return _usbd_rhport != RHPORT_INVALID;
|
return _usbd_rhport != RHPORT_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tud_init(uint8_t rhport) {
|
bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
// skip if already initialized
|
if (tud_inited()) {
|
||||||
if (tud_inited()) return true;
|
return true; // skip if already initialized
|
||||||
|
}
|
||||||
|
TU_ASSERT(rh_init);
|
||||||
|
|
||||||
TU_LOG_USBD("USBD init on controller %u, Highspeed = %u\r\n", rhport, TUD_OPT_HIGH_SPEED);
|
TU_LOG_USBD("USBD init on controller %u, speed = %s\r\n", rhport,
|
||||||
|
rh_init->speed == TUSB_SPEED_HIGH ? "High" : "Full");
|
||||||
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(usbd_device_t));
|
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(usbd_device_t));
|
||||||
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(dcd_event_t));
|
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(dcd_event_t));
|
||||||
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(tu_fifo_t));
|
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(tu_fifo_t));
|
||||||
@ -487,15 +490,16 @@ bool tud_init(uint8_t rhport) {
|
|||||||
_usbd_rhport = rhport;
|
_usbd_rhport = rhport;
|
||||||
|
|
||||||
// Init device controller driver
|
// Init device controller driver
|
||||||
dcd_init(rhport);
|
TU_ASSERT(dcd_init(rhport, rh_init));
|
||||||
dcd_int_enable(rhport);
|
dcd_int_enable(rhport);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tud_deinit(uint8_t rhport) {
|
bool tud_deinit(uint8_t rhport) {
|
||||||
// skip if not initialized
|
if (!tud_inited()) {
|
||||||
if (!tud_inited()) return true;
|
return true; // skip if not initialized
|
||||||
|
}
|
||||||
|
|
||||||
TU_LOG_USBD("USBD deinit on controller %u\r\n", rhport);
|
TU_LOG_USBD("USBD deinit on controller %u\r\n", rhport);
|
||||||
|
|
||||||
|
@ -37,8 +37,20 @@ extern "C" {
|
|||||||
// Application API
|
// Application API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// New API to replace tud_init() to init device stack on specific roothub port
|
||||||
|
bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
|
||||||
|
|
||||||
// Init device stack on roothub port
|
// Init device stack on roothub port
|
||||||
bool tud_init (uint8_t rhport);
|
#if TUSB_VERSION_NUMBER > 2000 // 0.20.0
|
||||||
|
TU_ATTR_DEPRECATED("Please use tusb_init(rhport, rh_init) instead")
|
||||||
|
#endif
|
||||||
|
TU_ATTR_ALWAYS_INLINE static inline bool tud_init (uint8_t rhport) {
|
||||||
|
const tusb_rhport_init_t rh_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUD_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL
|
||||||
|
};
|
||||||
|
return tud_rhport_init(rhport, &rh_init);
|
||||||
|
}
|
||||||
|
|
||||||
// Deinit device stack on roothub port
|
// Deinit device stack on roothub port
|
||||||
bool tud_deinit(uint8_t rhport);
|
bool tud_deinit(uint8_t rhport);
|
||||||
|
@ -53,26 +53,21 @@
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// MACRO CONSTANT TYPEDEF
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
HCD_EVENT_DEVICE_ATTACH,
|
HCD_EVENT_DEVICE_ATTACH,
|
||||||
HCD_EVENT_DEVICE_REMOVE,
|
HCD_EVENT_DEVICE_REMOVE,
|
||||||
HCD_EVENT_XFER_COMPLETE,
|
HCD_EVENT_XFER_COMPLETE,
|
||||||
|
|
||||||
// Not an HCD event, just a convenient way to defer ISR function
|
USBH_EVENT_FUNC_CALL, // Not an HCD event
|
||||||
USBH_EVENT_FUNC_CALL,
|
|
||||||
|
|
||||||
HCD_EVENT_COUNT
|
HCD_EVENT_COUNT
|
||||||
} hcd_eventid_t;
|
} hcd_eventid_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint8_t rhport;
|
uint8_t rhport;
|
||||||
uint8_t event_id;
|
uint8_t event_id;
|
||||||
uint8_t dev_addr;
|
uint8_t dev_addr;
|
||||||
|
|
||||||
union
|
union {
|
||||||
{
|
|
||||||
// Attach, Remove
|
// Attach, Remove
|
||||||
struct {
|
struct {
|
||||||
uint8_t hub_addr;
|
uint8_t hub_addr;
|
||||||
@ -93,11 +88,9 @@ typedef struct
|
|||||||
void* param;
|
void* param;
|
||||||
}func_call;
|
}func_call;
|
||||||
};
|
};
|
||||||
|
|
||||||
} hcd_event_t;
|
} hcd_event_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint8_t rhport;
|
uint8_t rhport;
|
||||||
uint8_t hub_addr;
|
uint8_t hub_addr;
|
||||||
uint8_t hub_port;
|
uint8_t hub_port;
|
||||||
@ -128,7 +121,7 @@ bool hcd_dcache_clean_invalidate(void const* addr, uint32_t data_size) TU_ATTR_W
|
|||||||
bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param);
|
bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param);
|
||||||
|
|
||||||
// Initialize controller to host mode
|
// Initialize controller to host mode
|
||||||
bool hcd_init(uint8_t rhport);
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
|
||||||
|
|
||||||
// De-initialize controller
|
// De-initialize controller
|
||||||
bool hcd_deinit(uint8_t rhport);
|
bool hcd_deinit(uint8_t rhport);
|
||||||
|
@ -352,11 +352,13 @@ bool tuh_inited(void) {
|
|||||||
return _usbh_controller != TUSB_INDEX_INVALID_8;
|
return _usbh_controller != TUSB_INDEX_INVALID_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tuh_init(uint8_t rhport) {
|
bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
// skip if already initialized
|
if (tuh_rhport_is_active(rhport)) {
|
||||||
if (tuh_rhport_is_active(rhport)) return true;
|
return true; // skip if already initialized
|
||||||
|
}
|
||||||
|
|
||||||
TU_LOG_USBH("USBH init on controller %u\r\n", rhport);
|
TU_LOG_USBH("USBH init on controller %u, speed = %s\r\n", rhport,
|
||||||
|
rh_init->speed == TUSB_SPEED_HIGH ? "High" : "Full");
|
||||||
|
|
||||||
// Init host stack if not already
|
// Init host stack if not already
|
||||||
if (!tuh_inited()) {
|
if (!tuh_inited()) {
|
||||||
@ -402,8 +404,8 @@ bool tuh_init(uint8_t rhport) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init host controller
|
// Init host controller
|
||||||
_usbh_controller = rhport;;
|
_usbh_controller = rhport;
|
||||||
TU_ASSERT(hcd_init(rhport));
|
TU_ASSERT(hcd_init(rhport, rh_init));
|
||||||
hcd_int_enable(rhport);
|
hcd_int_enable(rhport);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -120,8 +120,20 @@ void tuh_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr);
|
|||||||
// - cfg_param: configure data, structure depends on the ID
|
// - cfg_param: configure data, structure depends on the ID
|
||||||
bool tuh_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param);
|
bool tuh_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param);
|
||||||
|
|
||||||
|
// New API to replace tuh_init() to init host stack on specific roothub port
|
||||||
|
bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
|
||||||
|
|
||||||
// Init host stack
|
// Init host stack
|
||||||
bool tuh_init(uint8_t rhport);
|
#if TUSB_VERSION_NUMBER > 2000 // 0.20.0
|
||||||
|
TU_ATTR_DEPRECATED("Please use tusb_init(rhport, rh_init) instead")
|
||||||
|
#endif
|
||||||
|
TU_ATTR_ALWAYS_INLINE static inline bool tuh_init(uint8_t rhport) {
|
||||||
|
const tusb_rhport_init_t rh_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUH_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL,
|
||||||
|
};
|
||||||
|
return tuh_rhport_init(rhport, &rh_init);
|
||||||
|
}
|
||||||
|
|
||||||
// Deinit host stack on rhport
|
// Deinit host stack on rhport
|
||||||
bool tuh_deinit(uint8_t rhport);
|
bool tuh_deinit(uint8_t rhport);
|
||||||
@ -149,9 +161,10 @@ extern void hcd_int_handler(uint8_t rhport, bool in_isr);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Interrupt handler alias to HCD with in_isr as optional parameter
|
// Interrupt handler alias to HCD with in_isr as optional parameter
|
||||||
#define _tuh_int_handler_1arg(_rhport) hcd_int_handler(_rhport, true)
|
#define _tuh_int_handler_arg0() TU_VERIFY_STATIC(false, "tuh_int_handler() must have 1 or 2 arguments")
|
||||||
#define _tuh_int_hanlder_2arg(_rhport, _in_isr) hcd_int_handler(_rhport, _in_isr)
|
#define _tuh_int_handler_arg1(_rhport) hcd_int_handler(_rhport, true)
|
||||||
#define tuh_int_handler(...) TU_GET_3RD_ARG(__VA_ARGS__, _tuh_int_hanlder_2arg, _tuh_int_handler_1arg, _dummy)(__VA_ARGS__)
|
#define _tuh_int_handler_arg2(_rhport, _in_isr) hcd_int_handler(_rhport, _in_isr)
|
||||||
|
#define tuh_int_handler(...) TU_FUNC_OPTIONAL_ARG(_tuh_int_handler, __VA_ARGS__)
|
||||||
|
|
||||||
// Check if roothub port is initialized and active as a host
|
// Check if roothub port is initialized and active as a host
|
||||||
bool tuh_rhport_is_active(uint8_t rhport);
|
bool tuh_rhport_is_active(uint8_t rhport);
|
||||||
|
@ -494,8 +494,8 @@ bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize controller to host mode
|
// Initialize controller to host mode
|
||||||
bool hcd_init(uint8_t rhport) {
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rh_init;
|
||||||
|
|
||||||
tuh_max3421_int_api(rhport, false);
|
tuh_max3421_int_api(rhport, false);
|
||||||
|
|
||||||
|
@ -517,8 +517,8 @@ static uint16_t _ft9xx_dusb_out(uint8_t ep_number, uint8_t *buffer, uint16_t len
|
|||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
TU_LOG2("FT9xx initialisation\r\n");
|
TU_LOG2("FT9xx initialisation\r\n");
|
||||||
|
|
||||||
_dcd_ft9xx_attach();
|
_dcd_ft9xx_attach();
|
||||||
@ -526,6 +526,7 @@ void dcd_init(uint8_t rhport)
|
|||||||
interrupt_attach(interrupt_usb_device, (int8_t)interrupt_usb_device, _ft9xx_usbd_ISR);
|
interrupt_attach(interrupt_usb_device, (int8_t)interrupt_usb_device, _ft9xx_usbd_ISR);
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -267,9 +267,9 @@ static void process_bus_resume(uint8_t rhport)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Device API
|
/* Device API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
// save crystal-less setting (if available)
|
// save crystal-less setting (if available)
|
||||||
#if defined(FSL_FEATURE_USB_KHCI_IRC48M_MODULE_CLOCK_ENABLED) && FSL_FEATURE_USB_KHCI_IRC48M_MODULE_CLOCK_ENABLED == 1
|
#if defined(FSL_FEATURE_USB_KHCI_IRC48M_MODULE_CLOCK_ENABLED) && FSL_FEATURE_USB_KHCI_IRC48M_MODULE_CLOCK_ENABLED == 1
|
||||||
@ -296,6 +296,7 @@ void dcd_init(uint8_t rhport)
|
|||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
// NVIC_ClearPendingIRQ(CIFS_IRQN);
|
// NVIC_ClearPendingIRQ(CIFS_IRQN);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||||
|
@ -234,13 +234,13 @@ static void bus_reset(uint8_t rhport)
|
|||||||
dcd_dcache_clean_invalidate(&_dcd_data, sizeof(dcd_data_t));
|
dcd_dcache_clean_invalidate(&_dcd_data, sizeof(dcd_data_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
tu_memclr(&_dcd_data, sizeof(dcd_data_t));
|
tu_memclr(&_dcd_data, sizeof(dcd_data_t));
|
||||||
|
|
||||||
ci_hs_regs_t* dcd_reg = CI_HS_REG(rhport);
|
ci_hs_regs_t* dcd_reg = CI_HS_REG(rhport);
|
||||||
|
|
||||||
TU_ASSERT(ci_ep_count(dcd_reg) <= TUP_DCD_ENDPOINT_MAX, );
|
TU_ASSERT(ci_ep_count(dcd_reg) <= TUP_DCD_ENDPOINT_MAX);
|
||||||
|
|
||||||
// Reset controller
|
// Reset controller
|
||||||
dcd_reg->USBCMD |= USBCMD_RESET;
|
dcd_reg->USBCMD |= USBCMD_RESET;
|
||||||
@ -268,6 +268,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
usbcmd |= USBCMD_RUN_STOP; // run
|
usbcmd |= USBCMD_RUN_STOP; // run
|
||||||
|
|
||||||
dcd_reg->USBCMD = usbcmd;
|
dcd_reg->USBCMD = usbcmd;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -70,7 +70,8 @@ bool hcd_dcache_clean_invalidate(void const* addr, uint32_t data_size) {
|
|||||||
// Controller API
|
// Controller API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
bool hcd_init(uint8_t rhport) {
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
|
(void) rh_init;
|
||||||
ci_hs_regs_t *hcd_reg = CI_HS_REG(rhport);
|
ci_hs_regs_t *hcd_reg = CI_HS_REG(rhport);
|
||||||
|
|
||||||
// Reset controller
|
// Reset controller
|
||||||
@ -82,7 +83,9 @@ bool hcd_init(uint8_t rhport) {
|
|||||||
// LPC18XX/43XX need to set VBUS Power Select to HIGH
|
// LPC18XX/43XX need to set VBUS Power Select to HIGH
|
||||||
// RHPORT1 is fullspeed only (need external PHY for Highspeed)
|
// RHPORT1 is fullspeed only (need external PHY for Highspeed)
|
||||||
hcd_reg->USBMODE = USBMODE_CM_HOST | USBMODE_VBUS_POWER_SELECT;
|
hcd_reg->USBMODE = USBMODE_CM_HOST | USBMODE_VBUS_POWER_SELECT;
|
||||||
if ( rhport == 1 ) hcd_reg->PORTSC1 |= PORTSC1_FORCE_FULL_SPEED;
|
if (rhport == 1) {
|
||||||
|
hcd_reg->PORTSC1 |= PORTSC1_FORCE_FULL_SPEED;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
hcd_reg->USBMODE = USBMODE_CM_HOST;
|
hcd_reg->USBMODE = USBMODE_CM_HOST;
|
||||||
#endif
|
#endif
|
||||||
|
@ -804,15 +804,16 @@ static void handle_ep0_nak(void)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
_dcd.init_called = true;
|
_dcd.init_called = true;
|
||||||
if (_dcd.vbus_present)
|
if (_dcd.vbus_present) {
|
||||||
{
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -172,8 +172,8 @@ static void enum_done_processing(void)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
ESP_LOGV(TAG, "DCD init - Start");
|
ESP_LOGV(TAG, "DCD init - Start");
|
||||||
|
|
||||||
// A. Disconnect
|
// A. Disconnect
|
||||||
@ -211,6 +211,7 @@ void dcd_init(uint8_t rhport)
|
|||||||
USB_DISCONNINTMSK_M; // host most only
|
USB_DISCONNINTMSK_M; // host most only
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||||
|
@ -582,7 +582,8 @@ void print_musb_info(musb_regs_t* musb_regs) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
|
(void) rh_init;
|
||||||
musb_regs_t* musb_regs = MUSB_REGS(rhport);
|
musb_regs_t* musb_regs = MUSB_REGS(rhport);
|
||||||
|
|
||||||
#if CFG_TUSB_DEBUG >= MUSB_DEBUG
|
#if CFG_TUSB_DEBUG >= MUSB_DEBUG
|
||||||
@ -593,6 +594,7 @@ void dcd_init(uint8_t rhport) {
|
|||||||
musb_dcd_int_clear(rhport);
|
musb_dcd_int_clear(rhport);
|
||||||
musb_dcd_phy_init(rhport);
|
musb_dcd_phy_init(rhport);
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
@ -556,9 +556,9 @@ static void process_pipe_rx(uint8_t rhport, uint_fast8_t pipenum)
|
|||||||
* Host API
|
* Host API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
bool hcd_init(uint8_t rhport)
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rhport;
|
||||||
(void)rhport;
|
(void) rh_init;
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ(USB0_IRQn);
|
NVIC_ClearPendingIRQ(USB0_IRQn);
|
||||||
_hcd.bmRequestType = REQUEST_TYPE_INVALID;
|
_hcd.bmRequestType = REQUEST_TYPE_INVALID;
|
||||||
|
@ -470,8 +470,8 @@ static void process_bus_resume(uint8_t rhport)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Device API
|
/* Device API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
intr_disable(rhport);
|
intr_disable(rhport);
|
||||||
intr_clear(rhport);
|
intr_clear(rhport);
|
||||||
|
|
||||||
@ -502,6 +502,7 @@ void dcd_init(uint8_t rhport)
|
|||||||
U1IE = _U1IE_URSTIE_MASK;
|
U1IE = _U1IE_URSTIE_MASK;
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -120,8 +120,8 @@ static ep0_stage_t ep0_get_stage(void)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
// Disable endpoint interrupts for now
|
// Disable endpoint interrupts for now
|
||||||
USB_REGS->INTRRXEbits.w = 0;
|
USB_REGS->INTRRXEbits.w = 0;
|
||||||
USB_REGS->INTRTXEbits.w = 0;
|
USB_REGS->INTRTXEbits.w = 0;
|
||||||
@ -129,6 +129,7 @@ void dcd_init(uint8_t rhport)
|
|||||||
USB_REGS->INTRUSBEbits.w = 7;
|
USB_REGS->INTRUSBEbits.w = 7;
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -78,9 +78,9 @@ static void bus_reset(void)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init (uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
// Reset to get in a clean state.
|
// Reset to get in a clean state.
|
||||||
USB->DEVICE.CTRLA.bit.SWRST = true;
|
USB->DEVICE.CTRLA.bit.SWRST = true;
|
||||||
@ -102,6 +102,8 @@ void dcd_init (uint8_t rhport)
|
|||||||
|
|
||||||
USB->DEVICE.INTFLAG.reg |= USB->DEVICE.INTFLAG.reg; // clear pending
|
USB->DEVICE.INTFLAG.reg |= USB->DEVICE.INTFLAG.reg; // clear pending
|
||||||
USB->DEVICE.INTENSET.reg = /* USB_DEVICE_INTENSET_SOF | */ USB_DEVICE_INTENSET_EORST;
|
USB->DEVICE.INTENSET.reg = /* USB_DEVICE_INTENSET_SOF | */ USB_DEVICE_INTENSET_EORST;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CFG_TUSB_MCU == OPT_MCU_SAMD51 || CFG_TUSB_MCU == OPT_MCU_SAME5X
|
#if CFG_TUSB_MCU == OPT_MCU_SAMD51 || CFG_TUSB_MCU == OPT_MCU_SAME5X
|
||||||
|
@ -155,10 +155,13 @@ static void bus_reset(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init (uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
tu_memclr(_dcd_xfer, sizeof(_dcd_xfer));
|
tu_memclr(_dcd_xfer, sizeof(_dcd_xfer));
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -104,9 +104,10 @@ TU_ATTR_ALWAYS_INLINE static inline void CleanInValidateCache(uint32_t *addr, in
|
|||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init (uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -245,9 +245,9 @@ static void process_bus_active(uint8_t rhport)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Device API
|
/* Device API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
tu_memclr(&_dcd, sizeof(_dcd));
|
tu_memclr(&_dcd, sizeof(_dcd));
|
||||||
USB_OTG_FS->BDT_PAGE_01 = (uint8_t)((uintptr_t)_dcd.bdt >> 8);
|
USB_OTG_FS->BDT_PAGE_01 = (uint8_t)((uintptr_t)_dcd.bdt >> 8);
|
||||||
@ -256,6 +256,7 @@ void dcd_init(uint8_t rhport)
|
|||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
NVIC_ClearPendingIRQ(USB_FS_IRQn);
|
NVIC_ClearPendingIRQ(USB_FS_IRQn);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
#define USB_DEVICE_INTERRUPT_PRIORITY (3U)
|
#define USB_DEVICE_INTERRUPT_PRIORITY (3U)
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -230,9 +230,11 @@ static void xact_in_dma(uint8_t epnum) {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Controller API
|
// Controller API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void dcd_init(uint8_t rhport) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
TU_LOG2("dcd init\r\n");
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
TU_LOG2("dcd init\r\n");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
@ -201,9 +201,9 @@ static const uint32_t enabled_irqs = USBD_INTSTS_FLDET_STS_Msk | USBD_INTSTS_BUS
|
|||||||
NUC100/NUC120 TinyUSB API driver implementation
|
NUC100/NUC120 TinyUSB API driver implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
USBD->ATTR = 0x7D0;
|
USBD->ATTR = 0x7D0;
|
||||||
|
|
||||||
@ -215,6 +215,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
|
|
||||||
USBD->INTSTS = enabled_irqs;
|
USBD->INTSTS = enabled_irqs;
|
||||||
USBD->INTEN = enabled_irqs;
|
USBD->INTEN = enabled_irqs;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -209,9 +209,9 @@ enum {
|
|||||||
NUC121/NUC125/NUC126 TinyUSB API driver implementation
|
NUC121/NUC125/NUC126 TinyUSB API driver implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
#ifdef SUPPORT_LPM
|
#ifdef SUPPORT_LPM
|
||||||
USBD->ATTR = 0x7D0 | USBD_LPMACK;
|
USBD->ATTR = 0x7D0 | USBD_LPMACK;
|
||||||
@ -227,6 +227,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
|
|
||||||
USBD->INTSTS = ENABLED_IRQS;
|
USBD->INTSTS = ENABLED_IRQS;
|
||||||
USBD->INTEN = ENABLED_IRQS;
|
USBD->INTEN = ENABLED_IRQS;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -279,9 +279,9 @@ static const uint32_t enabled_irqs = USBD_GINTEN_USBIEN_Msk | \
|
|||||||
NUC505 TinyUSB API driver implementation
|
NUC505 TinyUSB API driver implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
/* configure interrupts in their initial state; BUSINTEN and CEPINTEN will be subsequently and dynamically re-written as needed */
|
/* configure interrupts in their initial state; BUSINTEN and CEPINTEN will be subsequently and dynamically re-written as needed */
|
||||||
USBD->GINTEN = enabled_irqs;
|
USBD->GINTEN = enabled_irqs;
|
||||||
@ -291,6 +291,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
bus_reset();
|
bus_reset();
|
||||||
|
|
||||||
usb_attach();
|
usb_attach();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -265,9 +265,9 @@ static void process_bus_resume(uint8_t rhport)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Device API
|
/* Device API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
// save crystal-less setting (if available)
|
// save crystal-less setting (if available)
|
||||||
#if defined(FSL_FEATURE_USB_KHCI_IRC48M_MODULE_CLOCK_ENABLED) && FSL_FEATURE_USB_KHCI_IRC48M_MODULE_CLOCK_ENABLED == 1
|
#if defined(FSL_FEATURE_USB_KHCI_IRC48M_MODULE_CLOCK_ENABLED) && FSL_FEATURE_USB_KHCI_IRC48M_MODULE_CLOCK_ENABLED == 1
|
||||||
@ -294,6 +294,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
NVIC_ClearPendingIRQ(USB0_IRQn);
|
NVIC_ClearPendingIRQ(USB0_IRQn);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -368,10 +368,9 @@ static void process_bus_reset(uint8_t rhport)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Host API
|
/* Host API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
bool hcd_init(uint8_t rhport)
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rhport;
|
||||||
(void)rhport;
|
(void) rh_init;
|
||||||
|
|
||||||
KHCI->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
|
KHCI->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
|
||||||
while (KHCI->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
|
while (KHCI->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
|
||||||
|
|
||||||
|
@ -167,9 +167,9 @@ static void bus_reset(void)
|
|||||||
tu_memclr(&_dcd, sizeof(dcd_data_t));
|
tu_memclr(&_dcd, sizeof(dcd_data_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
//------------- user manual 11.13 usb device controller initialization -------------//
|
//------------- user manual 11.13 usb device controller initialization -------------//
|
||||||
// step 6 : set up control endpoint
|
// step 6 : set up control endpoint
|
||||||
@ -186,6 +186,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
|
|
||||||
// Clear pending IRQ
|
// Clear pending IRQ
|
||||||
NVIC_ClearPendingIRQ(USB_IRQn);
|
NVIC_ClearPendingIRQ(USB_IRQn);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -289,8 +289,8 @@ static void edpt_reset_all(uint8_t rhport)
|
|||||||
}
|
}
|
||||||
prepare_setup_packet(rhport);
|
prepare_setup_packet(rhport);
|
||||||
}
|
}
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
edpt_reset_all(rhport);
|
edpt_reset_all(rhport);
|
||||||
|
|
||||||
dcd_registers_t* dcd_reg = _dcd_controller[rhport].regs;
|
dcd_registers_t* dcd_reg = _dcd_controller[rhport].regs;
|
||||||
@ -303,6 +303,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
DEVCMDSTAT_RESET_CHANGE_MASK | DEVCMDSTAT_CONNECT_CHANGE_MASK | DEVCMDSTAT_SUSPEND_CHANGE_MASK;
|
DEVCMDSTAT_RESET_CHANGE_MASK | DEVCMDSTAT_CONNECT_CHANGE_MASK | DEVCMDSTAT_SUSPEND_CHANGE_MASK;
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ(_dcd_controller[rhport].irqnum);
|
NVIC_ClearPendingIRQ(_dcd_controller[rhport].irqnum);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -178,9 +178,9 @@ TU_ATTR_ALWAYS_INLINE static inline void *_virt_addr(void *physical_address)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialization according to 5.1.1.4
|
// Initialization according to 5.1.1.4
|
||||||
bool hcd_init(uint8_t rhport)
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
//------------- Data Structure init -------------//
|
//------------- Data Structure init -------------//
|
||||||
tu_memclr(&ohci_data, sizeof(ohci_data_t));
|
tu_memclr(&ohci_data, sizeof(ohci_data_t));
|
||||||
|
@ -50,12 +50,13 @@ static usb_descriptor_buffers_t desc;
|
|||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init (uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
static pio_usb_configuration_t config = PIO_USB_DEFAULT_CONFIG;
|
static pio_usb_configuration_t config = PIO_USB_DEFAULT_CONFIG;
|
||||||
usb_device = pio_usb_device_init(&config, &desc);
|
usb_device = pio_usb_device_init(&config, &desc);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -55,8 +55,9 @@ bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void *cfg_param) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hcd_init(uint8_t rhport) {
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
// To run USB SOF interrupt in core1, call this init in core1
|
// To run USB SOF interrupt in core1, call this init in core1
|
||||||
pio_usb_host_init(&pio_host_cfg);
|
pio_usb_host_init(&pio_host_cfg);
|
||||||
|
@ -369,7 +369,8 @@ static void __tusb_irq_path_func(dcd_rp2040_irq)(void) {
|
|||||||
#define PICO_SHARED_IRQ_HANDLER_HIGHEST_ORDER_PRIORITY 0xff
|
#define PICO_SHARED_IRQ_HANDLER_HIGHEST_ORDER_PRIORITY 0xff
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
|
(void) rh_init;
|
||||||
assert(rhport == 0);
|
assert(rhport == 0);
|
||||||
|
|
||||||
TU_LOG(2, "Chip Version B%u\r\n", rp2040_chip_version());
|
TU_LOG(2, "Chip Version B%u\r\n", rp2040_chip_version());
|
||||||
@ -405,6 +406,7 @@ void dcd_init(uint8_t rhport) {
|
|||||||
(FORCE_VBUS_DETECT ? 0 : USB_INTS_DEV_CONN_DIS_BITS);
|
(FORCE_VBUS_DETECT ? 0 : USB_INTS_DEV_CONN_DIS_BITS);
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_deinit(uint8_t rhport) {
|
bool dcd_deinit(uint8_t rhport) {
|
||||||
|
@ -375,9 +375,9 @@ static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t dev_addr, uint8_t
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HCD API
|
// HCD API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool hcd_init(uint8_t rhport)
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
pico_trace("hcd_init %d\n", rhport);
|
pico_trace("hcd_init %d\n", rhport);
|
||||||
assert(rhport == 0);
|
assert(rhport == 0);
|
||||||
|
|
||||||
|
@ -657,14 +657,14 @@ static void enable_interrupt(uint32_t pswi)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
rusb2_reg_t* rusb = RUSB2_REG(rhport);
|
rusb2_reg_t* rusb = RUSB2_REG(rhport);
|
||||||
rusb2_module_start(rhport, true);
|
rusb2_module_start(rhport, true);
|
||||||
|
|
||||||
// We disable SOF for now until needed later on.
|
// We disable SOF for now until needed later on.
|
||||||
// Since TinyUSB doesn't use SOF for now, and this interrupt often (1ms interval)
|
// Since TinyUSB doesn't use SOF for now, and this interrupt often (1ms interval)
|
||||||
_dcd.sof_enabled = false;
|
_dcd.sof_enabled = false;
|
||||||
|
|
||||||
#ifdef RUSB2_SUPPORT_HIGHSPEED
|
#ifdef RUSB2_SUPPORT_HIGHSPEED
|
||||||
if ( rusb2_is_highspeed_rhport(rhport) ) {
|
if ( rusb2_is_highspeed_rhport(rhport) ) {
|
||||||
@ -719,6 +719,8 @@ _dcd.sof_enabled = false;
|
|||||||
if (rusb->INTSTS0_b.VBSTS) {
|
if (rusb->INTSTS0_b.VBSTS) {
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
@ -466,8 +466,8 @@ static void enable_interrupt(uint32_t pswi)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool hcd_init(uint8_t rhport)
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
rusb2_reg_t* rusb = RUSB2_REG(rhport);
|
rusb2_reg_t* rusb = RUSB2_REG(rhport);
|
||||||
rusb2_module_start(rhport, true);
|
rusb2_module_start(rhport, true);
|
||||||
|
|
||||||
|
@ -201,9 +201,9 @@ static void _dcd_resume(FAR struct usbdevclass_driver_s *driver, FAR struct usbd
|
|||||||
dcd_event_bus_signal(0, DCD_EVENT_RESUME, true);
|
dcd_event_bus_signal(0, DCD_EVENT_RESUME, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
usbdcd_driver.usbdevclass_driver.speed = USB_SPEED_HIGH;
|
usbdcd_driver.usbdevclass_driver.speed = USB_SPEED_HIGH;
|
||||||
usbdcd_driver.usbdevclass_driver.ops = &g_driverops;
|
usbdcd_driver.usbdevclass_driver.ops = &g_driverops;
|
||||||
@ -211,6 +211,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
usbdcd_driver.setup_queue = osal_queue_create(&_setup_queue_def);
|
usbdcd_driver.setup_queue = osal_queue_create(&_setup_queue_def);
|
||||||
|
|
||||||
usbdev_register(&usbdcd_driver.usbdevclass_driver);
|
usbdev_register(&usbdcd_driver.usbdevclass_driver);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -184,7 +184,8 @@ TU_ATTR_ALWAYS_INLINE static inline xfer_ctl_t *xfer_ctl_ptr(uint8_t epnum, uint
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Controller API
|
// Controller API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void dcd_init(uint8_t rhport) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
|
(void) rh_init;
|
||||||
// Follow the RM mentions to use a special ordering of PDWN and FRES
|
// Follow the RM mentions to use a special ordering of PDWN and FRES
|
||||||
for (volatile uint32_t i = 0; i < 200; i++) { // should be a few us
|
for (volatile uint32_t i = 0; i < 200; i++) { // should be a few us
|
||||||
asm("NOP");
|
asm("NOP");
|
||||||
@ -223,6 +224,8 @@ void dcd_init(uint8_t rhport) {
|
|||||||
|
|
||||||
// Enable pull-up if supported
|
// Enable pull-up if supported
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_sof_enable(uint8_t rhport, bool en) {
|
void dcd_sof_enable(uint8_t rhport, bool en) {
|
||||||
|
@ -867,8 +867,9 @@ static void usb_isr_handler(void) {
|
|||||||
dcd_int_handler(0);
|
dcd_int_handler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rh_init;
|
||||||
|
|
||||||
dcd_disconnect(rhport);
|
dcd_disconnect(rhport);
|
||||||
USBC_HardwareReset();
|
USBC_HardwareReset();
|
||||||
USBC_PhyConfig();
|
USBC_PhyConfig();
|
||||||
@ -895,6 +896,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
f1c100s_intc_set_isr(F1C100S_IRQ_USBOTG, usb_isr_handler);
|
f1c100s_intc_set_isr(F1C100S_IRQ_USBOTG, usb_isr_handler);
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect by enabling internal pull-up resistor on D+/D-
|
// Connect by enabling internal pull-up resistor on D+/D-
|
||||||
|
@ -650,13 +650,15 @@ static bool check_dwc2(dwc2_regs_t* dwc2) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
// Programming model begins in the last section of the chapter on the USB
|
// Programming model begins in the last section of the chapter on the USB
|
||||||
// peripheral in each Reference Manual.
|
// peripheral in each Reference Manual.
|
||||||
dwc2_regs_t* dwc2 = DWC2_REG(rhport);
|
dwc2_regs_t* dwc2 = DWC2_REG(rhport);
|
||||||
|
|
||||||
// Check Synopsys ID register, failed if controller clock/power is not enabled
|
// Check Synopsys ID register, failed if controller clock/power is not enabled
|
||||||
TU_ASSERT(check_dwc2(dwc2), );
|
TU_ASSERT(check_dwc2(dwc2));
|
||||||
dcd_disconnect(rhport);
|
dcd_disconnect(rhport);
|
||||||
|
|
||||||
if (phy_hs_supported(dwc2)) {
|
if (phy_hs_supported(dwc2)) {
|
||||||
@ -725,6 +727,8 @@ void dcd_init(uint8_t rhport) {
|
|||||||
// TU_LOG_HEX(DWC2_DEBUG, dwc2->gahbcfg);
|
// TU_LOG_HEX(DWC2_DEBUG, dwc2->gahbcfg);
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
@ -40,54 +40,45 @@
|
|||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init (uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rhport; (void) rh_init;
|
||||||
(void) rhport;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
void dcd_int_enable (uint8_t rhport)
|
void dcd_int_enable (uint8_t rhport) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable device interrupt
|
// Disable device interrupt
|
||||||
void dcd_int_disable (uint8_t rhport)
|
void dcd_int_disable (uint8_t rhport) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive Set Address request, mcu port must also include status IN response
|
// Receive Set Address request, mcu port must also include status IN response
|
||||||
void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address (uint8_t rhport, uint8_t dev_addr) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) dev_addr;
|
(void) dev_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wake up host
|
// Wake up host
|
||||||
void dcd_remote_wakeup (uint8_t rhport)
|
void dcd_remote_wakeup (uint8_t rhport) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect by enabling internal pull-up resistor on D+/D-
|
// Connect by enabling internal pull-up resistor on D+/D-
|
||||||
void dcd_connect(uint8_t rhport)
|
void dcd_connect(uint8_t rhport) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disconnect by disabling internal pull-up resistor on D+/D-
|
// Disconnect by disabling internal pull-up resistor on D+/D-
|
||||||
void dcd_disconnect(uint8_t rhport)
|
void dcd_disconnect(uint8_t rhport) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_sof_enable(uint8_t rhport, bool en)
|
void dcd_sof_enable(uint8_t rhport, bool en) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) en;
|
(void) en;
|
||||||
|
|
||||||
// TODO implement later
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
@ -95,8 +86,7 @@ void dcd_sof_enable(uint8_t rhport, bool en)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Configure endpoint's registers according to descriptor
|
// Configure endpoint's registers according to descriptor
|
||||||
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
|
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * ep_desc) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) ep_desc;
|
(void) ep_desc;
|
||||||
return false;
|
return false;
|
||||||
@ -118,14 +108,12 @@ bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_edpt_close_all (uint8_t rhport)
|
void dcd_edpt_close_all (uint8_t rhport) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) ep_addr;
|
(void) ep_addr;
|
||||||
(void) buffer;
|
(void) buffer;
|
||||||
@ -134,8 +122,7 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
|
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
|
||||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) ep_addr;
|
(void) ep_addr;
|
||||||
(void) ff;
|
(void) ff;
|
||||||
@ -144,19 +131,15 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stall endpoint
|
// Stall endpoint
|
||||||
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
|
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) ep_addr;
|
(void) ep_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear stall, data toggle is also reset to DATA0
|
// clear stall, data toggle is also reset to DATA0
|
||||||
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) ep_addr;
|
(void) ep_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,9 +44,9 @@ bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize controller to host mode
|
// Initialize controller to host mode
|
||||||
bool hcd_init(uint8_t rhport) {
|
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +130,8 @@ static void enable_functional_reset(const bool enable)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init (uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
(void) rhport; (void) rh_init;
|
||||||
(void) rhport;
|
|
||||||
|
|
||||||
USBKEYPID = USBKEY;
|
USBKEYPID = USBKEY;
|
||||||
|
|
||||||
@ -164,6 +163,8 @@ void dcd_init (uint8_t rhport)
|
|||||||
}
|
}
|
||||||
|
|
||||||
USBKEYPID = 0;
|
USBKEYPID = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is no "USB peripheral interrupt disable" bit on MSP430, so we have
|
// There is no "USB peripheral interrupt disable" bit on MSP430, so we have
|
||||||
@ -699,7 +700,11 @@ static void handle_bus_power_event(void *param) {
|
|||||||
|
|
||||||
// A successful lock is indicated by all PLL-related interrupt flags being cleared.
|
// A successful lock is indicated by all PLL-related interrupt flags being cleared.
|
||||||
if(!USBPLLIR) {
|
if(!USBPLLIR) {
|
||||||
dcd_init(0); // Re-initialize the USB module.
|
const tusb_rhport_init_t rhport_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_FULL
|
||||||
|
};
|
||||||
|
dcd_init(0, &rhport_init); // Re-initialize the USB module.
|
||||||
}
|
}
|
||||||
} else { // Event caused by removal of bus power.
|
} else { // Event caused by removal of bus power.
|
||||||
USBPWRCTL |= VBONIE; // Enable bus-power-applied interrupt.
|
USBPWRCTL |= VBONIE; // Enable bus-power-applied interrupt.
|
||||||
|
@ -336,9 +336,9 @@ static void dcd_reset(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initializes the USB peripheral for device mode and enables it.
|
// Initializes the USB peripheral for device mode and enables it.
|
||||||
void dcd_init(uint8_t rhport)
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
{
|
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
usb_pullup_out_write(0);
|
usb_pullup_out_write(0);
|
||||||
|
|
||||||
@ -352,6 +352,8 @@ void dcd_init(uint8_t rhport)
|
|||||||
|
|
||||||
// Turn on the external pullup
|
// Turn on the external pullup
|
||||||
usb_pullup_out_write(1);
|
usb_pullup_out_write(1);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enables or disables the USB device interrupt(s). May be used to
|
// Enables or disables the USB device interrupt(s). May be used to
|
||||||
|
@ -123,7 +123,8 @@ static void update_out(uint8_t rhport, uint8_t ep, size_t rx_len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
void dcd_init(uint8_t rhport) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
|
(void) rh_init;
|
||||||
// init registers
|
// init registers
|
||||||
USBOTG_FS->BASE_CTRL = USBFS_CTRL_SYS_CTRL | USBFS_CTRL_INT_BUSY | USBFS_CTRL_DMA_EN;
|
USBOTG_FS->BASE_CTRL = USBFS_CTRL_SYS_CTRL | USBFS_CTRL_INT_BUSY | USBFS_CTRL_DMA_EN;
|
||||||
USBOTG_FS->UDEV_CTRL = USBFS_UDEV_CTRL_PD_DIS | USBFS_UDEV_CTRL_PORT_EN;
|
USBOTG_FS->UDEV_CTRL = USBFS_UDEV_CTRL_PD_DIS | USBFS_UDEV_CTRL_PORT_EN;
|
||||||
@ -153,6 +154,8 @@ void dcd_init(uint8_t rhport) {
|
|||||||
EP_DMA(3) = (uint32_t) &data.ep3_buffer.out[0];
|
EP_DMA(3) = (uint32_t) &data.ep3_buffer.out[0];
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_handler(uint8_t rhport) {
|
void dcd_int_handler(uint8_t rhport) {
|
||||||
|
@ -131,8 +131,9 @@ static void xfer_data_packet(uint8_t ep_num, tusb_dir_t ep_dir, xfer_ctl_t* xfer
|
|||||||
ep_set_response_and_toggle(ep_num, ep_dir, USBHS_EP_R_RES_ACK);
|
ep_set_response_and_toggle(ep_num, ep_dir, USBHS_EP_R_RES_ACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
memset(&xfer_status, 0, sizeof(xfer_status));
|
memset(&xfer_status, 0, sizeof(xfer_status));
|
||||||
|
|
||||||
@ -170,6 +171,8 @@ void dcd_init(uint8_t rhport) {
|
|||||||
|
|
||||||
USBHSD->DEV_AD = 0;
|
USBHSD->DEV_AD = 0;
|
||||||
USBHSD->CONTROL |= USBHS_DEV_PU_EN;
|
USBHSD->CONTROL |= USBHS_DEV_PU_EN;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
32
src/tusb.c
32
src/tusb.c
@ -47,19 +47,27 @@ static tusb_role_t _rhport_role[TUP_USBIP_CONTROLLER_NUM] = { 0 };
|
|||||||
// Public API
|
// Public API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
bool _tusb_rhport_init(uint8_t rhport, tusb_role_t role) {
|
bool tusb_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
// backward compatible called with tusb_init(void)
|
// backward compatible called with tusb_init(void)
|
||||||
#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
|
#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
|
||||||
if (rhport == 0xff || role == TUSB_ROLE_INVALID) {
|
if (rh_init == NULL) {
|
||||||
#if CFG_TUD_ENABLED && defined(TUD_OPT_RHPORT)
|
#if CFG_TUD_ENABLED && defined(TUD_OPT_RHPORT)
|
||||||
// init device stack CFG_TUSB_RHPORTx_MODE must be defined
|
// init device stack CFG_TUSB_RHPORTx_MODE must be defined
|
||||||
TU_ASSERT ( tud_init(TUD_OPT_RHPORT) );
|
const tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUD_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL
|
||||||
|
};
|
||||||
|
TU_ASSERT ( tud_rhport_init(rhport, &dev_init) );
|
||||||
_rhport_role[TUD_OPT_RHPORT] = TUSB_ROLE_DEVICE;
|
_rhport_role[TUD_OPT_RHPORT] = TUSB_ROLE_DEVICE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUH_ENABLED && defined(TUH_OPT_RHPORT)
|
#if CFG_TUH_ENABLED && defined(TUH_OPT_RHPORT)
|
||||||
// init host stack CFG_TUSB_RHPORTx_MODE must be defined
|
// init host stack CFG_TUSB_RHPORTx_MODE must be defined
|
||||||
TU_ASSERT( tuh_init(TUH_OPT_RHPORT) );
|
const tusb_rhport_init_t host_init = {
|
||||||
|
.role = TUSB_ROLE_HOST,
|
||||||
|
.speed = TUH_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL
|
||||||
|
};
|
||||||
|
TU_ASSERT( tuh_rhport_init(TUH_OPT_RHPORT, &host_init) );
|
||||||
_rhport_role[TUH_OPT_RHPORT] = TUSB_ROLE_HOST;
|
_rhport_role[TUH_OPT_RHPORT] = TUSB_ROLE_HOST;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -68,21 +76,21 @@ bool _tusb_rhport_init(uint8_t rhport, tusb_role_t role) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// new API with explicit rhport and role
|
// new API with explicit rhport and role
|
||||||
TU_ASSERT(rhport < TUP_USBIP_CONTROLLER_NUM && role != TUSB_ROLE_INVALID);
|
TU_ASSERT(rhport < TUP_USBIP_CONTROLLER_NUM && rh_init->role != TUSB_ROLE_INVALID);
|
||||||
|
|
||||||
#if CFG_TUD_ENABLED
|
#if CFG_TUD_ENABLED
|
||||||
if (role == TUSB_ROLE_DEVICE) {
|
if (rh_init->role == TUSB_ROLE_DEVICE) {
|
||||||
TU_ASSERT( tud_init(rhport) );
|
TU_ASSERT(tud_rhport_init(rhport, rh_init));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUH_ENABLED
|
#if CFG_TUH_ENABLED
|
||||||
if (role == TUSB_ROLE_HOST) {
|
if (rh_init->role == TUSB_ROLE_HOST) {
|
||||||
TU_ASSERT( tuh_init(rhport) );
|
TU_ASSERT(tuh_rhport_init(rhport, rh_init));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_rhport_role[rhport] = role;
|
_rhport_role[rhport] = rh_init->role;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,13 +114,13 @@ void tusb_int_handler(uint8_t rhport, bool in_isr) {
|
|||||||
#if CFG_TUD_ENABLED
|
#if CFG_TUD_ENABLED
|
||||||
if (_rhport_role[rhport] == TUSB_ROLE_DEVICE) {
|
if (_rhport_role[rhport] == TUSB_ROLE_DEVICE) {
|
||||||
(void) in_isr;
|
(void) in_isr;
|
||||||
tud_int_handler(rhport);
|
dcd_int_handler(rhport);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUH_ENABLED
|
#if CFG_TUH_ENABLED
|
||||||
if (_rhport_role[rhport] == TUSB_ROLE_HOST) {
|
if (_rhport_role[rhport] == TUSB_ROLE_HOST) {
|
||||||
tuh_int_handler(rhport, in_isr);
|
hcd_int_handler(rhport, in_isr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
17
src/tusb.h
17
src/tusb.h
@ -129,19 +129,26 @@
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION API
|
// APPLICATION API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
#if CFG_TUH_ENABLED || CFG_TUD_ENABLED
|
#if CFG_TUH_ENABLED || CFG_TUD_ENABLED
|
||||||
|
|
||||||
// Internal helper for backward compatible with tusb_init(void)
|
// Internal helper for backward compatible with tusb_init(void)
|
||||||
bool _tusb_rhport_init(uint8_t rhport, tusb_role_t role);
|
bool tusb_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
|
||||||
|
|
||||||
// Initialize roothub port with device/host role
|
// Initialize roothub port with device/host role
|
||||||
// Note: when using with RTOS, this should be called after scheduler/kernel is started.
|
// Note: when using with RTOS, this should be called after scheduler/kernel is started.
|
||||||
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
||||||
// Note2: defined as macro for backward compatible with tusb_init(void), can be changed to function in the future.
|
// Note2: defined as macro for backward compatible with tusb_init(void), can be changed to function in the future.
|
||||||
#define _tusb_init_0arg() _tusb_rhport_init(0xff, TUSB_ROLE_INVALID)
|
#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
|
||||||
#define _tusb_init_1arg(_rhport) _tusb_rhport_init(_rhport, TUSB_ROLE_INVALID)
|
#define _tusb_init_arg0() tusb_rhport_init(0, NULL)
|
||||||
#define _tusb_init_2arg(_rhport, _role) _tusb_rhport_init(_rhport, _role)
|
#else
|
||||||
#define tusb_init(...) TU_GET_3RD_ARG(__VA_ARGS__, _tusb_init_2arg, _tusb_init_1arg, _tusb_init_0arg)(__VA_ARGS__)
|
#define _tusb_init_arg0() TU_VERIFY_STATIC(false, "CFG_TUSB_RHPORT0_MODE/CFG_TUSB_RHPORT1_MODE must be defined")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define _tusb_init_arg1(_rhport) _tusb_init_arg0()
|
||||||
|
#define _tusb_init_arg2(_rhport, _rh_init) tusb_rhport_init(_rhport, _rh_init)
|
||||||
|
#define tusb_init(...) TU_FUNC_OPTIONAL_ARG(_tusb_init, __VA_ARGS__)
|
||||||
|
|
||||||
// Check if stack is initialized
|
// Check if stack is initialized
|
||||||
bool tusb_inited(void);
|
bool tusb_inited(void);
|
||||||
|
@ -46,9 +46,10 @@ tu_static State state = {false, 0, 0};
|
|||||||
// All no-ops as we are fuzzing.
|
// All no-ops as we are fuzzing.
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void dcd_init(uint8_t rhport) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
UNUSED(rhport);
|
UNUSED(rhport);
|
||||||
return;
|
UNUSED(rh_init);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_handler(uint8_t rhport) {
|
void dcd_int_handler(uint8_t rhport) {
|
||||||
|
@ -197,10 +197,14 @@ void setUp(void)
|
|||||||
dcd_int_disable_Ignore();
|
dcd_int_disable_Ignore();
|
||||||
dcd_int_enable_Ignore();
|
dcd_int_enable_Ignore();
|
||||||
|
|
||||||
if ( !tud_inited() )
|
if ( !tud_inited() ) {
|
||||||
{
|
tusb_rhport_init_t dev_init = {
|
||||||
dcd_init_Expect(rhport);
|
.role = TUSB_ROLE_DEVICE,
|
||||||
tusb_init(0, TUSB_ROLE_DEVICE);
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
|
||||||
|
dcd_init_ExpectAndReturn(0, &dev_init, true);
|
||||||
|
tusb_init(0, &dev_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcd_event_bus_reset(rhport, TUSB_SPEED_HIGH, false);
|
dcd_event_bus_reset(rhport, TUSB_SPEED_HIGH, false);
|
||||||
|
@ -102,38 +102,38 @@ uint8_t const* desc_configuration;
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
//
|
//
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
uint8_t const * tud_descriptor_device_cb(void)
|
uint8_t const * tud_descriptor_device_cb(void) {
|
||||||
{
|
|
||||||
return desc_device;
|
return desc_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
|
uint8_t const * tud_descriptor_configuration_cb(uint8_t index) {
|
||||||
{
|
|
||||||
return desc_configuration;
|
return desc_configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
|
uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
|
||||||
{
|
|
||||||
(void) langid;
|
(void) langid;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUp(void)
|
void setUp(void) {
|
||||||
{
|
|
||||||
dcd_int_disable_Ignore();
|
dcd_int_disable_Ignore();
|
||||||
dcd_int_enable_Ignore();
|
dcd_int_enable_Ignore();
|
||||||
|
|
||||||
if ( !tud_inited() )
|
if ( !tud_inited() ) {
|
||||||
{
|
tusb_rhport_init_t dev_init = {
|
||||||
|
.role = TUSB_ROLE_DEVICE,
|
||||||
|
.speed = TUSB_SPEED_AUTO
|
||||||
|
};
|
||||||
|
|
||||||
mscd_init_Expect();
|
mscd_init_Expect();
|
||||||
dcd_init_Expect(rhport);
|
dcd_init_ExpectAndReturn(0, &dev_init, true);
|
||||||
tusb_init(0, TUSB_ROLE_DEVICE);
|
|
||||||
|
tusb_init(0, &dev_init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tearDown(void)
|
void tearDown(void) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
Loading…
x
Reference in New Issue
Block a user