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
impl ControlPipe
Sourcepub const fn new(max_packet_size: u16) -> Self
pub const fn new(max_packet_size: u16) -> Self
Create an idle control pipe with an empty staging buffer.
Sourcepub fn waiting_for_response(&self) -> bool
pub fn waiting_for_response(&self) -> bool
Returns true when waiting for a class or device to call accept_* / reject.
Sourcepub fn data(&self) -> &[u8]
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).
Sourcepub fn handle_setup<B: UsbBus>(&mut self, bus: &B) -> Option<Request>
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).
Sourcepub fn handle_out<B: UsbBus>(&mut self, bus: &B) -> UsbResult<Option<Request>>
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).
Sourcepub fn handle_in_complete<B: UsbBus>(&mut self, bus: &B) -> UsbResult<bool>
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.
Sourcepub fn accept_in<B: UsbBus>(
&mut self,
bus: &B,
f: impl FnOnce(&mut [u8]) -> UsbResult<usize>,
) -> UsbResult<()>
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.
Sourcepub fn accept_with<B: UsbBus>(&mut self, bus: &B, data: &[u8]) -> UsbResult<()>
pub fn accept_with<B: UsbBus>(&mut self, bus: &B, data: &[u8]) -> UsbResult<()>
Accept a control IN request with a pre-built slice.
Sourcepub fn accept_with_static<B: UsbBus>(
&mut self,
bus: &B,
data: &'static [u8],
) -> UsbResult<()>
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).