Initial commit
[kk_librfid.git] / firmware / src / os / usb_descriptors_hid.h
blob93996922e79409f0addec6dc0b5d2d025d5bf237
1 #ifndef _USB_DESCRIPTORS_H
2 #define _USB_DESCRIPTORS_H
4 #include <usb_ch9.h>
5 #include <usb_hid.h>
6 #include <sys/types.h>
7 #include <openpcd.h>
8 #include <dfu/dfu.h>
10 #include "../config.h"
12 /* The USB descriptor set for emulating a HID device */
14 const struct usb_device_descriptor dev_descriptor = {
15 .bLength = USB_DT_DEVICE_SIZE,
16 .bDescriptorType = USB_DT_DEVICE,
17 .bcdUSB = 0x0100,
18 .bDeviceClass = 0x00,
19 .bDeviceSubClass = 0x00,
20 .bDeviceProtocol = 0x00,
21 .bMaxPacketSize0 = 0x08,
22 .idVendor = USB_VENDOR_ID,
23 .idProduct = USB_PRODUCT_ID,
24 .bcdDevice = 0x0030, /* Version 0.3 */
25 #ifdef CONFIG_USB_STRING
26 .iManufacturer = 3,
27 .iProduct = 4,
28 .iSerialNumber = 0,
29 #else
30 .iManufacturer = 0,
31 .iProduct = 0,
32 .iSerialNumber = 0,
33 #endif
34 .bNumConfigurations = 0x01,
37 struct _desc {
38 struct usb_config_descriptor ucfg;
39 struct usb_interface_descriptor uif;
40 struct usb_hid_descriptor hid;
41 struct usb_endpoint_descriptor ep[1];
42 #ifdef CONFIG_DFU
43 struct usb_interface_descriptor uif_dfu[2];
44 #endif
47 const struct _desc cfg_descriptor = {
48 .ucfg = {
49 .bLength = USB_DT_CONFIG_SIZE,
50 .bDescriptorType = USB_DT_CONFIG,
51 .wTotalLength = USB_DT_CONFIG_SIZE +
52 #ifdef CONFIG_DFU
53 3 * USB_DT_INTERFACE_SIZE +
54 1 * USB_DT_ENDPOINT_SIZE,
55 .bNumInterfaces = 3,
56 #else
57 1 * USB_DT_INTERFACE_SIZE +
58 1 * USB_DT_ENDPOINT_SIZE,
59 .bNumInterfaces = 1,
60 #endif
61 .bConfigurationValue = 1,
62 #ifdef CONFIG_USB_STRING
63 .iConfiguration = 5,
64 #else
65 .iConfiguration = 0,
66 #endif
67 .bmAttributes = USB_CONFIG_ATT_ONE,
68 .bMaxPower = 250, /* 500mA */
70 .uif = {
71 .bLength = USB_DT_INTERFACE_SIZE,
72 .bDescriptorType = USB_DT_INTERFACE,
73 .bInterfaceNumber = 0,
74 .bAlternateSetting = 0,
75 .bNumEndpoints = 1,
76 .bInterfaceClass = USB_CLASS_HID,
77 .bInterfaceSubClass = 0,
78 .bInterfaceProtocol = 0x01,
79 #ifdef CONFIG_USB_STRING
80 .iInterface = 6,
81 #else
82 .iInterface = 0,
83 #endif
85 .hid = {
86 .bLength = 0x09,
87 .bDescriptorType = HID_DT_HID,
88 .bcdHID = 0x0111,
89 .bCountryCode = 0,
90 .bNumDescriptors = 1,
91 .desc[0] = {
92 .bDescriptorType = HID_DT_REPORT,
93 .bLength = FIXME,
96 .ep = {
98 .bLength = USB_DT_ENDPOINT_SIZE,
99 .bDescriptorType = USB_DT_ENDPOINT,
100 .bEndpointAddress = OPENPCD_IRQ_EP,
101 .bmAttributes = USB_ENDPOINT_XFER_INT,
102 .wMaxPacketSize = AT91C_EP_IN_SIZE,
103 .bInterval = 0x0a, /* FIXME */
107 #ifdef CONFIG_DFU
108 .uif_dfu = DFU_RT_IF_DESC,
109 #endif
112 #endif /* _USB_DESCRIPTORS_H */