Skip to content

Commit 523eb82

Browse files
committed
fix(tusb.h): Fixed backward comatibility for port selection
1 parent 4b4c984 commit 523eb82

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/tusb.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,16 @@ bool tusb_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
140140
// Note: when using with RTOS, this should be called after scheduler/kernel is started.
141141
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
142142
// Note2: defined as macro for backward compatible with tusb_init(void), can be changed to function in the future.
143-
#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
144-
#define _tusb_init_arg0() tusb_rhport_init(0, NULL)
143+
#if defined(TUD_OPT_RHPORT)
144+
#define TUx_OPT_RHPORT TUD_OPT_RHPORT
145+
#endif //
146+
#if defined(TUH_OPT_RHPORT)
147+
#define TUx_OPT_RHPORT TUH_OPT_RHPORT
148+
#endif //
149+
150+
#if defined(TUx_OPT_RHPORT)
151+
// _tusb_init_arg0() get the port number from TUD_OPT_RHPORT or TUH_OPT_RHPORT option
152+
#define _tusb_init_arg0() tusb_rhport_init(TUx_OPT_RHPORT, NULL)
145153
#else
146154
#define _tusb_init_arg0() TU_VERIFY_STATIC(false, "CFG_TUSB_RHPORT0_MODE/CFG_TUSB_RHPORT1_MODE must be defined")
147155
#endif

0 commit comments

Comments
 (0)