PageRenderTime 56ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/firmware/usbcdc/cdc.h

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