Expand description
USB-HID device stack.
Initialises an embassy-usb device that exposes one vendor-defined HID
interface, per the projectβs USB protocol (see crate hsm-usb-protocol).
The two endpoints are split into a [embassy_usb::class::hid::HidReader] (host -> token) and a
[embassy_usb::class::hid::HidWriter] (token -> host). They are owned by separate async tasks
in crate::tasks so reads and writes proceed independently.
Β§Lifetime model
[embassy_usb::class::hid::State] is invariant over its lifetime
parameter, which means the 'd lifetime tag of the [HidReaderWriter]
must match exactly the lifetime tag of the State it borrows. We
therefore take the State as a separate parameter to build_usb
with its own borrow, and the device lifetime 'd is derived from
whichever borrow is shortest. In practice both borrows come from
static storage at the call site, so 'd = 'static.
StructsΒ§
- Irqs π
- UsbBuffers π
- Descriptor and control-transfer buffers borrowed by the embassy-usb builder for the lifetime of the device.
ConstantsΒ§
- REPORT_
SIZE π - Size of the HID report in bytes (matches
HID_REPORT_SIZE).
FunctionsΒ§
- USBCTRL_
IRQ π β - build_
usb π - Build the USB device with one HID interface.