embassy-usb-driver

Crates

git

Versions

default

Flavors

Skip to main content

Bus

Trait Bus 

Source
pub trait Bus {
    // Required methods
    async fn enable(&mut self);
    async fn disable(&mut self);
    async fn poll(&mut self) -> Event;
    async fn endpoint_set_enabled(
        &mut self,
        ep_addr: EndpointAddress,
        enabled: bool,
    );
    fn endpoint_is_enabled(&mut self, ep_addr: EndpointAddress) -> bool;
    async 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
    async 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

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

Enable or disable an endpoint.

All non-control endpoints are initially disabled after Driver::start, and a USB bus reset (Event::Reset) disables all non-control endpoints without the stack calling this method. Enabling an endpoint clears any STALL condition on it, unblocks Endpoint::wait_enabled, and sets Endpoint::is_enabled to true. Disabling an endpoint must abort or prevent pending transfers with EndpointError::Disabled.

Source

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

Get whether an endpoint is enabled.

Source

async 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.

Whether this waits for the remote wakeup signaling to complete or only initiates it is implementation-defined.

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

Provided Methods§

Source

async 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§