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/common | |
| parent | a4fb8354e41b2604f66e7da22afa292b1a44f0a2 (diff) | |
change tusb_init(), tusb_rhport_init() to use init struct for expandability
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/tusb_common.h | 2 | ||||
| -rw-r--r-- | src/common/tusb_compiler.h | 8 | ||||
| -rw-r--r-- | src/common/tusb_types.h | 10 | ||||
| -rw-r--r-- | src/common/tusb_verify.h | 3 |
4 files changed, 19 insertions, 4 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h index 0d4082c03..d3e0cf888 100644 --- a/src/common/tusb_common.h +++ b/src/common/tusb_common.h @@ -79,7 +79,7 @@ //--------------------------------------------------------------------+ // 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 diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h index ce5566ffe..646c22b29 100644 --- a/src/common/tusb_compiler.h +++ b/src/common/tusb_compiler.h @@ -119,6 +119,14 @@ #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 //--------------------------------------------------------------------+ diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index adf4b5720..5dfe3ff98 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -50,6 +50,7 @@ typedef enum { TUSB_SPEED_FULL = 0, TUSB_SPEED_LOW = 1, TUSB_SPEED_HIGH = 2, + TUSB_SPEED_AUTO = 0xaa, TUSB_SPEED_INVALID = 0xff, } tusb_speed_t; @@ -274,6 +275,15 @@ enum { }; //--------------------------------------------------------------------+ +// +//--------------------------------------------------------------------+ +typedef struct { + uint8_t rhport; + tusb_role_t role; + tusb_speed_t speed; +} tusb_rhport_init_t; + +//--------------------------------------------------------------------+ // USB Descriptors //--------------------------------------------------------------------+ diff --git a/src/common/tusb_verify.h b/src/common/tusb_verify.h index 8ad218b03..3e0f1f106 100644 --- a/src/common/tusb_verify.h +++ b/src/common/tusb_verify.h @@ -93,9 +93,6 @@ #define TU_BREAKPOINT() do {} while (0) #endif -// Helper to implement optional parameter for TU_VERIFY Macro family -#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...) arg3 - /*------------------------------------------------------------------*/ /* TU_VERIFY * - TU_VERIFY_1ARGS : return false if failed |
