1
0

usb_cdci.h 11 KB

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