usb_desc.h
上传用户:sourcesun
上传日期:2013-09-23
资源大小:362k
文件大小:4k
源码类别:

DNA

开发平台:

Asm

  1. /*************************************************************************
  2.  *
  3.  *    Used with ICCARM and AARM.
  4.  *
  5.  *    (c) Copyright IAR Systems 2005
  6.  *
  7.  *    File name   : usb_des.h
  8.  *    Description : Define standart usb descriptors module
  9.  *
  10.  *    History :
  11.  *    1. Data        : August 10, 2005
  12.  *       Author      : Stanimir Bonev
  13.  *       Description : Create
  14.  *
  15.  *    $Revision: 1.2.2.1 $
  16. **************************************************************************/
  17. #include <includes.h>
  18. #ifndef __USB_DESC_H
  19. #define __USB_DESC_H
  20. #define UsbConfigPower_mA(mA)   ((mA)/2)
  21. #define UsbEpOut(addr)          ((addr) | 0x00)
  22. #define UsbEpIn(addr)           ((addr) | 0x80)
  23. #define UsbDescLengthOffset     0
  24. #define UsbDescDescriptorOffset 1
  25. typedef enum
  26. {
  27.   UsbDescriptorDevice = 1, UsbDescriptorConfiguration, UsbDescriptorString,
  28.   UsbDescriptorInterface, UsbDescriptorEp, UsbDescriptorDeviceQualifier,
  29.   UsbDescriptorOtherSeedConfiguration, UsbDescriptorInterfacePower
  30. } UsbDescriptorType_t;
  31. typedef enum
  32. {
  33.   iLanguagesStr = 0, iManufacturerStr, iProductStr, iSerialNumberStr,
  34.   iConfigurationStr,
  35.   iInterface,
  36. } UsbStringsIndex_t;
  37. typedef enum
  38. {
  39. /* USB Device Classes */
  40.   UsbDeviceClassReserved = 0, UsbDeviceClassAudio,
  41.   UsbDeviceClassCommunications,UsbDeviceClassHumanInterface,
  42.   UsbDeviceClassMonitor,UsbDeviceClassPhysicalInterface,
  43.   UsbDeviceClassPower,UsbDeviceClassPrinter,
  44.   UsbDeviceClassStorage,UsbDeviceClassHub,
  45.   UsbDeviceClassVendorSpecific = 0xFF
  46. } UsbDeviceClassses_t;
  47. typedef union
  48. {
  49.   Int8U Data;
  50.   struct
  51.   {
  52.     Int8U Reserved      : 5;
  53.     Int8U RemoteWakeup  : 1;
  54.     Int8U SelfPowered   : 1;
  55.     Int8U MustBeOne     : 1;
  56.   };
  57. } CnfgArtr_t;
  58. #define USBPowerMask          0x40
  59. #define USBRemoteWakeUpMask   0x20
  60. typedef enum
  61. {
  62.   UsbRemoteWakeup = 0x20, UsbSelfPowered = 0x40,  UsbConfigurationCommmonAttr = 0x80
  63. } _UsbConfigurationAttr_t;
  64. typedef enum
  65. {
  66.   UsbEpTransferControl = 0, UsbEpTransferIsochronous,
  67.   UsbEpTransferBulk,UsbEpTransferInterrupt
  68. }UsbEpTransferType_t;
  69. typedef enum
  70. {
  71.   UsbEpSynchNoSynchronization = 0, UsbEpSynchAsynchronous = 1<<2,
  72.   UsbEpSynchAdaptive = 2<<2, UsbEpSynchSynchronous = 3<<2
  73. }UsbEpSynchronizationType_t;
  74. typedef enum
  75. {
  76.   UsbEpUsageData = 0, UsbEpUsageFeedback = 1<<4,
  77.   UsbEpUsageImplicit = 2<<4, UsbEpUsageReserved = 3<<4
  78. }UsbEpUsageType_t;
  79. typedef union
  80. {
  81.   Int8U Data;
  82.   struct
  83.   {
  84.     Int8U TransferType        : 2;
  85.     Int8U SynchronizationType : 2;
  86.     Int8U UsageType           : 2;
  87.   };
  88. } EpAttr_t;
  89. #pragma pack(1)
  90. typedef struct
  91. {
  92.   Int8U       bLength;
  93.   Int8U       bDescriptorType;
  94.   Int16U      bcdUSB;
  95.   Int8U       bDeviceClass;
  96.   Int8U       bDeviceSubClass;
  97.   Int8U       bDeviceProtocol;
  98.   Int8U       bMaxPacketSize0;
  99.   Int16U      idVendor;
  100.   Int16U      idProduct;
  101.   Int16U      bcdDevice;
  102.   Int8U       iManufacturer;
  103.   Int8U       iProduct;
  104.   Int8U       iSerialNumber;
  105.   Int8U       bNumConfigurations;
  106. } UsbStandardDeviceDescriptorStr_t;
  107. typedef struct
  108. {
  109.   Int8U       bLength;
  110.   Int8U       bDescriptorType;
  111.   Int16U      wTotalLength;
  112.   Int8U       bNumInterfaces;
  113.   Int8U       bConfigurationValue;
  114.   Int8U       iConfiguration;
  115.   CnfgArtr_t  bmAttributes;
  116.   Int8U       bMaxPower;
  117. } UsbStandardConfigurationDescriptor_t;
  118. typedef struct
  119. {
  120.   Int8U       bLength;
  121.   Int8U       bDescriptorType;
  122.   Int8U       bInterfaceNumber;
  123.   Int8U       bAlternateSetting;
  124.   Int8U       bNumEndpoints;
  125.   Int8U       bInterfaceClass;
  126.   Int8U       bInterfaceSubClass;
  127.   Int8U       bInterfaceProtocol;
  128.   Int8U       iInterface;
  129. } UsbStandardInterfaceDescriptor_t;
  130. typedef struct
  131. {
  132.   Int8U       bLength;
  133.   Int8U       bDescriptorType;
  134.   Int8U       bEndpointAddress;
  135.   EpAttr_t    bmAttributes;
  136.   Int16U      wMaxPacketSize;
  137.   Int8U       bInterval;
  138. } UsbStandardEpDescriptor_t;
  139. #pragma pack()
  140. extern const UsbStandardDeviceDescriptorStr_t UsbStandardDeviceDescriptorStr;
  141. extern const Int8U UsbStandardConfigurationDescriptor[];
  142. extern const Int8U UsbLanguagesStr [];
  143. extern const Int8U * const * const UsbString[];
  144. #endif //__USB_DESC_H