Skip to content

Usbh improve hub #3096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2025
Merged

Usbh improve hub #3096

merged 4 commits into from
Apr 24, 2025

Conversation

hathach
Copy link
Owner

@hathach hathach commented Apr 24, 2025

Describe the PR

  • refactor hub driver and move port reset on connection change to usbh.
  • hub: add hub_port_get_status_local(), ignore resp in hub_port_get_status(pot != 0)
  • usbh properly deboucning with hub/rootport accordingly to usb specs, also add 10ms of reset recovery
  • change debouncing delay from 200ms to 150ms (min is 100ms)

image

This pull request introduces several updates to improve USB host functionality, enhance clarity in the codebase, and add new features. Key changes include the addition of callback interception for port status handling, the introduction of local status retrieval, and various refactorings for consistency and maintainability.

USB Host Enhancements:

  • Added a callback interception mechanism in hub_port_get_status to save port status locally before invoking the user callback. This allows for efficient status handling without requiring the user to process raw responses. (src/host/hub.c, [1] [2]
  • Introduced a new function, hub_port_get_status_local, to retrieve port status from a local cache instead of sending a request to the device. (src/host/hub.c, [1]; src/host/hub.h, [2]

Refactoring and Code Simplification:

  • Replaced dev_addr with daddr across multiple functions for consistency with existing naming conventions. (src/host/hub.c, [1] [2]; src/host/hub.h, [3]
  • Refactored the process_new_status function to consolidate and streamline the handling of hub and port status changes, replacing multiple redundant functions. (src/host/hub.c, [1] [2]

Descriptor and Device Information Updates:

  • Renamed fields in usbh_device_t for clarity, including changing vid/pid to idVendor/idProduct and other descriptor fields to match USB specification naming. (src/host/usbh.c, [1] [2] [3]
  • Added a new function, tuh_address_set, to support setting a new USB device address via a standard control transfer. (src/host/usbh.c, src/host/usbh.cR1143-R1169)

Miscellaneous Improvements:

  • Updated comments and inline documentation to clarify the behavior of key functions, such as hub_port_get_status. (src/host/hub.h, [1] [2]
  • Removed unused or redundant code, such as the _usbh_data.enumerating_daddr reset in tuh_task_ext. (src/host/usbh.c, src/host/usbh.cL539)

hathach added 2 commits April 24, 2025 10:41
minor rename and move code around
hub: add hub_port_get_status_local(), ignore resp in hub_port_get_status(pot != 0)
usbh properly deboucning with hub/rootport accordingly to usb specs, also add 10ms of reset recovery
@hathach hathach merged commit b5d4d0f into master Apr 24, 2025
178 checks passed
@hathach hathach deleted the usbh-improve-hub branch April 24, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant