USB.H
上传用户:ids068
上传日期:2013-04-04
资源大小:639k
文件大小:4k
源码类别:

USB编程

开发平台:

C/C++

  1. //***********************************************************************
  2. //       *
  3. //                P H I L I P S   P R O P R I E T A R Y           *
  4. //                                                                      *
  5. //          COPYRIGHT (c)   1999 BY PHILIPS SINGAPORE (APIC).     *
  6. //                    --  ALL RIGHTS RESERVED  --                  *
  7. //                                                                      *
  8. //  File Name :       USB.h                                      *
  9. //  Author :       Albert Goh   *
  10. //  Created :       3 March 2000                                *
  11. //                                                                   *
  12. //***********************************************************************
  13. //***********************************************************************
  14. //                                                                      *
  15. //  Module History *
  16. //  ************** *
  17. // *
  18. //  Date    Version Author Changes *
  19. //  ==== ======= ====== ======= *
  20. //  030300   0.1  Albert Created     *
  21. //                                                                      *
  22. //                                                                      *
  23. //***********************************************************************
  24. //#define ENDPT_NUMBER 8
  25. //#define INTERFACE_NO 2
  26. #define ENDPT_NUMBER 4
  27. #define INTERFACE_NO 1
  28. #define SWAP(x)    ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
  29. #define CONFIG_LENGTH sizeof(CONFIGURATION_DESCRIPTOR) + 
  30. (INTERFACE_NO * sizeof(INTERFACE_DESCRIPTOR)) + 
  31. (ENDPT_NUMBER * sizeof(ENDPOINT_DESCRIPTOR))
  32. typedef struct DEVICE_DESCRIPTOR 
  33. {
  34.     UC bLength;
  35.     UC bDescriptorType;
  36.     UI bcdUSB;
  37.     UC bDeviceClass;
  38.     UC bDeviceSubClass;
  39.     UC bDeviceProtocol;
  40.     UC bMaxPacketSize0;
  41.     UI idVendor;
  42.     UI idProduct;
  43.     UI bcdDevice;
  44.     UC iManufacturer;
  45.     UC iProduct;
  46.     UC iSerialNumber;
  47.     UC bNumConfigurations;
  48. } DEVICE_DESCRIPTOR;
  49. typedef struct HS_DEVICE_QUALIFIER
  50. {
  51. UC bLength; //length of HS Device Descriptor
  52. UC bQualifier;  //HS Device Qualifier Type
  53. UI wVersion; // USB 2.0 version
  54. UC bDeviceClass; //Device class
  55. UC bDeviceSubClasss; //Device SubClass
  56. UC bProtocol; //Device Protocol Code
  57. UC MaxPktSize; //Maximum Packet SIze for other speed
  58. UC bOther_Config; //Number of Other speed configurations
  59. UC Reserved; //Reserved
  60. }HS_DEVICE_QUALIFIER;
  61. typedef struct CONFIGURATION_DESCRIPTOR 
  62. {
  63.     UC bLength;
  64.     UC bDescriptorType;
  65.     UI wTotalLength;
  66.     UC bNumInterfaces;
  67.     UC bConfigurationValue;
  68.     UC iConfiguration;
  69.     UC bmAttributes;
  70.     UC MaxPower;
  71. } CONFIGURATION_DESCRIPTOR;
  72. typedef struct OTHER_SPEED_CONFIG_DESCRIPTOR
  73. {
  74. UC bLength; //length of other speed configuration descriptor
  75. UC bDescriptorType; //Other speed configuration Type
  76. UI bTotalLength; //Total length
  77. UC No_Interface; //No of interface supported
  78. UC Configuration_Value; //Configuration Value
  79. UC String_Index_Descriptor; //Index of string descriptor
  80. UC Config_Characteristic; //Configurations Characteristic
  81. UC Max_Power; //Maximun Power
  82. }OTHER_SPEED_CONFIG_DESCRIPTOR;
  83. typedef struct INTERFACE_DESCRIPTOR 
  84. {
  85.     UC bLength;
  86.     UC bDescriptorType;
  87.     UC bInterfaceNumber;
  88.     UC bAlternateSetting;
  89.     UC bNumEndpoints;
  90.     UC bInterfaceClass;
  91.     UC bInterfaceSubClass;
  92.     UC bInterfaceProtocol;
  93.     UC iInterface;
  94. } INTERFACE_DESCRIPTOR;
  95. typedef struct ENDPOINT_DESCRIPTOR 
  96. {
  97.     UC bLength;
  98.     UC bDescriptorType;
  99.     UC bEndpointAddress;
  100.     UC bmAttributes;
  101.     UI wMaxPacketSize;
  102.     UC bInterval;
  103. } ENDPOINT_DESCRIPTOR;
  104. typedef struct STRING_ID 
  105. {
  106.     UC bLength;
  107.     UC bDescriptorType;
  108.     UC bString[2];
  109. } STRING_ID;
  110. typedef struct STRING_DESCRIPTOR 
  111. {
  112.     UC bLength;
  113.     UC bDescriptorType;
  114.     UC bString[30];
  115. } STRING_DESCRIPTOR;