?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*******************************************************************************
2  
3 USB Chapter 9 Protocol (Header File)
4  
5 Summary:
6 This file defines data structures, constants, and macros that are used to
7 to support the USB Device Framework protocol described in Chapter 9 of the
8 USB 2.0 specification.
9  
10 Description:
11 This file defines data structures, constants, and macros that are used to
12 to support the USB Device Framework protocol described in Chapter 9 of the
13 USB 2.0 specification.
14  
15 This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB"
16 directory.
17  
18 When including this file in a new project, this file can either be
19 referenced from the directory in which it was installed or copied
20 directly into the user application folder. If the first method is
21 chosen to keep the file located in the folder in which it is installed
22 then include paths need to be added so that the library and the
23 application both know where to reference each others files. If the
24 application folder is located in the same folder as the Microchip
25 folder (like the current demo folders), then the following include
26 paths need to be added to the application's project:
27  
28 .
29  
30 ..\\..\\Microchip\\Include
31  
32 If a different directory structure is used, modify the paths as
33 required. An example using absolute paths instead of relative paths
34 would be the following:
35  
36 C:\\Microchip Solutions\\Microchip\\Include
37  
38 C:\\Microchip Solutions\\My Demo Application
39 *******************************************************************************/
40 //DOM-IGNORE-BEGIN
41 /*******************************************************************************
42  
43 * FileName: usb_ch9.h
44 * Dependencies: None
45 * Processor: PIC18/PIC24/PIC32MX microcontrollers with USB module
46 * Compiler: C18 v3.13+/C30 v2.01+/C32 v0.00.18+
47 * Company: Microchip Technology, Inc.
48 * File Description:
49 * This file contains the definitions and prototypes used for
50 * specification chapter 9 compliance.
51  
52 Software License Agreement
53  
54 The software supplied herewith by Microchip Technology Incorporated
55 (the “Company”) for its PICmicro® Microcontroller is intended and
56 supplied to you, the Company’s customer, for use solely and
57 exclusively on Microchip PICmicro Microcontroller products. The
58 software is owned by the Company and/or its supplier, and is
59 protected under applicable copyright laws. All rights are reserved.
60 Any use in violation of the foregoing restrictions may subject the
61 user to criminal sanctions under applicable laws, as well as to
62 civil liability for the breach of the terms and conditions of this
63 license.
64  
65 THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
66 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
67 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
68 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
69 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
70 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
71  
72 *******************************************************************************/
73 //DOM-IGNORE-END
74  
75 //DOM-IGNORE-BEGIN
76 /********************************************************************
77 Change History:
78 Rev Description
79 ---- -----------
80 2.6 Moved many of the CH9 defintions from the device stack files
81 into this file.
82 2.6a- No Change
83 2.7a
84 ********************************************************************/
85 //DOM-IGNORE-END
86  
87 //DOM-IGNORE-BEGIN
88 #ifndef _USB_CH9_H_
89 #define _USB_CH9_H_
90 //DOM-IGNORE-END
91  
92  
93 // *****************************************************************************
94 // *****************************************************************************
95 // Section: USB Descriptors
96 // *****************************************************************************
97 // *****************************************************************************
98  
99 #define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor.
100 #define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor.
101 #define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor.
102 #define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor.
103 #define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor.
104 #define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier.
105 #define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration.
106 #define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power.
107 #define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor.
108  
109 // *****************************************************************************
110 /* USB Device Descriptor Structure
111  
112 This struct defines the structure of a USB Device Descriptor. Note that this
113 structure may need to be packed, or even accessed as bytes, to properly access
114 the correct fields when used on some device architectures.
115 */
116 typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR
117 {
118 BYTE bLength; // Length of this descriptor.
119 BYTE bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE).
120 WORD bcdUSB; // USB Spec Release Number (BCD).
121 BYTE bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific.
122 BYTE bDeviceSubClass; // Subclass code (assigned by the USB-IF).
123 BYTE bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific.
124 BYTE bMaxPacketSize0; // Maximum packet size for endpoint 0.
125 WORD idVendor; // Vendor ID (assigned by the USB-IF).
126 WORD idProduct; // Product ID (assigned by the manufacturer).
127 WORD bcdDevice; // Device release number (BCD).
128 BYTE iManufacturer; // Index of String Descriptor describing the manufacturer.
129 BYTE iProduct; // Index of String Descriptor describing the product.
130 BYTE iSerialNumber; // Index of String Descriptor with the device's serial number.
131 BYTE bNumConfigurations; // Number of possible configurations.
132 } USB_DEVICE_DESCRIPTOR;
133  
134  
135 // *****************************************************************************
136 /* USB Configuration Descriptor Structure
137  
138 This struct defines the structure of a USB Configuration Descriptor. Note that this
139 structure may need to be packed, or even accessed as bytes, to properly access
140 the correct fields when used on some device architectures.
141 */
142 typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR
143 {
144 BYTE bLength; // Length of this descriptor.
145 BYTE bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION).
146 WORD wTotalLength; // Total length of all descriptors for this configuration.
147 BYTE bNumInterfaces; // Number of interfaces in this configuration.
148 BYTE bConfigurationValue; // Value of this configuration (1 based).
149 BYTE iConfiguration; // Index of String Descriptor describing the configuration.
150 BYTE bmAttributes; // Configuration characteristics.
151 BYTE bMaxPower; // Maximum power consumed by this configuration.
152 } USB_CONFIGURATION_DESCRIPTOR;
153  
154 // Attributes bits
155 #define USB_CFG_DSC_REQUIRED 0x80 // Required attribute
156 #define USB_CFG_DSC_SELF_PWR (0x40|USB_CFG_DSC_REQUIRED) // Device is self powered.
157 #define USB_CFG_DSC_REM_WAKE (0x20|USB_CFG_DSC_REQUIRED) // Device can request remote wakup
158  
159  
160 // *****************************************************************************
161 /* USB Interface Descriptor Structure
162  
163 This struct defines the structure of a USB Interface Descriptor. Note that this
164 structure may need to be packed, or even accessed as bytes, to properly access
165 the correct fields when used on some device architectures.
166 */
167 typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR
168 {
169 BYTE bLength; // Length of this descriptor.
170 BYTE bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE).
171 BYTE bInterfaceNumber; // Number of this interface (0 based).
172 BYTE bAlternateSetting; // Value of this alternate interface setting.
173 BYTE bNumEndpoints; // Number of endpoints in this interface.
174 BYTE bInterfaceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific.
175 BYTE bInterfaceSubClass; // Subclass code (assigned by the USB-IF).
176 BYTE bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific.
177 BYTE iInterface; // Index of String Descriptor describing the interface.
178 } USB_INTERFACE_DESCRIPTOR;
179  
180  
181 // *****************************************************************************
182 /* USB Endpoint Descriptor Structure
183  
184 This struct defines the structure of a USB Endpoint Descriptor. Note that this
185 structure may need to be packed, or even accessed as bytes, to properly access
186 the correct fields when used on some device architectures.
187 */
188 typedef struct __attribute__ ((packed)) _USB_ENDPOINT_DESCRIPTOR
189 {
190 BYTE bLength; // Length of this descriptor.
191 BYTE bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT).
192 BYTE bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN).
193 BYTE bmAttributes; // Endpoint transfer type.
194 WORD wMaxPacketSize; // Maximum packet size.
195 BYTE bInterval; // Polling interval in frames.
196 } USB_ENDPOINT_DESCRIPTOR;
197  
198  
199 // Endpoint Direction
200 #define EP_DIR_IN 0x80 // Data flows from device to host
201 #define EP_DIR_OUT 0x00 // Data flows from host to device
202  
203  
204 // ******************************************************************
205 // USB Endpoint Attributes
206 // ******************************************************************
207  
208 // Section: Transfer Types
209 #define EP_ATTR_CONTROL (0<<0) // Endoint used for control transfers
210 #define EP_ATTR_ISOCH (1<<0) // Endpoint used for isochronous transfers
211 #define EP_ATTR_BULK (2<<0) // Endpoint used for bulk transfers
212 #define EP_ATTR_INTR (3<<0) // Endpoint used for interrupt transfers
213  
214 // Section: Synchronization Types (for isochronous enpoints)
215 #define EP_ATTR_NO_SYNC (0<<2) // No Synchronization
216 #define EP_ATTR_ASYNC (1<<2) // Asynchronous
217 #define EP_ATTR_ADAPT (2<<2) // Adaptive synchronization
218 #define EP_ATTR_SYNC (3<<2) // Synchronous
219  
220 // Section: Usage Types (for isochronous endpoints)
221 #define EP_ATTR_DATA (0<<4) // Data Endpoint
222 #define EP_ATTR_FEEDBACK (1<<4) // Feedback endpoint
223 #define EP_ATTR_IMP_FB (2<<4) // Implicit Feedback data EP
224  
225 // Section: Max Packet Sizes
226 #define EP_MAX_PKT_INTR_LS 8 // Max low-speed interrupt packet
227 #define EP_MAX_PKT_INTR_FS 64 // Max full-speed interrupt packet
228 #define EP_MAX_PKT_ISOCH_FS 1023 // Max full-speed isochronous packet
229 #define EP_MAX_PKT_BULK_FS 64 // Max full-speed bulk packet
230 #define EP_LG_PKT_BULK_FS 32 // Large full-speed bulk packet
231 #define EP_MED_PKT_BULK_FS 16 // Medium full-speed bulk packet
232 #define EP_SM_PKT_BULK_FS 8 // Small full-speed bulk packet
233  
234 /* Descriptor IDs
235 The descriptor ID type defines the information required by the HOST during a
236 GET_DESCRIPTOR request
237 */
238 typedef struct
239 {
240 BYTE index;
241 BYTE type;
242 UINT16 language_id;
243  
244 } DESCRIPTOR_ID;
245  
246 // *****************************************************************************
247 /* USB OTG Descriptor Structure
248  
249 This struct defines the structure of a USB OTG Descriptor. Note that this
250 structure may need to be packed, or even accessed as bytes, to properly access
251 the correct fields when used on some device architectures.
252 */
253 typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR
254 {
255 BYTE bLength; // Length of this descriptor.
256 BYTE bDescriptorType; // OTG descriptor type (USB_DESCRIPTOR_OTG).
257 BYTE bmAttributes; // OTG attributes.
258 } USB_OTG_DESCRIPTOR;
259  
260  
261 // ******************************************************************
262 // Section: USB String Descriptor Structure
263 // ******************************************************************
264 // This structure describes the USB string descriptor. The string
265 // descriptor provides user-readable information about various aspects of
266 // the device. The first string desriptor (string descriptor zero (0)),
267 // provides a list of the number of languages supported by the set of
268 // string descriptors for this device instead of an actual string.
269 //
270 // Note: The strings are in 2-byte-per-character unicode, not ASCII.
271 //
272 // Note: This structure only describes the "header" of the string
273 // descriptor. The actual data (either the language ID array or the
274 // array of unicode characters making up the string, must be allocated
275 // immediately following this header with no padding between them.
276  
277 typedef struct __attribute__ ((packed)) _USB_STRING_DSC
278 {
279 BYTE bLength; // Size of this descriptor
280 BYTE bDescriptorType; // Type, USB_DSC_STRING
281  
282 } USB_STRING_DESCRIPTOR;
283  
284  
285 // ******************************************************************
286 // Section: USB Device Qualifier Descriptor Structure
287 // ******************************************************************
288 // This structure describes the device qualifier descriptor. The device
289 // qualifier descriptor provides overall device information if the device
290 // supports "other" speeds.
291 //
292 // Note: A high-speed device may support "other" speeds (ie. full or low).
293 // If so, it may need to implement the the device qualifier and other
294 // speed descriptors.
295  
296 typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR
297 {
298 BYTE bLength; // Size of this descriptor
299 BYTE bType; // Type, always USB_DESCRIPTOR_DEVICE_QUALIFIER
300 WORD bcdUSB; // USB spec version, in BCD
301 BYTE bDeviceClass; // Device class code
302 BYTE bDeviceSubClass; // Device sub-class code
303 BYTE bDeviceProtocol; // Device protocol
304 BYTE bMaxPacketSize0; // EP0, max packet size
305 BYTE bNumConfigurations; // Number of "other-speed" configurations
306 BYTE bReserved; // Always zero (0)
307  
308 } USB_DEVICE_QUALIFIER_DESCRIPTOR;
309  
310 // ******************************************************************
311 // Section: USB Setup Packet Structure
312 // ******************************************************************
313 // This structure describes the data contained in a USB standard device
314 // request's setup packet. It is the data packet sent from the host to
315 // the device to control and configure the device.
316 //
317 // Note: Refer to the USB 2.0 specification for additional details on the
318 // usage of the setup packet and standard device requests.
319 typedef union __attribute__ ((packed))
320 {
321 /** Standard Device Requests ***********************************/
322 struct __attribute__ ((packed))
323 {
324 BYTE bmRequestType; //from table 9-2 of USB2.0 spec
325 BYTE bRequest; //from table 9-2 of USB2.0 spec
326 WORD wValue; //from table 9-2 of USB2.0 spec
327 WORD wIndex; //from table 9-2 of USB2.0 spec
328 WORD wLength; //from table 9-2 of USB2.0 spec
329 };
330 struct __attribute__ ((packed))
331 {
332 unsigned :8;
333 unsigned :8;
334 WORD_VAL W_Value; //from table 9-2 of USB2.0 spec, allows byte/bitwise access
335 WORD_VAL W_Index; //from table 9-2 of USB2.0 spec, allows byte/bitwise access
336 WORD_VAL W_Length; //from table 9-2 of USB2.0 spec, allows byte/bitwise access
337 };
338 struct __attribute__ ((packed))
339 {
340 unsigned Recipient:5; //Device,Interface,Endpoint,Other
341 unsigned RequestType:2; //Standard,Class,Vendor,Reserved
342 unsigned DataDir:1; //Host-to-device,Device-to-host
343 unsigned :8;
344 BYTE bFeature; //DEVICE_REMOTE_WAKEUP,ENDPOINT_HALT
345 unsigned :8;
346 unsigned :8;
347 unsigned :8;
348 unsigned :8;
349 unsigned :8;
350 };
351 struct __attribute__ ((packed))
352 {
353 union // offset description
354 { // ------ ------------------------
355 BYTE bmRequestType; // 0 Bit-map of request type
356 struct
357 {
358 BYTE recipient: 5; // Recipient of the request
359 BYTE type: 2; // Type of request
360 BYTE direction: 1; // Direction of data X-fer
361 };
362 }requestInfo;
363 };
364 struct __attribute__ ((packed))
365 {
366 unsigned :8;
367 unsigned :8;
368 BYTE bDscIndex; //For Configuration and String DSC Only
369 BYTE bDescriptorType; //Device,Configuration,String
370 WORD wLangID; //Language ID
371 unsigned :8;
372 unsigned :8;
373 };
374 struct __attribute__ ((packed))
375 {
376 unsigned :8;
377 unsigned :8;
378 BYTE_VAL bDevADR; //Device Address 0-127
379 BYTE bDevADRH; //Must equal zero
380 unsigned :8;
381 unsigned :8;
382 unsigned :8;
383 unsigned :8;
384 };
385 struct __attribute__ ((packed))
386 {
387 unsigned :8;
388 unsigned :8;
389 BYTE bConfigurationValue; //Configuration Value 0-255
390 BYTE bCfgRSD; //Must equal zero (Reserved)
391 unsigned :8;
392 unsigned :8;
393 unsigned :8;
394 unsigned :8;
395 };
396 struct __attribute__ ((packed))
397 {
398 unsigned :8;
399 unsigned :8;
400 BYTE bAltID; //Alternate Setting Value 0-255
401 BYTE bAltID_H; //Must equal zero
402 BYTE bIntfID; //Interface Number Value 0-255
403 BYTE bIntfID_H; //Must equal zero
404 unsigned :8;
405 unsigned :8;
406 };
407 struct __attribute__ ((packed))
408 {
409 unsigned :8;
410 unsigned :8;
411 unsigned :8;
412 unsigned :8;
413 BYTE bEPID; //Endpoint ID (Number & Direction)
414 BYTE bEPID_H; //Must equal zero
415 unsigned :8;
416 unsigned :8;
417 };
418 struct __attribute__ ((packed))
419 {
420 unsigned :8;
421 unsigned :8;
422 unsigned :8;
423 unsigned :8;
424 unsigned EPNum:4; //Endpoint Number 0-15
425 unsigned :3;
426 unsigned EPDir:1; //Endpoint Direction: 0-OUT, 1-IN
427 unsigned :8;
428 unsigned :8;
429 unsigned :8;
430 };
431  
432 /** End: Standard Device Requests ******************************/
433  
434 } CTRL_TRF_SETUP, SETUP_PKT, *PSETUP_PKT;
435  
436  
437 // ******************************************************************
438 // ******************************************************************
439 // Section: USB Specification Constants
440 // ******************************************************************
441 // ******************************************************************
442  
443 // Section: Valid PID Values
444 //DOM-IGNORE-BEGIN
445 #define PID_OUT 0x1 // PID for an OUT token
446 #define PID_ACK 0x2 // PID for an ACK handshake
447 #define PID_DATA0 0x3 // PID for DATA0 data
448 #define PID_PING 0x4 // Special PID PING
449 #define PID_SOF 0x5 // PID for a SOF token
450 #define PID_NYET 0x6 // PID for a NYET handshake
451 #define PID_DATA2 0x7 // PID for DATA2 data
452 #define PID_SPLIT 0x8 // Special PID SPLIT
453 #define PID_IN 0x9 // PID for a IN token
454 #define PID_NAK 0xA // PID for a NAK handshake
455 #define PID_DATA1 0xB // PID for DATA1 data
456 #define PID_PRE 0xC // Special PID PRE (Same as PID_ERR)
457 #define PID_ERR 0xC // Special PID ERR (Same as PID_PRE)
458 #define PID_SETUP 0xD // PID for a SETUP token
459 #define PID_STALL 0xE // PID for a STALL handshake
460 #define PID_MDATA 0xF // PID for MDATA data
461  
462 #define PID_MASK_DATA 0x03 // Data PID mask
463 #define PID_MASK_DATA_SHIFTED (PID_MASK_DATA << 2) // Data PID shift to proper position
464 //DOM-IGNORE-END
465  
466 // Section: USB Token Types
467 //DOM-IGNORE-BEGIN
468 #define USB_TOKEN_OUT 0x01 // U1TOK - OUT token
469 #define USB_TOKEN_IN 0x09 // U1TOK - IN token
470 #define USB_TOKEN_SETUP 0x0D // U1TOK - SETUP token
471 //DOM-IGNORE-END
472  
473 // Section: OTG Descriptor Constants
474  
475 #define OTG_HNP_SUPPORT 0x02 // OTG Descriptor bmAttributes - HNP support flag
476 #define OTG_SRP_SUPPORT 0x01 // OTG Descriptor bmAttributes - SRP support flag
477  
478 // Section: Endpoint Directions
479  
480 #define USB_IN_EP 0x80 // IN endpoint mask
481 #define USB_OUT_EP 0x00 // OUT endpoint mask
482  
483 // Section: Standard Device Requests
484  
485 #define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS
486 #define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE
487 #define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE
488 #define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS
489 #define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR
490 #define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR
491 #define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION
492 #define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION
493 #define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE
494 #define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE
495 #define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME
496  
497 #define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt
498 #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up
499 #define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode
500  
501 // Section: Setup Data Constants
502  
503 #define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer
504 #define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer
505 #define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard
506 #define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class
507 #define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor
508 #define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device
509 #define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface
510 #define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint
511 #define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other
512  
513 #define USB_SETUP_HOST_TO_DEVICE_BITFIELD (USB_SETUP_HOST_TO_DEVICE>>7) // Device Request bmRequestType transfer direction - host to device transfer - bit definition
514 #define USB_SETUP_DEVICE_TO_HOST_BITFIELD (USB_SETUP_DEVICE_TO_HOST>>7) // Device Request bmRequestType transfer direction - device to host transfer - bit definition
515 #define USB_SETUP_TYPE_STANDARD_BITFIELD (USB_SETUP_TYPE_STANDARD>>5) // Device Request bmRequestType type - standard
516 #define USB_SETUP_TYPE_CLASS_BITFIELD (USB_SETUP_TYPE_CLASS>>5) // Device Request bmRequestType type - class
517 #define USB_SETUP_TYPE_VENDOR_BITFIELD (USB_SETUP_TYPE_VENDOR>>5) // Device Request bmRequestType type - vendor
518 #define USB_SETUP_RECIPIENT_DEVICE_BITFIELD (USB_SETUP_RECIPIENT_DEVICE) // Device Request bmRequestType recipient - device
519 #define USB_SETUP_RECIPIENT_INTERFACE_BITFIELD (USB_SETUP_RECIPIENT_INTERFACE) // Device Request bmRequestType recipient - interface
520 #define USB_SETUP_RECIPIENT_ENDPOINT_BITFIELD (USB_SETUP_RECIPIENT_ENDPOINT) // Device Request bmRequestType recipient - endpoint
521 #define USB_SETUP_RECIPIENT_OTHER_BITFIELD (USB_SETUP_RECIPIENT_OTHER) // Device Request bmRequestType recipient - other
522  
523 // Section: OTG SET FEATURE Constants
524  
525 #define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP
526 #define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP
527 #define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP
528  
529 // Section: USB Endpoint Transfer Types
530  
531 #define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint.
532 #define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint.
533 #define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint.
534 #define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint.
535  
536 // Section: Standard Feature Selectors for CLEAR_FEATURE Requests
537 #define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient
538 #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient
539 #define USB_FEATURE_TEST_MODE 2 // Device recipient
540  
541  
542 // Section: USB Class Code Definitions
543 #define USB_HUB_CLASSCODE 0x09 // Class code for a hub.
544  
545 /********************************************************************
546 USB Endpoint Definitions
547 USB Standard EP Address Format: DIR:X:X:X:EP3:EP2:EP1:EP0
548 This is used in the descriptors.
549 ********************************************************************/
550 #define _EP_IN 0x80
551 #define _EP_OUT 0x00
552 #define _EP01_OUT 0x01
553 #define _EP01_IN 0x81
554 #define _EP02_OUT 0x02
555 #define _EP02_IN 0x82
556 #define _EP03_OUT 0x03
557 #define _EP03_IN 0x83
558 #define _EP04_OUT 0x04
559 #define _EP04_IN 0x84
560 #define _EP05_OUT 0x05
561 #define _EP05_IN 0x85
562 #define _EP06_OUT 0x06
563 #define _EP06_IN 0x86
564 #define _EP07_OUT 0x07
565 #define _EP07_IN 0x87
566 #define _EP08_OUT 0x08
567 #define _EP08_IN 0x88
568 #define _EP09_OUT 0x09
569 #define _EP09_IN 0x89
570 #define _EP10_OUT 0x0A
571 #define _EP10_IN 0x8A
572 #define _EP11_OUT 0x0B
573 #define _EP11_IN 0x8B
574 #define _EP12_OUT 0x0C
575 #define _EP12_IN 0x8C
576 #define _EP13_OUT 0x0D
577 #define _EP13_IN 0x8D
578 #define _EP14_OUT 0x0E
579 #define _EP14_IN 0x8E
580 #define _EP15_OUT 0x0F
581 #define _EP15_IN 0x8F
582  
583 /* Configuration Attributes */
584 #define _DEFAULT (0x01<<7) //Default Value (Bit 7 is set)
585 #define _SELF (0x01<<6) //Self-powered (Supports if set)
586 #define _RWU (0x01<<5) //Remote Wakeup (Supports if set)
587 #define _HNP (0x01 << 1) //HNP (Supports if set)
588 #define _SRP (0x01) //SRP (Supports if set)
589  
590 /* Endpoint Transfer Type */
591 #define _CTRL 0x00 //Control Transfer
592 #define _ISO 0x01 //Isochronous Transfer
593 #define _BULK 0x02 //Bulk Transfer
594  
595 #define _INTERRUPT 0x03 //Interrupt Transfer
596 #if defined(__18CXX) || defined(__C30__)
597 #define _INT 0x03 //Interrupt Transfer
598 #endif
599  
600 /* Isochronous Endpoint Synchronization Type */
601 #define _NS (0x00<<2) //No Synchronization
602 #define _AS (0x01<<2) //Asynchronous
603 #define _AD (0x02<<2) //Adaptive
604 #define _SY (0x03<<2) //Synchronous
605  
606 /* Isochronous Endpoint Usage Type */
607 #define _DE (0x00<<4) //Data endpoint
608 #define _FE (0x01<<4) //Feedback endpoint
609 #define _IE (0x02<<4) //Implicit feedback Data endpoint
610  
611 //These are the directional indicators used for the USBTransferOnePacket()
612 // function.
613 #define OUT_FROM_HOST 0
614 #define IN_TO_HOST 1
615  
616 #endif // _USB_CH9_H_
617 /*************************************************************************
618 * EOF
619 */
620  
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3