Struct usbd_hid::hid_class::HIDClass [−][src]
pub struct HIDClass<'a, B: UsbBus> { /* fields omitted */ }
Expand description
HIDClass provides an interface to declare, read & write HID reports.
Users are expected to provide the report descriptor, as well as pack and unpack reports which are read or staged for transmission.
Implementations
pub fn new<'a>(
alloc: &'a UsbBusAllocator<B>,
report_descriptor: &'static [u8],
poll_ms: u8
) -> HIDClass<'a, B>
pub fn new<'a>(
alloc: &'a UsbBusAllocator<B>,
report_descriptor: &'static [u8],
poll_ms: u8
) -> HIDClass<'a, B>
Creates a new HIDClass with the provided UsbBus & HID report descriptor.
poll_ms configures how frequently the host should poll for reading/writing HID reports. A lower value means better throughput & latency, at the expense of CPU on the device & bandwidth on the bus. A value of 10 is reasonable for high performance uses, and a value of 255 is good for best-effort usecases.
This allocates two endpoints (IN and OUT). See new_ep_in (IN endpoint only) and new_ep_out (OUT endpoint only) to only create a single endpoint.
pub fn new_ep_in<'a>(
alloc: &'a UsbBusAllocator<B>,
report_descriptor: &'static [u8],
poll_ms: u8
) -> HIDClass<'a, B>
pub fn new_ep_in<'a>(
alloc: &'a UsbBusAllocator<B>,
report_descriptor: &'static [u8],
poll_ms: u8
) -> HIDClass<'a, B>
Creates a new HIDClass with the provided UsbBus & HID report descriptor. See new() for more details.
pub fn new_ep_out<'a>(
alloc: &'a UsbBusAllocator<B>,
report_descriptor: &'static [u8],
poll_ms: u8
) -> HIDClass<'a, B>
pub fn new_ep_out<'a>(
alloc: &'a UsbBusAllocator<B>,
report_descriptor: &'static [u8],
poll_ms: u8
) -> HIDClass<'a, B>
Creates a new HIDClass with the provided UsbBus & HID report descriptor. See new() for more details.
Tries to write an input report by serializing the given report structure. A BufferOverflow error is returned if the serialized report is greater than 64 bytes in size.
Tries to write an input (device-to-host) report from the given raw bytes. Data is expected to be a valid HID report for INPUT items. If report ID’s were used in the descriptor, the report ID corresponding to this report must be be present before the contents of the report.
Trait Implementations
Called when a GET_DESCRIPTOR request is received for a configuration descriptor. When
called, the implementation should write its interface, endpoint and any extra class
descriptors into writer
. The configuration descriptor itself will be written by
UsbDevice and shouldn’t be written by classes. Read more
Called when a control request is received with direction DeviceToHost. Read more
Called when a control request is received with direction HostToDevice. Read more
Gets a class-specific string descriptor. Read more
Called when endpoint with address addr
has received a SETUP packet. Implementing this
shouldn’t be necessary in most cases, but is provided for completeness’ sake. Read more
Called when endpoint with address addr
has received data (OUT packet). Read more
Called when endpoint with address addr
has completed transmitting data (IN packet). Read more