usb_cdci.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* This file is the part of the LUS32 project
  2. *
  3. * Copyright ©2016 Dmitry Filimonchuk <dmitrystu[at]gmail[dot]com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. /** \ingroup USB_CDC
  16. * \addtogroup USB_CDC_ISDN USB CDC ISDN subclass
  17. * \brief USB CDC ISDN subclass definitions
  18. * \details This module based on "Universal Serial Bus Communications Class Subclass Specification for ISDN Devices" Revision 1.2
  19. * \details This module cotains definitions for
  20. * + Multiple Line Control Model
  21. * + CAPI Control Model
  22. * @{ */
  23. #ifndef _USB_CDC_ISDN_H_
  24. #define _USB_CDC_ISDN_H_
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /**\name Communications Class Subclass Codes
  29. * @{ */
  30. #define USB_CDC_SUBCLASS_MCNL 0x04 /**< Multi-Channel Control Model */
  31. #define USB_CDC_SUBCLASS_CAPI 0x05 /**< CAPI Control Model */
  32. /* @} */
  33. /** \name CDC ISDN Data Interface Class Protocol Codes
  34. * @{ */
  35. #define USB_CDC_PROTO_I340 0x30 /**< Physical interface protocol for ISDN BRI */
  36. #define USB_CDC_PROTO_HDLC 0x31 /**< HDLC */
  37. #define USB_CDC_PROTO_TRANSPARENT 0x32 /**< Transparent */
  38. #define USB_CDC_PROTO_Q921M 0x50 /**< Management protocol for Q.921 data link protocol */
  39. #define USB_CDC_PROTO_Q921 0x51 /**< Data link protocol for Q.931 */
  40. #define USB_CDC_PROTO_Q921TM 0x52 /**< TEI-multiplexor for Q.921 data link protocol */
  41. #define USB_CDC_PROTO_V42BIS 0x90 /**< Data compression procedures */
  42. #define USB_CDC_PROTO_Q931 0x91 /**< Euro-ISDN protocol control */
  43. #define USB_CDC_PROTO_V120 0x92 /**< V.24 rate adaptation to ISDN */
  44. #define USB_CDC_PROTO_CAPI20 0x93 /**< CAPI Commands */
  45. /** @} */
  46. /**\name CDC ISDN subclass specific Functional Descriptors codes
  47. * @{ */
  48. #define USB_DTYPE_CDC_TERMINAL 0x09 /**< USB Terminal Functional Descriptor \ref usb_cdc_terminal_desc */
  49. #define USB_DTYPE_CDC_NETWORK_TERMINAL 0x0A /**< Network Channel Terminal Descriptor \ref usb_cdc_network_terminal_desc*/
  50. #define USB_DTYPE_CDC_PROTOCOL_UNIT 0x0B /**< Protocol Unit Functional Descriptor \ref usb_cdc_proto_unit_desc*/
  51. #define USB_DTYPE_CDC_EXTENSION_UNIT 0x0C /**< Extension Unit Functional Descriptor \ref usb_cdc_ext_unit_desc*/
  52. #define USB_DTYPE_CDC_MCNL_MANAGEMENT 0x0D /**< Multi-Channel Management Functional Descriptor \ref usb_cdc_mcnl_managemnt_desc */
  53. #define USB_DTYPE_CDC_CAPI_CONTROL 0x0E /**< CAPI Control Management Functional Descriptor */
  54. /** @} */
  55. /**\name CDC ISDN subclass specific requests
  56. * @{ */
  57. #define USB_CDC_SET_UNIT_PARAMETER 0x37 /**< Used to set a Unit specific parameter. */
  58. #define USB_CDC_GET_UNIT_PARAMETER 0x38 /**< Used to retrieve a Unit specific parameter */
  59. #define USB_CDC_CLEAR_UNIT_PARAMETER 0x39 /**< Used to set a Unit specific parameter to its default state. */
  60. #define USB_CDC_GET_PROFILE 0x3A /**< Returns the implemented capabilities of the device */
  61. /** @} */
  62. /**\anchor USB_DFU_MCNHCAP
  63. * \name Multi-Channel Management Functional Descriptor capabilities
  64. * @{ */
  65. #define USB_CDC_MCHN_UNIT_NVRAM 0x01 /**< Device stores Unit parameters in non-volatile memory. */
  66. #define USB_CDC_MCHN_UNIT_CLR 0x02 /**< Device supports the request Clear_Unit_Parameter. */
  67. #define USB_CDC_MCHN_UNIR_SET 0x04 /**< Device supports the request Set_Unit_Parameter.*/
  68. /** @} */
  69. /**\anchor USB_DFU_CAPICAP
  70. * \name CAPI Control Management Functional Descriptor capabilities
  71. * @{ */
  72. #define USB_CDC_CAPI_SIMPLE 0x00 /**< Device is a Simple CAPI device. */
  73. #define USB_CDC_CAPI_INTELLIGENT 0x01 /**< Device is an Intelligent CAPI device. */
  74. /** @} */
  75. /** \brief USB Terminal Functional Descriptor
  76. * \details The USB Terminal Functional Descriptor provides a means to indicate a relationship between a Unit and an USB
  77. * Interface. It also defines parameters specific to the interface between the device and the host. It can only occur within
  78. * the class-specific portion of an Interface descriptor.
  79. */
  80. struct usb_cdc_terminal_desc {
  81. uint8_t bFunctionLength; /**< Size of this functional descriptor, in bytes. */
  82. uint8_t bDescriptorType; /**< CS_INTERFACE descriptor type. \see \ref USB_DTYPE_CS_INTERFACE */
  83. uint8_t bDescriptorSubType; /**< USB Terminal Functional Descriptor \ref USB_DTYPE_CDC_TERMINAL */
  84. uint8_t bEntityId; /**< Constant uniquely identifying the Terminal */
  85. uint8_t bInInterfaceNo; /**< The input interface number of the associated USB interface. */
  86. uint8_t bOutInterfaceNo; /**< The output interface number of the associated USB interface. */
  87. uint8_t bmOptions; /**< D0: Protocol wrapper usage */
  88. uint8_t bChildId0; /**< First ID of lower Terminal or Unit to which this Terminal is connected. */
  89. /* ... and there can be a lot of Terminals or Units */
  90. } __attribute__ ((packed));
  91. /** \brief Network Channel Terminal Functional Descriptor
  92. * \details The Network Channel Terminal Functional descriptor provides a means to indicate a relationship between a Unit and a
  93. * Network Channel. It can only occur within the class-specific portion of an Interface descriptor.
  94. */
  95. struct usb_cdc_network_terminal_desc {
  96. uint8_t bFunctionLength; /**< Size of this functional descriptor, in bytes. */
  97. uint8_t bDescriptorType; /**< CS_INTERFACE descriptor type. \see \ref USB_DTYPE_CS_INTERFACE */
  98. uint8_t bDescriptorSubType; /**< Network Channel Terminal Functional Descriptor \ref USB_DTYPE_CDC_NETWORK_TERMINAL */
  99. uint8_t bEntityId; /**< Constant uniquely identifying the Terminal */
  100. uint8_t iName; /**< Index of string descriptor, describing the name of the Network Channel Terminal. */
  101. uint8_t bChannelIndex; /**< The channel index of the associated network channel according to indexing rules below. */
  102. uint8_t bPhysicalInterface; /**< Type of physical interface.
  103. * + 0 none
  104. * + 1 ISDN
  105. * + 2-200 RESERVED
  106. * + 201 -255 Vendor specific */
  107. } __attribute__ ((packed));
  108. /** \brief Protocol Unit Functional Descriptor
  109. * \details A communication protocol stack is a combination of communication functions (protocols) into a layered structure.
  110. * Each layer in the stack presents some abstract function for the layer above according to some layer-interface-standard,
  111. * making it possible to replace a function with another as long as it conforms to the standard. Each layer may have a set
  112. * of protocol parameters, defined in Appendix E, to configure it for proper operation in the actual environment and the
  113. * parameters may be retrieved and/or modified. The Unit state is initially reset. See Section 6.2.23 “SetUnitParameter”,
  114. * Section 6.2.24 “GetUnitParameter”, and Section 6.2.25 “ClearUnitParameter” for details.
  115. * A Protocol Unit Functional Descriptor identifies with bEntityId a specific protocol instance of bProtocol in a stack. It
  116. * can only occur within the class-specific portion of an Interface descriptor.
  117. */
  118. struct usb_cdc_proto_unit_desc {
  119. uint8_t bFunctionLength; /**< Size of this functional descriptor, in bytes. */
  120. uint8_t bDescriptorType; /**< CS_INTERFACE descriptor type. \see \ref USB_DTYPE_CS_INTERFACE */
  121. uint8_t bDescriptorSubType; /**< Network Channel Terminal Functional Descriptor \ref USB_DTYPE_CDC_PROTOCOL_UNIT */
  122. uint8_t bEntityId; /**< Constant uniquely identifying the Unit */
  123. uint8_t bProtocol; /**< Protocol code */
  124. } __attribute__ ((packed));
  125. /** \brief Extension Unit Functional Descriptor
  126. * \details The Extension Unit Functional Descriptor provides minimal information about the Extension Unit for a
  127. * generic driver at least to notice the presence of vendor-specific components within the protocol stack.
  128. */
  129. struct usb_cdc_ext_unit_desc {
  130. uint8_t bFunctionLength; /**< Size of this functional descriptor, in bytes. */
  131. uint8_t bDescriptorType; /**< CS_INTERFACE descriptor type. \see \ref USB_DTYPE_CS_INTERFACE */
  132. uint8_t bDescriptorSubType; /**< Network Channel Terminal Functional Descriptor \ref USB_DTYPE_CDC_EXTENSION_UNIT */
  133. uint8_t bEntityId; /**< Constant uniquely identifying the Unit */
  134. uint8_t bExtensionCode; /**< Vendor specific code identifying the Extension Unit. */
  135. uint8_t iName; /**< Index of string descriptor, describing the name of the Extension Unit. */
  136. uint8_t bChildId0; /**< First ID of lower Terminal or Unit to which this Terminal is connected. */
  137. /* ... and there can be a lot of Terminals or Units */
  138. } __attribute__ ((packed));
  139. /**\brief Multi-Channel Management Functional Descriptor
  140. * \details The Multi-Channel Management functional descriptor describes the commands supported by the
  141. * Communications Class interface, as defined in CDC , with the SubClass code of Multi-Channel.
  142. */
  143. struct usb_cdc_mcnl_managemnt_desc {
  144. uint8_t bFunctionLength; /**< Size of this functional descriptor, in bytes. */
  145. uint8_t bDescriptorType; /**< CS_INTERFACE descriptor type. \see \ref USB_DTYPE_CS_INTERFACE */
  146. uint8_t bDescriptorSubType; /**< Multi-Channel Management Functional Descriptor \ref USB_DTYPE_CDC_MCNL_MANAGEMENT */
  147. uint8_t bmCapabilities; /**< The capabilities that this configuration supports. \ref USB_DFU_MCNHCAP */
  148. } __attribute__ ((packed));
  149. /**\brief CAPI Control Management Functional Descriptor
  150. * \details The CAPI control management functional descriptor describes the commands supported by the CAPI
  151. * Control Model over the Data Class interface with the protocol code of CAPI control.
  152. */
  153. struct usb_cdc_capi_ctl_desc {
  154. uint8_t bFunctionLength; /**< Size of this functional descriptor, in bytes. */
  155. uint8_t bDescriptorType; /**< CS_INTERFACE descriptor type. \see \ref USB_DTYPE_CS_INTERFACE */
  156. uint8_t bDescriptorSubType; /**< CAPI Control Management Functional Descriptor \ref USB_DTYPE_CDC_CAPI_CONTROL */
  157. uint8_t bmCapabilities; /**< The capabilities that this configuration supports. \ref USB_DFU_CAPICAP */
  158. } __attribute__ ((packed));
  159. /** @} */
  160. #ifdef __cplusplus
  161. }
  162. #endif
  163. #endif /* _USB_CDC_ISDN_H_ */