Skip to main content

ControlPipe

Struct ControlPipe 

Source
pub struct ControlPipe { /* private fields */ }
Expand description

EP0 control transfer state machine + staging buffer.

Not generic over the bus type; bus I/O is performed via trait-object-style &B references passed on each call.

Implementations§

Source§

impl ControlPipe

Source

pub const fn new(max_packet_size: u16) -> Self

Create an idle control pipe with an empty staging buffer.

Source

pub fn reset(&mut self)

Reset to idle (called on bus reset).

Source

pub fn waiting_for_response(&self) -> bool

Returns true when waiting for a class or device to call accept_* / reject.

Source

pub fn data(&self) -> &[u8]

Data received during the OUT data stage.

Empty for a zero-length OUT transfer, which several requests use (an SMBus quick command, for example).

Source

pub fn handle_setup<B: UsbBus>(&mut self, bus: &B) -> Option<Request>

Called when the bus reports a SETUP packet on EP0.

Reads the 8-byte packet from the bus and returns the parsed Request if we should dispatch it immediately, or None if we’re still in a data stage (OUT transfers with a wLength > 0 need more packets first).

Source

pub fn handle_out<B: UsbBus>(&mut self, bus: &B) -> UsbResult<Option<Request>>

Called when the bus reports an OUT packet on EP0 (non-SETUP).

Source

pub fn handle_in_complete<B: UsbBus>(&mut self, bus: &B) -> UsbResult<bool>

Called when the bus reports an IN-complete on EP0.

Returns true when the entire transfer (including status stage) completed.

Source

pub fn accept_in<B: UsbBus>( &mut self, bus: &B, f: impl FnOnce(&mut [u8]) -> UsbResult<usize>, ) -> UsbResult<()>

Accept a control IN request by writing data into the staging buffer.

Source

pub fn accept_with<B: UsbBus>(&mut self, bus: &B, data: &[u8]) -> UsbResult<()>

Accept a control IN request with a pre-built slice.

Source

pub fn accept_with_static<B: UsbBus>( &mut self, bus: &B, data: &'static [u8], ) -> UsbResult<()>

Accept a control IN request with a 'static slice (zero-copy).

Source

pub fn accept_out<B: UsbBus>(&mut self, bus: &B) -> UsbResult<()>

Accept a control OUT request (send ZLP status IN).

Source

pub fn reject<B: UsbBus>(&mut self, bus: &B) -> UsbResult<()>

Reject the pending control request by stalling EP0.

Trait Implementations§

Source§

impl Default for ControlPipe

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.