change tusb_init(), tusb_rhport_init() to use init struct for expandability

This commit is contained in:
hathach
2024-10-11 12:58:18 +07:00
parent a4fb8354e4
commit 92602b9de3
46 changed files with 348 additions and 80 deletions

View File

@@ -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

View File

@@ -118,6 +118,14 @@
#define _TU_ARGS_APPLY_7(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7) _X(_a1) _s _TU_ARGS_APPLY_6(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7)
#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
//--------------------------------------------------------------------+

View File

@@ -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;
@@ -273,6 +274,15 @@ enum {
TUSB_INDEX_INVALID_8 = 0xFFu
};
//--------------------------------------------------------------------+
//
//--------------------------------------------------------------------+
typedef struct {
uint8_t rhport;
tusb_role_t role;
tusb_speed_t speed;
} tusb_rhport_init_t;
//--------------------------------------------------------------------+
// USB Descriptors
//--------------------------------------------------------------------+

View File

@@ -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