Crate usb_device
source · [−]Expand description
Experimental device-side USB stack for embedded devices.
Implementing a USB device
A USB device consists of a UsbDevice
instance, one or more
UsbClass
es, and a platform-specific UsbBus
implementation which together form a USB composite device.
In the future USB device implementors will be able to use pre-existing peripheral driver crates and USB class implementation crates. The necessary types for the basic USB composite device implementation are available with:
use usb_device::prelude::*
.
See the device
module for a more complete example.
USB classes
For information on how to implement new USB classes, see the class
module and the
TestClass
source code for an example of a custom USB device class
implementation. The necessary types for creating new classes are available with:
use usb_device::class_prelude::*
.
USB peripheral drivers
New peripheral driver crates can be created by implementing the UsbBus
trait.
Note about terminology
This crate uses standard host-centric USB terminology for transfer directions. Therefore an OUT transfer refers to a host-to-device transfer, and an IN transfer refers to a device-to-host transfer. This is mainly a concern for implementing new USB peripheral drivers and USB classes, and people doing that should be familiar with the USB standard.