[][src]Crate usb_device

Experimental device-side USB stack for embedded devices.

Implementing a USB device

A USB device consists of a UsbDevice instance, one or more UsbClasses, 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.

Modules

bus

For implementing peripheral drivers.

class

For implementing standard as well as vendor-specific USB classes.

class_prelude

Prelude for class implementors.

control

USB control transfers and the SETUP packet.

descriptor

Creating USB descriptors

device

USB composite device.

endpoint

USB endpoints.

prelude

Prelude for device implementors.

test_class

Test USB class for testing USB driver implementations. Peripheral driver implementations should include an example called "test_class" that creates a device with this class to enable the driver to be tested with the test_class_host example in this crate.

Enums

UsbDirection

Direction of USB traffic. Note that in the USB standard the direction is always indicated from the perspective of the host, which is backward for devices, but the standard directions are used for consistency.

UsbError

A USB stack error.

Type Definitions

Result

Result for USB operations.