change tusb_init(), tusb_rhport_init() to use init struct for expandability
This commit is contained in:
@@ -120,8 +120,21 @@ void tuh_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr);
|
||||
// - cfg_param: configure data, structure depends on the ID
|
||||
bool tuh_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param);
|
||||
|
||||
// New API to replace tuh_init() to init host stack on specific roothub port
|
||||
bool tuh_rhport_init(const tusb_rhport_init_t* rh_init);
|
||||
|
||||
// Init host stack
|
||||
bool tuh_init(uint8_t rhport);
|
||||
#if TUSB_VERSION_NUMBER > 2000 // 0.20.0
|
||||
TU_ATTR_DEPRECATED("Please use tusb_init(tusb_rhport_init_t*) instead")
|
||||
#endif
|
||||
TU_ATTR_ALWAYS_INLINE static inline bool tuh_init(uint8_t rhport) {
|
||||
const tusb_rhport_init_t rh_init = {
|
||||
.rhport = rhport,
|
||||
.role = TUSB_ROLE_HOST,
|
||||
.speed = TUH_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL,
|
||||
};
|
||||
return tuh_rhport_init(&rh_init);
|
||||
}
|
||||
|
||||
// Deinit host stack on rhport
|
||||
bool tuh_deinit(uint8_t rhport);
|
||||
@@ -149,9 +162,10 @@ extern void hcd_int_handler(uint8_t rhport, bool in_isr);
|
||||
#endif
|
||||
|
||||
// Interrupt handler alias to HCD with in_isr as optional parameter
|
||||
#define _tuh_int_handler_1arg(_rhport) hcd_int_handler(_rhport, true)
|
||||
#define _tuh_int_hanlder_2arg(_rhport, _in_isr) hcd_int_handler(_rhport, _in_isr)
|
||||
#define tuh_int_handler(...) TU_GET_3RD_ARG(__VA_ARGS__, _tuh_int_hanlder_2arg, _tuh_int_handler_1arg, _dummy)(__VA_ARGS__)
|
||||
#define _tuh_int_handler_arg0() TU_VERIFY_STATIC(false, "tuh_int_handler() must have 1 or 2 arguments")
|
||||
#define _tuh_int_handler_arg1(_rhport) hcd_int_handler(_rhport, true)
|
||||
#define _tuh_int_handler_arg2(_rhport, _in_isr) hcd_int_handler(_rhport, _in_isr)
|
||||
#define tuh_int_handler(...) TU_FUNC_OPTIONAL_ARG(_tuh_int_handler, __VA_ARGS__)
|
||||
|
||||
// Check if roothub port is initialized and active as a host
|
||||
bool tuh_rhport_is_active(uint8_t rhport);
|
||||
|
Reference in New Issue
Block a user