usb_cdcp.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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_PSTN USB CDC PSTN subclass
  17. * \brief USB CDC PSTN subclass definitions
  18. * \details This module based on "Universal Serial Bus Communications Class Subclass Specification
  19. * for PSTN Devices" Revision 1.2
  20. * \details This module contains definitions for
  21. * + Direct Line Control Model
  22. * + Telephony Control Model
  23. * @{ */
  24. #ifndef _USB_CDC_PSTN_H_
  25. #define _USB_CDC_PSTN_H_
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /**\name Communications Class Subclass Codes
  30. * @{ */
  31. #define USB_CDC_SUBCLASS_DLC 0x01 /**<\brief Direct Line Control Model */
  32. #define USB_CDC_SUBCLASS_TEL 0x03 /**<\brief Telephone Control Model */
  33. /* @} */
  34. /**\name CDC PSTN subclass specific Functional Descriptors codes
  35. * @{ */
  36. #define USB_DTYPE_CDC_LINE_MANAGEMENT 0x03 /**<\brief Direct Line Management Functional Descriptor.*/
  37. #define USB_DTYPE_CDC_TEL_RING 0x04 /**<\brief Telephone Ringer Functional Descriptor. */
  38. #define USB_DTYPE_CDC_TEL_CALL 0x05 /**<\brief Telephone Call and Line State Reporting
  39. * Capabilities Functional Descriptor.*/
  40. #define USB_DTYPE_CDC_TEL_OPMODE 0x08 /**<\brief Telephone Operational Modes Functional Descriptor */
  41. /** @} */
  42. /**\name CDC PSTN subclass specific requests
  43. * @{ */
  44. #define USB_CDC_SET_AUX_LINE_STATE 0x10 /**<\brief Used to connect or disconnect a secondary
  45. *jack to POTS circuit or CODEC, depending on hook state.*/
  46. #define USB_CDC_SET_HOOK_STATE 0x11 /**<\brief Used to set the necessary POTS line relay code
  47. * for on-hook, off-hook, and caller ID states.*/
  48. #define USB_CDC_PULSE_SETU 0x12 /**<\brief Used to prepare for a pulse-dialing cycle.*/
  49. #define USB_CDC_SEND_PULSE 0x13 /**<\brief Used to generate a specified number of
  50. * make/break pulse cycles.*/
  51. #define USB_CDC_SET_PULSE_TIME 0x14 /**<\brief Sets the timing of the make and break periods
  52. * for pulse dialing.*/
  53. #define USB_CDC_RING_AUX_JACK 0x15 /**<\brief Used to generate a ring signal on a secondary
  54. * phone jack.*/
  55. #define USB_CDC_SET_RINGER_PARMS 0x30 /**<\brief Configures the ringer for the communication
  56. * device.*/
  57. #define USB_CDC_GET_RINGER_PARMS 0x31 /**<\brief Returns the ringer capabilities of the device
  58. * and the current status of the device’s ringer.*/
  59. #define USB_CDC_SET_OPERATION_PARMS 0x32 /**<\brief Sets the operational mode for the device,
  60. * between a simple mode, standalone mode and a host
  61. * centric mode. */
  62. #define USB_CDC_GET_OPERATION_PARMS 0x33 /**<\brief Gets the current operational mode for the device.*/
  63. #define USB_CDC_SET_LINE_PARMS 0x34 /**<\brief Used to change the state of the line.*/
  64. #define USB_CDC_GET_LINE_PARMS 0x35 /**<\brief Used to report the state of the line.*/
  65. #define USB_CDC_DIAL_DIGITS 0x36 /**<\brief Dials the DTMF digits over the specified line.*/
  66. /** @} */
  67. /**\name CDC PSTN subclass specific notifications
  68. * @{ */
  69. #define USB_CDC_NTF_AUX_JACK_HOOK_STATE 0x08 /**<\brief Indicates the loop has changed on the
  70. * auxiliary phone interface. */
  71. #define USB_CDC_NTF_RING_DETECT 0x09 /**<\brief Indicates ring voltage on the POTS line
  72. * interface.*/
  73. #define USB_CDC_NTF_CALL_STATE_CHANGE 0x28 /**<\brief Identifies that a change has occurred to the
  74. * state of a call on the line corresponding to the
  75. * interface or union for the line.*/
  76. #define USB_CDC_NTF_LINE_STATE_CHANGE 0x29 /**<\brief identifies that a change has occurred to the
  77. * state of the line corresponding to theinterface or
  78. * master interface of a union.*/
  79. /** @} */
  80. /**\anchor USB_CDC_DLMGMNTCAP
  81. * \name USB CDC Direct Line Management capabilities
  82. * @{ */
  83. #define USB_CDC_DLM_PULSE 0x01 /**<\brief Supports the request combination of Pulse_Setup,
  84. * Send_Pulse, and Set_Pulse_Time. */
  85. #define USB_CDC_DLM_AUX 0x02 /**<\brief Supports the request combination of Set_Aux_Line_State,
  86. * Ring_Aux_Jack, and notification Aux_Jack_Hook_State. */
  87. #define USB_CDC_DLM_XTRAPULSE 0x04 /**<\brief Device requires extra Pulse_Setup request during
  88. * pulse dialing sequence to disengage holding circuit.*/
  89. /** @} */
  90. /**\anchor USB_CDC_TOMCAP
  91. * \name USB CDC Telephone Operational Modes capabilities
  92. * @{ */
  93. #define USB_CDC_TOM_SIMPLE 0x01 /**<\brief Supports Simple mode. */
  94. #define USB_CDC_TOM_STANDALONE 0x02 /**<\brief Supports Standalone mode. */
  95. #define USB_CDC_TOM_CENTRIC 0x04 /**<\brief Supports Computer Centric mode. */
  96. /** @} */
  97. /**\anchor USB_CDC_TCSCAP
  98. * \name USB CDC Telephone Call State Reporting capabilities
  99. * @{ */
  100. #define USB_CDC_TCS_DIALTONE 0x01 /**<\brief Reports interrupted dialtone in addition to
  101. * normal dialtone.*/
  102. #define USB_CDC_TCS_STATE 0x02 /**<\brief Reports ringback, busy, and fast busy states.*/
  103. #define USB_CDC_TCS_CALLERID 0x04 /**<\brief Reports caller ID information. */
  104. #define USB_CDC_TCS_RINGING 0x08 /**<\brief Reports incoming distinctive ringing patterns.*/
  105. #define USB_CDC_TCS_DTMF 0x10 /**<\brief Can report DTMF digits input remotely over
  106. * the telephone line.*/
  107. #define USB_CDC_TCS_NOTIFY 0x20 /**<\brief Does support line state change notification.*/
  108. /** @} */
  109. /** \brief Direct Line Management Functional Descriptor
  110. * \details The Direct Line Management functional descriptor describes the commands supported by the
  111. * Communication Class interface, as defined in Section 3.6.1, with the SubClass code of Direct Line
  112. * Control Model. It can only occur within the class-specific portion of an Interface descriptor.*/
  113. struct usb_cdc_dlm_desc {
  114. uint8_t bFunctionLength; /**<\brief Size of this functional descriptor, in bytes. */
  115. uint8_t bDescriptorType; /**<\brief CS_INTERFACE descriptor type. */
  116. uint8_t bDescriptorSubType; /**<\brief Direct Line Management Functional Descriptor. */
  117. uint8_t bmCapabilities; /**<\brief The line management capabilities that this
  118. * configuration supports */
  119. } __attribute__ ((packed));
  120. /** \brief Telephone Ringer Functional Descriptor
  121. * \details The Telephone Ringer functional descriptor describes the ringer capabilities supported
  122. * by the Communication Class interface, as defined in Section 3.6.3.1, with the SubClass code of
  123. * Telephone Control. It can only occur within the class-specific portion of an Interface descriptor.*/
  124. struct usb_cdc_tring_desc {
  125. uint8_t bFunctionLength; /**<\brief Size of this functional descriptor, in bytes.*/
  126. uint8_t bDescriptorType; /**<\brief CS_INTERFACE descriptor type.*/
  127. uint8_t bDescriptorSubType; /**<\brief Direct Line Management Functional Descriptor.*/
  128. uint8_t bRingerVolSteps; /**<\brief Number of discrete steps in volume supported by the ringer.*/
  129. uint8_t bNumRingerPatterns; /**<\brief Number of ringer patterns supported.*/
  130. } __attribute__ ((packed));
  131. /** \brief Telephone Operational Modes Functional Descriptor
  132. * \details The Telephone Operational Modes functional descriptor describes the operational modes
  133. * supported by the Communication Class interface, as defined in Section 3.6.3.1, with the SubClass
  134. * code of Telephone Control. It can only occur within the class-specific portion of an Interface
  135. * descriptor. The modes supported are Simple, Standalone, and Computer Centric. See Section 6.2.18,
  136. * “SetOperationParms” for a definition of the various operational modes and Table 53 for the
  137. * definition of the operational mode values.*/
  138. struct usb_cdc_tom_desc {
  139. uint8_t bFunctionLength; /**<\brief Size of this functional descriptor, in bytes. */
  140. uint8_t bDescriptorType; /**<\brief CS_INTERFACE descriptor type. */
  141. uint8_t bDescriptorSubType; /**<\brief Direct Line Management Functional Descriptor. */
  142. uint8_t bmCapabilities; /**<\brief The perational modes capabilities that this
  143. * configuration supports */
  144. } __attribute__ ((packed));
  145. /** \brief Telephone Call State Reporting Capabilities Descriptor
  146. * \details The Telephone Call and Line State Reporting Capabilities functional descriptor describes
  147. * the abilities of a telephone device to report optional call and line states.
  148. */
  149. struct usb_cdc_tcs_desc {
  150. uint8_t bFunctionLength; /**<\brief Size of this functional descriptor, in bytes. */
  151. uint8_t bDescriptorType; /**<\brief CS_INTERFACE descriptor type. */
  152. uint8_t bDescriptorSubType; /**<\brief Direct Line Management Functional Descriptor. */
  153. uint32_t bmCapabilities; /**<\brief The call state capabilities that this configuration
  154. * supports */
  155. } __attribute__ ((packed));
  156. /** @} */
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif /* _USB_CDC_PSTN_H_ */