pub struct UsbBusAllocator<B: UsbBus> { /* private fields */ }
Expand description

Helper type used for UsbBus resource allocation and initialization.

Implementations§

source§

impl<B: UsbBus> UsbBusAllocator<B>

source

pub fn new(bus: B) -> UsbBusAllocator<B>

Creates a new UsbBusAllocator that wraps the provided UsbBus. Usually only called by USB driver implementations.

source

pub fn interface(&self) -> InterfaceNumber

Allocates a new interface number.

source

pub fn string(&self) -> StringIndex

Allocates a new string index.

source

pub fn alloc<D: EndpointDirection>( &self, ep_addr: Option<EndpointAddress>, ep_type: EndpointType, max_packet_size: u16, interval: u8 ) -> Result<Endpoint<'_, B, D>>

Allocates an endpoint with the specified direction and address.

This directly delegates to UsbBus::alloc_ep, so see that method for details. In most cases classes should call the endpoint type specific methods instead.

source

pub fn control<D: EndpointDirection>( &self, max_packet_size: u16 ) -> Endpoint<'_, B, D>

Allocates a control endpoint.

This crate implements the control state machine only for endpoint 0. If classes want to support control requests in other endpoints, the state machine must be implemented manually. This should rarely be needed by classes.

§Arguments
  • max_packet_size - Maximum packet size in bytes. Must be one of 8, 16, 32 or 64.
§Panics

Panics if endpoint allocation fails, because running out of endpoints or memory is not feasibly recoverable.

source

pub fn isochronous<D: EndpointDirection>( &self, synchronization: IsochronousSynchronizationType, usage: IsochronousUsageType, payload_size: u16, interval: u8 ) -> Endpoint<'_, B, D>

Allocates an isochronous endpoint.

§Arguments
  • synchronization - Type of synchronization used by the endpoint
  • usage - Whether the endpoint is data, explicit feedback, or data+implicit feedback
  • payload_size - Payload size in bytes.
  • interval - Interval for polling, expressed in frames/microframes.

See USB 2.0 section 9.6.6.

§Panics

Panics if endpoint allocation fails, because running out of endpoints or memory is not feasibly recoverable.

source

pub fn bulk<D: EndpointDirection>( &self, max_packet_size: u16 ) -> Endpoint<'_, B, D>

Allocates a bulk endpoint.

§Arguments
  • max_packet_size - Maximum packet size in bytes. Must be one of 8, 16, 32 or 64.
§Panics

Panics if endpoint allocation fails, because running out of endpoints or memory is not feasibly recoverable.

source

pub fn interrupt<D: EndpointDirection>( &self, max_packet_size: u16, interval: u8 ) -> Endpoint<'_, B, D>

Allocates an interrupt endpoint.

  • max_packet_size - Maximum packet size in bytes. Cannot exceed 64 bytes.
  • interval - Polling interval.
§Panics

Panics if endpoint allocation fails, because running out of endpoints or memory is not feasibly recoverable.

Auto Trait Implementations§

§

impl<B> !RefUnwindSafe for UsbBusAllocator<B>

§

impl<B> Send for UsbBusAllocator<B>
where B: Send,

§

impl<B> !Sync for UsbBusAllocator<B>

§

impl<B> Unpin for UsbBusAllocator<B>
where B: Unpin,

§

impl<B> UnwindSafe for UsbBusAllocator<B>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.