cdc.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2012-10-03 Yi Qiu first version
  9. * 2012-12-12 heyuanjie87 add CDC endpoints collection
  10. */
  11. #ifndef __CDC_H__
  12. #define __CDC_H__
  13. #define USB_CDC_BUFSIZE 0x40
  14. #define USB_CDC_CLASS_COMM 0x02
  15. #define USB_CDC_CLASS_DATA 0x0A
  16. #define USB_CDC_SUBCLASS_NONE 0x00
  17. #define USB_CDC_SUBCLASS_DLCM 0x01
  18. #define USB_CDC_SUBCLASS_ACM 0x02
  19. #define USB_CDC_SUBCLASS_TCM 0x03
  20. #define USB_CDC_SUBCLASS_MCCM 0x04
  21. #define USB_CDC_SUBCLASS_CCM 0x05
  22. #define USB_CDC_SUBCLASS_ETH 0x06
  23. #define USB_CDC_SUBCLASS_ATM 0x07
  24. #define USB_CDC_SUBCLASS_EEM 0x0C
  25. #define USB_CDC_PROTOCOL_NONE 0x00
  26. #define USB_CDC_PROTOCOL_V25TER 0x01
  27. #define USB_CDC_PROTOCOL_I430 0x30
  28. #define USB_CDC_PROTOCOL_HDLC 0x31
  29. #define USB_CDC_PROTOCOL_TRANS 0x32
  30. #define USB_CDC_PROTOCOL_Q921M 0x50
  31. #define USB_CDC_PROTOCOL_Q921 0x51
  32. #define USB_CDC_PROTOCOL_Q921TM 0x52
  33. #define USB_CDC_PROTOCOL_V42BIS 0x90
  34. #define USB_CDC_PROTOCOL_Q931 0x91
  35. #define USB_CDC_PROTOCOL_V120 0x92
  36. #define USB_CDC_PROTOCOL_CAPI20 0x93
  37. #define USB_CDC_PROTOCOL_HOST 0xFD
  38. #define USB_CDC_PROTOCOL_PUFD 0xFE
  39. #define USB_CDC_PROTOCOL_VENDOR 0xFF
  40. #define USB_CDC_PROTOCOL_EEM 0x07
  41. #define USB_CDC_CS_INTERFACE 0x24
  42. #define USB_CDC_CS_ENDPOINT 0x25
  43. #define USB_CDC_SCS_HEADER 0x00
  44. #define USB_CDC_SCS_CALL_MGMT 0x01
  45. #define USB_CDC_SCS_ACM 0x02
  46. #define USB_CDC_SCS_UNION 0x06
  47. #define USB_CDC_SCS_ETH 0x0F
  48. #define CDC_SEND_ENCAPSULATED_COMMAND 0x00
  49. #define CDC_GET_ENCAPSULATED_RESPONSE 0x01
  50. #define CDC_SET_COMM_FEATURE 0x02
  51. #define CDC_GET_COMM_FEATURE 0x03
  52. #define CDC_CLEAR_COMM_FEATURE 0x04
  53. #define CDC_SET_AUX_LINE_STATE 0x10
  54. #define CDC_SET_HOOK_STATE 0x11
  55. #define CDC_PULSE_SETUP 0x12
  56. #define CDC_SEND_PULSE 0x13
  57. #define CDC_SET_PULSE_TIME 0x14
  58. #define CDC_RING_AUX_JACK 0x15
  59. #define CDC_SET_LINE_CODING 0x20
  60. #define CDC_GET_LINE_CODING 0x21
  61. #define CDC_SET_CONTROL_LINE_STATE 0x22
  62. #define CDC_SEND_BREAK 0x23
  63. #define CDC_SET_RINGER_PARMS 0x30
  64. #define CDC_GET_RINGER_PARMS 0x31
  65. #define CDC_SET_OPERATION_PARMS 0x32
  66. #define CDC_GET_OPERATION_PARMS 0x33
  67. #define CDC_SET_LINE_PARMS 0x34
  68. #define CDC_GET_LINE_PARMS 0x35
  69. #define CDC_DIAL_DIGITS 0x36
  70. #define CDC_SET_UNIT_PARAMETER 0x37
  71. #define CDC_GET_UNIT_PARAMETER 0x38
  72. #define CDC_CLEAR_UNIT_PARAMETER 0x39
  73. #define CDC_GET_PROFILE 0x3A
  74. #define CDC_SET_ETH_MULTICAST_FILTERS 0x40
  75. #define CDC_SET_ETH_POWER_MGMT_FILT 0x41
  76. #define CDC_GET_ETH_POWER_MGMT_FILT 0x42
  77. #define CDC_SET_ETH_PACKET_FILTER 0x43
  78. #define CDC_GET_ETH_STATISTIC 0x44
  79. #define CDC_SET_ATM_DATA_FORMAT 0x50
  80. #define CDC_GET_ATM_DEVICE_STATISTICS 0x51
  81. #define CDC_SET_ATM_DEFAULT_VC 0x52
  82. #define CDC_GET_ATM_VC_STATISTICS 0x53
  83. #pragma pack(1)
  84. struct ucdc_header_descriptor
  85. {
  86. rt_uint8_t length;
  87. rt_uint8_t type;
  88. rt_uint8_t subtype;
  89. rt_uint16_t bcd;
  90. };
  91. typedef struct ucdc_header_descriptor* ucdc_hdr_desc_t;
  92. struct ucdc_acm_descriptor
  93. {
  94. rt_uint8_t length;
  95. rt_uint8_t type;
  96. rt_uint8_t subtype;
  97. rt_uint8_t capabilties;
  98. };
  99. typedef struct ucdc_acm_descriptor* ucdc_acm_desc_t;
  100. struct ucdc_call_mgmt_descriptor
  101. {
  102. rt_uint8_t length;
  103. rt_uint8_t type;
  104. rt_uint8_t subtype;
  105. rt_uint8_t capabilties;
  106. rt_uint8_t data_interface;
  107. };
  108. typedef struct ucdc_call_mgmt_descriptor* ucdc_call_mgmt_desc_t;
  109. struct ucdc_union_descriptor
  110. {
  111. rt_uint8_t length;
  112. rt_uint8_t type;
  113. rt_uint8_t subtype;
  114. rt_uint8_t master_interface;
  115. rt_uint8_t slave_interface0;
  116. };
  117. typedef struct ucdc_union_descriptor* ucdc_union_desc_t;
  118. struct ucdc_comm_descriptor
  119. {
  120. #ifdef RT_USB_DEVICE_COMPOSITE
  121. struct uiad_descriptor iad_desc;
  122. #endif
  123. struct uinterface_descriptor intf_desc;
  124. struct ucdc_header_descriptor hdr_desc;
  125. struct ucdc_call_mgmt_descriptor call_mgmt_desc;
  126. struct ucdc_acm_descriptor acm_desc;
  127. struct ucdc_union_descriptor union_desc;
  128. struct uendpoint_descriptor ep_desc;
  129. };
  130. typedef struct ucdc_comm_descriptor* ucdc_comm_desc_t;
  131. struct ucdc_enet_descriptor
  132. {
  133. rt_uint8_t bFunctionLength;
  134. rt_uint8_t bDescriptorType;
  135. rt_uint8_t bDescriptorSubtype;
  136. rt_uint8_t iMACAddress;
  137. rt_uint8_t bmEthernetStatistics[4];
  138. rt_uint16_t wMaxSegmentSize;
  139. rt_uint16_t wMCFilters;
  140. rt_uint8_t bNumberPowerFilters;
  141. };
  142. struct ucdc_eth_descriptor
  143. {
  144. #ifdef RT_USB_DEVICE_COMPOSITE
  145. struct uiad_descriptor iad_desc;
  146. #endif
  147. struct uinterface_descriptor intf_desc;
  148. struct ucdc_header_descriptor hdr_desc;
  149. struct ucdc_union_descriptor union_desc;
  150. struct ucdc_enet_descriptor enet_desc;
  151. struct uendpoint_descriptor ep_desc;
  152. };
  153. typedef struct ucdc_eth_descriptor* ucdc_eth_desc_t;
  154. struct ucdc_data_descriptor
  155. {
  156. struct uinterface_descriptor intf_desc;
  157. struct uendpoint_descriptor ep_out_desc;
  158. struct uendpoint_descriptor ep_in_desc;
  159. };
  160. typedef struct ucdc_data_descriptor* ucdc_data_desc_t;
  161. struct ucdc_line_coding
  162. {
  163. rt_uint32_t dwDTERate;
  164. rt_uint8_t bCharFormat;
  165. rt_uint8_t bParityType;
  166. rt_uint8_t bDataBits;
  167. };
  168. typedef struct ucdc_line_coding* ucdc_line_coding_t;
  169. struct cdc_eps
  170. {
  171. uep_t ep_out;
  172. uep_t ep_in;
  173. uep_t ep_cmd;
  174. };
  175. typedef struct cdc_eps* cdc_eps_t;
  176. struct ucdc_management_element_notifications
  177. {
  178. rt_uint8_t bmRequestType;
  179. rt_uint8_t bNotificatinCode;
  180. rt_uint16_t wValue;
  181. rt_uint16_t wIndex;
  182. rt_uint16_t wLength;
  183. };
  184. typedef struct ucdc_management_element_notifications * ucdc_mg_notifications_t;
  185. struct ucdc_connection_speed_change_data
  186. {
  187. rt_uint32_t down_bit_rate;
  188. rt_uint32_t up_bit_rate;
  189. };
  190. typedef struct connection_speed_change_data * connect_speed_data_t;
  191. enum ucdc_notification_code
  192. {
  193. UCDC_NOTIFI_NETWORK_CONNECTION = 0x00,
  194. UCDC_NOTIFI_RESPONSE_AVAILABLE = 0x01,
  195. UCDC_NOTIFI_AUX_JACK_HOOK_STATE = 0x08,
  196. UCDC_NOTIFI_RING_DETECT = 0x09,
  197. UCDC_NOTIFI_SERIAL_STATE = 0x20,
  198. UCDC_NOTIFI_CALL_STATE_CHANGE = 0x28,
  199. UCDC_NOTIFI_LINE_STATE_CHANGE = 0x29,
  200. UCDC_NOTIFI_CONNECTION_SPEED_CHANGE = 0x2A,
  201. };
  202. typedef enum ucdc_notification_code ucdc_notification_code_t;
  203. #pragma pack()
  204. #endif