diff options
| author | hathach <[email protected]> | 2024-10-11 12:58:18 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2024-10-11 13:41:53 +0700 |
| commit | 92602b9de3675c2d3e240bcd0838082e1a07b13b (patch) | |
| tree | 69c07f1d49d9d37223a679f1956ba7c8588bdcb6 /src/tusb.h | |
| parent | a4fb8354e41b2604f66e7da22afa292b1a44f0a2 (diff) | |
change tusb_init(), tusb_rhport_init() to use init struct for expandability
Diffstat (limited to 'src/tusb.h')
| -rw-r--r-- | src/tusb.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/tusb.h b/src/tusb.h index 911d1bae0..c12abba8b 100644 --- a/src/tusb.h +++ b/src/tusb.h @@ -129,19 +129,25 @@ //--------------------------------------------------------------------+ // APPLICATION API //--------------------------------------------------------------------+ + + #if CFG_TUH_ENABLED || CFG_TUD_ENABLED // Internal helper for backward compatible with tusb_init(void) -bool _tusb_rhport_init(uint8_t rhport, tusb_role_t role); +bool tusb_rhport_init(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. -#define _tusb_init_0arg() _tusb_rhport_init(0xff, TUSB_ROLE_INVALID) -#define _tusb_init_1arg(_rhport) _tusb_rhport_init(_rhport, TUSB_ROLE_INVALID) -#define _tusb_init_2arg(_rhport, _role) _tusb_rhport_init(_rhport, _role) -#define tusb_init(...) TU_GET_3RD_ARG(__VA_ARGS__, _tusb_init_2arg, _tusb_init_1arg, _tusb_init_0arg)(__VA_ARGS__) +#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT) +#define _tusb_init_arg0() tusb_rhport_init(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(...) TU_FUNC_OPTIONAL_ARG(_tusb_init, __VA_ARGS__) // Check if stack is initialized bool tusb_inited(void); |
