Struct usb_device::device::UsbDevice
source · pub struct UsbDevice<'a, B: UsbBus> { /* private fields */ }
Expand description
A USB device consisting of one or more device classes.
Implementations
sourceimpl<B: UsbBus> UsbDevice<'_, B>
impl<B: UsbBus> UsbDevice<'_, B>
sourcepub fn new<'a>(
bus: &'a UsbBusAllocator<B>,
vid_pid: UsbVidPid,
classes: &[&'a dyn UsbClass<B>]
) -> UsbDeviceBuilder<'a, B>
pub fn new<'a>(
bus: &'a UsbBusAllocator<B>,
vid_pid: UsbVidPid,
classes: &[&'a dyn UsbClass<B>]
) -> UsbDeviceBuilder<'a, B>
Creates a UsbDeviceBuilder
for constructing a new instance.
sourcepub fn state(&self) -> UsbDeviceState
pub fn state(&self) -> UsbDeviceState
Gets the current state of the device.
In general class traffic is only possible in the Configured
state.
sourcepub fn remote_wakeup_enabled(&self) -> bool
pub fn remote_wakeup_enabled(&self) -> bool
Gets whether host remote wakeup has been enabled by the host.
sourcepub fn self_powered(&self) -> bool
pub fn self_powered(&self) -> bool
Gets whether the device is currently self powered.
sourcepub fn set_self_powered(&mut self, is_self_powered: bool)
pub fn set_self_powered(&mut self, is_self_powered: bool)
Sets whether the device is currently self powered.
sourcepub fn force_reset(&mut self) -> Result<()>
pub fn force_reset(&mut self) -> Result<()>
Forces a reset on the UsbBus.
sourcepub fn poll<'t>(&'t mut self) -> bool
pub fn poll<'t>(&'t mut self) -> bool
Polls the UsbBus
for new events and dispatches them accordingly. Returns true if one of
the classes may have data available for reading or be ready for writing, false otherwise.
This should be called periodically as often as possible for the best data rate, or
preferably from an interrupt handler. Must be called at least one every 10 milliseconds to
be USB compliant.