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

USB编程

开发平台:

C/C++

  1. /****************************************Copyright (c)**************************************************
  2. **                               广州周立功单片机发展有限公司
  3. **                                     研    究    所
  4. **                                 http://www.zlgmcu.com
  5. **--------------当前版本修订------------------------------------------------------------------------------
  6. ** 修改人: 刘英斌
  7. ** 日 期:2003-03-13
  8. ** 描 述:ISP1581 V1.0
  9. **------------------------------------------------------------------------------------------------------
  10. ********************************************************************************************************/
  11. //#define ENDPT_NUMBER 8
  12. //#define INTERFACE_NO 2
  13. #define ENDPT_NUMBER 4
  14. #define INTERFACE_NO 1
  15. #define SWAP(x)    ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
  16. #define CONFIG_LENGTH sizeof(CONFIGURATION_DESCRIPTOR) + 
  17. (INTERFACE_NO * sizeof(INTERFACE_DESCRIPTOR)) + 
  18. (ENDPT_NUMBER * sizeof(ENDPOINT_DESCRIPTOR))
  19. typedef struct DEVICE_DESCRIPTOR 
  20. {
  21.     UC bLength;
  22.     UC bDescriptorType;
  23.     UI bcdUSB;
  24.     UC bDeviceClass;
  25.     UC bDeviceSubClass;
  26.     UC bDeviceProtocol;
  27.     UC bMaxPacketSize0;
  28.     UI idVendor;
  29.     UI idProduct;
  30.     UI bcdDevice;
  31.     UC iManufacturer;
  32.     UC iProduct;
  33.     UC iSerialNumber;
  34.     UC bNumConfigurations;
  35. } DEVICE_DESCRIPTOR;
  36. typedef struct HS_DEVICE_QUALIFIER
  37. {
  38. UC bLength; //length of HS Device Descriptor
  39. UC bQualifier;  //HS Device Qualifier Type
  40. UI wVersion; // USB 2.0 version
  41. UC bDeviceClass; //Device class
  42. UC bDeviceSubClasss; //Device SubClass
  43. UC bProtocol; //Device Protocol Code
  44. UC MaxPktSize; //Maximum Packet SIze for other speed
  45. UC bOther_Config; //Number of Other speed configurations
  46. UC Reserved; //Reserved
  47. }HS_DEVICE_QUALIFIER;
  48. typedef struct CONFIGURATION_DESCRIPTOR 
  49. {
  50.     UC bLength;
  51.     UC bDescriptorType;
  52.     UI wTotalLength;
  53.     UC bNumInterfaces;
  54.     UC bConfigurationValue;
  55.     UC iConfiguration;
  56.     UC bmAttributes;
  57.     UC MaxPower;
  58. } CONFIGURATION_DESCRIPTOR;
  59. typedef struct OTHER_SPEED_CONFIG_DESCRIPTOR
  60. {
  61. UC bLength; //length of other speed configuration descriptor
  62. UC bDescriptorType; //Other speed configuration Type
  63. UI bTotalLength; //Total length
  64. UC No_Interface; //No of interface supported
  65. UC Configuration_Value; //Configuration Value
  66. UC String_Index_Descriptor; //Index of string descriptor
  67. UC Config_Characteristic; //Configurations Characteristic
  68. UC Max_Power; //Maximun Power
  69. }OTHER_SPEED_CONFIG_DESCRIPTOR;
  70. typedef struct INTERFACE_DESCRIPTOR 
  71. {
  72.     UC bLength;
  73.     UC bDescriptorType;
  74.     UC bInterfaceNumber;
  75.     UC bAlternateSetting;
  76.     UC bNumEndpoints;
  77.     UC bInterfaceClass;
  78.     UC bInterfaceSubClass;
  79.     UC bInterfaceProtocol;
  80.     UC iInterface;
  81. } INTERFACE_DESCRIPTOR;
  82. typedef struct ENDPOINT_DESCRIPTOR 
  83. {
  84.     UC bLength;
  85.     UC bDescriptorType;
  86.     UC bEndpointAddress;
  87.     UC bmAttributes;
  88.     UI wMaxPacketSize;
  89.     UC bInterval;
  90. } ENDPOINT_DESCRIPTOR;
  91. typedef struct STRING_ID 
  92. {
  93.     UC bLength;
  94.     UC bDescriptorType;
  95.     UC bString[2];
  96. } STRING_ID;
  97. typedef struct STRING_DESCRIPTOR 
  98. {
  99.     UC bLength;
  100.     UC bDescriptorType;
  101.     UC bString[30];
  102. } STRING_DESCRIPTOR;