pub trait Bus {
    // Required methods
    async fn enable(&mut self);
    async fn disable(&mut self);
    async fn poll(&mut self) -> Event;
    fn endpoint_set_enabled(&mut self, ep_addr: EndpointAddress, enabled: bool);
    fn endpoint_set_stalled(&mut self, ep_addr: EndpointAddress, stalled: bool);
    fn endpoint_is_stalled(&mut self, ep_addr: EndpointAddress) -> bool;
    async fn remote_wakeup(&mut self) -> Result<(), Unsupported>;

    // Provided method
    fn force_reset(&mut self) -> Result<(), Unsupported> { ... }
}
Expand description

USB bus trait.

This trait provides methods that act on the whole bus. It is kept owned by the main USB task, and used to manage the bus.

Required Methods§

source

async fn enable(&mut self)

Enable the USB peripheral.

source

async fn disable(&mut self)

Disable and powers down the USB peripheral.

source

async fn poll(&mut self) -> Event

Wait for a bus-related event.

This method should asynchronously wait for an event to happen, then return it. See Event for the list of events this method should return.

source

fn endpoint_set_enabled(&mut self, ep_addr: EndpointAddress, enabled: bool)

Enable or disable an endpoint.

source

fn endpoint_set_stalled(&mut self, ep_addr: EndpointAddress, stalled: bool)

Set or clear the STALL condition for an endpoint.

If the endpoint is an OUT endpoint, it should be prepared to receive data again.

source

fn endpoint_is_stalled(&mut self, ep_addr: EndpointAddress) -> bool

Get whether the STALL condition is set for an endpoint.

source

async fn remote_wakeup(&mut self) -> Result<(), Unsupported>

Initiate a remote wakeup of the host by the device.

Errors
  • Unsupported - This UsbBus implementation doesn’t support remote wakeup or it has not been enabled at creation time.

Provided Methods§

source

fn force_reset(&mut self) -> Result<(), Unsupported>

Simulate a disconnect from the USB bus, causing the host to reset and re-enumerate the device.

The default implementation just returns Unsupported.

Errors
  • Unsupported - This UsbBus implementation doesn’t support simulating a disconnect or it has not been enabled at creation time.

Object Safety§

This trait is not object safe.

Implementors§