pub struct Endpoint<'a, B: UsbBus, D: EndpointDirection> { /* private fields */ }
Expand description

Handle for a USB endpoint. The endpoint direction is constrained by the D type argument, which must be either In or Out.

Implementations§

source§

impl<B: UsbBus, D: EndpointDirection> Endpoint<'_, B, D>

source

pub fn address(&self) -> EndpointAddress

Gets the endpoint address including direction bit.

source

pub fn ep_type(&self) -> EndpointType

Gets the endpoint transfer type.

source

pub fn max_packet_size(&self) -> u16

Gets the maximum packet size for the endpoint.

source

pub fn interval(&self) -> u8

Gets the poll interval for interrupt endpoints.

source

pub fn stall(&self)

Sets the STALL condition for the endpoint.

source

pub fn unstall(&self)

Clears the STALL condition of the endpoint.

source§

impl<B: UsbBus> Endpoint<'_, B, In>

source

pub fn write(&self, data: &[u8]) -> Result<usize>

Writes a single packet of data to the specified endpoint and returns number of bytes actually written. The buffer must not be longer than the max_packet_size specified when allocating the endpoint.

§Errors

Note: USB bus implementation errors are directly passed through, so be prepared to handle other errors as well.

  • WouldBlock - The transmission buffer of the USB peripheral is full and the packet cannot be sent now. A peripheral may or may not support concurrent transmission of packets.
  • BufferOverflow - The data is longer than the max_packet_size specified when allocating the endpoint. This is generally an error in the class implementation.
source§

impl<B: UsbBus> Endpoint<'_, B, Out>

source

pub fn read(&self, data: &mut [u8]) -> Result<usize>

Reads a single packet of data from the specified endpoint and returns the actual length of the packet. The buffer should be large enough to fit at least as many bytes as the max_packet_size specified when allocating the endpoint.

§Errors

Note: USB bus implementation errors are directly passed through, so be prepared to handle other errors as well.

  • WouldBlock - There is no packet to be read. Note that this is different from a received zero-length packet, which is valid and significant in USB. A zero-length packet will return Ok(0).
  • BufferOverflow - The received packet is too long to fit in data. This is generally an error in the class implementation.

Auto Trait Implementations§

§

impl<'a, B, D> RefUnwindSafe for Endpoint<'a, B, D>
where D: RefUnwindSafe,

§

impl<'a, B, D> Send for Endpoint<'a, B, D>
where D: Send,

§

impl<'a, B, D> Sync for Endpoint<'a, B, D>
where D: Sync,

§

impl<'a, B, D> Unpin for Endpoint<'a, B, D>
where D: Unpin,

§

impl<'a, B, D> UnwindSafe for Endpoint<'a, B, D>
where D: UnwindSafe,

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.