change the tusb_rhport_init_t struct, exclude the rhport to make API more consistent

This commit is contained in:
hathach 2024-10-14 18:27:52 +07:00
parent 1587d48e89
commit 1f18be93db
No known key found for this signature in database
GPG Key ID: 26FAB84F615C3C52
89 changed files with 174 additions and 213 deletions

View File

@ -29,7 +29,7 @@ jobs:
#ceedling test:all
- name: Run pre-commit
uses: pre-commit/action@v3.0.0
uses: pre-commit/action@v3.0.1
- name: Build Fuzzer
run: |

13
.idea/cmake.xml generated
View File

@ -2,6 +2,9 @@
<project version="4">
<component name="CMakeSharedSettings">
<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_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" />
@ -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" 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="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="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" />
@ -94,11 +97,11 @@
<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="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=&quot;-DCFG_TUD_DWC2_DMA=1&quot;" />
<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="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="stm32u5a5nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32u5a5nucleo -DLOG=1 -DLOGGER=RTT" />
<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="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="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="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" />
@ -148,6 +148,7 @@
<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="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>
</component>
</project>

View File

@ -87,11 +87,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -210,11 +210,10 @@ void usb_device_task(void* param)
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -80,11 +80,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -157,11 +157,10 @@ void usb_device_task(void* param)
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -98,11 +98,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -53,11 +53,10 @@ int main(void) {
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -52,11 +52,10 @@ int main(void) {
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -133,11 +133,10 @@ static void usb_device_task(void *param) {
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -47,11 +47,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
#if (CFG_TUSB_MCU == OPT_MCU_RP2040)
stdio_init_all();

View File

@ -76,11 +76,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -71,11 +71,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -58,11 +58,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -58,11 +58,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -59,11 +59,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -137,11 +137,10 @@ void usb_device_task(void* param)
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -82,11 +82,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -63,11 +63,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -64,11 +64,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -55,11 +55,10 @@ int main(void) {
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -217,11 +217,10 @@ int main(void) {
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -101,11 +101,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -107,11 +107,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -56,11 +56,10 @@ int main(void)
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -69,11 +69,10 @@ int main(void) {
#else
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();
@ -325,11 +324,10 @@ void usb_device_task(void *param) {
// This should be called after scheduler/kernel is started.
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -69,11 +69,10 @@ int main(void) {
#else
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();
@ -333,11 +332,10 @@ void usb_device_task(void *param) {
// This should be called after scheduler/kernel is started.
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -92,11 +92,10 @@ int main(void) {
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -80,18 +80,16 @@ int main(void) {
// init device and host stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
tusb_rhport_init_t host_init = {
.rhport = BOARD_TUH_RHPORT,
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&host_init);
tusb_init(BOARD_TUH_RHPORT, &host_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -83,18 +83,16 @@ int main(void) {
// init device and host stack on configured roothub port
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);
tusb_init(BOARD_TUD_RHPORT, &dev_init);
tusb_rhport_init_t host_init = {
.rhport = BOARD_TUH_RHPORT,
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&host_init);
tusb_init(BOARD_TUH_RHPORT, &host_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -63,11 +63,10 @@ int main(void)
// init host stack on configured roothub port
tusb_rhport_init_t host_init = {
.rhport = BOARD_TUH_RHPORT,
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&host_init);
tusb_init(BOARD_TUH_RHPORT, &host_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -51,11 +51,10 @@ int main(void) {
// init host stack on configured roothub port
tusb_rhport_init_t host_init = {
.rhport = BOARD_TUH_RHPORT,
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&host_init);
tusb_init(BOARD_TUH_RHPORT, &host_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -127,12 +127,11 @@ static void usb_host_task(void *param) {
// init host stack on configured roothub port
tusb_rhport_init_t host_init = {
.rhport = BOARD_TUH_RHPORT,
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
if (!tusb_init(&host_init)) {
if (!tusb_init(BOARD_TUH_RHPORT, &host_init)) {
printf("Failed to init USB Host Stack\r\n");
vTaskSuspend(NULL);
}

View File

@ -67,11 +67,10 @@ int main(void) {
// init host stack on configured roothub port
tusb_rhport_init_t host_init = {
.rhport = BOARD_TUH_RHPORT,
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&host_init);
tusb_init(BOARD_TUH_RHPORT, &host_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -53,11 +53,10 @@ int main(void)
// init host stack on configured roothub port
tusb_rhport_init_t host_init = {
.rhport = BOARD_TUH_RHPORT,
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&host_init);
tusb_init(BOARD_TUH_RHPORT, &host_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -79,11 +79,10 @@ int main(void) {
// init host stack on configured roothub port
tusb_rhport_init_t host_init = {
.rhport = BOARD_TUH_RHPORT,
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&host_init);
tusb_init(BOARD_TUH_RHPORT, &host_init);
if (board_init_after_tusb) {
board_init_after_tusb();

View File

@ -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. */
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);
tusb_desc_vc_itf_t const *vc = (tusb_desc_vc_itf_t const *)cur;

View File

@ -278,7 +278,6 @@ enum {
//
//--------------------------------------------------------------------+
typedef struct {
uint8_t rhport;
tusb_role_t role;
tusb_speed_t speed;
} tusb_rhport_init_t;

View File

@ -108,7 +108,7 @@ void dcd_dcache_clean_invalidate(void const* addr, uint32_t data_size) TU_ATTR_W
//--------------------------------------------------------------------+
// Initialize controller to device mode
void dcd_init(const tusb_rhport_init_t* rh_init);
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
// Deinitialize controller, unset device mode.
bool dcd_deinit(uint8_t rhport);

View File

@ -448,7 +448,7 @@ bool tud_inited(void) {
return _usbd_rhport != RHPORT_INVALID;
}
bool tud_rhport_init(const tusb_rhport_init_t* rh_init) {
bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
if (tud_inited()) {
return true; // skip if already initialized
}
@ -487,11 +487,11 @@ bool tud_rhport_init(const tusb_rhport_init_t* rh_init) {
driver->init();
}
_usbd_rhport = rh_init->rhport;
_usbd_rhport = rhport;
// Init device controller driver
dcd_init(rh_init);
dcd_int_enable(rh_init->rhport);
dcd_init(rhport, rh_init);
dcd_int_enable(rhport);
return true;
}

View File

@ -38,19 +38,18 @@ extern "C" {
//--------------------------------------------------------------------+
// New API to replace tud_init() to init device stack on specific roothub port
bool tud_rhport_init(const tusb_rhport_init_t* rh_init);
bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
// Init device stack on roothub port
#if TUSB_VERSION_NUMBER > 2000 // 0.20.0
TU_ATTR_DEPRECATED("Please use tusb_init(tusb_rhport_init_t*) instead")
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 = {
.rhport = rhport,
.role = TUSB_ROLE_DEVICE,
.speed = TUD_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL
};
return tud_rhport_init(&rh_init);
return tud_rhport_init(rhport, &rh_init);
}
// Deinit device stack on roothub port

View File

@ -121,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);
// Initialize controller to host mode
bool hcd_init(const tusb_rhport_init_t* rh_init);
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
// De-initialize controller
bool hcd_deinit(uint8_t rhport);

View File

@ -352,8 +352,8 @@ bool tuh_inited(void) {
return _usbh_controller != TUSB_INDEX_INVALID_8;
}
bool tuh_rhport_init(const tusb_rhport_init_t* rh_init) {
if (tuh_rhport_is_active(rh_init->rhport)) {
bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
if (tuh_rhport_is_active(rhport)) {
return true; // skip if already initialized
}
@ -404,9 +404,9 @@ bool tuh_rhport_init(const tusb_rhport_init_t* rh_init) {
}
// Init host controller
_usbh_controller = rh_init->rhport;
TU_ASSERT(hcd_init(rh_init));
hcd_int_enable(rh_init->rhport);
_usbh_controller = rhport;
TU_ASSERT(hcd_init(rhport, rh_init));
hcd_int_enable(rhport);
return true;
}

View File

@ -121,19 +121,18 @@ void tuh_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr);
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(const tusb_rhport_init_t* rh_init);
bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
// Init host stack
#if TUSB_VERSION_NUMBER > 2000 // 0.20.0
TU_ATTR_DEPRECATED("Please use tusb_init(tusb_rhport_init_t*) instead")
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 = {
.rhport = rhport,
.role = TUSB_ROLE_HOST,
.speed = TUH_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL,
};
return tuh_rhport_init(&rh_init);
return tuh_rhport_init(rhport, &rh_init);
}
// Deinit host stack on rhport

View File

@ -494,8 +494,8 @@ bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) {
}
// Initialize controller to host mode
bool hcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
tuh_max3421_int_api(rhport, false);

View File

@ -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
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
TU_LOG2("FT9xx initialisation\r\n");
_dcd_ft9xx_attach();

View File

@ -267,9 +267,9 @@ static void process_bus_resume(uint8_t rhport)
/*------------------------------------------------------------------*/
/* Device API
*------------------------------------------------------------------*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
// 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

View File

@ -234,8 +234,8 @@ static void bus_reset(uint8_t rhport)
dcd_dcache_clean_invalidate(&_dcd_data, sizeof(dcd_data_t));
}
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
tu_memclr(&_dcd_data, sizeof(dcd_data_t));
ci_hs_regs_t* dcd_reg = CI_HS_REG(rhport);

View File

@ -70,8 +70,8 @@ bool hcd_dcache_clean_invalidate(void const* addr, uint32_t data_size) {
// Controller API
//--------------------------------------------------------------------+
bool hcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->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);
// Reset controller
@ -83,7 +83,9 @@ bool hcd_init(const tusb_rhport_init_t* rh_init) {
// LPC18XX/43XX need to set VBUS Power Select to HIGH
// RHPORT1 is fullspeed only (need external PHY for Highspeed)
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
hcd_reg->USBMODE = USBMODE_CM_HOST;
#endif

View File

@ -804,9 +804,9 @@ static void handle_ep0_nak(void)
/*------------------------------------------------------------------*/
/* Controller API
*------------------------------------------------------------------*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
_dcd.init_called = true;
if (_dcd.vbus_present)

View File

@ -172,8 +172,8 @@ static void enum_done_processing(void)
/*------------------------------------------------------------------*/
/* Controller API
*------------------------------------------------------------------*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
ESP_LOGV(TAG, "DCD init - Start");
// A. Disconnect

View File

@ -582,8 +582,8 @@ void print_musb_info(musb_regs_t* musb_regs) {
}
#endif
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
musb_regs_t* musb_regs = MUSB_REGS(rhport);
#if CFG_TUSB_DEBUG >= MUSB_DEBUG

View File

@ -556,7 +556,8 @@ static void process_pipe_rx(uint8_t rhport, uint_fast8_t pipenum)
* Host API
*------------------------------------------------------------------*/
bool hcd_init(const tusb_rhport_init_t* rh_init) {
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
NVIC_ClearPendingIRQ(USB0_IRQn);

View File

@ -470,8 +470,8 @@ static void process_bus_resume(uint8_t rhport)
/*------------------------------------------------------------------*/
/* Device API
*------------------------------------------------------------------*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
intr_disable(rhport);
intr_clear(rhport);

View File

@ -120,8 +120,8 @@ static ep0_stage_t ep0_get_stage(void)
/*------------------------------------------------------------------*/
/* Controller API
*------------------------------------------------------------------*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
// Disable endpoint interrupts for now
USB_REGS->INTRRXEbits.w = 0;
USB_REGS->INTRTXEbits.w = 0;

View File

@ -78,8 +78,8 @@ static void bus_reset(void)
/*------------------------------------------------------------------*/
/* Controller API
*------------------------------------------------------------------*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
(void) rh_init;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport; (void) rh_init;
// Reset to get in a clean state.
USB->DEVICE.CTRLA.bit.SWRST = true;

View File

@ -155,8 +155,9 @@ static void bus_reset(void)
}
// Initialize controller to device mode
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
tu_memclr(_dcd_xfer, sizeof(_dcd_xfer));
dcd_connect(rhport);
}

View File

@ -104,8 +104,8 @@ TU_ATTR_ALWAYS_INLINE static inline void CleanInValidateCache(uint32_t *addr, in
//------------------------------------------------------------------
// Initialize controller to device mode
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
dcd_connect(rhport);
}

View File

@ -245,9 +245,9 @@ static void process_bus_active(uint8_t rhport)
/*------------------------------------------------------------------*/
/* Device API
*------------------------------------------------------------------*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
tu_memclr(&_dcd, sizeof(_dcd));
USB_OTG_FS->BDT_PAGE_01 = (uint8_t)((uintptr_t)_dcd.bdt >> 8);

View File

@ -230,10 +230,10 @@ static void xact_in_dma(uint8_t epnum) {
//--------------------------------------------------------------------+
// Controller API
//--------------------------------------------------------------------+
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
TU_LOG2("dcd init\r\n");
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
TU_LOG2("dcd init\r\n");
}
void dcd_int_enable(uint8_t rhport) {

View File

@ -201,9 +201,9 @@ static const uint32_t enabled_irqs = USBD_INTSTS_FLDET_STS_Msk | USBD_INTSTS_BUS
NUC100/NUC120 TinyUSB API driver implementation
*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
USBD->ATTR = 0x7D0;

View File

@ -209,9 +209,9 @@ enum {
NUC121/NUC125/NUC126 TinyUSB API driver implementation
*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
#ifdef SUPPORT_LPM
USBD->ATTR = 0x7D0 | USBD_LPMACK;

View File

@ -279,9 +279,9 @@ static const uint32_t enabled_irqs = USBD_GINTEN_USBIEN_Msk | \
NUC505 TinyUSB API driver implementation
*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
/* configure interrupts in their initial state; BUSINTEN and CEPINTEN will be subsequently and dynamically re-written as needed */
USBD->GINTEN = enabled_irqs;

View File

@ -265,9 +265,9 @@ static void process_bus_resume(uint8_t rhport)
/*------------------------------------------------------------------*/
/* Device API
*------------------------------------------------------------------*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
// 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

View File

@ -368,7 +368,8 @@ static void process_bus_reset(uint8_t rhport)
/*------------------------------------------------------------------*/
/* Host API
*------------------------------------------------------------------*/
bool hcd_init(const tusb_rhport_init_t* rh_init) {
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
KHCI->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
while (KHCI->USBTRC0 & USB_USBTRC0_USBRESET_MASK);

View File

@ -167,9 +167,9 @@ static void bus_reset(void)
tu_memclr(&_dcd, sizeof(dcd_data_t));
}
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
//------------- user manual 11.13 usb device controller initialization -------------//
// step 6 : set up control endpoint

View File

@ -289,8 +289,8 @@ static void edpt_reset_all(uint8_t rhport)
}
prepare_setup_packet(rhport);
}
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
edpt_reset_all(rhport);
dcd_registers_t* dcd_reg = _dcd_controller[rhport].regs;

View File

@ -178,9 +178,9 @@ TU_ATTR_ALWAYS_INLINE static inline void *_virt_addr(void *physical_address)
}
// Initialization according to 5.1.1.4
bool hcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
//------------- Data Structure init -------------//
tu_memclr(&ohci_data, sizeof(ohci_data_t));

View File

@ -50,7 +50,8 @@ static usb_descriptor_buffers_t desc;
*------------------------------------------------------------------*/
// Initialize controller to device mode
void dcd_init(const tusb_rhport_init_t* rh_init) {
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
static pio_usb_configuration_t config = PIO_USB_DEFAULT_CONFIG;
usb_device = pio_usb_device_init(&config, &desc);

View File

@ -55,7 +55,8 @@ bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void *cfg_param) {
return true;
}
bool hcd_init(const tusb_rhport_init_t* rh_init) {
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
// To run USB SOF interrupt in core1, call this init in core1

View File

@ -369,8 +369,8 @@ static void __tusb_irq_path_func(dcd_rp2040_irq)(void) {
#define PICO_SHARED_IRQ_HANDLER_HIGHEST_ORDER_PRIORITY 0xff
#endif
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
assert(rhport == 0);
TU_LOG(2, "Chip Version B%u\r\n", rp2040_chip_version());

View File

@ -375,7 +375,8 @@ static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t dev_addr, uint8_t
//--------------------------------------------------------------------+
// HCD API
//--------------------------------------------------------------------+
bool hcd_init(const tusb_rhport_init_t* rh_init) {
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
pico_trace("hcd_init %d\n", rhport);
assert(rhport == 0);

View File

@ -657,8 +657,8 @@ static void enable_interrupt(uint32_t pswi)
}
#endif
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
rusb2_reg_t* rusb = RUSB2_REG(rhport);
rusb2_module_start(rhport, true);

View File

@ -466,8 +466,8 @@ static void enable_interrupt(uint32_t pswi)
}
#endif
bool hcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->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_module_start(rhport, true);

View File

@ -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);
}
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
usbdcd_driver.usbdevclass_driver.speed = USB_SPEED_HIGH;
usbdcd_driver.usbdevclass_driver.ops = &g_driverops;

View File

@ -184,8 +184,8 @@ TU_ATTR_ALWAYS_INLINE static inline xfer_ctl_t *xfer_ctl_ptr(uint8_t epnum, uint
//--------------------------------------------------------------------+
// Controller API
//--------------------------------------------------------------------+
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void 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
for (volatile uint32_t i = 0; i < 200; i++) { // should be a few us
asm("NOP");

View File

@ -867,8 +867,8 @@ static void usb_isr_handler(void) {
dcd_int_handler(0);
}
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
dcd_disconnect(rhport);
USBC_HardwareReset();
USBC_PhyConfig();

View File

@ -650,10 +650,10 @@ static bool check_dwc2(dwc2_regs_t* dwc2) {
return true;
}
void dcd_init(const tusb_rhport_init_t* rh_init) {
void 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
// peripheral in each Reference Manual.
const uint8_t rhport = rh_init->rhport;
dwc2_regs_t* dwc2 = DWC2_REG(rhport);
// Check Synopsys ID register, failed if controller clock/power is not enabled

View File

@ -40,8 +40,8 @@
*------------------------------------------------------------------*/
// Initialize controller to device mode
void dcd_init(const tusb_rhport_init_t* rh_init) {
(void) rh_init;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport; (void) rh_init;
}
// Enable device interrupt

View File

@ -44,7 +44,8 @@ bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) {
}
// Initialize controller to host mode
bool hcd_init(const tusb_rhport_init_t* rh_init) {
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
return false;
}

View File

@ -130,8 +130,8 @@ static void enable_functional_reset(const bool enable)
/*------------------------------------------------------------------*/
/* Controller API
*------------------------------------------------------------------*/
void dcd_init(const tusb_rhport_init_t* rh_init) {
(void) rh_init;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport; (void) rh_init;
USBKEYPID = USBKEY;
@ -699,11 +699,10 @@ static void handle_bus_power_event(void *param) {
// A successful lock is indicated by all PLL-related interrupt flags being cleared.
if(!USBPLLIR) {
const tusb_rhport_init_t rhport_init = {
.rhport = 0,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_FULL
};
dcd_init(&rhport_init); // Re-initialize the USB module.
dcd_init(0, &rhport_init); // Re-initialize the USB module.
}
} else { // Event caused by removal of bus power.
USBPWRCTL |= VBONIE; // Enable bus-power-applied interrupt.

View File

@ -336,9 +336,9 @@ static void dcd_reset(void)
}
// Initializes the USB peripheral for device mode and enables it.
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
usb_pullup_out_write(0);

View File

@ -123,8 +123,8 @@ static void update_out(uint8_t rhport, uint8_t ep, size_t rx_len) {
}
/* public functions */
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rh_init;
// init registers
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;

View File

@ -131,9 +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);
}
void dcd_init(const tusb_rhport_init_t* rh_init) {
const uint8_t rhport = rh_init->rhport;
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
memset(&xfer_status, 0, sizeof(xfer_status));

View File

@ -47,29 +47,27 @@ static tusb_role_t _rhport_role[TUP_USBIP_CONTROLLER_NUM] = { 0 };
// Public API
//--------------------------------------------------------------------+
bool tusb_rhport_init(const tusb_rhport_init_t* rh_init) {
bool tusb_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
// backward compatible called with tusb_init(void)
#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
if (rh_init == NULL) {
#if CFG_TUD_ENABLED && defined(TUD_OPT_RHPORT)
// init device stack CFG_TUSB_RHPORTx_MODE must be defined
const tusb_rhport_init_t dev_init = {
.rhport = TUD_OPT_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUD_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL
};
TU_ASSERT ( tud_rhport_init(&dev_init) );
TU_ASSERT ( tud_rhport_init(rhport, &dev_init) );
_rhport_role[TUD_OPT_RHPORT] = TUSB_ROLE_DEVICE;
#endif
#if CFG_TUH_ENABLED && defined(TUH_OPT_RHPORT)
// init host stack CFG_TUSB_RHPORTx_MODE must be defined
const tusb_rhport_init_t host_init = {
.rhport = TUH_OPT_RHPORT,
.role = TUSB_ROLE_HOST,
.speed = TUH_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL
};
TU_ASSERT( tuh_rhport_init(&host_init) );
TU_ASSERT( tuh_rhport_init(TUH_OPT_RHPORT, &host_init) );
_rhport_role[TUH_OPT_RHPORT] = TUSB_ROLE_HOST;
#endif
@ -78,21 +76,21 @@ bool tusb_rhport_init(const tusb_rhport_init_t* rh_init) {
#endif
// new API with explicit rhport and role
TU_ASSERT(rh_init->rhport < TUP_USBIP_CONTROLLER_NUM && rh_init->role != TUSB_ROLE_INVALID);
TU_ASSERT(rhport < TUP_USBIP_CONTROLLER_NUM && rh_init->role != TUSB_ROLE_INVALID);
#if CFG_TUD_ENABLED
if (rh_init->role == TUSB_ROLE_DEVICE) {
TU_ASSERT( tud_rhport_init(rh_init) );
TU_ASSERT(tud_rhport_init(rhport, rh_init));
}
#endif
#if CFG_TUH_ENABLED
if (rh_init->role == TUSB_ROLE_HOST) {
TU_ASSERT( tuh_rhport_init(rh_init) );
TU_ASSERT(tuh_rhport_init(rhport, rh_init));
}
#endif
_rhport_role[rh_init->rhport] = rh_init->role;
_rhport_role[rhport] = rh_init->role;
return true;
}

View File

@ -134,19 +134,20 @@
#if CFG_TUH_ENABLED || CFG_TUD_ENABLED
// Internal helper for backward compatible with tusb_init(void)
bool tusb_rhport_init(const tusb_rhport_init_t* rh_init);
bool tusb_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
// Initialize roothub port with device/host role
// 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.
// Note2: defined as macro for backward compatible with tusb_init(void), can be changed to function in the future.
#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
#define _tusb_init_arg0() tusb_rhport_init(NULL)
#define _tusb_init_arg0() tusb_rhport_init(0, NULL)
#else
#define _tusb_init_arg0() TU_VERIFY_STATIC(false, "CFG_TUSB_RHPORT0_MODE/CFG_TUSB_RHPORT1_MODE must be defined")
#endif
#define _tusb_init_arg1(_rh_init) tusb_rhport_init(_rh_init)
#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

View File

@ -46,7 +46,8 @@ tu_static State state = {false, 0, 0};
// All no-ops as we are fuzzing.
//--------------------------------------------------------------------+
extern "C" {
void dcd_init(const tusb_rhport_init_t* rh_init) {
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
UNUSED(rhport);
UNUSED(rh_init);
return;
}

View File

@ -199,13 +199,12 @@ void setUp(void)
if ( !tud_inited() ) {
tusb_rhport_init_t dev_init = {
.rhport = 0,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
dcd_init_Expect(&dev_init);
tusb_init(&dev_init);
dcd_init_Expect(0, &dev_init);
tusb_init(0, &dev_init);
}
dcd_event_bus_reset(rhport, TUSB_SPEED_HIGH, false);

View File

@ -102,44 +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;
}
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
{
uint8_t const * tud_descriptor_configuration_cb(uint8_t index) {
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;
return NULL;
}
void setUp(void)
{
void setUp(void) {
dcd_int_disable_Ignore();
dcd_int_enable_Ignore();
if ( !tud_inited() ) {
tusb_rhport_init_t dev_init = {
.rhport = 0,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
mscd_init_Expect();
dcd_init_Expect(&dev_init);
dcd_init_Expect(0, &dev_init);
tusb_init(&dev_init);
tusb_init(0, &dev_init);
}
}
void tearDown(void)
{
void tearDown(void) {
}
//--------------------------------------------------------------------+