change the tusb_rhport_init_t struct, exclude the rhport to make API more consistent
This commit is contained in:
@@ -121,7 +121,7 @@ bool hcd_dcache_clean_invalidate(void const* addr, uint32_t data_size) TU_ATTR_W
|
||||
bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param);
|
||||
|
||||
// Initialize controller to host mode
|
||||
bool hcd_init(const tusb_rhport_init_t* rh_init);
|
||||
bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
|
||||
|
||||
// De-initialize controller
|
||||
bool hcd_deinit(uint8_t rhport);
|
||||
|
||||
@@ -352,8 +352,8 @@ bool tuh_inited(void) {
|
||||
return _usbh_controller != TUSB_INDEX_INVALID_8;
|
||||
}
|
||||
|
||||
bool tuh_rhport_init(const tusb_rhport_init_t* rh_init) {
|
||||
if (tuh_rhport_is_active(rh_init->rhport)) {
|
||||
bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||
if (tuh_rhport_is_active(rhport)) {
|
||||
return true; // skip if already initialized
|
||||
}
|
||||
|
||||
@@ -404,9 +404,9 @@ bool tuh_rhport_init(const tusb_rhport_init_t* rh_init) {
|
||||
}
|
||||
|
||||
// Init host controller
|
||||
_usbh_controller = rh_init->rhport;
|
||||
TU_ASSERT(hcd_init(rh_init));
|
||||
hcd_int_enable(rh_init->rhport);
|
||||
_usbh_controller = rhport;
|
||||
TU_ASSERT(hcd_init(rhport, rh_init));
|
||||
hcd_int_enable(rhport);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -121,19 +121,18 @@ void tuh_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr);
|
||||
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);
|
||||
bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
|
||||
|
||||
// Init host stack
|
||||
#if TUSB_VERSION_NUMBER > 2000 // 0.20.0
|
||||
TU_ATTR_DEPRECATED("Please use tusb_init(tusb_rhport_init_t*) instead")
|
||||
TU_ATTR_DEPRECATED("Please use tusb_init(rhport, rh_init) 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);
|
||||
return tuh_rhport_init(rhport, &rh_init);
|
||||
}
|
||||
|
||||
// Deinit host stack on rhport
|
||||
|
||||
Reference in New Issue
Block a user