usb100.h
上传用户:gzccxsp
上传日期:2015-07-14
资源大小:182k
文件大小:7k
源码类别:

MacOS编程

开发平台:

Visual C++

  1. #ifndef   __USB100_H__
  2. #define   __USB100_H__
  3. #include <PSHPACK1.H>
  4. #define MAXIMUM_USB_STRING_LENGTH 255
  5. // values for the bits returned by the USB GET_STATUS command
  6. #define USB_GETSTATUS_SELF_POWERED                0x01
  7. #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED       0x02
  8. #define USB_DEVICE_DESCRIPTOR_TYPE                0x01
  9. #define USB_CONFIGURATION_DESCRIPTOR_TYPE         0x02
  10. #define USB_STRING_DESCRIPTOR_TYPE                0x03
  11. #define USB_INTERFACE_DESCRIPTOR_TYPE             0x04
  12. #define USB_ENDPOINT_DESCRIPTOR_TYPE              0x05
  13. // descriptor types defined by DWG documents
  14. #define USB_RESERVED_DESCRIPTOR_TYPE              0x06
  15. #define USB_CONFIG_POWER_DESCRIPTOR_TYPE          0x07
  16. #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE       0x08
  17. #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d<<8 | i))
  18. //
  19. // Values for bmAttributes field of an
  20. // endpoint descriptor
  21. //
  22. #define USB_ENDPOINT_TYPE_MASK                    0x03
  23. #define USB_ENDPOINT_TYPE_CONTROL                 0x00
  24. #define USB_ENDPOINT_TYPE_ISOCHRONOUS             0x01
  25. #define USB_ENDPOINT_TYPE_BULK                    0x02
  26. #define USB_ENDPOINT_TYPE_INTERRUPT               0x03
  27. //
  28. // definitions for bits in the bmAttributes field of a 
  29. // configuration descriptor.
  30. //
  31. #define USB_CONFIG_POWERED_MASK                   0xc0
  32. #define USB_CONFIG_BUS_POWERED                    0x80
  33. #define USB_CONFIG_SELF_POWERED                   0x40
  34. #define USB_CONFIG_REMOTE_WAKEUP                  0x20
  35. //
  36. // Endpoint direction bit, stored in address
  37. //
  38. #define USB_ENDPOINT_DIRECTION_MASK               0x80
  39. // test direction bit in the bEndpointAddress field of
  40. // an endpoint descriptor.
  41. #define USB_ENDPOINT_DIRECTION_OUT(addr)          (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
  42. #define USB_ENDPOINT_DIRECTION_IN(addr)           ((addr) & USB_ENDPOINT_DIRECTION_MASK)
  43. //
  44. // USB defined request codes
  45. // see chapter 9 of the USB 1.0 specifcation for
  46. // more information.
  47. //
  48. // These are the correct values based on the USB 1.0
  49. // specification
  50. #define USB_REQUEST_GET_STATUS                    0x00
  51. #define USB_REQUEST_CLEAR_FEATURE                 0x01
  52. #define USB_REQUEST_SET_FEATURE                   0x03
  53. #define USB_REQUEST_SET_ADDRESS                   0x05
  54. #define USB_REQUEST_GET_DESCRIPTOR                0x06
  55. #define USB_REQUEST_SET_DESCRIPTOR                0x07
  56. #define USB_REQUEST_GET_CONFIGURATION             0x08
  57. #define USB_REQUEST_SET_CONFIGURATION             0x09
  58. #define USB_REQUEST_GET_INTERFACE                 0x0A
  59. #define USB_REQUEST_SET_INTERFACE                 0x0B
  60. #define USB_REQUEST_SYNC_FRAME                    0x0C
  61. //
  62. // defined USB device classes
  63. //
  64. #define USB_DEVICE_CLASS_RESERVED           0x00
  65. #define USB_DEVICE_CLASS_AUDIO              0x01
  66. #define USB_DEVICE_CLASS_COMMUNICATIONS     0x02
  67. #define USB_DEVICE_CLASS_HUMAN_INTERFACE    0x03
  68. #define USB_DEVICE_CLASS_MONITOR            0x04
  69. #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
  70. #define USB_DEVICE_CLASS_POWER              0x06
  71. #define USB_DEVICE_CLASS_PRINTER            0x07
  72. #define USB_DEVICE_CLASS_STORAGE            0x08
  73. #define USB_DEVICE_CLASS_HUB                0x09
  74. #define USB_DEVICE_CLASS_VENDOR_SPECIFIC    0xFF
  75. //
  76. // USB Core defined Feature selectors
  77. //
  78. #define USB_FEATURE_ENDPOINT_STALL          0x0000
  79. #define USB_FEATURE_REMOTE_WAKEUP           0x0001
  80. //
  81. // USB DWG defined Feature selectors
  82. //
  83. #define USB_FEATURE_INTERFACE_POWER_D0      0x0002
  84. #define USB_FEATURE_INTERFACE_POWER_D1      0x0003
  85. #define USB_FEATURE_INTERFACE_POWER_D2      0x0004
  86. #define USB_FEATURE_INTERFACE_POWER_D3      0x0005
  87. typedef struct _USB_DEVICE_DESCRIPTOR {
  88.     UCHAR bLength;
  89.     UCHAR bDescriptorType;
  90.     USHORT bcdUSB;
  91.     UCHAR bDeviceClass;
  92.     UCHAR bDeviceSubClass;
  93.     UCHAR bDeviceProtocol;
  94.     UCHAR bMaxPacketSize0;
  95.     USHORT idVendor;
  96.     USHORT idProduct;
  97.     USHORT bcdDevice;
  98.     UCHAR iManufacturer;
  99.     UCHAR iProduct;
  100.     UCHAR iSerialNumber;
  101.     UCHAR bNumConfigurations;
  102. } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
  103. typedef struct _USB_ENDPOINT_DESCRIPTOR {
  104.     UCHAR bLength;
  105.     UCHAR bDescriptorType;
  106.     UCHAR bEndpointAddress;
  107.     UCHAR bmAttributes;
  108.     USHORT wMaxPacketSize;
  109.     UCHAR bInterval;
  110. } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
  111. typedef struct _USB_CONFIGURATION_DESCRIPTOR {
  112.     UCHAR bLength;
  113.     UCHAR bDescriptorType;
  114.     USHORT wTotalLength;
  115.     UCHAR bNumInterfaces;
  116.     UCHAR bConfigurationValue;
  117.     UCHAR iConfiguration;
  118.     UCHAR bmAttributes;
  119.     UCHAR MaxPower;
  120. } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
  121. typedef struct _USB_INTERFACE_DESCRIPTOR {
  122.     UCHAR bLength;
  123.     UCHAR bDescriptorType;
  124.     UCHAR bInterfaceNumber;
  125.     UCHAR bAlternateSetting;
  126.     UCHAR bNumEndpoints;
  127.     UCHAR bInterfaceClass;
  128.     UCHAR bInterfaceSubClass;
  129.     UCHAR bInterfaceProtocol;
  130.     UCHAR iInterface;
  131. } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
  132. typedef struct _USB_STRING_DESCRIPTOR {
  133.     UCHAR bLength;
  134.     UCHAR bDescriptorType;
  135.     WCHAR bString[1];
  136. } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
  137. typedef struct _USB_COMMON_DESCRIPTOR {
  138.     UCHAR bLength;
  139.     UCHAR bDescriptorType;
  140. } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
  141. //
  142. // Standard USB HUB definitions 
  143. //
  144. // See Chapter 11 USB core specification
  145. //
  146. typedef struct _USB_HUB_DESCRIPTOR {
  147.     UCHAR        bDescriptorLength;      // Length of this descriptor
  148.     UCHAR        bDescriptorType;        // Hub configuration type
  149.     UCHAR        bNumberOfPorts;         // number of ports on this hub
  150.     USHORT       wHubCharacteristics;    // Hub Charateristics
  151.     UCHAR        bPowerOnToPowerGood;    // port power on till power good in 2ms
  152.     UCHAR        bHubControlCurrent;     // max current in mA
  153.     //
  154.     // room for 255 ports power control and removable bitmask
  155.     UCHAR        bRemoveAndPowerMask[64];       
  156. } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
  157. //
  158. // Structures defined by various DWG feature documents
  159. //
  160. //
  161. // See DWG USB Feature Specification: Interface Power Management
  162. //
  163. #define USB_SUPPORT_D0_COMMAND      0x01
  164. #define USB_SUPPORT_D1_COMMAND      0x02
  165. #define USB_SUPPORT_D2_COMMAND      0x04
  166. #define USB_SUPPORT_D3_COMMAND      0x08
  167. #define USB_SUPPORT_D1_WAKEUP       0x10
  168. #define USB_SUPPORT_D2_WAKEUP       0x20
  169. typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR {
  170.     UCHAR bLength;
  171.     UCHAR bDescriptorType;
  172.     UCHAR SelfPowerConsumedD0[3];
  173.     UCHAR bPowerSummaryId;
  174.     UCHAR bBusPowerSavingD1;
  175.     UCHAR bSelfPowerSavingD1;
  176.     UCHAR bBusPowerSavingD2;
  177.     UCHAR bSelfPowerSavingD2; 
  178.     UCHAR bBusPowerSavingD3;
  179.     UCHAR bSelfPowerSavingD3; 
  180.     USHORT TransitionTimeFromD1;
  181.     USHORT TransitionTimeFromD2;
  182.     USHORT TransitionTimeFromD3;
  183. } USB_CONFIGURATION_POWER_DESCRIPTOR, *PUSB_CONFIGURATION_POWER_DESCRIPTOR;
  184. typedef struct _USB_INTERFACE_POWER_DESCRIPTOR {
  185.     UCHAR bLength;
  186.     UCHAR bDescriptorType;
  187.     UCHAR bmCapabilitiesFlags;
  188.     UCHAR bBusPowerSavingD1;
  189.     UCHAR bSelfPowerSavingD1;
  190.     UCHAR bBusPowerSavingD2;
  191.     UCHAR bSelfPowerSavingD2; 
  192.     UCHAR bBusPowerSavingD3;
  193.     UCHAR bSelfPowerSavingD3; 
  194.     USHORT TransitionTimeFromD1;
  195.     USHORT TransitionTimeFromD2;
  196.     USHORT TransitionTimeFromD3;
  197. } USB_INTERFACE_POWER_DESCRIPTOR, *PUSB_INTERFACE_POWER_DESCRIPTOR;
  198. #include <POPPACK.H>
  199. #endif   /* __USB100_H__ */