usb_defs.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /******************************************************************************
  2. * USB Definitions: Standard Descriptors
  3. *****************************************************************************/
  4. #ifndef USBDEFS_STD_DSC_H
  5. #define USBDEFS_STD_DSC_H
  6. /** D E F I N I T I O N S ****************************************************/
  7. /* Descriptor Types */
  8. #define DSC_DEV 0x01
  9. #define DSC_CFG 0x02
  10. #define DSC_STR 0x03
  11. #define DSC_INTF 0x04
  12. #define DSC_EP 0x05
  13. /******************************************************************************
  14. * USB Endpoint Definitions
  15. * USB Standard EP Address Format: DIR:X:X:X:EP3:EP2:EP1:EP0
  16. * This is used in the descriptors. See autofiles\usbdsc.c
  17. *
  18. * NOTE: Do not use these values for checking against USTAT.
  19. * To check against USTAT, use values defined in "system\usb\usbdrv\usbdrv.h"
  20. *****************************************************************************/
  21. #define _EP01_OUT 0x01
  22. #define _EP01_IN 0x81
  23. #define _EP02_OUT 0x02
  24. #define _EP02_IN 0x82
  25. #define _EP03_OUT 0x03
  26. #define _EP03_IN 0x83
  27. #define _EP04_OUT 0x04
  28. #define _EP04_IN 0x84
  29. #define _EP05_OUT 0x05
  30. #define _EP05_IN 0x85
  31. #define _EP06_OUT 0x06
  32. #define _EP06_IN 0x86
  33. #define _EP07_OUT 0x07
  34. #define _EP07_IN 0x87
  35. #define _EP08_OUT 0x08
  36. #define _EP08_IN 0x88
  37. #define _EP09_OUT 0x09
  38. #define _EP09_IN 0x89
  39. #define _EP10_OUT 0x0A
  40. #define _EP10_IN 0x8A
  41. #define _EP11_OUT 0x0B
  42. #define _EP11_IN 0x8B
  43. #define _EP12_OUT 0x0C
  44. #define _EP12_IN 0x8C
  45. #define _EP13_OUT 0x0D
  46. #define _EP13_IN 0x8D
  47. #define _EP14_OUT 0x0E
  48. #define _EP14_IN 0x8E
  49. #define _EP15_OUT 0x0F
  50. #define _EP15_IN 0x8F
  51. /* Configuration Attributes */
  52. #define _DEFAULT 0x01<<7 //Default Value (Bit 7 is set)
  53. #define _SELF 0x01<<6 //Self-powered (Supports if set)
  54. #define _RWU 0x01<<5 //Remote Wakeup (Supports if set)
  55. /* Endpoint Transfer Type */
  56. #define _CTRL 0x00 //Control Transfer
  57. #define _ISO 0x01 //Isochronous Transfer
  58. #define _BULK 0x02 //Bulk Transfer
  59. #define _INT 0x03 //Interrupt Transfer
  60. /* Isochronous Endpoint Synchronization Type */
  61. #define _NS 0x00<<2 //No Synchronization
  62. #define _AS 0x01<<2 //Asynchronous
  63. #define _AD 0x02<<2 //Adaptive
  64. #define _SY 0x03<<2 //Synchronous
  65. /* Isochronous Endpoint Usage Type */
  66. #define _DE 0x00<<4 //Data endpoint
  67. #define _FE 0x01<<4 //Feedback endpoint
  68. #define _IE 0x02<<4 //Implicit feedback Data endpoint
  69. /** S T R U C T U R E ********************************************************/
  70. /******************************************************************************
  71. * USB Device Descriptor Structure
  72. *****************************************************************************/
  73. typedef struct _USB_DEV_DSC
  74. {
  75. unsigned char bLength; unsigned char bDscType; unsigned short bcdUSB;
  76. unsigned char bDevCls; unsigned char bDevSubCls; unsigned char bDevProtocol;
  77. unsigned char bMaxPktSize0; unsigned short idVendor; unsigned short idProduct;
  78. unsigned short bcdDevice; unsigned char iMFR; unsigned char iProduct;
  79. unsigned char iSerialNum; unsigned char bNumCfg;
  80. } USB_DEV_DSC;
  81. /******************************************************************************
  82. * USB Configuration Descriptor Structure
  83. *****************************************************************************/
  84. typedef struct _USB_CFG_DSC
  85. {
  86. unsigned char bLength; unsigned char bDscType; unsigned short wTotalLength;
  87. unsigned char bNumIntf; unsigned char bCfgValue; unsigned char iCfg;
  88. unsigned char bmAttributes; unsigned char bMaxPower;
  89. } USB_CFG_DSC;
  90. /******************************************************************************
  91. * USB Interface Descriptor Structure
  92. *****************************************************************************/
  93. typedef struct _USB_INTF_DSC
  94. {
  95. unsigned char bLength; unsigned char bDscType; unsigned char bIntfNum;
  96. unsigned char bAltSetting; unsigned char bNumEPs; unsigned char bIntfCls;
  97. unsigned char bIntfSubCls; unsigned char bIntfProtocol; unsigned char iIntf;
  98. } USB_INTF_DSC;
  99. /******************************************************************************
  100. * USB Endpoint Descriptor Structure
  101. *****************************************************************************/
  102. typedef struct _USB_EP_DSC
  103. {
  104. unsigned char bLength; unsigned char bDscType; unsigned char bEPAdr;
  105. unsigned char bmAttributes; unsigned short wMaxPktSize; unsigned char bInterval;
  106. } USB_EP_DSC;
  107. //
  108. // Standard Request Codes USB 2.0 Spec Ref Table 9-4
  109. //
  110. #define GET_STATUS 0
  111. #define CLEAR_FEATURE 1
  112. #define SET_FEATURE 3
  113. #define SET_ADDRESS 5
  114. #define GET_DESCRIPTOR 6
  115. #define SET_DESCRIPTOR 7
  116. #define GET_CONFIGURATION 8
  117. #define SET_CONFIGURATION 9
  118. #define GET_INTERFACE 10
  119. #define SET_INTERFACE 11
  120. #define SYNCH_FRAME 12
  121. // Standard Feature Selectors
  122. #define DEVICE_REMOTE_WAKEUP 0x01
  123. #define ENDPOINT_HALT 0x00
  124. // Descriptor Types
  125. #define DEVICE_DESCRIPTOR 0x01
  126. #define CONFIGURATION_DESCRIPTOR 0x02
  127. #define STRING_DESCRIPTOR 0x03
  128. #define INTERFACE_DESCRIPTOR 0x04
  129. #define ENDPOINT_DESCRIPTOR 0x05
  130. #define QUALIFIER_DESCRIPTOR 0x06
  131. // Device states (Chap 9.1.1)
  132. #define DETACHED 0
  133. #define ATTACHED 1
  134. #define POWERED 2
  135. #define DEFAULT 3
  136. #define ADDRESS 4
  137. #define CONFIGURED 5
  138. #endif //USBDEFS_STD_DSC_H