ariel_os::reexports::embassy_usb::driver

Trait Driver

pub trait Driver<'a> {
    type EndpointOut: EndpointOut + 'a;
    type EndpointIn: EndpointIn + 'a;
    type ControlPipe: ControlPipe + 'a;
    type Bus: Bus + 'a;

    // Required methods
    fn alloc_endpoint_out(
        &mut self,
        ep_type: EndpointType,
        max_packet_size: u16,
        interval_ms: u8,
    ) -> Result<Self::EndpointOut, EndpointAllocError>;
    fn alloc_endpoint_in(
        &mut self,
        ep_type: EndpointType,
        max_packet_size: u16,
        interval_ms: u8,
    ) -> Result<Self::EndpointIn, EndpointAllocError>;
    fn start(
        self,
        control_max_packet_size: u16,
    ) -> (Self::Bus, Self::ControlPipe);
}
Expand description

Main USB driver trait.

Implement this to add support for a new hardware platform.

Required Associated Types§

type EndpointOut: EndpointOut + 'a

Type of the OUT endpoints for this driver.

type EndpointIn: EndpointIn + 'a

Type of the IN endpoints for this driver.

type ControlPipe: ControlPipe + 'a

Type of the control pipe for this driver.

type Bus: Bus + 'a

Type for bus control for this driver.

Required Methods§

fn alloc_endpoint_out( &mut self, ep_type: EndpointType, max_packet_size: u16, interval_ms: u8, ) -> Result<Self::EndpointOut, EndpointAllocError>

Allocates an OUT endpoint.

This method is called by the USB stack to allocate endpoints. It can only be called before start is called.

§Arguments
  • ep_type - the endpoint’s type.
  • max_packet_size - Maximum packet size in bytes.
  • interval_ms - Polling interval parameter for interrupt endpoints.

fn alloc_endpoint_in( &mut self, ep_type: EndpointType, max_packet_size: u16, interval_ms: u8, ) -> Result<Self::EndpointIn, EndpointAllocError>

Allocates an IN endpoint.

This method is called by the USB stack to allocate endpoints. It can only be called before start is called.

§Arguments
  • ep_type - the endpoint’s type.
  • max_packet_size - Maximum packet size in bytes.
  • interval_ms - Polling interval parameter for interrupt endpoints.

fn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe)

Start operation of the USB device.

This returns the Bus and ControlPipe instances that are used to operate the USB device. Additionally, this makes all the previously allocated endpoints start operating.

This consumes the Driver instance, so it’s no longer possible to allocate more endpoints.

Implementors§

§

impl Driver<'_> for UsbDriver

§

type EndpointOut = DummyEndpointOut

§

type EndpointIn = DummyEndpointIn

§

type ControlPipe = DummyControlPipe

§

type Bus = DummyBus