Skip to content

USB Host: integrate class API [1: types] #94504

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 5 commits into
base: main
Choose a base branch
from

Conversation

josuah
Copy link
Contributor

@josuah josuah commented Aug 14, 2025

Downstream:

This is a very small, incremental change to help downstream pull requests use a shared base.

I was thinking of doing several such small pull requests with just a few commits, to progressively integrate the code of other pull requests:

Here is how I tested it:

west build -t run -b native_sim samples/subsys/usb/shell/ \
-DEXTRA_CONF_FILE=virtual.conf \
-DDTC_OVERLAY_FILE=virtual.overlay \
-DEXTRA_CONF_FILE=device_and_host_prj.conf

Then in another terminal, connect to the console, such as using picocom /dev/pts/0.

Josuah Demangeon added 5 commits August 13, 2025 15:13
Make the struct name match the device naming for ease of use, although
slightly longer name. Propagate the change to the subsystem, includes,
tests and samples.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Allocate extra room at the end of the USB descriptor buffer to ensure
that the device ends with `desc->bLength == 0`. For now, validating
`desc->bLength` from the device to ensure no access past the buffer
is still not done.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Add a "struct usbh_status" that contains a bitmask of flags to keep
track of the global state of the host context, like done for the
device_next implementation. Add helpers to check the status.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Hide the mutex lock details inside a wrapper call, like done for the
device stack API. This is not used for the per-device lock of the host
stack which use a different mutex lock.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Update the USB shell sample to the new syntax. This is based on tests
done with native_sim, along with the virtual.conf, virtual.overlay and
device_and_host_prj.conf extra config files.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
@josuah josuah added the area: USB Universal Serial Bus label Aug 14, 2025
Copy link

@josuah josuah marked this pull request as ready for review August 14, 2025 12:57
@zephyrbot zephyrbot added the area: Samples Samples label Aug 14, 2025
@josuah josuah changed the title Start refactoring the Host class API USB Host: integrate class API [1] Aug 17, 2025
@josuah josuah changed the title USB Host: integrate class API [1] USB Host: integrate class API [1: types] Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Samples Samples area: USB Universal Serial Bus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants