It's easy to add hub support to any of existing USBX host example.
- Confirm your code is built to support more than one device (UX_MAX_DEVICES > 1) and more than one class (UX_MAX_CLASS_DRIVER > 1).
- Add hub class registration into your code, after host stack initialize, something like following: /* The code below is required for installing the host portion of USBX. */
status = ux_host_stack_initialize(demo_system_host_change_function);
if (status != UX_SUCCESS)
return;#if DEMO_HUB_ENABLE /* Register the HUB class. */ status = ux_host_stack_class_register(_ux_system_host_class_hub_name, ux_host_class_hub_entry); if (status != UX_SUCCESS) return; #endif #if DEMO_HID_ENABLE /* Register hid class. */ status = ux_host_stack_class_register(_ux_system_host_class_hid_name, ux_host_class_hid_entry); if (status != UX_SUCCESS) return; #endif #if DEMO_CDC_ACM_ENABLE /* Register CDC ACM class. (optional, ignore error) */ ux_host_stack_class_register(_ux_system_host_class_cdc_acm_name, ux_host_class_cdc_acm_entry); #endif #if DEMO_STORAGE_ENABLE /* Register storage class. (optional, ignore error)*/ ux_host_stack_class_register(_ux_system_host_class_storage_name, ux_host_class_storage_entry); #endif
- Compile and run, connect hub, connect device to hub port.
Note because split transfer is not supported by controller driver right now, please connect full speed hub with full speed device or high-speed hub with high-speed device, a full speed device on high-speed hub is not supported.