usb_cdcp.h 9.8 KB

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