config.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * config.c
  3. *
  4. * USB device and configuration descriptors.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. const uint8_t device_descriptor[] aligned(2) = {
  12. 18, /* Length */
  13. DESC_DEVICE, /* Descriptor Type */
  14. 0x00,0x02, /* USB 2.0 */
  15. 2, 0, 0, /* Class, Subclass, Protocol: CDC */
  16. 64, /* Max Packet Size */
  17. 0x09,0x12, /* VID = pid.codes Open Source projects */
  18. 0x69,0x4D, /* PID = Keir Fraser Greaseweazle */
  19. 0,1, /* Device Release 1.0 */
  20. 1,2,3, /* Manufacturer, Product, Serial */
  21. 1 /* Number of configurations */
  22. };
  23. const uint8_t device_qualifier[] aligned(2) = {
  24. 10, /* Length */
  25. DESC_DEVICE_QUALIFIER,
  26. 0x00,0x02, /* USB 2.0 */
  27. 2, 0, 0, /* Class, Subclass, Protocol: CDC */
  28. 64, /* Max Packet Size */
  29. 1 /* Number of configurations */
  30. };
  31. const uint8_t config_fs_descriptor[] aligned(2) = {
  32. 0x09, /* 0 bLength */
  33. DESC_CONFIGURATION, /* 1 bDescriptortype - Configuration*/
  34. 0x43, 0x00, /* 2 wTotalLength */
  35. 0x02, /* 4 bNumInterfaces */
  36. 0x01, /* 5 bConfigurationValue */
  37. 0x00, /* 6 iConfiguration - index of string */
  38. 0x80, /* 7 bmAttributes - Bus powered */
  39. 0xFA, /* 8 bMaxPower - 500mA */
  40. /* CDC Communication interface */
  41. 0x09, /* 0 bLength */
  42. DESC_INTERFACE, /* 1 bDescriptorType - Interface */
  43. 0x00, /* 2 bInterfaceNumber - Interface 0 */
  44. 0x00, /* 3 bAlternateSetting */
  45. 0x01, /* 4 bNumEndpoints */
  46. 2, 2, 1, /* CDC ACM, AT Command Protocol */
  47. 0x00, /* 8 iInterface - No string descriptor */
  48. /* Header Functional descriptor */
  49. 0x05, /* 0 bLength */
  50. DESC_CS_INTERFACE, /* 1 bDescriptortype, CS_INTERFACE */
  51. 0x00, /* 2 bDescriptorsubtype, HEADER */
  52. 0x10, 0x01, /* 3 bcdCDC */
  53. /* ACM Functional descriptor */
  54. 0x04, /* 0 bLength */
  55. DESC_CS_INTERFACE, /* 1 bDescriptortype, CS_INTERFACE */
  56. 0x02, /* 2 bDescriptorsubtype, ABSTRACT CONTROL MANAGEMENT */
  57. 0x02, /* 3 bmCapabilities: Supports subset of ACM commands */
  58. /* Union Functional descriptor */
  59. 0x05, /* 0 bLength */
  60. DESC_CS_INTERFACE,/* 1 bDescriptortype, CS_INTERFACE */
  61. 0x06, /* 2 bDescriptorsubtype, UNION */
  62. 0x00, /* 3 bControlInterface - Interface 0 */
  63. 0x01, /* 4 bSubordinateInterface0 - Interface 1 */
  64. /* Call Management Functional descriptor */
  65. 0x05, /* 0 bLength */
  66. DESC_CS_INTERFACE,/* 1 bDescriptortype, CS_INTERFACE */
  67. 0x01, /* 2 bDescriptorsubtype, CALL MANAGEMENT */
  68. 0x03, /* 3 bmCapabilities, DIY */
  69. 0x01, /* 4 bDataInterface */
  70. /* Notification Endpoint descriptor */
  71. 0x07, /* 0 bLength */
  72. DESC_ENDPOINT, /* 1 bDescriptorType */
  73. 0x81, /* 2 bEndpointAddress */
  74. 0x03, /* 3 bmAttributes */
  75. 0x40, /* 4 wMaxPacketSize - Low */
  76. 0x00, /* 5 wMaxPacketSize - High */
  77. 0xFF, /* 6 bInterval */
  78. /* CDC Data interface */
  79. 0x09, /* 0 bLength */
  80. DESC_INTERFACE, /* 1 bDescriptorType */
  81. 0x01, /* 2 bInterfaceNumber */
  82. 0x00, /* 3 bAlternateSetting */
  83. 0x02, /* 4 bNumEndpoints */
  84. USB_CLASS_CDC_DATA, /* 5 bInterfaceClass */
  85. 0x00, /* 6 bInterfaceSubClass */
  86. 0x00, /* 7 bInterfaceProtocol*/
  87. 0x00, /* 8 iInterface - No string descriptor*/
  88. /* Data OUT Endpoint descriptor */
  89. 0x07, /* 0 bLength */
  90. DESC_ENDPOINT, /* 1 bDescriptorType */
  91. 0x02, /* 2 bEndpointAddress */
  92. 0x02, /* 3 bmAttributes */
  93. 0x40, /* 4 wMaxPacketSize - Low */
  94. 0x00, /* 5 wMaxPacketSize - High */
  95. 0x00, /* 6 bInterval */
  96. /* Data IN Endpoint descriptor */
  97. 0x07, /* 0 bLength */
  98. DESC_ENDPOINT, /* 1 bDescriptorType */
  99. 0x83, /* 2 bEndpointAddress */
  100. 0x02, /* 3 bmAttributes */
  101. 0x40, /* 4 wMaxPacketSize - Low byte */
  102. 0x00, /* 5 wMaxPacketSize - High byte */
  103. 0x00 /* 6 bInterval */
  104. };
  105. const uint8_t config_hs_descriptor[] aligned(2) = {
  106. 0x09, /* 0 bLength */
  107. DESC_CONFIGURATION, /* 1 bDescriptortype - Configuration*/
  108. 0x43, 0x00, /* 2 wTotalLength */
  109. 0x02, /* 4 bNumInterfaces */
  110. 0x01, /* 5 bConfigurationValue */
  111. 0x00, /* 6 iConfiguration - index of string */
  112. 0x80, /* 7 bmAttributes - Bus powered */
  113. 0xFA, /* 8 bMaxPower - 500mA */
  114. /* CDC Communication interface */
  115. 0x09, /* 0 bLength */
  116. DESC_INTERFACE, /* 1 bDescriptorType - Interface */
  117. 0x00, /* 2 bInterfaceNumber - Interface 0 */
  118. 0x00, /* 3 bAlternateSetting */
  119. 0x01, /* 4 bNumEndpoints */
  120. 2, 2, 1, /* CDC ACM, AT Command Protocol */
  121. 0x00, /* 8 iInterface - No string descriptor */
  122. /* Header Functional descriptor */
  123. 0x05, /* 0 bLength */
  124. DESC_CS_INTERFACE, /* 1 bDescriptortype, CS_INTERFACE */
  125. 0x00, /* 2 bDescriptorsubtype, HEADER */
  126. 0x10, 0x01, /* 3 bcdCDC */
  127. /* ACM Functional descriptor */
  128. 0x04, /* 0 bLength */
  129. DESC_CS_INTERFACE, /* 1 bDescriptortype, CS_INTERFACE */
  130. 0x02, /* 2 bDescriptorsubtype, ABSTRACT CONTROL MANAGEMENT */
  131. 0x02, /* 3 bmCapabilities: Supports subset of ACM commands */
  132. /* Union Functional descriptor */
  133. 0x05, /* 0 bLength */
  134. DESC_CS_INTERFACE,/* 1 bDescriptortype, CS_INTERFACE */
  135. 0x06, /* 2 bDescriptorsubtype, UNION */
  136. 0x00, /* 3 bControlInterface - Interface 0 */
  137. 0x01, /* 4 bSubordinateInterface0 - Interface 1 */
  138. /* Call Management Functional descriptor */
  139. 0x05, /* 0 bLength */
  140. DESC_CS_INTERFACE,/* 1 bDescriptortype, CS_INTERFACE */
  141. 0x01, /* 2 bDescriptorsubtype, CALL MANAGEMENT */
  142. 0x03, /* 3 bmCapabilities, DIY */
  143. 0x01, /* 4 bDataInterface */
  144. /* Notification Endpoint descriptor */
  145. 0x07, /* 0 bLength */
  146. DESC_ENDPOINT, /* 1 bDescriptorType */
  147. 0x81, /* 2 bEndpointAddress */
  148. 0x03, /* 3 bmAttributes */
  149. 0x40, /* 4 wMaxPacketSize - Low */
  150. 0x00, /* 5 wMaxPacketSize - High */
  151. 0x10, /* 6 bInterval */
  152. /* CDC Data interface */
  153. 0x09, /* 0 bLength */
  154. DESC_INTERFACE, /* 1 bDescriptorType */
  155. 0x01, /* 2 bInterfaceNumber */
  156. 0x00, /* 3 bAlternateSetting */
  157. 0x02, /* 4 bNumEndpoints */
  158. USB_CLASS_CDC_DATA, /* 5 bInterfaceClass */
  159. 0x00, /* 6 bInterfaceSubClass */
  160. 0x00, /* 7 bInterfaceProtocol*/
  161. 0x00, /* 8 iInterface - No string descriptor*/
  162. /* Data OUT Endpoint descriptor */
  163. 0x07, /* 0 bLength */
  164. DESC_ENDPOINT, /* 1 bDescriptorType */
  165. 0x02, /* 2 bEndpointAddress */
  166. 0x02, /* 3 bmAttributes */
  167. 0x00, /* 4 wMaxPacketSize - Low */
  168. 0x02, /* 5 wMaxPacketSize - High */
  169. 0x00, /* 6 bInterval */
  170. /* Data IN Endpoint descriptor */
  171. 0x07, /* 0 bLength */
  172. DESC_ENDPOINT, /* 1 bDescriptorType */
  173. 0x83, /* 2 bEndpointAddress */
  174. 0x02, /* 3 bmAttributes */
  175. 0x00, /* 4 wMaxPacketSize - Low byte */
  176. 0x02, /* 5 wMaxPacketSize - High byte */
  177. 0x00 /* 6 bInterval */
  178. };
  179. char serial_string[32];
  180. char * const string_descriptors[] = {
  181. "\x09\x04", /* LANGID: US English */
  182. "Keir Fraser",
  183. "Greaseweazle",
  184. serial_string,
  185. };
  186. /*
  187. * Local variables:
  188. * mode: C
  189. * c-file-style: "Linux"
  190. * c-basic-offset: 4
  191. * tab-width: 4
  192. * indent-tabs-mode: nil
  193. * End:
  194. */