Skip to content

drivers: uhc: uhc_mcux_common: add direction handling for non-setup packet #91924

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yimjiajun
Copy link
Contributor

to ensure proper processing by the SDK, logic has been enhanced to correctly determine the direction of non-setup USB transfers using the endpoint direction. This guarantees that USB_IN and USB_OUT directions are handled accurately, especially for bulk and other non-setup request packets.

…ackets

added logic to determine the direction of USB transfers for non-setup
packets using the endpoint direction. This ensures proper handling of
USB_IN and USB_OUT directions.

Signed-off-by: Richard Yim <[email protected]>
Copy link

@mmahadevan108
Copy link
Collaborator

@yimjiajun , were you seeing any failures?

@yimjiajun
Copy link
Contributor Author

yimjiajun commented Jun 20, 2025

yes, when sending to an endpoint other than 0 and not using standard request packet, the first byte is no longer bmRequestType. Therefore, the direction bit is not predictable in the same way. For example, in bulk transfers, an OUT token is might always used, even if the endpoint is configured with an IN direction.

@tmon-nordic
Copy link
Collaborator

For example, in bulk transfers, an OUT token is might always used, even if the endpoint is configured with an IN direction.

That must be some rather strange HAL design decision, it is definitely not how USB works. OUT token is only used for bulk OUT endpoints.

@yimjiajun
Copy link
Contributor Author

yimjiajun commented Jun 24, 2025

The OUT token can be used for interrupt or bulk either control transfers. it’s not limited to bulk transfers.
In this case, the mcux_xfer->direction value is used to pass the transfer direction to the NXP SDK, which uses it to determine whether to process the transfer as an IN or OUT token.

In USB, bit 7 of the endpoint address (bEndpointAddress) indicates the direction of the endpoint:
0: OUT (host to device)
1: IN (device to host)
This bit can be used to determine the transfer direction in the USB stack.
Where using on 1 to 15 endpoint-address[3:0] rather than 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus platform: NXP Drivers NXP Semiconductors, drivers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants