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

@@ -352,11 +352,13 @@ bool tuh_inited(void) {
return _usbh_controller != TUSB_INDEX_INVALID_8;
}
bool tuh_init(uint8_t rhport) {
// skip if already initialized
if (tuh_rhport_is_active(rhport)) return true;
bool tuh_rhport_init(const tusb_rhport_init_t* rh_init) {
if (tuh_rhport_is_active(rh_init->rhport)) {
return true; // skip if already initialized
}
TU_LOG_USBH("USBH init on controller %u\r\n", rhport);
TU_LOG_USBH("USBH init on controller %u, speed = %s\r\n", rhport,
rh_init->speed == TUSB_SPEED_HIGH ? "High" : "Full");
// Init host stack if not already
if (!tuh_inited()) {
@@ -402,9 +404,9 @@ bool tuh_init(uint8_t rhport) {
}
// Init host controller
_usbh_controller = rhport;;
TU_ASSERT(hcd_init(rhport));
hcd_int_enable(rhport);
_usbh_controller = rh_init->rhport;
TU_ASSERT(hcd_init(rh_init->rhport));
hcd_int_enable(rh_init->rhport);
return true;
}