pub trait UsbChannel<T: Type, D: Direction> {
// Required methods
async fn control_in(
&mut self,
setup: &SetupPacket,
buf: &mut [u8],
) -> Result<usize, ChannelError>
where T: IsControl,
D: IsIn;
async fn control_out(
&mut self,
setup: &SetupPacket,
buf: &[u8],
) -> Result<(), ChannelError>
where T: IsControl,
D: IsOut;
fn retarget_channel(
&mut self,
addr: u8,
endpoint: &EndpointInfo,
pre: bool,
) -> Result<(), HostError>;
async fn request_in(
&mut self,
buf: &mut [u8],
) -> Result<usize, ChannelError>
where D: IsIn;
async fn request_out(
&mut self,
buf: &[u8],
ensure_transaction_end: bool,
) -> Result<(), ChannelError>
where D: IsOut;
fn set_timeout(&mut self, timeout: TimeoutConfig);
}Expand description
§Virtual USB Channels
These contain the required information to send a packet correctly to a device endpoint.
The information is carried with the channel on creation (see UsbHostDriver::alloc_channel) and can be changed with UsbChannel::retarget_channel.
It is up to the HAL’s driver how to implement concurrent requests, some hardware IP may allow for multiple hardware channels while others may only have a single channel which needs to be multiplexed in software, while others still use DMA request linked-lists. Any of these are compatible with the UsbChannel with varying degrees of sync primitives required.
Required Methods§
Sourceasync fn control_in(
&mut self,
setup: &SetupPacket,
buf: &mut [u8],
) -> Result<usize, ChannelError>
async fn control_in( &mut self, setup: &SetupPacket, buf: &mut [u8], ) -> Result<usize, ChannelError>
Send IN control request.
Returns the number of bytes received into buf.
Sourceasync fn control_out(
&mut self,
setup: &SetupPacket,
buf: &[u8],
) -> Result<(), ChannelError>
async fn control_out( &mut self, setup: &SetupPacket, buf: &[u8], ) -> Result<(), ChannelError>
Send OUT control request
Sourcefn retarget_channel(
&mut self,
addr: u8,
endpoint: &EndpointInfo,
pre: bool,
) -> Result<(), HostError>
fn retarget_channel( &mut self, addr: u8, endpoint: &EndpointInfo, pre: bool, ) -> Result<(), HostError>
Retargets channel to a new endpoint, may error if the underlying driver runs out of resources
Sourceasync fn request_in(&mut self, buf: &mut [u8]) -> Result<usize, ChannelError>where
D: IsIn,
async fn request_in(&mut self, buf: &mut [u8]) -> Result<usize, ChannelError>where
D: IsIn,
Send IN request of type other from control For interrupt channels this will return the result of the next successful interrupt poll
Sourceasync fn request_out(
&mut self,
buf: &[u8],
ensure_transaction_end: bool,
) -> Result<(), ChannelError>where
D: IsOut,
async fn request_out(
&mut self,
buf: &[u8],
ensure_transaction_end: bool,
) -> Result<(), ChannelError>where
D: IsOut,
Send OUT request of type other from control ensure_transaction_end: Send a zero length packet at the end of transaction if last packet is of max size.
Sourcefn set_timeout(&mut self, timeout: TimeoutConfig)
fn set_timeout(&mut self, timeout: TimeoutConfig)
Configure the timeouts of this channel.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.