From 7da90438dd7851f66abfa81eba2eeb36ff9c9c25 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 18 Feb 2019 10:56:30 +0000 Subject: Add USB stack and simple HID implementation 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. --- src/device.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/device.rs (limited to 'src/device.rs') diff --git a/src/device.rs b/src/device.rs new file mode 100644 index 0000000..ea732e6 --- /dev/null +++ b/src/device.rs @@ -0,0 +1,16 @@ +// Copyright 2019 Robin Krahl +// SPDX-License-Identifier: GPL-3.0-or-later + +use usb_device::bus::{UsbBus, UsbBusAllocator}; +use usb_device::device::{UsbDevice, UsbDeviceBuilder, UsbVidPid}; + +const VID_CLAY_LOGIC: u16 = 0x20a0; +const PID_NITROKEY_PRO: u16 = 0x4108; + +pub fn create_usb_device(alloc: &UsbBusAllocator) -> UsbDevice<'_, B> { + UsbDeviceBuilder::new(alloc, UsbVidPid(VID_CLAY_LOGIC, PID_NITROKEY_PRO)) + .manufacturer("Nitrokey/ntw") + .product("Nitrokey Pro/ntw") + .serial_number("?") + .build() +} -- cgit v1.2.1