From 2571211957b28be7fd706d3cdd4209f17189788a Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 3 Jun 2022 11:32:09 +0700 Subject: [PATCH] remove static port defined for device/host --- examples/device/cdc_msc/src/main.c | 4 +++- hw/bsp/lpc18/family.c | 4 ++-- src/tusb.c | 10 ++++++---- src/tusb_option.h | 12 +----------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/examples/device/cdc_msc/src/main.c b/examples/device/cdc_msc/src/main.c index 131ae6549..c3666763b 100644 --- a/examples/device/cdc_msc/src/main.c +++ b/examples/device/cdc_msc/src/main.c @@ -54,7 +54,9 @@ void cdc_task(void); int main(void) { board_init(); - tusb_init(); + + // init device stack on configured roothub port + tud_init(BOARD_TUD_RHPORT); while (1) { diff --git a/hw/bsp/lpc18/family.c b/hw/bsp/lpc18/family.c index a59b6e89d..0fc788873 100644 --- a/hw/bsp/lpc18/family.c +++ b/hw/bsp/lpc18/family.c @@ -96,8 +96,8 @@ void board_init(void) SysTick_Config(SystemCoreClock / 1000); #elif CFG_TUSB_OS == OPT_OS_FREERTOS // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) - NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); - NVIC_SetPriority(USB1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); + NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY); + NVIC_SetPriority(USB1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY); #endif Chip_GPIO_Init(LPC_GPIO_PORT); diff --git a/src/tusb.c b/src/tusb.c index c86bdd891..709bb7d48 100644 --- a/src/tusb.c +++ b/src/tusb.c @@ -38,12 +38,14 @@ bool tusb_init(void) { -#if CFG_TUD_ENABLED - TU_ASSERT ( tud_init(TUD_OPT_RHPORT) ); // init device stack +#if CFG_TUD_ENABLED && defined(TUD_OPT_RHPORT) + // init device stack CFG_TUSB_RHPORTx_MODE must be defined + TU_ASSERT ( tud_init(TUD_OPT_RHPORT) ); #endif -#if CFG_TUH_ENABLED - TU_ASSERT( tuh_init(TUH_OPT_RHPORT) ); // init host stack +#if CFG_TUH_ENABLED && defined(TUH_OPT_RHPORT) + // init host stack CFG_TUSB_RHPORTx_MODE must be defined + TU_ASSERT( tuh_init(TUH_OPT_RHPORT) ); #endif return true; diff --git a/src/tusb_option.h b/src/tusb_option.h index c198e4ef3..0a0b20dca 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -197,15 +197,6 @@ typedef int make_iso_compilers_happy ; //------------- Roothub as Device -------------// -//#ifndef CFG_TUSB_RHPORT0_MODE -// #define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE -//#endif -// -//#ifndef CFG_TUSB_RHPORT1_MODE -// #define CFG_TUSB_RHPORT1_MODE OPT_MODE_NONE -//#endif - - #if defined(CFG_TUSB_RHPORT0_MODE) && ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE) #define TUD_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE) #define TUD_OPT_RHPORT 0 @@ -214,7 +205,6 @@ typedef int make_iso_compilers_happy ; #define TUD_OPT_RHPORT 1 #else #define TUD_RHPORT_MODE OPT_MODE_NONE - #define TUD_OPT_RHPORT -1 #endif #ifndef CFG_TUD_ENABLED @@ -228,7 +218,7 @@ typedef int make_iso_compilers_happy ; #endif // highspeed support indicator -#define TUD_OPT_HIGH_SPEED (CFG_TUD_MAX_SPEED ? CFG_TUD_MAX_SPEED : TUP_RHPORT_HIGHSPEED) +#define TUD_OPT_HIGH_SPEED (CFG_TUD_MAX_SPEED ? CFG_TUD_MAX_SPEED : TUP_RHPORT_HIGHSPEED) //------------- Roothub as Host -------------//