cdc.h 7.5 KB

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