Struct nrf52840_hal::usbd::Usbd
source · pub struct Usbd<T>where
T: UsbPeripheral,{ /* private fields */ }
Expand description
USB device implementation.
This type implements the UsbBus
trait and can be passed to a UsbBusAllocator
to
configure and use the USB device.
Implementations§
source§impl<T> Usbd<T>where
T: UsbPeripheral,
impl<T> Usbd<T>where
T: UsbPeripheral,
Trait Implementations§
source§impl<T> UsbBus for Usbd<T>where
T: UsbPeripheral,
impl<T> UsbBus for Usbd<T>where
T: UsbPeripheral,
source§fn alloc_ep(
&mut self,
ep_dir: UsbDirection,
ep_addr: Option<EndpointAddress>,
ep_type: EndpointType,
max_packet_size: u16,
_interval: u8
) -> Result<EndpointAddress, UsbError>
fn alloc_ep( &mut self, ep_dir: UsbDirection, ep_addr: Option<EndpointAddress>, ep_type: EndpointType, max_packet_size: u16, _interval: u8 ) -> Result<EndpointAddress, UsbError>
source§fn enable(&mut self)
fn enable(&mut self)
Enables and initializes the USB peripheral. Soon after enabling the device will be reset, so
there is no need to perform a USB reset in this method.
source§fn reset(&self)
fn reset(&self)
Called when the host resets the device. This will be soon called after
poll
returns PollResult::Reset
. This method should
reset the state of all endpoints and peripheral flags back to a state suitable for
enumeration, as well as ensure that all endpoints previously allocated with alloc_ep are
initialized as specified.source§fn set_device_address(&self, _addr: u8)
fn set_device_address(&self, _addr: u8)
Sets the device USB address to
addr
.source§fn write(&self, ep_addr: EndpointAddress, buf: &[u8]) -> Result<usize, UsbError>
fn write(&self, ep_addr: EndpointAddress, buf: &[u8]) -> Result<usize, UsbError>
Writes a single packet of data to the specified endpoint and returns number of bytes
actually written. Read more
source§fn read(
&self,
ep_addr: EndpointAddress,
buf: &mut [u8]
) -> Result<usize, UsbError>
fn read( &self, ep_addr: EndpointAddress, buf: &mut [u8] ) -> Result<usize, UsbError>
Reads a single packet of data from the specified endpoint and returns the actual length of
the packet. Read more
source§fn set_stalled(&self, ep_addr: EndpointAddress, stalled: bool)
fn set_stalled(&self, ep_addr: EndpointAddress, stalled: bool)
Sets or clears the STALL condition for an endpoint. If the endpoint is an OUT endpoint, it
should be prepared to receive data again.
source§fn is_stalled(&self, ep_addr: EndpointAddress) -> bool
fn is_stalled(&self, ep_addr: EndpointAddress) -> bool
Gets whether the STALL condition is set for an endpoint.
source§fn suspend(&self)
fn suspend(&self)
Causes the USB peripheral to enter USB suspend mode, lowering power consumption and
preparing to detect a USB wakeup event. This will be called after
poll
returns PollResult::Suspend
. The device will
continue be polled, and it shall return a value other than Suspend
from poll
when it no
longer detects the suspend condition.source§fn resume(&self)
fn resume(&self)
Resumes from suspend mode. This may only be called after the peripheral has been previously
suspended.
source§fn poll(&self) -> PollResult
fn poll(&self) -> PollResult
Gets information about events and incoming data. Usually called in a loop or from an
interrupt handler. See the
PollResult
struct for more information.source§fn force_reset(&self) -> Result<(), UsbError>
fn force_reset(&self) -> Result<(), UsbError>
Simulates a disconnect from the USB bus, causing the host to reset and re-enumerate the
device. Read more
source§const QUIRK_SET_ADDRESS_BEFORE_STATUS: bool = false
const QUIRK_SET_ADDRESS_BEFORE_STATUS: bool = false
Indicates that
set_device_address
must be called before accepting the corresponding
control transfer, not after. Read moreAuto Trait Implementations§
impl<T> !Freeze for Usbd<T>
impl<T> !RefUnwindSafe for Usbd<T>
impl<T> Send for Usbd<T>
impl<T> Sync for Usbd<T>
impl<T> Unpin for Usbd<T>where
T: Unpin,
impl<T> UnwindSafe for Usbd<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.