usb_desc.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
  2. * File Name : usb_desc.c
  3. * Author : MCD Application Team
  4. * Version : V3.0.1
  5. * Date : 04/27/2009
  6. * Description : Descriptors for Mass Storage Device
  7. ********************************************************************************
  8. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  9. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  10. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  11. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  12. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  13. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  14. *******************************************************************************/
  15. /* Includes ------------------------------------------------------------------*/
  16. #include "usb_desc.h"
  17. const uint8_t MASS_DeviceDescriptor[MASS_SIZ_DEVICE_DESC] =
  18. {
  19. 0x12, /* bLength */
  20. 0x01, /* bDescriptorType */
  21. 0x00, /* bcdUSB, version 2.00 */
  22. 0x02,
  23. 0x00, /* bDeviceClass : each interface define the device class */
  24. 0x00, /* bDeviceSubClass */
  25. 0x00, /* bDeviceProtocol */
  26. 0x40, /* bMaxPacketSize0 0x40 = 64 */
  27. 0x83, /* idVendor (0483) */
  28. 0x04,
  29. 0x20, /* idProduct */
  30. 0x57,
  31. 0x00, /* bcdDevice 2.00*/
  32. 0x02,
  33. 1, /* index of string Manufacturer */
  34. /**/
  35. 2, /* index of string descriptor of product*/
  36. /* */
  37. 3, /* */
  38. /* */
  39. /* */
  40. 0x01 /*bNumConfigurations */
  41. };
  42. const uint8_t MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] =
  43. {
  44. 0x09, /* bLength: Configuation Descriptor size */
  45. 0x02, /* bDescriptorType: Configuration */
  46. MASS_SIZ_CONFIG_DESC,
  47. 0x00,
  48. 0x01, /* bNumInterfaces: 1 interface */
  49. 0x01, /* bConfigurationValue: */
  50. /* Configuration value */
  51. 0x00, /* iConfiguration: */
  52. /* Index of string descriptor */
  53. /* describing the configuration */
  54. 0xC0, /* bmAttributes: */
  55. /* bus powered */
  56. 100, /* MaxPower 100 mA */
  57. /*****************接口描述符*******************/
  58. //bLength字段。接口描述符的长度为9字节。
  59. 0x09,
  60. //bDescriptorType字段。接口描述符的编号为0x04。
  61. 0x04,
  62. //bInterfaceNumber字段。该接口的编号,第一个接口,编号为0。
  63. 0x00,
  64. //bAlternateSetting字段。该接口的备用编号,为0。
  65. 0x00,
  66. //bNumEndpoints字段。非0端点的数目。该接口有2个批量端点
  67. 0x02,
  68. //bInterfaceClass字段。该接口所使用的类。大容量存储设备接口类的代码为0x08。
  69. 0x08,
  70. //bInterfaceSubClass字段。该接口所使用的子类。SCSI透明命令集的子类代码为0x06。
  71. 0x06,
  72. //bInterfaceProtocol字段。协议为仅批量传输,代码为0x50。
  73. 0x50,
  74. //iConfiguration字段。该接口的字符串索引值。
  75. 4, /* iInterface: */
  76. /*************标准批量数据输入端点描述符****************/
  77. /* 18 */
  78. 0x07, /*Endpoint descriptor length = 7*/
  79. 0x05, /*Endpoint descriptor type *///bDescriptorType字段。端点描述符编号为0x05。
  80. //bEndpointAddress字段。端点的地址。我们使用D12的输入端点2。
  81. //D7位表示数据方向,输入端点D7为1。所以输入端点2的地址为0x82。
  82. 0x81, /*Endpoint address (IN, address 1) */
  83. //bmAttributes字段。D1~D0为端点传输类型选择。
  84. //该端点为批端点。批量端点的编号为2。其它位保留为0。
  85. 0x02, /*Bulk endpoint type */
  86. 0x40, /*Maximum packet size (64 bytes) */
  87. 0x00,
  88. 0x00, /*Polling interval in milliseconds */
  89. /*************标准批量数据输出端点描述符****************/
  90. /* 25 */
  91. 0x07, /*Endpoint descriptor length = 7 */
  92. 0x05, /*Endpoint descriptor type */
  93. 0x02, /*Endpoint address (OUT, address 2) */
  94. 0x02, /*Bulk endpoint type */
  95. 0x40, /*Maximum packet size (64 bytes) */
  96. 0x00,
  97. 0x00 /*Polling interval in milliseconds*/
  98. /*32*/
  99. };
  100. const uint8_t MASS_StringLangID[MASS_SIZ_STRING_LANGID] =
  101. {
  102. MASS_SIZ_STRING_LANGID,
  103. 0x03,
  104. 0x09,
  105. 0x04
  106. }
  107. ; /* LangID = 0x0409: U.S. English */
  108. const uint8_t MASS_StringVendor[MASS_SIZ_STRING_VENDOR] =
  109. {
  110. MASS_SIZ_STRING_VENDOR, /* Size of manufaturer string */
  111. 0x03, /* bDescriptorType = String descriptor */
  112. /* Manufacturer: "STMicroelectronics" */
  113. 'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,
  114. 'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,
  115. 'c', 0, 's', 0
  116. };
  117. const uint8_t MASS_StringProduct[MASS_SIZ_STRING_PRODUCT] =
  118. {
  119. MASS_SIZ_STRING_PRODUCT,
  120. 0x03,
  121. /* Product name: "STM32F10x:USB Mass Storage" */
  122. 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'M', 0, 'a', 0, 's', 0,
  123. 's', 0, ' ', 0, 'S', 0, 't', 0, 'o', 0, 'r', 0, 'a', 0, 'g', 0, 'e', 0
  124. };
  125. uint8_t MASS_StringSerial[MASS_SIZ_STRING_SERIAL] =
  126. {
  127. MASS_SIZ_STRING_SERIAL,
  128. 0x03,
  129. /* STM3210 */
  130. 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, '1', 0, '0', 0
  131. };
  132. const uint8_t MASS_StringInterface[MASS_SIZ_STRING_INTERFACE] =
  133. {
  134. MASS_SIZ_STRING_INTERFACE,
  135. 0x03,
  136. /* Interface 0: "ST Mass" */
  137. 'S', 0, 'T', 0, ' ', 0, 'M', 0, 'a', 0, 's', 0, 's', 0
  138. };
  139. /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/