Expand description

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

To implement a new class, implement the UsbClass trait. The trait contains numerous callbacks that you can use to respond to USB events. None of the methods are required, and you only need to override the ones that your specific class needs to function. See the trait documentation for more information on the callback methods.

Your class should not hold a direct reference to the UsbBus object. Rather it should take a temporary reference to the UsbBusAllocator object exposed by the bus in its constructor, and use that to allocate endpoints, as well as interface and string handles. Using the Endpoint handles which wrap a reference to the UsbBus instance ensures that classes cannot inadvertently access an endpoint owned by another class.

In addition to implementing the trait, add struct methods for the end-user to send and receive data via your class. For example, a serial port class might have class-specific methods read and write to read and write data.

Structs

Handle for a control IN transfer. When implementing a class, use the methods of this object to response to the transfer with either data or an error (STALL condition). To ignore the request and pass it on to the next class, simply don’t call any method.
Handle for a control OUT transfer. When implementing a class, use the methods of this object to response to the transfer with an ACT or an error (STALL condition). To ignore the request and pass it on to the next class, simply don’t call any method.

Traits

A trait for implementing USB classes.