My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usbdesc.cpp 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /*----------------------------------------------------------------------------
  2. * U S B - K e r n e l
  3. *----------------------------------------------------------------------------
  4. * Name: usbdesc.c
  5. * Purpose: USB Descriptors
  6. * Version: V1.20
  7. *----------------------------------------------------------------------------
  8. * This software is supplied "AS IS" without any warranties, express,
  9. * implied or statutory, including but not limited to the implied
  10. * warranties of fitness for purpose, satisfactory quality and
  11. * noninfringement. Keil extends you a royalty-free right to reproduce
  12. * and distribute executable files created using this software for use
  13. * on NXP Semiconductors LPC microcontroller devices only. Nothing else
  14. * gives you the right to use this software.
  15. *
  16. * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
  17. *----------------------------------------------------------------------------
  18. * History:
  19. * V1.20 Changed string descriptor handling
  20. * V1.00 Initial Version
  21. *---------------------------------------------------------------------------*/
  22. extern "C" {
  23. #include "lpc_types.h"
  24. }
  25. #include "usb.h"
  26. #include "cdc.h"
  27. #include "msc.h"
  28. #include "usbcfg.h"
  29. #include "usbdesc.h"
  30. /* USB Standard Device Descriptor */
  31. const uint8_t USB_DeviceDescriptor[] = {
  32. USB_DEVICE_DESC_SIZE, /* bLength */
  33. USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
  34. WBVAL(0x0200), /* 2.0 */ /* bcdUSB */
  35. USB_DEVICE_CLASS_MISCELLANEOUS, /* bDeviceClass Composite*/
  36. 0x02, /* bDeviceSubClass */
  37. 0x01, /* bDeviceProtocol */
  38. USB_MAX_PACKET0, /* bMaxPacketSize0 */
  39. WBVAL(0x1d50), /* idVendor */
  40. WBVAL(0x6029), /* idProduct */
  41. WBVAL(0x0100), /* 1.00 */ /* bcdDevice */
  42. 0x01, /* iManufacturer */
  43. 0x02, /* iProduct */
  44. 0x03, /* iSerialNumber */
  45. 0x01 /* bNumConfigurations: one possible configuration*/
  46. };
  47. /* USB Configuration Descriptor */
  48. /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
  49. const uint8_t USB_ConfigDescriptor[] = {
  50. /* Configuration 1 */
  51. USB_CONFIGUARTION_DESC_SIZE, /* bLength */
  52. USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
  53. WBVAL( /* wTotalLength */
  54. 1*USB_CONFIGUARTION_DESC_SIZE +
  55. // Interface Association Descriptor
  56. 8 +
  57. //CDC Control Interface
  58. 1*USB_INTERFACE_DESC_SIZE + /* communication interface */
  59. 0x0013 + /* CDC functions */
  60. 1*USB_ENDPOINT_DESC_SIZE + /* interrupt endpoint */
  61. //CDC Data Interface
  62. 1*USB_INTERFACE_DESC_SIZE + /* data interface */
  63. 2*USB_ENDPOINT_DESC_SIZE + /* bulk endpoints */
  64. //MSC Interface
  65. 1*USB_INTERFACE_DESC_SIZE +
  66. 2*USB_ENDPOINT_DESC_SIZE
  67. ),
  68. 0x03, /* bNumInterfaces */
  69. 0x01, /* bConfigurationValue: 0x01 is used to select this configuration */
  70. 0x00, /* iConfiguration: no string to describe this configuration */
  71. USB_CONFIG_BUS_POWERED, /* bmAttributes */
  72. USB_CONFIG_POWER_MA(500), /* bMaxPower, device power consumption is 500 mA */
  73. /* Interface Association Descriptor */
  74. 0x08,
  75. 0x0B, //DescriptorType : Interface Association
  76. 0x00, //FirstInterface
  77. 0x02, //InterfaceCount
  78. 0x02, //FunctionClass
  79. 0x02, //FunctionSubClass
  80. 0x01, //FunctionProtocol
  81. 0x00, //Function
  82. /* Interface 0, Alternate Setting 0, Communication class interface descriptor */
  83. USB_INTERFACE_DESC_SIZE, /* bLength */
  84. USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
  85. USB_CDC_CIF_NUM, /* bInterfaceNumber: Number of Interface */
  86. 0x00, /* bAlternateSetting: Alternate setting */
  87. 0x01, /* bNumEndpoints: One endpoint used */
  88. CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */
  89. CDC_ABSTRACT_CONTROL_MODEL, /* bInterfaceSubClass: Abstract Control Model */
  90. 0x00, /* bInterfaceProtocol: no protocol used */
  91. 0x00, /* iInterface: */
  92. /*Header Functional Descriptor*/
  93. 0x05, /* bLength: Endpoint Descriptor size */
  94. CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
  95. CDC_HEADER, /* bDescriptorSubtype: Header Func Desc */
  96. WBVAL(CDC_V1_10), /* 1.10 */ /* bcdCDC */
  97. /*Call Management Functional Descriptor*/
  98. 0x05, /* bFunctionLength */
  99. CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
  100. CDC_CALL_MANAGEMENT, /* bDescriptorSubtype: Call Management Func Desc */
  101. CDC_CALLMGMT_CAP_CALLMGMT | CDC_CALLMGMT_CAP_DATAINTF, /* bmCapabilities: device handles call management */
  102. 0x01, /* bDataInterface: CDC data IF ID */
  103. /*Abstract Control Management Functional Descriptor*/
  104. 0x04, /* bFunctionLength */
  105. CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
  106. CDC_ABSTRACT_CONTROL_MANAGEMENT, /* bDescriptorSubtype: Abstract Control Management desc */
  107. CDC_ACM_CAP_LINE | CDC_ACM_CAP_BRK,/* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */
  108. /*Union Functional Descriptor*/
  109. 0x05, /* bFunctionLength */
  110. CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
  111. CDC_UNION, /* bDescriptorSubtype: Union func desc */
  112. USB_CDC_CIF_NUM, /* bMasterInterface: Communication class interface is master */
  113. USB_CDC_DIF_NUM, /* bSlaveInterface0: Data class interface is slave 0 */
  114. /*Endpoint 1 Descriptor*/ /* event notification (optional) */
  115. USB_ENDPOINT_DESC_SIZE, /* bLength */
  116. USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
  117. USB_ENDPOINT_IN(1), /* bEndpointAddress */
  118. USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */
  119. WBVAL(0x0010), /* wMaxPacketSize */
  120. 0x10, /* bInterval */
  121. /* Interface 1, Alternate Setting 0, Data class interface descriptor*/
  122. USB_INTERFACE_DESC_SIZE, /* bLength */
  123. USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
  124. USB_CDC_DIF_NUM, /* bInterfaceNumber: Number of Interface */
  125. 0x00, /* bAlternateSetting: no alternate setting */
  126. 0x02, /* bNumEndpoints: two endpoints used */
  127. CDC_DATA_INTERFACE_CLASS, /* bInterfaceClass: Data Interface Class */
  128. 0x00, /* bInterfaceSubClass: no subclass available */
  129. 0x00, /* bInterfaceProtocol: no protocol used */
  130. 0x00, /* iInterface: */
  131. /* Endpoint, EP2 Bulk Out */
  132. USB_ENDPOINT_DESC_SIZE, /* bLength */
  133. USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
  134. USB_ENDPOINT_OUT(2), /* bEndpointAddress */
  135. USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
  136. WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */
  137. 0x00, /* bInterval: ignore for Bulk transfer */
  138. /* Endpoint, EP2 Bulk In */
  139. USB_ENDPOINT_DESC_SIZE, /* bLength */
  140. USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
  141. USB_ENDPOINT_IN(2), /* bEndpointAddress */
  142. USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
  143. WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */
  144. 0x00, /* bInterval: ignore for Bulk transfer */
  145. /* MSC Interface */
  146. /* Interface 2, Alternate Setting 0, Data class interface descriptor*/
  147. USB_INTERFACE_DESC_SIZE, /* bLength */
  148. USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
  149. 0x02, /* bInterfaceNumber */
  150. 0x00, /* bAlternateSetting */
  151. 0x02, /* bNumEndpoints */
  152. USB_DEVICE_CLASS_STORAGE, /* bInterfaceClass */
  153. MSC_SUBCLASS_SCSI, /* bInterfaceSubClass */
  154. MSC_PROTOCOL_BULK_ONLY, /* bInterfaceProtocol */
  155. 0x00, /* iInterface */
  156. /* Bulk In Endpoint */
  157. USB_ENDPOINT_DESC_SIZE, /* bLength */
  158. USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
  159. USB_ENDPOINT_IN(5), /* bEndpointAddress */
  160. USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
  161. WBVAL(0x0040), /* wMaxPacketSize */
  162. 0x00, /* bInterval */
  163. /* Bulk Out Endpoint */
  164. USB_ENDPOINT_DESC_SIZE, /* bLength */
  165. USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
  166. USB_ENDPOINT_OUT(5), /* bEndpointAddress */
  167. USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
  168. WBVAL(0x0040), /* wMaxPacketSize */
  169. 0,
  170. /* Terminator */
  171. 0 /* bLength */
  172. };
  173. /* USB String Descriptor (optional) */
  174. const uint8_t USB_StringDescriptor[] = {
  175. /* Index 0x00: LANGID Codes */
  176. 0x04, /* bLength */
  177. USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
  178. WBVAL(0x0409), /* US English */ /* wLANGID */
  179. /* Index 0x01: Manufacturer */
  180. (13*2 + 2), /* bLength (13 Char + Type + length) */
  181. USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
  182. 'm',0,
  183. 'a',0,
  184. 'r',0,
  185. 'l',0,
  186. 'i',0,
  187. 'n',0,
  188. 'f',0,
  189. 'w',0,
  190. '.',0,
  191. 'o',0,
  192. 'r',0,
  193. 'g',0,
  194. ' ',0,
  195. /* Index 0x02: Product */
  196. (17*2 + 2), /* bLength ( 17 Char + Type + length) */
  197. USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
  198. 'M',0,
  199. 'a',0,
  200. 'r',0,
  201. 'l',0,
  202. 'i',0,
  203. 'n',0,
  204. ' ',0,
  205. 'U',0,
  206. 'S',0,
  207. 'B',0,
  208. ' ',0,
  209. 'D',0,
  210. 'e',0,
  211. 'v',0,
  212. 'i',0,
  213. 'c',0,
  214. 'e',0,
  215. /* Index 0x03: Serial Number */
  216. (12*2 + 2), /* bLength (12 Char + Type + length) */
  217. USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
  218. '1',0,
  219. '.',0,
  220. '0',0,
  221. '0',0,
  222. '0',0,
  223. '0',0,
  224. '0',0,
  225. '0',0,
  226. '0',0,
  227. '0',0,
  228. '0',0,
  229. '0',0,
  230. /* Index 0x04: Interface 0, Alternate Setting 0 */
  231. ( 4*2 + 2), /* bLength (4 Char + Type + length) */
  232. USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
  233. 'V',0,
  234. 'C',0,
  235. 'O',0,
  236. 'M',0,
  237. };