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.

usb_protocol_cdc.h 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. /**
  2. * \file
  3. *
  4. * \brief USB Communication Device Class (CDC) protocol definitions
  5. *
  6. * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
  7. *
  8. * \asf_license_start
  9. *
  10. * \page License
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. *
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. *
  22. * 3. The name of Atmel may not be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * 4. This software may only be redistributed and used in connection with an
  26. * Atmel microcontroller product.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  29. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  30. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  31. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  32. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. * \asf_license_stop
  41. *
  42. */
  43. /*
  44. * Support and FAQ: visit <a href="https://www.atmel.com/design-support/">Atmel Support</a>
  45. */
  46. #ifndef _USB_PROTOCOL_CDC_H_
  47. #define _USB_PROTOCOL_CDC_H_
  48. #include "compiler.h"
  49. /**
  50. * \ingroup usb_protocol_group
  51. * \defgroup cdc_protocol_group Communication Device Class Definitions
  52. * @{
  53. */
  54. /**
  55. * \name Possible values of class
  56. */
  57. //@{
  58. #define CDC_CLASS_DEVICE 0x02 //!< USB Communication Device Class
  59. #define CDC_CLASS_COMM 0x02 //!< CDC Communication Class Interface
  60. #define CDC_CLASS_DATA 0x0A //!< CDC Data Class Interface
  61. #define CDC_CLASS_MULTI 0xEF //!< CDC Multi-interface Function
  62. //@}
  63. //! \name USB CDC Subclass IDs
  64. //@{
  65. #define CDC_SUBCLASS_DLCM 0x01 //!< Direct Line Control Model
  66. #define CDC_SUBCLASS_ACM 0x02 //!< Abstract Control Model
  67. #define CDC_SUBCLASS_TCM 0x03 //!< Telephone Control Model
  68. #define CDC_SUBCLASS_MCCM 0x04 //!< Multi-Channel Control Model
  69. #define CDC_SUBCLASS_CCM 0x05 //!< CAPI Control Model
  70. #define CDC_SUBCLASS_ETH 0x06 //!< Ethernet Networking Control Model
  71. #define CDC_SUBCLASS_ATM 0x07 //!< ATM Networking Control Model
  72. //@}
  73. //! \name USB CDC Communication Interface Protocol IDs
  74. //@{
  75. #define CDC_PROTOCOL_V25TER 0x01 //!< Common AT commands
  76. //@}
  77. //! \name USB CDC Data Interface Protocol IDs
  78. //@{
  79. #define CDC_PROTOCOL_I430 0x30 //!< ISDN BRI
  80. #define CDC_PROTOCOL_HDLC 0x31 //!< HDLC
  81. #define CDC_PROTOCOL_TRANS 0x32 //!< Transparent
  82. #define CDC_PROTOCOL_Q921M 0x50 //!< Q.921 management protocol
  83. #define CDC_PROTOCOL_Q921 0x51 //!< Q.931 [sic] Data link protocol
  84. #define CDC_PROTOCOL_Q921TM 0x52 //!< Q.921 TEI-multiplexor
  85. #define CDC_PROTOCOL_V42BIS 0x90 //!< Data compression procedures
  86. #define CDC_PROTOCOL_Q931 0x91 //!< Euro-ISDN protocol control
  87. #define CDC_PROTOCOL_V120 0x92 //!< V.24 rate adaption to ISDN
  88. #define CDC_PROTOCOL_CAPI20 0x93 //!< CAPI Commands
  89. #define CDC_PROTOCOL_HOST 0xFD //!< Host based driver
  90. /**
  91. * \brief Describes the Protocol Unit Functional Descriptors [sic]
  92. * on Communication Class Interface
  93. */
  94. #define CDC_PROTOCOL_PUFD 0xFE
  95. //@}
  96. //! \name USB CDC Functional Descriptor Types
  97. //@{
  98. #define CDC_CS_INTERFACE 0x24 //!< Interface Functional Descriptor
  99. #define CDC_CS_ENDPOINT 0x25 //!< Endpoint Functional Descriptor
  100. //@}
  101. //! \name USB CDC Functional Descriptor Subtypes
  102. //@{
  103. #define CDC_SCS_HEADER 0x00 //!< Header Functional Descriptor
  104. #define CDC_SCS_CALL_MGMT 0x01 //!< Call Management
  105. #define CDC_SCS_ACM 0x02 //!< Abstract Control Management
  106. #define CDC_SCS_UNION 0x06 //!< Union Functional Descriptor
  107. //@}
  108. //! \name USB CDC Request IDs
  109. //@{
  110. #define USB_REQ_CDC_SEND_ENCAPSULATED_COMMAND 0x00
  111. #define USB_REQ_CDC_GET_ENCAPSULATED_RESPONSE 0x01
  112. #define USB_REQ_CDC_SET_COMM_FEATURE 0x02
  113. #define USB_REQ_CDC_GET_COMM_FEATURE 0x03
  114. #define USB_REQ_CDC_CLEAR_COMM_FEATURE 0x04
  115. #define USB_REQ_CDC_SET_AUX_LINE_STATE 0x10
  116. #define USB_REQ_CDC_SET_HOOK_STATE 0x11
  117. #define USB_REQ_CDC_PULSE_SETUP 0x12
  118. #define USB_REQ_CDC_SEND_PULSE 0x13
  119. #define USB_REQ_CDC_SET_PULSE_TIME 0x14
  120. #define USB_REQ_CDC_RING_AUX_JACK 0x15
  121. #define USB_REQ_CDC_SET_LINE_CODING 0x20
  122. #define USB_REQ_CDC_GET_LINE_CODING 0x21
  123. #define USB_REQ_CDC_SET_CONTROL_LINE_STATE 0x22
  124. #define USB_REQ_CDC_SEND_BREAK 0x23
  125. #define USB_REQ_CDC_SET_RINGER_PARMS 0x30
  126. #define USB_REQ_CDC_GET_RINGER_PARMS 0x31
  127. #define USB_REQ_CDC_SET_OPERATION_PARMS 0x32
  128. #define USB_REQ_CDC_GET_OPERATION_PARMS 0x33
  129. #define USB_REQ_CDC_SET_LINE_PARMS 0x34
  130. #define USB_REQ_CDC_GET_LINE_PARMS 0x35
  131. #define USB_REQ_CDC_DIAL_DIGITS 0x36
  132. #define USB_REQ_CDC_SET_UNIT_PARAMETER 0x37
  133. #define USB_REQ_CDC_GET_UNIT_PARAMETER 0x38
  134. #define USB_REQ_CDC_CLEAR_UNIT_PARAMETER 0x39
  135. #define USB_REQ_CDC_GET_PROFILE 0x3A
  136. #define USB_REQ_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
  137. #define USB_REQ_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x41
  138. #define USB_REQ_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x42
  139. #define USB_REQ_CDC_SET_ETHERNET_PACKET_FILTER 0x43
  140. #define USB_REQ_CDC_GET_ETHERNET_STATISTIC 0x44
  141. #define USB_REQ_CDC_SET_ATM_DATA_FORMAT 0x50
  142. #define USB_REQ_CDC_GET_ATM_DEVICE_STATISTICS 0x51
  143. #define USB_REQ_CDC_SET_ATM_DEFAULT_VC 0x52
  144. #define USB_REQ_CDC_GET_ATM_VC_STATISTICS 0x53
  145. // Added bNotification codes according cdc spec 1.1 chapter 6.3
  146. #define USB_REQ_CDC_NOTIFY_RING_DETECT 0x09
  147. #define USB_REQ_CDC_NOTIFY_SERIAL_STATE 0x20
  148. #define USB_REQ_CDC_NOTIFY_CALL_STATE_CHANGE 0x28
  149. #define USB_REQ_CDC_NOTIFY_LINE_STATE_CHANGE 0x29
  150. //@}
  151. /*
  152. * Need to pack structures tightly, or the compiler might insert padding
  153. * and violate the spec-mandated layout.
  154. */
  155. COMPILER_PACK_SET(1)
  156. //! \name USB CDC Descriptors
  157. //@{
  158. //! CDC Header Functional Descriptor
  159. typedef struct {
  160. uint8_t bFunctionLength;
  161. uint8_t bDescriptorType;
  162. uint8_t bDescriptorSubtype;
  163. le16_t bcdCDC;
  164. } usb_cdc_hdr_desc_t;
  165. //! CDC Call Management Functional Descriptor
  166. typedef struct {
  167. uint8_t bFunctionLength;
  168. uint8_t bDescriptorType;
  169. uint8_t bDescriptorSubtype;
  170. uint8_t bmCapabilities;
  171. uint8_t bDataInterface;
  172. } usb_cdc_call_mgmt_desc_t;
  173. //! CDC ACM Functional Descriptor
  174. typedef struct {
  175. uint8_t bFunctionLength;
  176. uint8_t bDescriptorType;
  177. uint8_t bDescriptorSubtype;
  178. uint8_t bmCapabilities;
  179. } usb_cdc_acm_desc_t;
  180. //! CDC Union Functional Descriptor
  181. typedef struct {
  182. uint8_t bFunctionLength;
  183. uint8_t bDescriptorType;
  184. uint8_t bDescriptorSubtype;
  185. uint8_t bMasterInterface;
  186. uint8_t bSlaveInterface0;
  187. } usb_cdc_union_desc_t;
  188. //! \name USB CDC Call Management Capabilities
  189. //@{
  190. //! Device handles call management itself
  191. #define CDC_CALL_MGMT_SUPPORTED (1 << 0)
  192. //! Device can send/receive call management info over a Data Class interface
  193. #define CDC_CALL_MGMT_OVER_DCI (1 << 1)
  194. //@}
  195. //! \name USB CDC ACM Capabilities
  196. //@{
  197. //! Device supports the request combination of
  198. //! Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
  199. #define CDC_ACM_SUPPORT_FEATURE_REQUESTS (1 << 0)
  200. //! Device supports the request combination of
  201. //! Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding,
  202. //! and the notification Serial_State.
  203. #define CDC_ACM_SUPPORT_LINE_REQUESTS (1 << 1)
  204. //! Device supports the request Send_Break
  205. #define CDC_ACM_SUPPORT_SENDBREAK_REQUESTS (1 << 2)
  206. //! Device supports the notification Network_Connection.
  207. #define CDC_ACM_SUPPORT_NOTIFY_REQUESTS (1 << 3)
  208. //@}
  209. //@}
  210. //! \name USB CDC line control
  211. //@{
  212. //! \name USB CDC line coding
  213. //@{
  214. //! Line Coding structure
  215. typedef struct {
  216. le32_t dwDTERate;
  217. uint8_t bCharFormat;
  218. uint8_t bParityType;
  219. uint8_t bDataBits;
  220. } usb_cdc_line_coding_t;
  221. //! Possible values of bCharFormat
  222. enum cdc_char_format {
  223. CDC_STOP_BITS_1 = 0, //!< 1 stop bit
  224. CDC_STOP_BITS_1_5 = 1, //!< 1.5 stop bits
  225. CDC_STOP_BITS_2 = 2, //!< 2 stop bits
  226. };
  227. //! Possible values of bParityType
  228. enum cdc_parity {
  229. CDC_PAR_NONE = 0, //!< No parity
  230. CDC_PAR_ODD = 1, //!< Odd parity
  231. CDC_PAR_EVEN = 2, //!< Even parity
  232. CDC_PAR_MARK = 3, //!< Parity forced to 0 (space)
  233. CDC_PAR_SPACE = 4, //!< Parity forced to 1 (mark)
  234. };
  235. //@}
  236. //! \name USB CDC control signals
  237. //! spec 1.1 chapter 6.2.14
  238. //@{
  239. //! Control signal structure
  240. typedef struct {
  241. uint16_t value;
  242. } usb_cdc_control_signal_t;
  243. //! \name Possible values in usb_cdc_control_signal_t
  244. //@{
  245. //! Carrier control for half duplex modems.
  246. //! This signal corresponds to V.24 signal 105 and RS-232 signal RTS.
  247. //! The device ignores the value of this bit
  248. //! when operating in full duplex mode.
  249. #define CDC_CTRL_SIGNAL_ACTIVATE_CARRIER (1 << 1)
  250. //! Indicates to DCE if DTE is present or not.
  251. //! This signal corresponds to V.24 signal 108/2 and RS-232 signal DTR.
  252. #define CDC_CTRL_SIGNAL_DTE_PRESENT (1 << 0)
  253. //@}
  254. //@}
  255. //! \name USB CDC notification message
  256. //@{
  257. typedef struct {
  258. uint8_t bmRequestType;
  259. uint8_t bNotification;
  260. le16_t wValue;
  261. le16_t wIndex;
  262. le16_t wLength;
  263. } usb_cdc_notify_msg_t;
  264. //! \name USB CDC serial state
  265. //@{*
  266. //! Hardware handshake support (cdc spec 1.1 chapter 6.3.5)
  267. typedef struct {
  268. usb_cdc_notify_msg_t header;
  269. le16_t value;
  270. } usb_cdc_notify_serial_state_t;
  271. //! \name Possible values in usb_cdc_notify_serial_state_t
  272. //@{
  273. #define CDC_SERIAL_STATE_DCD CPU_TO_LE16((1<<0))
  274. #define CDC_SERIAL_STATE_DSR CPU_TO_LE16((1<<1))
  275. #define CDC_SERIAL_STATE_BREAK CPU_TO_LE16((1<<2))
  276. #define CDC_SERIAL_STATE_RING CPU_TO_LE16((1<<3))
  277. #define CDC_SERIAL_STATE_FRAMING CPU_TO_LE16((1<<4))
  278. #define CDC_SERIAL_STATE_PARITY CPU_TO_LE16((1<<5))
  279. #define CDC_SERIAL_STATE_OVERRUN CPU_TO_LE16((1<<6))
  280. //@}
  281. //! @}
  282. //! @}
  283. COMPILER_PACK_RESET()
  284. //! @}
  285. #endif // _USB_PROTOCOL_CDC_H_