aboutsummaryrefslogtreecommitdiff
path: root/src/hid.rs
Commit message (Collapse)AuthorAge
* Simplify handling of GET_DESCRIPTOR requestsRobin Krahl2019-02-18
| | | | | | | | Previously, we used the ControlIn::accept method and copied the generated buffer returned by HidDevice::report_descriptor to the buffer provided by usb_device::UsbClass in get_report_descriptor. But it is easier to directly pass the returned buffer to ControlIn::accept_with, so we drop the get_report_descriptor method.
* hid: Add support for {Get,Set}_Report requestsRobin Krahl2019-02-18
| | | | | | | | | This patch adds support for Get_Report and Set_Report requests to HidClass. We parse the request metadata and the delegate the request handling to the HidDevice. Our HidDevice implementation, Nitrokey, stores the data sent with Set_Report requests. The Get_Report handling is not implemented yet.
* hid: Add HID and Report descriptorsRobin Krahl2019-02-18
| | | | | | | | | | | HID implementations must provide a HID and a Report descriptor. This patch adds these descriptors. The Report descriptor is copied from the Nitrokey Pro. As the control_in implementation in usb-device only handles GET_DESCRIPTOR requests on the device level, we have to change the control_in method in HidClass to handle GET_DESCRIPTOR on interface level (required for the Report descriptor).
* Add HidDevice trait for device-specific informationRobin Krahl2019-02-18
| | | | | | | | | The HID USB class needs device-specific information – currently, the subclass and the protocol of the device, but also the report descriptors and request handlers once we support these functions. Therefore, this patch introduces the HidDevice trait that provides this data. It also adds a Nitrokey struct that implements this trait for the Nitrokey Pro device.
* hid: Add interrupt_in endpoint to HidClassRobin Krahl2019-02-18
| | | | | | | The HID standard requires an interrupt_in endpoint that can be used to send unrequested data from the device to the driver. This patch adds the interrupt_in endpoint, although there is no code that will ever write to it.
* Add enum_u8 macro to simplify enum conversionRobin Krahl2019-02-18
| | | | | | | | We need several enums that map to a u8 value. This patch adds the enum_u8 macro that automatically derives the From and TryFrom macros for an enum to make these conversions easier. As TryFrom is not stable yet, we add our own TryFrom trait.
* Add USB stack and simple HID implementationRobin Krahl2019-02-18
This patch adds the usb-device and stm32f103xx-usb crates that provide a USB stack. It introduces the HidClass struct, a basic implementation of the Human Interface Device (HID) USB class. Devices with that class are recognized as HID devices with the specified vendor and product ID, but do not provide the endpoints required for interaction.