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.

cdc.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /*----------------------------------------------------------------------------
  2. * U S B - K e r n e l
  3. *----------------------------------------------------------------------------
  4. * Name: CDC.h
  5. * Purpose: USB Communication Device Class Definitions
  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 family microcontroller devices only. Nothing
  14. * else gives you the right to use this software.
  15. *
  16. * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
  17. *---------------------------------------------------------------------------*/
  18. #ifndef __CDC_H
  19. #define __CDC_H
  20. extern "C" {
  21. #include <lpc_types.h>
  22. }
  23. #if defined ( __GNUC__ )
  24. #define __packed __attribute__((__packed__))
  25. #endif
  26. /*----------------------------------------------------------------------------
  27. * Definitions based on usbcdc11.pdf (www.usb.org)
  28. *---------------------------------------------------------------------------*/
  29. // Communication device class specification version 1.10
  30. #define CDC_V1_10 0x0110
  31. // Communication interface class code
  32. // (usbcdc11.pdf, 4.2, Table 15)
  33. #define CDC_COMMUNICATION_INTERFACE_CLASS 0x02
  34. // Communication interface class subclass codes
  35. // (usbcdc11.pdf, 4.3, Table 16)
  36. #define CDC_DIRECT_LINE_CONTROL_MODEL 0x01
  37. #define CDC_ABSTRACT_CONTROL_MODEL 0x02
  38. #define CDC_TELEPHONE_CONTROL_MODEL 0x03
  39. #define CDC_MULTI_CHANNEL_CONTROL_MODEL 0x04
  40. #define CDC_CAPI_CONTROL_MODEL 0x05
  41. #define CDC_ETHERNET_NETWORKING_CONTROL_MODEL 0x06
  42. #define CDC_ATM_NETWORKING_CONTROL_MODEL 0x07
  43. // Communication interface class control protocol codes
  44. // (usbcdc11.pdf, 4.4, Table 17)
  45. #define CDC_PROTOCOL_COMMON_AT_COMMANDS 0x01
  46. // Data interface class code
  47. // (usbcdc11.pdf, 4.5, Table 18)
  48. #define CDC_DATA_INTERFACE_CLASS 0x0A
  49. // Data interface class protocol codes
  50. // (usbcdc11.pdf, 4.7, Table 19)
  51. #define CDC_PROTOCOL_ISDN_BRI 0x30
  52. #define CDC_PROTOCOL_HDLC 0x31
  53. #define CDC_PROTOCOL_TRANSPARENT 0x32
  54. #define CDC_PROTOCOL_Q921_MANAGEMENT 0x50
  55. #define CDC_PROTOCOL_Q921_DATA_LINK 0x51
  56. #define CDC_PROTOCOL_Q921_MULTIPLEXOR 0x52
  57. #define CDC_PROTOCOL_V42 0x90
  58. #define CDC_PROTOCOL_EURO_ISDN 0x91
  59. #define CDC_PROTOCOL_V24_RATE_ADAPTATION 0x92
  60. #define CDC_PROTOCOL_CAPI 0x93
  61. #define CDC_PROTOCOL_HOST_BASED_DRIVER 0xFD
  62. #define CDC_PROTOCOL_DESCRIBED_IN_PUFD 0xFE
  63. // Type values for bDescriptorType field of functional descriptors
  64. // (usbcdc11.pdf, 5.2.3, Table 24)
  65. #define CDC_CS_INTERFACE 0x24
  66. #define CDC_CS_ENDPOINT 0x25
  67. // Type values for bDescriptorSubtype field of functional descriptors
  68. // (usbcdc11.pdf, 5.2.3, Table 25)
  69. #define CDC_HEADER 0x00
  70. #define CDC_CALL_MANAGEMENT 0x01
  71. #define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02
  72. #define CDC_DIRECT_LINE_MANAGEMENT 0x03
  73. #define CDC_TELEPHONE_RINGER 0x04
  74. #define CDC_REPORTING_CAPABILITIES 0x05
  75. #define CDC_UNION 0x06
  76. #define CDC_COUNTRY_SELECTION 0x07
  77. #define CDC_TELEPHONE_OPERATIONAL_MODES 0x08
  78. #define CDC_USB_TERMINAL 0x09
  79. #define CDC_NETWORK_CHANNEL 0x0A
  80. #define CDC_PROTOCOL_UNIT 0x0B
  81. #define CDC_EXTENSION_UNIT 0x0C
  82. #define CDC_MULTI_CHANNEL_MANAGEMENT 0x0D
  83. #define CDC_CAPI_CONTROL_MANAGEMENT 0x0E
  84. #define CDC_ETHERNET_NETWORKING 0x0F
  85. #define CDC_ATM_NETWORKING 0x10
  86. // CDC class-specific request codes
  87. // (usbcdc11.pdf, 6.2, Table 46)
  88. // see Table 45 for info about the specific requests.
  89. #define CDC_SEND_ENCAPSULATED_COMMAND 0x00
  90. #define CDC_GET_ENCAPSULATED_RESPONSE 0x01
  91. #define CDC_SET_COMM_FEATURE 0x02
  92. #define CDC_GET_COMM_FEATURE 0x03
  93. #define CDC_CLEAR_COMM_FEATURE 0x04
  94. #define CDC_SET_AUX_LINE_STATE 0x10
  95. #define CDC_SET_HOOK_STATE 0x11
  96. #define CDC_PULSE_SETUP 0x12
  97. #define CDC_SEND_PULSE 0x13
  98. #define CDC_SET_PULSE_TIME 0x14
  99. #define CDC_RING_AUX_JACK 0x15
  100. #define CDC_SET_LINE_CODING 0x20
  101. #define CDC_GET_LINE_CODING 0x21
  102. #define CDC_SET_CONTROL_LINE_STATE 0x22
  103. #define CDC_SEND_BREAK 0x23
  104. #define CDC_SET_RINGER_PARMS 0x30
  105. #define CDC_GET_RINGER_PARMS 0x31
  106. #define CDC_SET_OPERATION_PARMS 0x32
  107. #define CDC_GET_OPERATION_PARMS 0x33
  108. #define CDC_SET_LINE_PARMS 0x34
  109. #define CDC_GET_LINE_PARMS 0x35
  110. #define CDC_DIAL_DIGITS 0x36
  111. #define CDC_SET_UNIT_PARAMETER 0x37
  112. #define CDC_GET_UNIT_PARAMETER 0x38
  113. #define CDC_CLEAR_UNIT_PARAMETER 0x39
  114. #define CDC_GET_PROFILE 0x3A
  115. #define CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
  116. #define CDC_SET_ETHERNET_PMP_FILTER 0x41
  117. #define CDC_GET_ETHERNET_PMP_FILTER 0x42
  118. #define CDC_SET_ETHERNET_PACKET_FILTER 0x43
  119. #define CDC_GET_ETHERNET_STATISTIC 0x44
  120. #define CDC_SET_ATM_DATA_FORMAT 0x50
  121. #define CDC_GET_ATM_DEVICE_STATISTICS 0x51
  122. #define CDC_SET_ATM_DEFAULT_VC 0x52
  123. #define CDC_GET_ATM_VC_STATISTICS 0x53
  124. // Communication feature selector codes
  125. // (usbcdc11.pdf, 6.2.2..6.2.4, Table 47)
  126. #define CDC_ABSTRACT_STATE 0x01
  127. #define CDC_COUNTRY_SETTING 0x02
  128. // Feature Status returned for ABSTRACT_STATE Selector
  129. // (usbcdc11.pdf, 6.2.3, Table 48)
  130. #define CDC_IDLE_SETTING (1 << 0)
  131. #define CDC_DATA_MULTPLEXED_STATE (1 << 1)
  132. // Control signal bitmap values for the SetControlLineState request
  133. // (usbcdc11.pdf, 6.2.14, Table 51)
  134. #define CDC_DTE_PRESENT (1 << 0)
  135. #define CDC_ACTIVATE_CARRIER (1 << 1)
  136. // CDC class-specific notification codes
  137. // (usbcdc11.pdf, 6.3, Table 68)
  138. // see Table 67 for Info about class-specific notifications
  139. #define CDC_NOTIFICATION_NETWORK_CONNECTION 0x00
  140. #define CDC_RESPONSE_AVAILABLE 0x01
  141. #define CDC_AUX_JACK_HOOK_STATE 0x08
  142. #define CDC_RING_DETECT 0x09
  143. #define CDC_NOTIFICATION_SERIAL_STATE 0x20
  144. #define CDC_CALL_STATE_CHANGE 0x28
  145. #define CDC_LINE_STATE_CHANGE 0x29
  146. #define CDC_CONNECTION_SPEED_CHANGE 0x2A
  147. // UART state bitmap values (Serial state notification).
  148. // (usbcdc11.pdf, 6.3.5, Table 69)
  149. #define CDC_SERIAL_STATE_OVERRUN (1 << 6) // receive data overrun error has occurred
  150. #define CDC_SERIAL_STATE_PARITY (1 << 5) // parity error has occurred
  151. #define CDC_SERIAL_STATE_FRAMING (1 << 4) // framing error has occurred
  152. #define CDC_SERIAL_STATE_RING (1 << 3) // state of ring signal detection
  153. #define CDC_SERIAL_STATE_BREAK (1 << 2) // state of break detection
  154. #define CDC_SERIAL_STATE_TX_CARRIER (1 << 1) // state of transmission carrier
  155. #define CDC_SERIAL_STATE_RX_CARRIER (1 << 0) // state of receiver carrier
  156. // capabilities callmgmt
  157. #define CDC_CALLMGMT_CAP_CALLMGMT 0x01
  158. #define CDC_CALLMGMT_CAP_DATAINTF 0x02
  159. // capabilities acm
  160. #define CDC_ACM_CAP_COMM 0x01
  161. #define CDC_ACM_CAP_LINE 0x02
  162. #define CDC_ACM_CAP_BRK 0x04
  163. #define CDC_ACM_CAP_NOTIFY 0x08
  164. /*----------------------------------------------------------------------------
  165. * Structures based on usbcdc11.pdf (www.usb.org)
  166. *---------------------------------------------------------------------------*/
  167. // Header functional descriptor
  168. // (usbcdc11.pdf, 5.2.3.1)
  169. // This header must precede any list of class-specific descriptors.
  170. typedef struct __packed _CDC_HEADER_DESCRIPTOR{
  171. uint8_t bFunctionLength; // size of this descriptor in bytes
  172. uint8_t bDescriptorType; // CS_INTERFACE descriptor type
  173. uint8_t bDescriptorSubtype; // Header functional descriptor subtype
  174. uint16_t bcdCDC; // USB CDC specification release version
  175. } CDC_HEADER_DESCRIPTOR;
  176. //Call management functional descriptor
  177. // (usbcdc11.pdf, 5.2.3.2)
  178. // Describes the processing of calls for the communication class interface.
  179. typedef struct __packed _CDC_CALL_MANAGEMENT_DESCRIPTOR{
  180. uint8_t bFunctionLength; // size of this descriptor in bytes
  181. uint8_t bDescriptorType; // CS_INTERFACE descriptor type
  182. uint8_t bDescriptorSubtype; // call management functional descriptor subtype
  183. uint8_t bmCapabilities; // capabilities that this configuration supports
  184. uint8_t bDataInterface; // interface number of the data class interface used for call management (optional)
  185. } CDC_CALL_MANAGEMENT_DESCRIPTOR;
  186. // Abstract control management functional descriptor
  187. // (usbcdc11.pdf, 5.2.3.3)
  188. // Describes the command supported by the communication interface class with the Abstract Control Model subclass code.
  189. typedef struct __packed _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR{
  190. uint8_t bFunctionLength; // size of this descriptor in bytes
  191. uint8_t bDescriptorType; // CS_INTERFACE descriptor type
  192. uint8_t bDescriptorSubtype; // abstract control management functional descriptor subtype
  193. uint8_t bmCapabilities; // capabilities supported by this configuration
  194. } CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR;
  195. // Union functional descriptors
  196. // (usbcdc11.pdf, 5.2.3.8)
  197. // Describes the relationship between a group of interfaces that can be considered to form a functional unit.
  198. typedef struct __packed _CDC_UNION_DESCRIPTOR{
  199. uint8_t bFunctionLength; // size of this descriptor in bytes
  200. uint8_t bDescriptorType; // CS_INTERFACE descriptor type
  201. uint8_t bDescriptorSubtype; // union functional descriptor subtype
  202. uint8_t bMasterInterface; // interface number designated as master
  203. } CDC_UNION_DESCRIPTOR;
  204. // Union functional descriptors with one slave interface
  205. // (usbcdc11.pdf, 5.2.3.8)
  206. typedef struct __packed _CDC_UNION_1SLAVE_DESCRIPTOR{
  207. CDC_UNION_DESCRIPTOR sUnion; // Union functional descriptor
  208. uint8_t bSlaveInterfaces[1]; // Slave interface 0
  209. } CDC_UNION_1SLAVE_DESCRIPTOR;
  210. // Line coding structure
  211. // Format of the data returned when a GetLineCoding request is received
  212. // (usbcdc11.pdf, 6.2.13)
  213. typedef struct __packed _CDC_LINE_CODING{
  214. uint32_t dwDTERate; // Data terminal rate in bits per second
  215. uint8_t bCharFormat; // Number of stop bits
  216. uint8_t bParityType; // Parity bit type
  217. uint8_t bDataBits; // Number of data bits
  218. } CDC_LINE_CODING;
  219. // Notification header
  220. // Data sent on the notification endpoint must follow this header.
  221. // see USB_SETUP_PACKET in file usb.h
  222. typedef USB_SETUP_PACKET CDC_NOTIFICATION_HEADER;
  223. #endif /* __CDC_H */