descriptors.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. This work is licensed under the Creative Commons Attribution 3.0 Unported License.
  3. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/
  4. or send a letter to
  5. Creative Commons,
  6. 171 Second Street,
  7. Suite 300,
  8. San Francisco,
  9. California,
  10. 94105,
  11. USA.
  12. */
  13. #ifndef __DESCRIPTORS_H__
  14. #define __DESCRIPTORS_H__
  15. // JTR v0.2a
  16. /* String identifiers */
  17. #define USB_iManufacturer 1u
  18. #define USB_iProduct 2u
  19. #define USB_iSerialNum 3u
  20. #define USB_NUM_STRINGS 4u
  21. ROMPTR const unsigned char cdc_device_descriptor[] = {
  22. 0x12, // bLength
  23. USB_DEVICE_DESCRIPTOR_TYPE, // bDescriptorType
  24. 0x00, // bcdUSB (low byte)
  25. 0x02, // bcdUSB (high byte)
  26. 0x02, // bDeviceClass
  27. 0x00, // bDeviceSubClass
  28. 0x00, // bDeviceProtocol
  29. USB_EP0_BUFFER_SIZE, // bMaxPacketSize
  30. LOWB(USB_VID), // idVendor (low byte)
  31. HIGHB(USB_VID), // idVendor (high byte)
  32. LOWB(USB_PID), // idProduct (low byte)
  33. HIGHB(USB_PID), // idProduct (high byte)
  34. LOWB(USB_DEV), // bcdDevice (low byte)
  35. HIGHB(USB_DEV), // bcdDevice (high byte)
  36. USB_iManufacturer, // iManufacturer
  37. USB_iProduct, // iProduct
  38. USB_iSerialNum, // iSerialNumber (none)
  39. USB_NUM_CONFIGURATIONS // bNumConfigurations
  40. };
  41. #define USB_CONFIG_DESC_TOT_LENGTH (9+9+5+4+5+5+7+9+7+7)
  42. ROMPTR const unsigned char cdc_config_descriptor[] = {
  43. 0x09, // bLength
  44. USB_CONFIGURATION_DESCRIPTOR_TYPE, // bDescriptorType
  45. LOWB(USB_CONFIG_DESC_TOT_LENGTH), // wTotalLength (low byte)
  46. HIGHB(USB_CONFIG_DESC_TOT_LENGTH), // wTotalLength (high byte)
  47. USB_NUM_INTERFACES, // bNumInterfaces
  48. 0x01, // bConfigurationValue
  49. 0x00, // iConfiguration (0=none)
  50. 0x80, // bmAttributes (0x80 = bus powered)
  51. 0x64, // bMaxPower (in 2 mA units, 50=100 mA)
  52. //Interface0 descriptor starts here
  53. 0x09, // bLength (Interface0 descriptor starts here)
  54. USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
  55. 0x00, // bInterfaceNumber
  56. 0x00, // bAlternateSetting
  57. 0x01, // bNumEndpoints (excluding EP0)
  58. 0x02, // bInterfaceClass 0x02=com interface
  59. 0x02, // bInterfaceSubClass 0x02=ACM
  60. 0x01, // bInterfaceProtocol 0x01=AT modem
  61. 0x00, // iInterface (none)
  62. // CDC header descriptor
  63. 0x05, // bFunctionLength
  64. 0x24, // bDescriptorType
  65. 0x00, // bDescriptorSubtype (CDC header descriptor)
  66. 0x10, // bcdCDC (low byte)
  67. 0x01, // bcdCDC (high byte)
  68. // CDC abstract control management descriptor
  69. 0x04, // bFunctionLength
  70. 0x24, // bDescriptorType
  71. 0x02, // bDescriptorSubtype (CDC abstract control management descriptor)
  72. 0x02, // bmCapabilities
  73. // CDC union descriptor
  74. 0x05, // bFunctionLength
  75. 0x24, // bDescriptorType
  76. 0x06, // bDescriptorSubtype (CDC union descriptor)
  77. 0x00, // bControlInterface
  78. 0x01, // bSubordinateInterface0
  79. // Call management descriptor
  80. 0x05, // bFunctionLength
  81. 0x24, // bDescriptorType
  82. 0x01, // bDescriptorSubtype (Call management descriptor)
  83. 0x01, // bmCapabilities
  84. 0x01, // bInterfaceNum
  85. // CDC Endpoint 1 IN descriptor (INTERRUPT, Not used)
  86. 0x07, // bLength (Endpoint1 descriptor)
  87. USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType
  88. 0x81, // bEndpointAddress
  89. 0x03, // bmAttributes (0x03=intr)
  90. LOWB(CDC_NOTICE_BUFFER_SIZE), // wMaxPacketSize (low byte)
  91. HIGHB(CDC_NOTICE_BUFFER_SIZE), // wMaxPacketSize (high byte)
  92. 0x40, // bInterval
  93. //Interface1 descriptor
  94. 0x09, // bLength (Interface1 descriptor)
  95. USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
  96. 0x01, // bInterfaceNumber
  97. 0x00, // bAlternateSetting
  98. 0x02, // bNumEndpoints
  99. 0x0A, // datainterface type
  100. 0x00, // bInterfaceSubClass
  101. 0x00, // bInterfaceProtocol (0x00=no protocol, 0xFE=functional unit, 0xFF=vendor specific)
  102. 0x00, // iInterface
  103. // CDC Endpoint 2 OUT descriptor (BULK)
  104. 0x07, // bLength (Enpoint2 descriptor)
  105. USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType
  106. 0x02, // bEndpointAddress
  107. 0x02, // bmAttributes (0x02=bulk)
  108. LOWB(CDC_BUFFER_SIZE), // wMaxPacketSize (low byte)
  109. HIGHB(CDC_BUFFER_SIZE), // wMaxPacketSize (high byte)
  110. 0x00, // bInterval
  111. // CDC Endpoint 2 IN descriptor (BULK)
  112. 0x07, // bLength
  113. USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType
  114. 0x82, // bEndpointAddress
  115. 0x02, // bmAttributes (0x02=bulk)
  116. LOWB(CDC_BUFFER_SIZE), // wMaxPacketSize (low byte)
  117. HIGHB(CDC_BUFFER_SIZE), // wMaxPacketSize (high byte)
  118. 0x00 // bInterval
  119. };
  120. ROM const unsigned char cdc_str_descs[] = {
  121. /* 0 */ 4, USB_STRING_DESCRIPTOR_TYPE, LOWB(USB_LANGID_English_United_States), HIGHB(USB_LANGID_English_United_States),
  122. /* USB_iManufacturer */ 42, USB_STRING_DESCRIPTOR_TYPE, 'D',0,'a',0,'n',0,'g',0,'e',0,'r',0,'o',0,'u',0,'s',0,' ',0,'P',0,'r',0,'o',0,'t',0,'o',0,'t',0,'y',0,'p',0,'e',0,'s',0,
  123. /* USB_iProduct */ 25, USB_STRING_DESCRIPTOR_TYPE, 'F',0,'r',0,'a',0,'i',0,'s',0,'e',0,'M',0,'a',0,'s',0,'t',0,'e',0,'r',
  124. /* USB_iSerialNum */ 18, USB_STRING_DESCRIPTOR_TYPE, '0',0,'0',0,'0',0,'0',0,'0',0,'0',0,'0',0,'1',0
  125. };
  126. /* TODO: Develop prebuild script for generating all complex structures */
  127. #endif//__DESCRIPTORS_H__