1 |
/*---------------------------------------------------------------------------- |
---|
2 |
* U S B - K e r n e l |
---|
3 |
*---------------------------------------------------------------------------- |
---|
4 |
* Name: USBDESC.C |
---|
5 |
* Purpose: USB Descriptors |
---|
6 |
* Version: V1.10 |
---|
7 |
*---------------------------------------------------------------------------- |
---|
8 |
* This file is part of the uVision/ARM development tools. |
---|
9 |
* This software may only be used under the terms of a valid, current, |
---|
10 |
* end user licence from KEIL for a compatible version of KEIL software |
---|
11 |
* development tools. Nothing else gives you the right to use it. |
---|
12 |
* |
---|
13 |
* Copyright (c) 2005-2006 Keil Software. |
---|
14 |
*---------------------------------------------------------------------------*/ |
---|
15 |
|
---|
16 |
#include "type.h" |
---|
17 |
|
---|
18 |
#include "usb.h" |
---|
19 |
#include "hid.h" |
---|
20 |
#include "usbcfg.h" |
---|
21 |
#include "usbdesc.h" |
---|
22 |
|
---|
23 |
|
---|
24 |
/* HID Report Descriptor */ |
---|
25 |
const BYTE HID_ReportDescriptor[] = |
---|
26 |
{ |
---|
27 |
HID_UsagePageVendor(0x00), // Generic Page (0x06,0x00,0xFF) |
---|
28 |
HID_Usage(0x01), // (0x09,0x01) |
---|
29 |
HID_Collection(HID_Application), // Start Collection (0xA1,0x01) |
---|
30 |
|
---|
31 |
// Start Input Report // |
---|
32 |
HID_UsagePage(HID_USAGE_PAGE_BUTTON), // (0x05,0x09) |
---|
33 |
HID_UsageMin(1), // (0x19,0x01) |
---|
34 |
HID_UsageMax(3), // (0x29,0x03) |
---|
35 |
|
---|
36 |
// Report = Input = 8 Bit x 1 Field |
---|
37 |
HID_LogicalMin(0), // Min Input Value |
---|
38 |
HID_LogicalMax(1), // Max Input Value |
---|
39 |
HID_ReportCount(3), // Create Input Report = 3 Field |
---|
40 |
HID_ReportSize(1), // Create Input Report = 1 Bit / Field |
---|
41 |
HID_Input(HID_Data | HID_Variable | HID_Absolute), |
---|
42 |
|
---|
43 |
HID_ReportCount(1), |
---|
44 |
HID_ReportSize(5), |
---|
45 |
HID_Input(HID_Constant), |
---|
46 |
|
---|
47 |
// Start Output Report // |
---|
48 |
HID_UsagePage(HID_USAGE_PAGE_LED), |
---|
49 |
HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR), |
---|
50 |
|
---|
51 |
// Report = Output = 8 Bit x 5 Field |
---|
52 |
HID_LogicalMin(0), // Min Output Value |
---|
53 |
HID_LogicalMax(1), // Max Output Value |
---|
54 |
HID_ReportCount(8), // Create Output Report = 8 Field |
---|
55 |
HID_ReportSize(1), // Create Output Report = 1 Bit / Field |
---|
56 |
HID_Output(HID_Data | HID_Variable | HID_Absolute), |
---|
57 |
HID_EndCollection, |
---|
58 |
}; |
---|
59 |
|
---|
60 |
const WORD HID_ReportDescSize = sizeof(HID_ReportDescriptor); |
---|
61 |
|
---|
62 |
|
---|
63 |
/* USB Standard Device Descriptor */ |
---|
64 |
const BYTE USB_DeviceDescriptor[] = |
---|
65 |
{ |
---|
66 |
USB_DEVICE_DESC_SIZE, /* bLength */ |
---|
67 |
USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ |
---|
68 |
WBVAL(0x0110), /* 1.10 */ /* bcdUSB */ |
---|
69 |
0x00, /* bDeviceClass */ |
---|
70 |
0x00, /* bDeviceSubClass */ |
---|
71 |
0x00, /* bDeviceProtocol */ |
---|
72 |
USB_MAX_PACKET0, /* bMaxPacketSize0 */ |
---|
73 |
WBVAL(0xC251), /* idVendor */ |
---|
74 |
WBVAL(0x1701), /* idProduct */ |
---|
75 |
WBVAL(0x0100), /* 1.00 */ /* bcdDevice */ |
---|
76 |
0x04, /* iManufacturer */ |
---|
77 |
0x20, /* iProduct */ |
---|
78 |
0x42, /* iSerialNumber */ |
---|
79 |
0x01 /* bNumConfigurations */ |
---|
80 |
}; |
---|
81 |
|
---|
82 |
/* USB Configuration Descriptor */ |
---|
83 |
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */ |
---|
84 |
const BYTE USB_ConfigDescriptor[] = |
---|
85 |
{ |
---|
86 |
/* Configuration 1 */ |
---|
87 |
USB_CONFIGUARTION_DESC_SIZE, /* bDescriptorType */ |
---|
88 |
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ |
---|
89 |
WBVAL( /* wTotalLength */ |
---|
90 |
USB_CONFIGUARTION_DESC_SIZE + |
---|
91 |
USB_INTERFACE_DESC_SIZE + |
---|
92 |
HID_DESC_SIZE + |
---|
93 |
USB_ENDPOINT_DESC_SIZE |
---|
94 |
), |
---|
95 |
0x01, /* bNumInterfaces */ |
---|
96 |
0x01, /* bConfigurationValue */ |
---|
97 |
0x00, /* iConfiguration */ |
---|
98 |
USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */ |
---|
99 |
/*USB_CONFIG_REMOTE_WAKEUP*/, |
---|
100 |
USB_CONFIG_POWER_MA(100), /* bMaxPower */ |
---|
101 |
/* Interface 0, Alternate Setting 0, HID Class */ |
---|
102 |
USB_INTERFACE_DESC_SIZE, /* bLength */ |
---|
103 |
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ |
---|
104 |
0x00, /* bInterfaceNumber */ |
---|
105 |
0x00, /* bAlternateSetting */ |
---|
106 |
0x01, /* bNumEndpoints */ |
---|
107 |
USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ |
---|
108 |
HID_SUBCLASS_NONE, /* bInterfaceSubClass */ |
---|
109 |
HID_PROTOCOL_NONE, /* bInterfaceProtocol */ |
---|
110 |
0x5C, /* iInterface */ |
---|
111 |
/* HID Class Descriptor */ |
---|
112 |
/* HID_DESC_OFFSET = 0x0012 */ |
---|
113 |
HID_DESC_SIZE, /* bLength */ |
---|
114 |
HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */ |
---|
115 |
WBVAL(0x0100), /* 1.00 */ /* bcdHID */ |
---|
116 |
0x00, /* bCountryCode */ |
---|
117 |
0x01, /* bNumDescriptors */ |
---|
118 |
HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */ |
---|
119 |
WBVAL(HID_REPORT_DESC_SIZE), /* wDescriptorLength */ |
---|
120 |
/* Endpoint, HID Interrupt In */ |
---|
121 |
USB_ENDPOINT_DESC_SIZE, /* bLength */ |
---|
122 |
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ |
---|
123 |
USB_ENDPOINT_IN(1), /* bEndpointAddress */ |
---|
124 |
USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ |
---|
125 |
WBVAL(0x0004), /* wMaxPacketSize */ |
---|
126 |
0x20, /* 32ms */ /* bInterval */ |
---|
127 |
/* Terminator */ |
---|
128 |
0 /* bLength */ |
---|
129 |
}; |
---|
130 |
|
---|
131 |
/*************************************/ |
---|
132 |
/* Page-72 of USB Book (HID1_11.PDF) */ |
---|
133 |
/* USB String Descriptor (optional) */ |
---|
134 |
/*************************************/ |
---|
135 |
const BYTE USB_StringDescriptor[] = |
---|
136 |
{ |
---|
137 |
/* Index 0x00: LANGID Codes */ |
---|
138 |
0x04, // (1 Byte)bLength = 4Byte |
---|
139 |
USB_STRING_DESCRIPTOR_TYPE, // (1 Byte)bDescriptorType = 03H |
---|
140 |
WBVAL(0x0409), // (2 Byte)wLANGID[0] = 0409H = US English |
---|
141 |
|
---|
142 |
/* Index 0x04: Manufacturer */ |
---|
143 |
0x1C, // (1 Byte)bLength = 28 |
---|
144 |
USB_STRING_DESCRIPTOR_TYPE, // (1 Byte)bDescriptorType = 03H |
---|
145 |
'E',0, // 26 Byte String |
---|
146 |
'T',0, |
---|
147 |
'T',0, |
---|
148 |
' ',0, |
---|
149 |
'C',0, |
---|
150 |
'O',0, |
---|
151 |
'.',0, |
---|
152 |
',',0, |
---|
153 |
'L',0, |
---|
154 |
'T',0, |
---|
155 |
'D',0, |
---|
156 |
'.',0, |
---|
157 |
' ',0, |
---|
158 |
|
---|
159 |
/* Index 0x20: Product */ |
---|
160 |
0x22, // (1 Byte)bLength = 34 |
---|
161 |
USB_STRING_DESCRIPTOR_TYPE, // (1 Byte)bDescriptorType = 03H |
---|
162 |
'E',0, // 32 Byte String |
---|
163 |
'T',0, |
---|
164 |
'-',0, |
---|
165 |
'A',0, |
---|
166 |
'R',0, |
---|
167 |
'M',0, |
---|
168 |
'7',0, |
---|
169 |
'(',0, |
---|
170 |
'L',0, |
---|
171 |
'P',0, |
---|
172 |
'C',0, |
---|
173 |
'2',0, |
---|
174 |
'3',0, |
---|
175 |
'6',0, |
---|
176 |
'8',0, |
---|
177 |
')',0, |
---|
178 |
|
---|
179 |
/* Index 0x42: Serial Number */ |
---|
180 |
0x1A, // (1 Byte)bLength = 26 |
---|
181 |
USB_STRING_DESCRIPTOR_TYPE, // (1 Byte)bDescriptorType = 03H |
---|
182 |
'H',0, // 24 Byte String |
---|
183 |
'I',0, |
---|
184 |
'D',0, |
---|
185 |
' ',0, |
---|
186 |
'D',0, |
---|
187 |
'E',0, |
---|
188 |
'M',0, |
---|
189 |
'O',0, |
---|
190 |
' ',0, |
---|
191 |
'V',0, |
---|
192 |
'1',0, |
---|
193 |
'0',0, |
---|
194 |
|
---|
195 |
/* Index 0x5C: Interface 0, Alternate Setting 0 */ |
---|
196 |
0x08, // (1 Byte)bLength = 8 |
---|
197 |
USB_STRING_DESCRIPTOR_TYPE, // (1 Byte)bDescriptorType = 03H |
---|
198 |
'H',0, // 6 Byte String |
---|
199 |
'I',0, |
---|
200 |
'D',0, |
---|
201 |
}; |
---|