config.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. 0x10,0x01, /* USB 1.1 */
  15. 2, 0, 0, /* Class, Subclass, Protocol: CDC */
  16. 64, /* Max Packet Size */
  17. 0x09,0x12, /* VID = pid.codes Open Source projects */
  18. 0x01,0x00, /* PID = Test PID #1 */
  19. 0,1, /* Device Release 1.0 */
  20. 1,2,0, /* Manufacturer, Product, Serial */
  21. 1 /* Number of configurations */
  22. };
  23. const uint8_t config_descriptor[] __aligned(2) = {
  24. 0x09, /* 0 bLength */
  25. DESC_CONFIGURATION, /* 1 bDescriptortype - Configuration*/
  26. 0x43, 0x00, /* 2 wTotalLength */
  27. 0x02, /* 4 bNumInterfaces */
  28. 0x01, /* 5 bConfigurationValue */
  29. 0x00, /* 6 iConfiguration - index of string */
  30. 0x80, /* 7 bmAttributes - Bus powered */
  31. 0xC8, /* 8 bMaxPower - 400mA */
  32. /* CDC Communication interface */
  33. 0x09, /* 0 bLength */
  34. DESC_INTERFACE, /* 1 bDescriptorType - Interface */
  35. 0x00, /* 2 bInterfaceNumber - Interface 0 */
  36. 0x00, /* 3 bAlternateSetting */
  37. 0x01, /* 4 bNumEndpoints */
  38. 2, 2, 1, /* CDC ACM, AT Command Protocol */
  39. 0x00, /* 8 iInterface - No string descriptor */
  40. /* Header Functional descriptor */
  41. 0x05, /* 0 bLength */
  42. DESC_CS_INTERFACE, /* 1 bDescriptortype, CS_INTERFACE */
  43. 0x00, /* 2 bDescriptorsubtype, HEADER */
  44. 0x10, 0x01, /* 3 bcdCDC */
  45. /* ACM Functional descriptor */
  46. 0x04, /* 0 bLength */
  47. DESC_CS_INTERFACE, /* 1 bDescriptortype, CS_INTERFACE */
  48. 0x02, /* 2 bDescriptorsubtype, ABSTRACT CONTROL MANAGEMENT */
  49. 0x02, /* 3 bmCapabilities: Supports subset of ACM commands */
  50. /* Union Functional descriptor */
  51. 0x05, /* 0 bLength */
  52. DESC_CS_INTERFACE,/* 1 bDescriptortype, CS_INTERFACE */
  53. 0x06, /* 2 bDescriptorsubtype, UNION */
  54. 0x00, /* 3 bControlInterface - Interface 0 */
  55. 0x01, /* 4 bSubordinateInterface0 - Interface 1 */
  56. /* Call Management Functional descriptor */
  57. 0x05, /* 0 bLength */
  58. DESC_CS_INTERFACE,/* 1 bDescriptortype, CS_INTERFACE */
  59. 0x01, /* 2 bDescriptorsubtype, CALL MANAGEMENT */
  60. 0x03, /* 3 bmCapabilities, DIY */
  61. 0x01, /* 4 bDataInterface */
  62. /* Notification Endpoint descriptor */
  63. 0x07, /* 0 bLength */
  64. DESC_ENDPOINT, /* 1 bDescriptorType */
  65. 0x81, /* 2 bEndpointAddress */
  66. 0x03, /* 3 bmAttributes */
  67. 0x40, /* 4 wMaxPacketSize - Low */
  68. 0x00, /* 5 wMaxPacketSize - High */
  69. 0xFF, /* 6 bInterval */
  70. /* CDC Data interface */
  71. 0x09, /* 0 bLength */
  72. DESC_INTERFACE, /* 1 bDescriptorType */
  73. 0x01, /* 2 bInterfaceNumber */
  74. 0x00, /* 3 bAlternateSetting */
  75. 0x02, /* 4 bNumEndpoints */
  76. USB_CLASS_CDC_DATA, /* 5 bInterfaceClass */
  77. 0x00, /* 6 bInterfaceSubClass */
  78. 0x00, /* 7 bInterfaceProtocol*/
  79. 0x00, /* 8 iInterface - No string descriptor*/
  80. /* Data OUT Endpoint descriptor */
  81. 0x07, /* 0 bLength */
  82. DESC_ENDPOINT, /* 1 bDescriptorType */
  83. 0x02, /* 2 bEndpointAddress */
  84. 0x02, /* 3 bmAttributes */
  85. 0x40, /* 4 wMaxPacketSize - Low */
  86. 0x00, /* 5 wMaxPacketSize - High */
  87. 0x00, /* 6 bInterval */
  88. /* Data IN Endpoint descriptor */
  89. 0x07, /* 0 bLength */
  90. DESC_ENDPOINT, /* 1 bDescriptorType */
  91. 0x82, /* 2 bEndpointAddress */
  92. 0x02, /* 3 bmAttributes */
  93. 0x40, /* 4 wMaxPacketSize - Low byte */
  94. 0x00, /* 5 wMaxPacketSize - High byte */
  95. 0x00 /* 6 bInterval */
  96. };
  97. const char *string_descriptors[] = {
  98. "\x09\x04", /* LANGID: US English */
  99. "Keir Fraser",
  100. "GreaseWeazle",
  101. };
  102. /*
  103. * Local variables:
  104. * mode: C
  105. * c-file-style: "Linux"
  106. * c-basic-offset: 4
  107. * tab-width: 4
  108. * indent-tabs-mode: nil
  109. * End:
  110. */