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