1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-25 09:22:33 +00:00

Fix U2F hid interface index for debug link

This commit is contained in:
Jochen Hoenicke 2016-05-26 20:02:54 +02:00
parent e093371129
commit 18d549c83d

View File

@ -28,6 +28,12 @@
#include "storage.h" #include "storage.h"
#include "util.h" #include "util.h"
#if DEBUG_LINK
#define USB_INTERFACE_INDEX_U2F 2
#else
#define USB_INTERFACE_INDEX_U2F 1
#endif
#define ENDPOINT_ADDRESS_IN (0x81) #define ENDPOINT_ADDRESS_IN (0x81)
#define ENDPOINT_ADDRESS_OUT (0x01) #define ENDPOINT_ADDRESS_OUT (0x01)
#define ENDPOINT_ADDRESS_DEBUG_IN (0x82) #define ENDPOINT_ADDRESS_DEBUG_IN (0x82)
@ -181,11 +187,7 @@ static const struct usb_endpoint_descriptor hid_endpoints_u2f[2] = {{
static const struct usb_interface_descriptor hid_iface_u2f[] = {{ static const struct usb_interface_descriptor hid_iface_u2f[] = {{
.bLength = USB_DT_INTERFACE_SIZE, .bLength = USB_DT_INTERFACE_SIZE,
.bDescriptorType = USB_DT_INTERFACE, .bDescriptorType = USB_DT_INTERFACE,
#if DEBUG_LINK .bInterfaceNumber = USB_INTERFACE_INDEX_U2F,
.bInterfaceNumber = 2,
#else
.bInterfaceNumber = 1,
#endif
.bAlternateSetting = 0, .bAlternateSetting = 0,
.bNumEndpoints = 2, .bNumEndpoints = 2,
.bInterfaceClass = USB_CLASS_HID, .bInterfaceClass = USB_CLASS_HID,
@ -275,7 +277,7 @@ static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, uin
(req->wValue != 0x2200)) (req->wValue != 0x2200))
return 0; return 0;
if (req->wIndex==1) { if (req->wIndex == USB_INTERFACE_INDEX_U2F) {
debugLog(0, "", "hid_control_request u2f"); debugLog(0, "", "hid_control_request u2f");
*buf = (uint8_t *)hid_report_descriptor_u2f; *buf = (uint8_t *)hid_report_descriptor_u2f;
*len = sizeof(hid_report_descriptor_u2f); *len = sizeof(hid_report_descriptor_u2f);