1 |
/////////////////////////////////////////////////////////////////////////// |
1 |
/////////////////////////////////////////////////////////////////////////// |
2 |
/// usbconfig.h //// |
2 |
/// usbconfig.h //// |
3 |
//// //// |
3 |
//// //// |
4 |
//// An example set of device / configuration descriptors. //// |
4 |
//// An example set of device / configuration descriptors. //// |
5 |
//// This set works exclusively with ex_usb_mouse.c example. //// |
5 |
//// This set works exclusively with ex_usb_mouse.c example. //// |
6 |
//// //// |
6 |
//// //// |
7 |
/////////////////////////////////////////////////////////////////////////// |
7 |
/////////////////////////////////////////////////////////////////////////// |
8 |
//// //// |
8 |
//// //// |
9 |
//// Version History: //// |
9 |
//// Version History: //// |
10 |
//// //// |
10 |
//// //// |
11 |
//// March 5th, 2009: //// |
11 |
//// March 5th, 2009: //// |
12 |
//// Cleanup for Wizard. //// |
12 |
//// Cleanup for Wizard. //// |
13 |
//// PIC24 Initial release. //// |
13 |
//// PIC24 Initial release. //// |
14 |
//// //// |
14 |
//// //// |
15 |
//// June 20th, 2005: //// |
15 |
//// June 20th, 2005: //// |
16 |
//// Initial 18Fxx5x release //// |
16 |
//// Initial 18Fxx5x release //// |
17 |
//// //// |
17 |
//// //// |
18 |
//// March 21st, 2005: //// |
18 |
//// March 21st, 2005: //// |
19 |
//// EP 0x81 now uses USB_EP1_TX_SIZE to define max packet size, to //// |
19 |
//// EP 0x81 now uses USB_EP1_TX_SIZE to define max packet size, to //// |
20 |
//// make it easier for dynamically changed code. //// |
20 |
//// make it easier for dynamically changed code. //// |
21 |
//// EP 0x81 will now use 1ms polling interval if using a full speed //// |
21 |
//// EP 0x81 will now use 1ms polling interval if using a full speed //// |
22 |
//// device. //// |
22 |
//// device. //// |
23 |
//// //// |
23 |
//// //// |
24 |
//// June 24th, 2002: Cleanup //// |
24 |
//// June 24th, 2002: Cleanup //// |
25 |
//// //// |
25 |
//// //// |
26 |
/////////////////////////////////////////////////////////////////////////// |
26 |
/////////////////////////////////////////////////////////////////////////// |
27 |
//// (C) Copyright 1996,2005 Custom Computer Services //// |
27 |
//// (C) Copyright 1996,2005 Custom Computer Services //// |
28 |
//// This source code may only be used by licensed users of the CCS //// |
28 |
//// This source code may only be used by licensed users of the CCS //// |
29 |
//// C compiler. This source code may only be distributed to other //// |
29 |
//// C compiler. This source code may only be distributed to other //// |
30 |
//// licensed users of the CCS C compiler. No other use, //// |
30 |
//// licensed users of the CCS C compiler. No other use, //// |
31 |
//// reproduction or distribution is permitted without written //// |
31 |
//// reproduction or distribution is permitted without written //// |
32 |
//// permission. Derivative programs created using this software //// |
32 |
//// permission. Derivative programs created using this software //// |
33 |
//// in object code form are not restricted in any way. //// |
33 |
//// in object code form are not restricted in any way. //// |
34 |
/////////////////////////////////////////////////////////////////////////// |
34 |
/////////////////////////////////////////////////////////////////////////// |
35 |
|
35 |
|
36 |
#IFNDEF __USB_DESCRIPTORS__ |
36 |
#IFNDEF __USB_DESCRIPTORS__ |
37 |
#DEFINE __USB_DESCRIPTORS__ |
37 |
#DEFINE __USB_DESCRIPTORS__ |
38 |
|
38 |
|
39 |
///////// config options, although it's best to leave alone for this demo ///// |
39 |
///////// config options, although it's best to leave alone for this demo ///// |
40 |
#define USB_CONFIG_PID 0xc631 |
40 |
#define USB_CONFIG_PID 0xc631 |
41 |
#define USB_CONFIG_VID 0x0403 |
41 |
#define USB_CONFIG_VID 0x0403 |
42 |
#define USB_CONFIG_BUS_POWER 100 //100mA (range is 0..500) |
42 |
#define USB_CONFIG_BUS_POWER 100 //100mA (range is 0..500) |
43 |
#define USB_CONFIG_VERSION 0x0205 //01.00 //range is 00.00 to 99.99 |
43 |
#define USB_CONFIG_VERSION 0x0205 //01.00 //range is 00.00 to 99.99 |
44 |
//////// end config /////////////////////////////////////////////////////////// |
44 |
//////// end config /////////////////////////////////////////////////////////// |
45 |
|
45 |
|
46 |
|
46 |
|
- |
|
47 |
//#DEFINE USB_CONFIG_BUS_POWER FALSE |
- |
|
48 |
//#define USB_USE_FULL_SPEED FALSE |
47 |
|
49 |
|
48 |
#DEFINE USB_HID_DEVICE TRUE //Tells the CCS PIC USB firmware |
50 |
#DEFINE USB_HID_DEVICE FALSE //Tells the CCS PIC USB firmware |
49 |
//to include HID handling code. |
51 |
//Enable to include HID handling code. |
50 |
|
52 |
|
51 |
//turn on EP1 for IN interrupt transfers. (IN = PIC -> PC) |
53 |
//turn on EP0 for IN control transfers. (IN = PIC -> PC) |
52 |
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT |
54 |
#define USB_EP0_TX_ENABLE USB_ENABLE_CONTROL |
- |
|
55 |
#define USB_EP0_TX_SIZE 64 //max packet size of this endpoint |
53 |
|
56 |
|
- |
|
57 |
#define USB_EP0_RX_ENABLE USB_ENABLE_CONTROL |
54 |
#define USB_EP1_TX_SIZE 8 //max packet size of this endpoint |
58 |
#define USB_EP0_RX_SIZE 64 //max packet size of this endpoint |
55 |
|
59 |
|
56 |
#include <usb.h> |
- |
|
57 |
|
- |
|
58 |
////////////////////////////////////////////////////////////////// |
- |
|
59 |
/// |
- |
|
60 |
/// HID Report. Tells HID driver how to handle and deal with |
- |
|
61 |
/// received data. HID Reports can be extremely complex, |
- |
|
62 |
/// see HID specifcation for help on writing your own. |
- |
|
63 |
/// |
- |
|
64 |
/// This examples configures HID driver to take received data |
- |
|
65 |
/// as mouse x, y and button data. |
- |
|
66 |
/// |
- |
|
67 |
////////////////////////////////////////////////////////////////// |
- |
|
68 |
|
- |
|
69 |
const char USB_CLASS_SPECIFIC_DESC[] = |
60 |
//#define USB_EP1_TX_ENABLE USB_ENABLE_CONTROL |
70 |
{ |
- |
|
71 |
0x05, 0x01, // usage page (generic desktop Choose the usage page "mouse" is on |
- |
|
72 |
0x09, 0x02, // usage (mouse) Device is a mouse |
- |
|
73 |
0xA1, 0x01, // collection (application) This collection encompasses the report format |
- |
|
74 |
0x09, 0x01, // usage (pointer) Choose the key code usage page |
- |
|
75 |
0xA1, 0x00, // collection (physical) Physical collection |
- |
|
76 |
0x05, 0x09, // usage page (buttons) Choose the button usage page |
- |
|
77 |
0x19, 0x01, // usage minimum (1) There are three buttons |
- |
|
78 |
0x29, 0x03, // usage maximum (3) |
- |
|
79 |
0x15, 0x00, // logical minimum (0) Each button is represented by one bit |
- |
|
80 |
0x25, 0x01, // logical maximum (1) |
- |
|
81 |
0x95, 0x03, // report count (3) Three reports, one bit each |
- |
|
82 |
0x75, 0x01, // report size (1) |
- |
|
83 |
0x81, 0x02, // input (data, variable, absolute) Defined bits above are data bits |
- |
|
84 |
0x95, 0x01, // report count (1) One report, five bits in length |
61 |
//#define USB_EP1_TX_SIZE 8 //max packet size of this endpoint |
85 |
0x75, 0x05, // report size (5) |
- |
|
86 |
0x81, 0x01, // input (constant) Bit stuff to fill byte |
- |
|
87 |
0x05, 0x01, // usage page (generic desktop) Choose the usage pare X and Y are on |
- |
|
88 |
0x09, 0x30, // usage (X) X direction of pointer |
- |
|
89 |
0x09, 0x31, // usage (Y) Y direction of pointer |
- |
|
90 |
0x09, 0x38 // usage (wheel) |
- |
|
91 |
0x15, 0x81, // logical minimum (-127) Range of report data is -127 to 127 |
- |
|
92 |
0x25, 0x7F, // logical maximum (127) |
- |
|
93 |
0x75, 0x08, // report size (8) Two reports, eight bits each |
- |
|
94 |
0x95, 0x03, // report count (3) |
- |
|
95 |
0x81, 0x06, // input (data, variable, absolute) Defined bits above are data bits |
- |
|
96 |
0xC0, // end collection End physical collection |
- |
|
97 |
0xC0 // end collection End application collection |
- |
|
98 |
}; |
- |
|
99 |
|
62 |
|
100 |
//if a class has an extra descriptor not part of the config descriptor, |
- |
|
101 |
// this lookup table defines where to look for it in the const |
- |
|
102 |
// USB_CLASS_SPECIFIC_DESC[] array. |
63 |
//#define USB_EP1_RX_ENABLE USB_ENABLE_CONTROL |
103 |
//first element is the config number (if your device has more than one config) |
64 |
//#define USB_EP1_RX_SIZE 8 //max packet size of this endpoint |
104 |
//second element is which interface number |
- |
|
105 |
//set element to 0xFFFF if this config/interface combo doesn't exist |
- |
|
106 |
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP[USB_NUM_CONFIGURATIONS][1] = |
- |
|
107 |
{ |
- |
|
108 |
//config 1 |
- |
|
109 |
//interface 0 |
- |
|
110 |
0 |
- |
|
111 |
}; |
- |
|
112 |
|
65 |
|
113 |
//if a class has an extra descriptor not part of the config descriptor, |
- |
|
114 |
// this lookup table defines the size of that descriptor. |
- |
|
115 |
//first element is the config number (if your device has more than one config) |
- |
|
116 |
//second element is which interface number |
- |
|
117 |
//set element to 0xFFFF if this config/interface combo doesn't exist |
- |
|
118 |
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[USB_NUM_CONFIGURATIONS][1] = |
- |
|
119 |
{ |
- |
|
120 |
//config 1 |
- |
|
121 |
//interface 0 |
- |
|
122 |
sizeof(USB_CLASS_SPECIFIC_DESC) |
- |
|
123 |
}; |
- |
|
124 |
|
66 |
|
125 |
|
67 |
|
- |
|
68 |
#include <usb.h> |
126 |
|
69 |
|
127 |
////////////////////////////////////////////////////////////////// |
70 |
////////////////////////////////////////////////////////////////// |
128 |
/// |
71 |
/// |
129 |
/// start config descriptor |
72 |
/// start config descriptor |
130 |
/// right now we only support one configuration descriptor. |
73 |
/// right now we only support one configuration descriptor. |
131 |
/// the config, interface, class, and endpoint goes into this array. |
74 |
/// the config, interface, class, and endpoint goes into this array. |
132 |
/// |
75 |
/// |
133 |
////////////////////////////////////////////////////////////////// |
76 |
////////////////////////////////////////////////////////////////// |
134 |
|
77 |
|
135 |
#DEFINE USB_TOTAL_CONFIG_LEN 34 //config+interface+class+endpoint |
78 |
#DEFINE USB_TOTAL_CONFIG_LEN 32 //config+interface+class+endpoint |
136 |
|
79 |
|
137 |
const char USB_CONFIG_DESC[] = { |
80 |
const char USB_CONFIG_DESC[] = { |
138 |
//IN ORDER TO COMPLY WITH WINDOWS HOSTS, THE ORDER OF THIS ARRAY MUST BE: |
81 |
//IN ORDER TO COMPLY WITH WINDOWS HOSTS, THE ORDER OF THIS ARRAY MUST BE: |
139 |
// config(s) |
82 |
// config(s) |
140 |
// interface(s) |
83 |
// interface(s) |
141 |
// class(es) |
84 |
// class(es) |
142 |
// endpoint(s) |
85 |
// endpoint(s) |
143 |
|
86 |
|
144 |
//config_descriptor for config index 1 |
87 |
//config_descriptor for config index 1 |
145 |
USB_DESC_CONFIG_LEN, //length of descriptor size ==1 |
88 |
USB_DESC_CONFIG_LEN, //length of descriptor size ==1 |
146 |
USB_DESC_CONFIG_TYPE, //constant CONFIGURATION (CONFIGURATION 0x02) ==2 |
89 |
USB_DESC_CONFIG_TYPE, //constant CONFIGURATION (CONFIGURATION 0x02) ==2 |
147 |
USB_TOTAL_CONFIG_LEN,0, //size of all data returned for this config ==3,4 |
90 |
USB_TOTAL_CONFIG_LEN,0, //size of all data returned for this config ==3,4 |
148 |
1, //number of interfaces this device supports ==5 |
91 |
1, //number of interfaces this device supports ==5 |
149 |
0x01, //identifier for this configuration. (IF we had more than one configurations) ==6 |
92 |
0x01, //identifier for this configuration. (IF we had more than one configurations) ==6 |
150 |
0x00, //index of string descriptor for this configuration ==7 |
93 |
0x00, //index of string descriptor for this configuration ==7 |
151 |
#if USB_CONFIG_BUS_POWER |
94 |
#if USB_CONFIG_BUS_POWER |
152 |
0xC0, //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 unused and bit7=1 ==8 |
95 |
0xC0, //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 unused and bit7=1 ==8 |
153 |
#else |
96 |
#else |
154 |
0x80, //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 unused and bit7=1 ==8 |
97 |
0x80, //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 unused and bit7=1 ==8 |
155 |
#endif |
98 |
#endif |
156 |
USB_CONFIG_BUS_POWER/2, //maximum bus power required (maximum milliamperes/2) (0x32 = 100mA) ==9 |
99 |
USB_CONFIG_BUS_POWER/2, //maximum bus power required (maximum milliamperes/2) (0x32 = 100mA) ==9 |
157 |
|
100 |
|
158 |
//interface descriptor 1 |
101 |
//interface descriptor 1 |
159 |
USB_DESC_INTERFACE_LEN, //length of descriptor =10 |
102 |
USB_DESC_INTERFACE_LEN, //length of descriptor =10 |
160 |
USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04) =11 |
103 |
USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04) =11 |
161 |
0x00, //number defining this interface (IF we had more than one interface) ==12 |
104 |
0x00, //number defining this interface (IF we had more than one interface) ==12 |
162 |
0x00, //alternate setting ==13 |
105 |
0x00, //alternate setting ==13 |
163 |
1, //number of endpoints, except 0 ==14 |
106 |
2, //number of endpoints, except 0 ==14 |
164 |
0x03, //class code, 03 = HID ==15 |
107 |
0xff, //class code, 03 = HID ==15 |
165 |
0x01, //subclass code //boot ==16 |
108 |
0xff, //subclass code //boot ==16 |
166 |
0x02, //protocol code ==17 |
109 |
0xff, //protocol code ==17 |
167 |
0x00, //index of string descriptor for interface ==18 |
110 |
0x00, //index of string descriptor for interface ==18 |
168 |
|
111 |
|
169 |
//class descriptor 1 (HID) |
112 |
//class descriptor 1 (HID) |
170 |
USB_DESC_CLASS_LEN, //length of descriptor ==19 |
113 |
/* USB_DESC_CLASS_LEN, //length of descriptor ==19 |
171 |
USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID) ==20 |
114 |
USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID) ==20 |
172 |
0x00,0x01, //hid class release number (1.0) (try 1.10) ==21,22 |
115 |
0x00,0x01, //hid class release number (1.0) (try 1.10) ==21,22 |
173 |
0x00, //localized country code (0 = none) ==23 |
116 |
0x00, //localized country code (0 = none) ==23 |
174 |
0x01, //number of hid class descrptors that follow (1) ==24 |
117 |
0x01, //number of hid class descrptors that follow (1) ==24 |
175 |
0x22, //report descriptor type (0x22 == HID) ==25 |
118 |
0x22, //report descriptor type (0x22 == HID) ==25 |
176 |
USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][0], 0x00, //length of report descriptor ==26,27 |
119 |
0, 0x00, //length of report descriptor ==26,27 |
- |
|
120 |
*/ |
- |
|
121 |
//endpoint descriptor |
- |
|
122 |
USB_DESC_ENDPOINT_LEN, //length of descriptor ==28 |
- |
|
123 |
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==29 |
- |
|
124 |
0x80, //endpoint number and direction (0x80 = EP0 IN) ==30 |
- |
|
125 |
USB_ENDPOINT_TYPE_CONTROL, //transfer type supported (0x03 is interrupt) ==31 |
- |
|
126 |
USB_EP0_TX_SIZE,0x00, //maximum packet size supported ==32,33 |
- |
|
127 |
10 //polling interval, in ms. (cant be smaller than 10 for slow speed devices) ==34 |
177 |
|
128 |
|
178 |
//endpoint descriptor |
129 |
//endpoint descriptor |
179 |
USB_DESC_ENDPOINT_LEN, //length of descriptor ==28 |
130 |
USB_DESC_ENDPOINT_LEN, //length of descriptor ==28 |
180 |
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==29 |
131 |
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==29 |
181 |
0x81, //endpoint number and direction (0x81 = EP1 IN) ==30 |
132 |
0x00, //endpoint number and direction (0x80 = EP0 IN) ==30 |
182 |
USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt) ==31 |
133 |
USB_ENDPOINT_TYPE_CONTROL, //transfer type supported (0x03 is interrupt) ==31 |
183 |
USB_EP1_TX_SIZE,0x00, //maximum packet size supported ==32,33 |
134 |
USB_EP0_RX_SIZE,0x00, //maximum packet size supported ==32,33 |
184 |
10 //polling interval, in ms. (cant be smaller than 10 for slow speed devices) ==34 |
135 |
10 //polling interval, in ms. (cant be smaller than 10 for slow speed devices) ==34 |
185 |
}; |
136 |
}; |
186 |
|
137 |
|
187 |
|
138 |
|
188 |
//****** BEGIN CONFIG DESCRIPTOR LOOKUP TABLES ******** |
139 |
//****** BEGIN CONFIG DESCRIPTOR LOOKUP TABLES ******** |
189 |
//since we can't make pointers to constants in certain pic16s, this is an offset table to find |
140 |
//since we can't make pointers to constants in certain pic16s, this is an offset table to find |
190 |
// a specific descriptor in the above table. |
141 |
// a specific descriptor in the above table. |
191 |
|
142 |
|
192 |
//NOTE: DO TO A LIMITATION OF THE CCS CODE, ALL HID INTERFACES MUST START AT 0 AND BE SEQUENTIAL |
143 |
//NOTE: DO TO A LIMITATION OF THE CCS CODE, ALL HID INTERFACES MUST START AT 0 AND BE SEQUENTIAL |
193 |
// FOR EXAMPLE, IF YOU HAVE 2 HID INTERFACES THEY MUST BE INTERFACE 0 AND INTERFACE 1 |
144 |
// FOR EXAMPLE, IF YOU HAVE 2 HID INTERFACES THEY MUST BE INTERFACE 0 AND INTERFACE 1 |
194 |
#define USB_NUM_HID_INTERFACES 1 |
145 |
#define USB_NUM_HID_INTERFACES 1 |
195 |
|
146 |
|
196 |
//the maximum number of interfaces seen on any config |
147 |
//the maximum number of interfaces seen on any config |
197 |
//for example, if config 1 has 1 interface and config 2 has 2 interfaces you must define this as 2 |
148 |
//for example, if config 1 has 1 interface and config 2 has 2 interfaces you must define this as 2 |
198 |
#define USB_MAX_NUM_INTERFACES 1 |
149 |
#define USB_MAX_NUM_INTERFACES 1 |
199 |
|
150 |
|
200 |
//define how many interfaces there are per config. [0] is the first config, etc. |
151 |
//define how many interfaces there are per config. [0] is the first config, etc. |
201 |
const char USB_NUM_INTERFACES[USB_NUM_CONFIGURATIONS]={1}; |
152 |
const char USB_NUM_INTERFACES[USB_NUM_CONFIGURATIONS]={1}; |
202 |
|
153 |
|
203 |
//define where to find class descriptors |
154 |
//define where to find class descriptors |
204 |
//first dimension is the config number |
155 |
//first dimension is the config number |
205 |
//second dimension specifies which interface |
156 |
//second dimension specifies which interface |
206 |
//last dimension specifies which class in this interface to get, but most will only have 1 class per interface |
157 |
//last dimension specifies which class in this interface to get, but most will only have 1 class per interface |
207 |
//if a class descriptor is not valid, set the value to 0xFFFF |
158 |
//if a class descriptor is not valid, set the value to 0xFFFF |
208 |
const int16 USB_CLASS_DESCRIPTORS[USB_NUM_CONFIGURATIONS][USB_NUM_HID_INTERFACES][1]= |
159 |
const int16 USB_CLASS_DESCRIPTORS[USB_NUM_CONFIGURATIONS][USB_NUM_HID_INTERFACES][1]= |
209 |
{ |
160 |
{ |
210 |
//config 1 |
161 |
//config 1 |
211 |
//interface 0 |
162 |
//interface 0 |
212 |
//class 1 |
163 |
//class 1 |
213 |
18 |
164 |
18 |
214 |
}; |
165 |
}; |
215 |
|
166 |
|
216 |
|
167 |
|
217 |
#if (sizeof(USB_CONFIG_DESC) != USB_TOTAL_CONFIG_LEN) |
168 |
#if (sizeof(USB_CONFIG_DESC) != USB_TOTAL_CONFIG_LEN) |
218 |
#error USB_TOTAL_CONFIG_LEN not defined correctly |
169 |
#error USB_TOTAL_CONFIG_LEN not defined correctly |
219 |
#endif |
170 |
#endif |
220 |
|
171 |
|
221 |
|
172 |
|
222 |
////////////////////////////////////////////////////////////////// |
173 |
////////////////////////////////////////////////////////////////// |
223 |
/// |
174 |
/// |
224 |
/// start device descriptors |
175 |
/// start device descriptors |
225 |
/// |
176 |
/// |
226 |
////////////////////////////////////////////////////////////////// |
177 |
////////////////////////////////////////////////////////////////// |
227 |
|
178 |
|
228 |
const char USB_DEVICE_DESC[] = { |
179 |
const char USB_DEVICE_DESC[] = { |
229 |
//starts of with device configuration. only one possible |
180 |
//starts of with device configuration. only one possible |
230 |
USB_DESC_DEVICE_LEN, //the length of this report ==1 |
181 |
USB_DESC_DEVICE_LEN, //the length of this report ==1 |
231 |
0x01, //the constant DEVICE (DEVICE 0x01) ==2 |
182 |
0x01, //the constant DEVICE (DEVICE 0x01) ==2 |
232 |
0x10,0x01, //usb version in bcd (pic167xx is 1.1) ==3,4 |
183 |
0x10,0x01, //usb version in bcd (pic167xx is 1.1) ==3,4 |
233 |
0xff, //class code ==5 |
184 |
0xff, //class code vendor specific |
234 |
0x00, //subclass code ==6 |
185 |
0x00, //subclass code ==6 |
235 |
0x00, //protocol code ==7 |
186 |
0x00, //protocol code ==7 |
236 |
USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8) ==8 |
187 |
USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8) ==8 |
237 |
USB_CONFIG_VID & 0xFF, ((USB_CONFIG_VID >> 8) & 0xFF), //vendor id ==9, 10 |
188 |
USB_CONFIG_VID & 0xFF, ((USB_CONFIG_VID >> 8) & 0xFF), //vendor id ==9, 10 |
238 |
USB_CONFIG_PID & 0xFF, ((USB_CONFIG_PID >> 8) & 0xFF), //product id, don't use 0xffff ==11, 12 |
189 |
USB_CONFIG_PID & 0xFF, ((USB_CONFIG_PID >> 8) & 0xFF), //product id, don't use 0xffff ==11, 12 |
239 |
USB_CONFIG_VERSION & 0xFF, ((USB_CONFIG_VERSION >> 8) & 0xFF), //device release number ==13,14 |
190 |
USB_CONFIG_VERSION & 0xFF, ((USB_CONFIG_VERSION >> 8) & 0xFF), //device release number ==13,14 |
240 |
0x01, //index of string description of manufacturer. therefore we point to string_1 array (see below) ==15 |
191 |
0x01, //index of string description of manufacturer. therefore we point to string_1 array (see below) ==15 |
241 |
0x02, //index of string descriptor of the product ==16 |
192 |
0x02, //index of string descriptor of the product ==16 |
242 |
0x00, //index of string descriptor of serial number ==17 |
193 |
0x00, //index of string descriptor of serial number ==17 |
243 |
USB_NUM_CONFIGURATIONS //number of possible configurations ==18 |
194 |
USB_NUM_CONFIGURATIONS //number of possible configurations ==18 |
244 |
}; |
195 |
}; |
245 |
|
196 |
|
246 |
#if (sizeof(USB_DEVICE_DESC) != USB_DESC_DEVICE_LEN) |
197 |
#if (sizeof(USB_DEVICE_DESC) != USB_DESC_DEVICE_LEN) |
247 |
#error USB_DESC_DEVICE_LEN not defined correctly |
198 |
#error USB_DESC_DEVICE_LEN not defined correctly |
248 |
#endif |
199 |
#endif |
249 |
|
200 |
|
250 |
|
201 |
|
251 |
////////////////////////////////////////////////////////////////// |
202 |
////////////////////////////////////////////////////////////////// |
252 |
/// |
203 |
/// |
253 |
/// start string descriptors |
204 |
/// start string descriptors |
254 |
/// String 0 is a special language string, and must be defined. People in U.S.A. can leave this alone. |
205 |
/// String 0 is a special language string, and must be defined. People in U.S.A. can leave this alone. |
255 |
/// |
206 |
/// |
256 |
////////////////////////////////////////////////////////////////// |
207 |
////////////////////////////////////////////////////////////////// |
257 |
|
208 |
|
258 |
//the offset of the starting location of each string. offset[0] is the start of string 0, offset[1] is the start of string 1, etc. |
209 |
//the offset of the starting location of each string. offset[0] is the start of string 0, offset[1] is the start of string 1, etc. |
259 |
const char USB_STRING_DESC_OFFSET[]={0,4,12}; |
210 |
const char USB_STRING_DESC_OFFSET[]={0,4,12}; |
260 |
|
211 |
|
261 |
//number of strings you have, including string 0. |
212 |
//number of strings you have, including string 0. |
262 |
#define USB_STRING_DESC_COUNT sizeof(USB_STRING_DESC_OFFSET) |
213 |
#define USB_STRING_DESC_COUNT sizeof(USB_STRING_DESC_OFFSET) |
263 |
|
214 |
|
264 |
// Here is where the "CCS" Manufacturer string and "CCS USB Mouse" are stored. |
215 |
// Here is where the "CCS" Manufacturer string and "CCS USB Mouse" are stored. |
265 |
// Strings are saved as unicode. |
216 |
// Strings are saved as unicode. |
266 |
char const USB_STRING_DESC[]={ |
217 |
char const USB_STRING_DESC[]={ |
267 |
//string 0 |
218 |
//string 0 |
268 |
4, //length of string index |
219 |
4, //length of string index |
269 |
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING) |
220 |
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING) |
270 |
0x09,0x04, //Microsoft Defined for US-English |
221 |
0x09,0x04, //Microsoft Defined for US-English |
271 |
//string 1 |
222 |
//string 1 |
272 |
8, //length of string index |
223 |
8, //length of string index |
273 |
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING) |
224 |
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING) |
274 |
'U',0, |
225 |
'U',0, |
275 |
'S',0, |
226 |
'S',0, |
276 |
'T',0, |
227 |
'T',0, |
277 |
//string 2 |
228 |
//string 2 |
278 |
28, //length of string index |
229 |
28, //length of string index |
279 |
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING) |
230 |
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING) |
280 |
'i',0, |
231 |
'i',0, |
281 |
'2',0, |
232 |
'2',0, |
282 |
'c',0, |
233 |
'c',0, |
283 |
'-',0, |
234 |
'-',0, |
284 |
'P',0, |
235 |
'P',0, |
285 |
'I',0, |
236 |
'I',0, |
286 |
'C',0, |
237 |
'C',0, |
287 |
'-',0, |
238 |
'-',0, |
288 |
'U',0, |
239 |
'U',0, |
289 |
'S',0, |
240 |
'S',0, |
290 |
'B',0, |
241 |
'B',0, |
291 |
' ',0, |
242 |
' ',0, |
292 |
' ',0 |
243 |
' ',0 |
293 |
}; |
244 |
}; |