usb: builtin handling of interface alternate settings

The stack reads its own descriptors to figure out which endpoints
are used in which alt settings, and enables/disables them as needed.

The ControlHandler has a callback so it can get notified of alternate
setting changes, which is purely informative (it doesn't have to do anything).
This commit is contained in:
Dario Nieuwenhuis
2022-04-16 04:47:27 +02:00
parent ea0a701ebd
commit 092c2b7dfe
9 changed files with 357 additions and 146 deletions

View File

@ -79,17 +79,17 @@ pub trait Bus {
fn poll<'a>(&'a mut self) -> Self::PollFuture<'a>;
/// Sets the device USB address to `addr`.
fn set_device_address(&mut self, addr: u8);
fn set_address(&mut self, addr: u8);
/// Sets the device configured state.
fn set_configured(&mut self, configured: bool);
/// Enables or disables an endpoint.
fn endpoint_set_enabled(&mut self, ep_addr: EndpointAddress, enabled: bool);
/// Sets or clears the STALL condition for an endpoint. If the endpoint is an OUT endpoint, it
/// should be prepared to receive data again. Only used during control transfers.
fn set_stalled(&mut self, ep_addr: EndpointAddress, stalled: bool);
fn endpoint_set_stalled(&mut self, ep_addr: EndpointAddress, stalled: bool);
/// Gets whether the STALL condition is set for an endpoint. Only used during control transfers.
fn is_stalled(&mut self, ep_addr: EndpointAddress) -> bool;
fn endpoint_is_stalled(&mut self, ep_addr: EndpointAddress) -> bool;
/// Simulates a disconnect from the USB bus, causing the host to reset and re-enumerate the
/// device.