tinyusb  0.4
Click here to lend your support to tinyusb donation and make a donation at pledgie.com
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
cdc.h
Go to the documentation of this file.
1 /**************************************************************************/
37 /**************************************************************************/
38 
44 #ifndef _TUSB_CDC_H__
45 #define _TUSB_CDC_H__
46 
47 #include "common/common.h"
48 
49 #ifdef __cplusplus
50  extern "C" {
51 #endif
52 
57 typedef enum {
64 
65 //--------------------------------------------------------------------+
66 // CDC COMMUNICATION INTERFACE CLASS
67 //--------------------------------------------------------------------+
69 typedef enum {
83 
85 typedef enum {
94 
95 //------------- SubType Descriptor in COMM Functional Descriptor -------------//
97 typedef enum {
125 
126 //--------------------------------------------------------------------+
127 // CDC DATA INTERFACE CLASS
128 //--------------------------------------------------------------------+
129 
130 // SUBCLASS code of Data Interface is not used and should/must be zero
132 typedef enum{
146 
147 //--------------------------------------------------------------------+
148 // MANAGEMENT ELEMENT REQUEST (CONTROL ENDPOINT)
149 //--------------------------------------------------------------------+
151 typedef enum {
154 
155  CDC_REQUEST_SET_COMM_FEATURE = 0x02,
156  CDC_REQUEST_GET_COMM_FEATURE = 0x03,
157  CDC_REQUEST_CLEAR_COMM_FEATURE = 0x04,
158 
159  CDC_REQUEST_SET_AUX_LINE_STATE = 0x10,
160  CDC_REQUEST_SET_HOOK_STATE = 0x11,
161  CDC_REQUEST_PULSE_SETUP = 0x12,
162  CDC_REQUEST_SEND_PULSE = 0x13,
163  CDC_REQUEST_SET_PULSE_TIME = 0x14,
164  CDC_REQUEST_RING_AUX_JACK = 0x15,
165 
166  CDC_REQUEST_SET_LINE_CODING = 0x20,
167  CDC_REQUEST_GET_LINE_CODING = 0x21,
168  CDC_REQUEST_SET_CONTROL_LINE_STATE = 0x22,
169  CDC_REQUEST_SEND_BREAK = 0x23,
170 
171  CDC_REQUEST_SET_RINGER_PARMS = 0x30,
172  CDC_REQUEST_GET_RINGER_PARMS = 0x31,
173  CDC_REQUEST_SET_OPERATION_PARMS = 0x32,
174  CDC_REQUEST_GET_OPERATION_PARMS = 0x33,
175  CDC_REQUEST_SET_LINE_PARMS = 0x34,
176  CDC_REQUEST_GET_LINE_PARMS = 0x35,
177  CDC_REQUEST_DIAL_DIGITS = 0x36,
178  CDC_REQUEST_SET_UNIT_PARAMETER = 0x37,
179  CDC_REQUEST_GET_UNIT_PARAMETER = 0x38,
180  CDC_REQUEST_CLEAR_UNIT_PARAMETER = 0x39,
181  CDC_REQUEST_GET_PROFILE = 0x3A,
182 
183  CDC_REQUEST_SET_ETHERNET_MULTICAST_FILTERS = 0x40,
184  CDC_REQUEST_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x41,
185  CDC_REQUEST_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x42,
186  CDC_REQUEST_SET_ETHERNET_PACKET_FILTER = 0x43,
187  CDC_REQUEST_GET_ETHERNET_STATISTIC = 0x44,
188 
189  CDC_REQUEST_SET_ATM_DATA_FORMAT = 0x50,
190  CDC_REQUEST_GET_ATM_DEVICE_STATISTICS = 0x51,
191  CDC_REQUEST_SET_ATM_DEFAULT_VC = 0x52,
192  CDC_REQUEST_GET_ATM_VC_STATISTICS = 0x53,
193 
194  CDC_REQUEST_MDLM_SEMANTIC_MODEL = 0x60,
196 
197 //--------------------------------------------------------------------+
198 // MANAGEMENT ELEMENENT NOTIFICATION (NOTIFICATION ENDPOINT)
199 //--------------------------------------------------------------------+
201 typedef enum {
204 
205  AUX_JACK_HOOK_STATE = 0x08,
206  RING_DETECT = 0x09,
207 
208  SERIAL_STATE = 0x20,
209 
210  CALL_STATE_CHANGE = 0x28,
211  LINE_STATE_CHANGE = 0x29,
213  MDLM_SEMANTIC_MODEL_NOTIFICATION = 0x40,
215 
216 //--------------------------------------------------------------------+
217 // FUNCTIONAL DESCRIPTOR (COMMUNICATION INTERFACE)
218 //--------------------------------------------------------------------+
220 typedef ATTR_PACKED_STRUCT(struct) {
221  uint8_t bLength ;
222  uint8_t bDescriptorType ;
224  uint16_t bcdCDC ;
226 
228 typedef ATTR_PACKED_STRUCT(struct) {
229  uint8_t bLength ;
230  uint8_t bDescriptorType ;
232  uint8_t bControlInterface ;
235 
236 #define cdc_desc_func_union_n_t(no_slave)\
237  ATTR_PACKED_STRUCT(struct) { \
238  uint8_t bLength ;\
239  uint8_t bDescriptorType ;\
240  uint8_t bDescriptorSubType ;\
241  uint8_t bControlInterface ;\
242  uint8_t bSubordinateInterface[no_slave] ;\
243 }
244 
246 typedef ATTR_PACKED_STRUCT(struct) {
247  uint8_t bLength ;
248  uint8_t bDescriptorType ;
251  uint16_t wCountryCode[] ;
253 
254 #define cdc_desc_func_country_selection_n_t(no_country) \
255  ATTR_PACKED_STRUCT(struct) {\
256  uint8_t bLength ;\
257  uint8_t bDescriptorType ;\
258  uint8_t bDescriptorSubType ;\
259  uint8_t iCountryCodeRelDate ;\
260  uint16_t wCountryCode[no_country] ;\
261 }
262 
263 //--------------------------------------------------------------------+
264 // PUBLIC SWITCHED TELEPHONE NETWORK (PSTN) SUBCLASS
265 //--------------------------------------------------------------------+
266 
269 typedef ATTR_PACKED_STRUCT(struct) {
270  uint8_t bLength ;
271  uint8_t bDescriptorType ;
273 
274  struct {
275  uint8_t handle_call : 1;
276  uint8_t send_recv_call : 1;
277  uint8_t : 0;
278  } bmCapabilities;
279 
280  uint8_t bDataInterface;
282 
283 
284 typedef ATTR_PACKED_STRUCT(struct) {
285  uint8_t support_comm_request : 1;
286  uint8_t support_line_request : 1;
287  uint8_t support_send_break : 1;
288  uint8_t support_notification_network_connection : 1;
289  uint8_t : 0;
291 
292 STATIC_ASSERT(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler");
293 
296 typedef ATTR_PACKED_STRUCT(struct) {
297  uint8_t bLength ;
298  uint8_t bDescriptorType ;
300  cdc_acm_capability_t bmCapabilities ;
302 
305 typedef ATTR_PACKED_STRUCT(struct) {
306  uint8_t bLength ;
307  uint8_t bDescriptorType ;
309  struct {
310  uint8_t require_pulse_setup : 1;
311  uint8_t support_aux_request : 1;
312  uint8_t support_pulse_request : 1;
313  uint8_t : 0;
314  } bmCapabilities;
316 
320 typedef ATTR_PACKED_STRUCT(struct) {
321  uint8_t bLength ;
322  uint8_t bDescriptorType ;
324  uint8_t bRingerVolSteps ;
325  uint8_t bNumRingerPatterns ;
327 
331 typedef ATTR_PACKED_STRUCT(struct) {
332  uint8_t bLength ;
333  uint8_t bDescriptorType ;
335  struct {
336  uint8_t simple_mode : 1;
337  uint8_t standalone_mode : 1;
338  uint8_t computer_centric_mode : 1;
339  uint8_t : 0;
340  } bmCapabilities;
342 
346 typedef ATTR_PACKED_STRUCT(struct) {
347  uint8_t bLength ;
348  uint8_t bDescriptorType ;
350  struct {
351  uint32_t interrupted_dialtone : 1;
352  uint32_t ringback_busy_fastbusy : 1;
353  uint32_t caller_id : 1;
354  uint32_t incoming_distinctive : 1;
355  uint32_t dual_tone_multi_freq : 1;
356  uint32_t line_state_change : 1;
357  uint32_t : 0;
358  } bmCapabilities;
360 
361 static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) ATTR_PURE ATTR_ALWAYS_INLINE;
362 static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
363 {
364  return p_desc[2];
365 }
366 
367 //--------------------------------------------------------------------+
368 // Requests
369 //--------------------------------------------------------------------+
370 typedef ATTR_PACKED_STRUCT(struct) {
371  uint32_t bit_rate;
372  uint8_t stop_bits;
373  uint8_t parity;
374  uint8_t data_bits;
376 
377 STATIC_ASSERT(sizeof(cdc_line_coding_t) == 7, "size is not correct");
378 
379 typedef ATTR_PACKED_STRUCT(struct) {
380  uint16_t dte_is_present : 1;
381  uint16_t half_duplex_carrier_control : 1;
382  uint16_t : 14;
384 
385 STATIC_ASSERT(sizeof(cdc_line_control_state_t) == 2, "size is not correct");
386 
389 #ifdef __cplusplus
390  }
391 #endif
392 
393 #endif
394 
uint8_t bLength
Size of this descriptor in bytes.
Definition: cdc.h:270
uint8_t bDescriptorSubType
Descriptor SubType one of above CDC_FUCN_DESC_.
Definition: cdc.h:349
uint8_t bDescriptorSubType
Descriptor SubType one of above CDC_FUCN_DESC_.
Definition: cdc.h:249
uint8_t bDescriptorSubType
Descriptor SubType one of above CDC_FUCN_DESC_.
Definition: cdc.h:272
uint8_t bLength
Size of this descriptor in bytes.
Definition: cdc.h:221
Management protocol for Q.921 data link protocol.
Definition: cdc.h:136
cdc_comm_protocol_type_t
Communication Interface Protocol Codes.
Definition: cdc.h:85
Abstract Control Model [USBPSTN1.2].
Definition: cdc.h:71
Host based driver. Note: This protocol code should only be used in messages between host and device t...
Definition: cdc.h:143
uint8_t bLength
Size of this descriptor in bytes.
Definition: cdc.h:297
is used to issue a command in the format of the supported control protocol of the Communications Clas...
Definition: cdc.h:152
uint8_t bDescriptorType
Descriptor Type, must be Class-Specific.
Definition: cdc.h:222
Command Set Functional Descriptor.
Definition: cdc.h:120
OBEX Service Identifier Functional Descriptor.
Definition: cdc.h:123
uint8_t bDescriptorSubType
Descriptor SubType one of above CDC_FUCN_DESC_.
Definition: cdc.h:231
uint8_t bDescriptorType
Descriptor Type, must be Class-Specific.
Definition: cdc.h:298
Telephone Call and Line State Reporting Capabilities Descriptor.
Definition: cdc.h:346
USB Terminal Functional Descriptor.
Definition: cdc.h:107
AT Commands defined by PCCA-101 & Annex O.
Definition: cdc.h:88
Direct Line Control Model [USBPSTN1.2].
Definition: cdc.h:70
Multi-Channel Control Model [USBISDN1.2].
Definition: cdc.h:73
cdc_data_protocol_type_t
Data Interface Protocol Codes.
Definition: cdc.h:132
uint8_t bDescriptorType
Descriptor Type, must be Class-Specific.
Definition: cdc.h:333
CAPI Control Model [USBISDN1.2].
Definition: cdc.h:74
AT Commands: V.250 etc.
Definition: cdc.h:86
This notification allows the device to notify the host about network connection status.
Definition: cdc.h:202
uint8_t bDescriptorType
Descriptor Type, must be Class-Specific.
Definition: cdc.h:230
uint8_t bDescriptorType
Descriptor Type, must be Class-Specific.
Definition: cdc.h:271
Notification pipe.
Definition: cdc.h:59
TEI-multiplexor for Q.921 data link protocol.
Definition: cdc.h:138
OBEX Functional Descriptor.
Definition: cdc.h:119
Network Channel Terminal Descriptor.
Definition: cdc.h:108
Protocol Unit Functional Descriptor.
Definition: cdc.h:109
Mobile Direct Line Model [USBWMC1.1].
Definition: cdc.h:79
#define ATTR_PURE
Many functions have no effects except the return value and their return value depends only on the par...
Definition: compiler_gcc.h:96
Header Functional Descriptor, which marks the beginning of the concatenated set of functional descrip...
Definition: cdc.h:98
This notification allows the device to inform the host-networking driver that a change in either the ...
Definition: cdc.h:212
Telephone Call and Line State Reporting Capabilities Functional Descriptor.
Definition: cdc.h:103
uint8_t iCountryCodeRelDate
Index of a string giving the release date for the implemented ISO 3166 Country Codes.
Definition: cdc.h:250
Device Management Model Functional Descriptor.
Definition: cdc.h:118
Direct Line Management Functional Descriptor.
Definition: cdc.h:101
Telephone Control Model [USBPSTN1.2].
Definition: cdc.h:72
Ethernet Networking Functional Descriptor.
Definition: cdc.h:113
Device Management [USBWMC1.1].
Definition: cdc.h:78
uint8_t bSubordinateInterface
Array of Interface number of Data Interface.
Definition: cdc.h:233
uint8_t stop_bits
0: 1 stop bit - 1: 1.5 stop bits - 2: 2 stop bits
Definition: cdc.h:372
Telephone Operational ModesFunctional Descriptor.
Definition: cdc.h:106
uint8_t bLength
Size of this descriptor in bytes.
Definition: cdc.h:306
Data in pipe.
Definition: cdc.h:60
uint8_t bDescriptorSubType
Descriptor SubType one of above CDC_FUCN_DESC_.
Definition: cdc.h:323
uint8_t bDescriptorType
Descriptor Type, must be Class-Specific.
Definition: cdc.h:322
Telephone Control Model Functional Descriptor.
Definition: cdc.h:122
Ethernet Emulation Model.
Definition: cdc.h:92
uint16_t bcdCDC
CDC release number in Binary-Coded Decimal.
Definition: cdc.h:224
AT Commands defined by GSM 07.07.
Definition: cdc.h:89
Extension Unit Functional Descriptor.
Definition: cdc.h:110
is used to request a response in the format of the supported control protocol of the Communications C...
Definition: cdc.h:153
uint8_t bDescriptorSubType
Descriptor SubType one of above CDC_FUCN_DESC_.
Definition: cdc.h:334
Wireless Handset Control Model [USBWMC1.1].
Definition: cdc.h:77
Physical interface protocol for ISDN BRI.
Definition: cdc.h:133
AT Commands defined by TIA for CDMA.
Definition: cdc.h:91
The protocol(s) are described using a ProtocolUnit Functional Descriptors on Communications Class Int...
Definition: cdc.h:144
cdc_management_request_t
Communication Interface Management Element Request Codes.
Definition: cdc.h:151
Abstract Control Management Functional Descriptor.
Definition: cdc.h:100
cdc_func_desc_type_t
Communication Interface SubType Descriptor.
Definition: cdc.h:97
OBEX [USBWMC1.1].
Definition: cdc.h:80
CAPI Control Management Functional Descriptor.
Definition: cdc.h:112
uint8_t bDescriptorSubType
Descriptor SubType one of above CDC_FUCN_DESC_.
Definition: cdc.h:223
Data link protocol for Q.931.
Definition: cdc.h:137
Invalid Pipe ID.
Definition: cdc.h:62
ATM Networking Control Model [USBATM1.2].
Definition: cdc.h:76
Wireless Handset Control Model Functional Descriptor.
Definition: cdc.h:115
Union Functional Descriptor.
Definition: cdc.h:104
Call Management Functional Descriptor.
Definition: cdc.h:269
Euro-ISDN protocol control.
Definition: cdc.h:140
cdc_pipeid_t
CDC Pipe ID, used to indicate which pipe the API is addressing to (Notification, Out, In)
Definition: cdc.h:58
Call Management Functional Descriptor.
Definition: cdc.h:99
cdc_comm_sublcass_type_t
Communication Interface Subclass Codes.
Definition: cdc.h:69
Telephone Operational Modes Functional Descriptor.
Definition: cdc.h:331
Country Selection Functional Descriptor (Communication Interface)
Definition: cdc.h:246
Direct Line Management Functional Descriptor.
Definition: cdc.h:305
AT Commands defined by 3GPP 27.007.
Definition: cdc.h:90
This notification allows the device to notify the hostthat a response is available. This response can be retrieved with a subsequent CDC_REQUEST_GET_ENCAPSULATED_RESPONSE request.
Definition: cdc.h:203
Abstract Control Management Functional Descriptor.
Definition: cdc.h:296
Telephone Ringer Functional Descriptor.
Definition: cdc.h:102
Mobile Direct Line Model Functional Descriptor.
Definition: cdc.h:116
uint8_t bDescriptorSubType
Descriptor SubType one of above CDC_FUCN_DESC_.
Definition: cdc.h:299
ATM Networking Functional Descriptor.
Definition: cdc.h:114
uint8_t bLength
Size of this descriptor in bytes.
Definition: cdc.h:347
Header Functional Descriptor (Communication Interface)
Definition: cdc.h:220
uint8_t bDescriptorType
Descriptor Type, must be Class-Specific.
Definition: cdc.h:348
uint8_t bDescriptorSubType
Descriptor SubType one of above CDC_FUCN_DESC_.
Definition: cdc.h:308
Command Set Detail Functional Descriptor.
Definition: cdc.h:121
Union Functional Descriptor (Communication Interface)
Definition: cdc.h:228
uint8_t bControlInterface
Interface number of Communication Interface.
Definition: cdc.h:232
uint8_t bDescriptorType
Descriptor Type, must be Class-Specific.
Definition: cdc.h:248
uint8_t bLength
Size of this descriptor in bytes.
Definition: cdc.h:229
Ethernet Networking Control Model [USBECM1.2].
Definition: cdc.h:75
uint8_t data_bits
can be 5, 6, 7, 8 or 16
Definition: cdc.h:374
uint8_t bLength
Size of this descriptor in bytes.
Definition: cdc.h:332
uint8_t parity
0: None - 1: Odd - 2: Even - 3: Mark - 4: Space
Definition: cdc.h:373
uint8_t bLength
Size of this descriptor in bytes.
Definition: cdc.h:321
Ethernet Emulation Model [USBEEM1.0].
Definition: cdc.h:81
#define ATTR_ALWAYS_INLINE
Generally, functions are not inlined unless optimization is specified. For functions declared inline...
Definition: compiler_gcc.h:89
Telephone Ringer Functional Descriptor.
Definition: cdc.h:320
Multi-Channel Management Functional Descriptor.
Definition: cdc.h:111
MDLM Detail Functional Descriptor.
Definition: cdc.h:117
uint8_t bDescriptorType
Descriptor Type, must be Class-Specific.
Definition: cdc.h:307
Data compression procedures.
Definition: cdc.h:139
cdc_notification_request_t
Communication Interface Management Element Notification Codes.
Definition: cdc.h:201
Data out pipe.
Definition: cdc.h:61
CAPI Commands.
Definition: cdc.h:142
uint8_t bLength
Size of this descriptor in bytes.
Definition: cdc.h:247
Country Selection Functional Descriptor.
Definition: cdc.h:105
V.24 rate adaptation to ISDN.
Definition: cdc.h:141
AT Commands defined by PCCA-101.
Definition: cdc.h:87