pub struct HidSpec {
pub report_descriptor: &'static [u8],
pub in_report_size: u16,
pub out_report_size: u16,
pub subclass: u8,
pub protocol: u8,
pub poll_interval_ms: u8,
pub report_ids: bool,
}Expand description
Static description of a HID function.
Everything a HidClass needs to allocate its endpoints
and write its descriptors, plus the two facts about the reports that cannot
be derived from the report descriptor itself (its size and whether it
declares report IDs).
use my_hal_usb::class::hid::{HidSpec, hid_protocol, hid_subclass};
static MY_DESCRIPTOR: &[u8] = &[0x05, 0x01, 0x09, 0x06, 0xA1, 0x01, 0xC0];
const SPEC: HidSpec = HidSpec::new(MY_DESCRIPTOR, 8)
.subclass(hid_subclass::BOOT)
.protocol(hid_protocol::KEYBOARD)
.out_report_size(1)
.poll_interval_ms(8);Fields§
§report_descriptor: &'static [u8]Report descriptor, served for Get Descriptor (HID Report).
in_report_size: u16Size of the interrupt IN endpoint — at least the largest input report, including its report ID byte when report IDs are used.
out_report_size: u16Size of the interrupt OUT endpoint, or 0 for a function without one.
subclass: u8HID subclass: 0 (none) or hid_subclass::BOOT.
protocol: u8HID protocol: 0 (none) or a boot protocol.
poll_interval_ms: u8Interrupt endpoint polling interval, in milliseconds.
report_ids: booltrue when the report descriptor declares report IDs.
Output reports on the interrupt OUT endpoint then carry the report ID as
their first byte (HID 1.11 §7.2.2), whereas Set Report passes it in
wValue and leaves it out of the data.
Implementations§
Source§impl HidSpec
impl HidSpec
Sourcepub const fn new(report_descriptor: &'static [u8], in_report_size: u16) -> Self
pub const fn new(report_descriptor: &'static [u8], in_report_size: u16) -> Self
A spec with no subclass, no protocol, no OUT endpoint, a 10 ms poll interval and no report IDs.
Sourcepub const fn subclass(self, subclass: u8) -> Self
pub const fn subclass(self, subclass: u8) -> Self
Set the HID subclass (and, for boot devices, the protocol).
Sourcepub const fn protocol(self, protocol: u8) -> Self
pub const fn protocol(self, protocol: u8) -> Self
Set the HID protocol reported in the interface descriptor.
Sourcepub const fn out_report_size(self, size: u16) -> Self
pub const fn out_report_size(self, size: u16) -> Self
Allocate an interrupt OUT endpoint of size bytes.
Sourcepub const fn poll_interval_ms(self, interval: u8) -> Self
pub const fn poll_interval_ms(self, interval: u8) -> Self
Set the interrupt endpoint polling interval, in milliseconds.
Sourcepub const fn report_ids(self, report_ids: bool) -> Self
pub const fn report_ids(self, report_ids: bool) -> Self
Declare that the report descriptor uses report IDs.