blob: e345139eab0964db3dc5847eb40607bf71cca079 [file] [log] [blame]
Austin Schuh41baf202022-01-01 14:33:40 -08001/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2019 Ha Thach (tinyusb.org)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
27/** \ingroup group_class
28 * \defgroup ClassDriver_CDC Communication Device Class (CDC)
29 * Currently only Abstract Control Model subclass is supported
30 * @{ */
31
32#ifndef _TUSB_CDC_H__
33#define _TUSB_CDC_H__
34
35#include "common/tusb_common.h"
36
37#ifdef __cplusplus
38 extern "C" {
39#endif
40
41/** \defgroup ClassDriver_CDC_Common Common Definitions
42 * @{ */
43
44// TODO remove
45/// CDC Pipe ID, used to indicate which pipe the API is addressing to (Notification, Out, In)
46typedef enum
47{
48 CDC_PIPE_NOTIFICATION , ///< Notification pipe
49 CDC_PIPE_DATA_IN , ///< Data in pipe
50 CDC_PIPE_DATA_OUT , ///< Data out pipe
51 CDC_PIPE_ERROR , ///< Invalid Pipe ID
52}cdc_pipeid_t;
53
54//--------------------------------------------------------------------+
55// CDC Communication Interface Class
56//--------------------------------------------------------------------+
57
58/// Communication Interface Subclass Codes
59typedef enum
60{
61 CDC_COMM_SUBCLASS_DIRECT_LINE_CONTROL_MODEL = 0x01 , ///< Direct Line Control Model [USBPSTN1.2]
62 CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL = 0x02 , ///< Abstract Control Model [USBPSTN1.2]
63 CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL = 0x03 , ///< Telephone Control Model [USBPSTN1.2]
64 CDC_COMM_SUBCLASS_MULTICHANNEL_CONTROL_MODEL = 0x04 , ///< Multi-Channel Control Model [USBISDN1.2]
65 CDC_COMM_SUBCLASS_CAPI_CONTROL_MODEL = 0x05 , ///< CAPI Control Model [USBISDN1.2]
66 CDC_COMM_SUBCLASS_ETHERNET_CONTROL_MODEL = 0x06 , ///< Ethernet Networking Control Model [USBECM1.2]
67 CDC_COMM_SUBCLASS_ATM_NETWORKING_CONTROL_MODEL = 0x07 , ///< ATM Networking Control Model [USBATM1.2]
68 CDC_COMM_SUBCLASS_WIRELESS_HANDSET_CONTROL_MODEL = 0x08 , ///< Wireless Handset Control Model [USBWMC1.1]
69 CDC_COMM_SUBCLASS_DEVICE_MANAGEMENT = 0x09 , ///< Device Management [USBWMC1.1]
70 CDC_COMM_SUBCLASS_MOBILE_DIRECT_LINE_MODEL = 0x0A , ///< Mobile Direct Line Model [USBWMC1.1]
71 CDC_COMM_SUBCLASS_OBEX = 0x0B , ///< OBEX [USBWMC1.1]
72 CDC_COMM_SUBCLASS_ETHERNET_EMULATION_MODEL = 0x0C , ///< Ethernet Emulation Model [USBEEM1.0]
73 CDC_COMM_SUBCLASS_NETWORK_CONTROL_MODEL = 0x0D ///< Network Control Model [USBNCM1.0]
74} cdc_comm_sublcass_type_t;
75
76/// Communication Interface Protocol Codes
77typedef enum
78{
79 CDC_COMM_PROTOCOL_NONE = 0x00 , ///< No specific protocol
80 CDC_COMM_PROTOCOL_ATCOMMAND = 0x01 , ///< AT Commands: V.250 etc
81 CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101 = 0x02 , ///< AT Commands defined by PCCA-101
82 CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101_AND_ANNEXO = 0x03 , ///< AT Commands defined by PCCA-101 & Annex O
83 CDC_COMM_PROTOCOL_ATCOMMAND_GSM_707 = 0x04 , ///< AT Commands defined by GSM 07.07
84 CDC_COMM_PROTOCOL_ATCOMMAND_3GPP_27007 = 0x05 , ///< AT Commands defined by 3GPP 27.007
85 CDC_COMM_PROTOCOL_ATCOMMAND_CDMA = 0x06 , ///< AT Commands defined by TIA for CDMA
86 CDC_COMM_PROTOCOL_ETHERNET_EMULATION_MODEL = 0x07 ///< Ethernet Emulation Model
87} cdc_comm_protocol_type_t;
88
89//------------- SubType Descriptor in COMM Functional Descriptor -------------//
90/// Communication Interface SubType Descriptor
91typedef enum
92{
93 CDC_FUNC_DESC_HEADER = 0x00 , ///< Header Functional Descriptor, which marks the beginning of the concatenated set of functional descriptors for the interface.
94 CDC_FUNC_DESC_CALL_MANAGEMENT = 0x01 , ///< Call Management Functional Descriptor.
95 CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT = 0x02 , ///< Abstract Control Management Functional Descriptor.
96 CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT = 0x03 , ///< Direct Line Management Functional Descriptor.
97 CDC_FUNC_DESC_TELEPHONE_RINGER = 0x04 , ///< Telephone Ringer Functional Descriptor.
98 CDC_FUNC_DESC_TELEPHONE_CALL_AND_LINE_STATE_REPORTING_CAPACITY = 0x05 , ///< Telephone Call and Line State Reporting Capabilities Functional Descriptor.
99 CDC_FUNC_DESC_UNION = 0x06 , ///< Union Functional Descriptor
100 CDC_FUNC_DESC_COUNTRY_SELECTION = 0x07 , ///< Country Selection Functional Descriptor
101 CDC_FUNC_DESC_TELEPHONE_OPERATIONAL_MODES = 0x08 , ///< Telephone Operational ModesFunctional Descriptor
102 CDC_FUNC_DESC_USB_TERMINAL = 0x09 , ///< USB Terminal Functional Descriptor
103 CDC_FUNC_DESC_NETWORK_CHANNEL_TERMINAL = 0x0A , ///< Network Channel Terminal Descriptor
104 CDC_FUNC_DESC_PROTOCOL_UNIT = 0x0B , ///< Protocol Unit Functional Descriptor
105 CDC_FUNC_DESC_EXTENSION_UNIT = 0x0C , ///< Extension Unit Functional Descriptor
106 CDC_FUNC_DESC_MULTICHANEL_MANAGEMENT = 0x0D , ///< Multi-Channel Management Functional Descriptor
107 CDC_FUNC_DESC_CAPI_CONTROL_MANAGEMENT = 0x0E , ///< CAPI Control Management Functional Descriptor
108 CDC_FUNC_DESC_ETHERNET_NETWORKING = 0x0F , ///< Ethernet Networking Functional Descriptor
109 CDC_FUNC_DESC_ATM_NETWORKING = 0x10 , ///< ATM Networking Functional Descriptor
110 CDC_FUNC_DESC_WIRELESS_HANDSET_CONTROL_MODEL = 0x11 , ///< Wireless Handset Control Model Functional Descriptor
111 CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL = 0x12 , ///< Mobile Direct Line Model Functional Descriptor
112 CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL_DETAIL = 0x13 , ///< MDLM Detail Functional Descriptor
113 CDC_FUNC_DESC_DEVICE_MANAGEMENT_MODEL = 0x14 , ///< Device Management Model Functional Descriptor
114 CDC_FUNC_DESC_OBEX = 0x15 , ///< OBEX Functional Descriptor
115 CDC_FUNC_DESC_COMMAND_SET = 0x16 , ///< Command Set Functional Descriptor
116 CDC_FUNC_DESC_COMMAND_SET_DETAIL = 0x17 , ///< Command Set Detail Functional Descriptor
117 CDC_FUNC_DESC_TELEPHONE_CONTROL_MODEL = 0x18 , ///< Telephone Control Model Functional Descriptor
118 CDC_FUNC_DESC_OBEX_SERVICE_IDENTIFIER = 0x19 , ///< OBEX Service Identifier Functional Descriptor
119 CDC_FUNC_DESC_NCM = 0x1A , ///< NCM Functional Descriptor
120}cdc_func_desc_type_t;
121
122//--------------------------------------------------------------------+
123// CDC Data Interface Class
124//--------------------------------------------------------------------+
125
126// SUBCLASS code of Data Interface is not used and should/must be zero
127
128// Data Interface Protocol Codes
129typedef enum{
130 CDC_DATA_PROTOCOL_ISDN_BRI = 0x30, ///< Physical interface protocol for ISDN BRI
131 CDC_DATA_PROTOCOL_HDLC = 0x31, ///< HDLC
132 CDC_DATA_PROTOCOL_TRANSPARENT = 0x32, ///< Transparent
133 CDC_DATA_PROTOCOL_Q921_MANAGEMENT = 0x50, ///< Management protocol for Q.921 data link protocol
134 CDC_DATA_PROTOCOL_Q921_DATA_LINK = 0x51, ///< Data link protocol for Q.931
135 CDC_DATA_PROTOCOL_Q921_TEI_MULTIPLEXOR = 0x52, ///< TEI-multiplexor for Q.921 data link protocol
136 CDC_DATA_PROTOCOL_V42BIS_DATA_COMPRESSION = 0x90, ///< Data compression procedures
137 CDC_DATA_PROTOCOL_EURO_ISDN = 0x91, ///< Euro-ISDN protocol control
138 CDC_DATA_PROTOCOL_V24_RATE_ADAPTION_TO_ISDN = 0x92, ///< V.24 rate adaptation to ISDN
139 CDC_DATA_PROTOCOL_CAPI_COMMAND = 0x93, ///< CAPI Commands
140 CDC_DATA_PROTOCOL_HOST_BASED_DRIVER = 0xFD, ///< Host based driver. Note: This protocol code should only be used in messages between host and device to identify the host driver portion of a protocol stack.
141 CDC_DATA_PROTOCOL_IN_PROTOCOL_UNIT_FUNCTIONAL_DESCRIPTOR = 0xFE ///< The protocol(s) are described using a ProtocolUnit Functional Descriptors on Communications Class Interface
142}cdc_data_protocol_type_t;
143
144//--------------------------------------------------------------------+
145// Management Element Request (Control Endpoint)
146//--------------------------------------------------------------------+
147
148/// Communication Interface Management Element Request Codes
149typedef enum
150{
151 CDC_REQUEST_SEND_ENCAPSULATED_COMMAND = 0x00, ///< is used to issue a command in the format of the supported control protocol of the Communications Class interface
152 CDC_REQUEST_GET_ENCAPSULATED_RESPONSE = 0x01, ///< is used to request a response in the format of the supported control protocol of the Communications Class interface.
153 CDC_REQUEST_SET_COMM_FEATURE = 0x02,
154 CDC_REQUEST_GET_COMM_FEATURE = 0x03,
155 CDC_REQUEST_CLEAR_COMM_FEATURE = 0x04,
156
157 CDC_REQUEST_SET_AUX_LINE_STATE = 0x10,
158 CDC_REQUEST_SET_HOOK_STATE = 0x11,
159 CDC_REQUEST_PULSE_SETUP = 0x12,
160 CDC_REQUEST_SEND_PULSE = 0x13,
161 CDC_REQUEST_SET_PULSE_TIME = 0x14,
162 CDC_REQUEST_RING_AUX_JACK = 0x15,
163
164 CDC_REQUEST_SET_LINE_CODING = 0x20,
165 CDC_REQUEST_GET_LINE_CODING = 0x21,
166 CDC_REQUEST_SET_CONTROL_LINE_STATE = 0x22,
167 CDC_REQUEST_SEND_BREAK = 0x23,
168
169 CDC_REQUEST_SET_RINGER_PARMS = 0x30,
170 CDC_REQUEST_GET_RINGER_PARMS = 0x31,
171 CDC_REQUEST_SET_OPERATION_PARMS = 0x32,
172 CDC_REQUEST_GET_OPERATION_PARMS = 0x33,
173 CDC_REQUEST_SET_LINE_PARMS = 0x34,
174 CDC_REQUEST_GET_LINE_PARMS = 0x35,
175 CDC_REQUEST_DIAL_DIGITS = 0x36,
176 CDC_REQUEST_SET_UNIT_PARAMETER = 0x37,
177 CDC_REQUEST_GET_UNIT_PARAMETER = 0x38,
178 CDC_REQUEST_CLEAR_UNIT_PARAMETER = 0x39,
179 CDC_REQUEST_GET_PROFILE = 0x3A,
180
181 CDC_REQUEST_SET_ETHERNET_MULTICAST_FILTERS = 0x40,
182 CDC_REQUEST_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x41,
183 CDC_REQUEST_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x42,
184 CDC_REQUEST_SET_ETHERNET_PACKET_FILTER = 0x43,
185 CDC_REQUEST_GET_ETHERNET_STATISTIC = 0x44,
186
187 CDC_REQUEST_SET_ATM_DATA_FORMAT = 0x50,
188 CDC_REQUEST_GET_ATM_DEVICE_STATISTICS = 0x51,
189 CDC_REQUEST_SET_ATM_DEFAULT_VC = 0x52,
190 CDC_REQUEST_GET_ATM_VC_STATISTICS = 0x53,
191
192 CDC_REQUEST_MDLM_SEMANTIC_MODEL = 0x60,
193}cdc_management_request_t;
194
195//--------------------------------------------------------------------+
196// Management Elemenent Notification (Notification Endpoint)
197//--------------------------------------------------------------------+
198
199/// 6.3 Notification Codes
200typedef enum
201{
202 CDC_NOTIF_NETWORK_CONNECTION = 0x00, ///< This notification allows the device to notify the host about network connection status.
203 CDC_NOTIF_RESPONSE_AVAILABLE = 0x01, ///< This notification allows the device to notify the hostthat a response is available. This response can be retrieved with a subsequent \ref CDC_REQUEST_GET_ENCAPSULATED_RESPONSE request.
204 CDC_NOTIF_AUX_JACK_HOOK_STATE = 0x08,
205 CDC_NOTIF_RING_DETECT = 0x09,
206 CDC_NOTIF_SERIAL_STATE = 0x20,
207 CDC_NOTIF_CALL_STATE_CHANGE = 0x28,
208 CDC_NOTIF_LINE_STATE_CHANGE = 0x29,
209 CDC_NOTIF_CONNECTION_SPEED_CHANGE = 0x2A, ///< This notification allows the device to inform the host-networking driver that a change in either the upstream or the downstream bit rate of the connection has occurred
210 CDC_NOTIF_MDLM_SEMANTIC_MODEL_NOTIFICATION = 0x40,
211}cdc_notification_request_t;
212
213//--------------------------------------------------------------------+
214// Class Specific Functional Descriptor (Communication Interface)
215//--------------------------------------------------------------------+
216
217// Start of all packed definitions for compiler without per-type packed
218TU_ATTR_PACKED_BEGIN
219TU_ATTR_BIT_FIELD_ORDER_BEGIN
220
221/// Header Functional Descriptor (Communication Interface)
222typedef struct TU_ATTR_PACKED
223{
224 uint8_t bLength ; ///< Size of this descriptor in bytes.
225 uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
226 uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUNC_DESC_
227 uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal
228}cdc_desc_func_header_t;
229
230/// Union Functional Descriptor (Communication Interface)
231typedef struct TU_ATTR_PACKED
232{
233 uint8_t bLength ; ///< Size of this descriptor in bytes.
234 uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
235 uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
236 uint8_t bControlInterface ; ///< Interface number of Communication Interface
237 uint8_t bSubordinateInterface ; ///< Array of Interface number of Data Interface
238}cdc_desc_func_union_t;
239
240#define cdc_desc_func_union_n_t(no_slave)\
241 struct TU_ATTR_PACKED { \
242 uint8_t bLength ;\
243 uint8_t bDescriptorType ;\
244 uint8_t bDescriptorSubType ;\
245 uint8_t bControlInterface ;\
246 uint8_t bSubordinateInterface[no_slave] ;\
247}
248
249/// Country Selection Functional Descriptor (Communication Interface)
250typedef struct TU_ATTR_PACKED
251{
252 uint8_t bLength ; ///< Size of this descriptor in bytes.
253 uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
254 uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
255 uint8_t iCountryCodeRelDate ; ///< Index of a string giving the release date for the implemented ISO 3166 Country Codes.
256 uint16_t wCountryCode ; ///< Country code in the format as defined in [ISO3166], release date as specified inoffset 3 for the first supported country.
257}cdc_desc_func_country_selection_t;
258
259#define cdc_desc_func_country_selection_n_t(no_country) \
260 struct TU_ATTR_PACKED { \
261 uint8_t bLength ;\
262 uint8_t bDescriptorType ;\
263 uint8_t bDescriptorSubType ;\
264 uint8_t iCountryCodeRelDate ;\
265 uint16_t wCountryCode[no_country] ;\
266}
267
268//--------------------------------------------------------------------+
269// PUBLIC SWITCHED TELEPHONE NETWORK (PSTN) SUBCLASS
270//--------------------------------------------------------------------+
271
272/// \brief Call Management Functional Descriptor
273/// \details This functional descriptor describes the processing of calls for the Communications Class interface.
274typedef struct TU_ATTR_PACKED
275{
276 uint8_t bLength ; ///< Size of this descriptor in bytes.
277 uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
278 uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
279
280 struct {
281 uint8_t handle_call : 1; ///< 0 - Device sends/receives call management information only over the Communications Class interface. 1 - Device can send/receive call management information over a Data Class interface.
282 uint8_t send_recv_call : 1; ///< 0 - Device does not handle call management itself. 1 - Device handles call management itself.
283 uint8_t TU_RESERVED : 6;
284 } bmCapabilities;
285
286 uint8_t bDataInterface;
287}cdc_desc_func_call_management_t;
288
289typedef struct TU_ATTR_PACKED
290{
291 uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
292 uint8_t support_line_request : 1; ///< Device supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State.
293 uint8_t support_send_break : 1; ///< Device supports the request Send_Break
294 uint8_t support_notification_network_connection : 1; ///< Device supports the notification Network_Connection.
295 uint8_t TU_RESERVED : 4;
296}cdc_acm_capability_t;
297
298TU_VERIFY_STATIC(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler");
299
300/// Abstract Control Management Functional Descriptor
301/// This functional descriptor describes the commands supported by by the Communications Class interface with SubClass code of \ref CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL
302typedef struct TU_ATTR_PACKED
303{
304 uint8_t bLength ; ///< Size of this descriptor in bytes.
305 uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
306 uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
307 cdc_acm_capability_t bmCapabilities ;
308}cdc_desc_func_acm_t;
309
310/// \brief Direct Line Management Functional Descriptor
311/// \details This functional descriptor describes the commands supported by the Communications Class interface with SubClass code of \ref CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT
312typedef struct TU_ATTR_PACKED
313{
314 uint8_t bLength ; ///< Size of this descriptor in bytes.
315 uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
316 uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
317 struct {
318 uint8_t require_pulse_setup : 1; ///< Device requires extra Pulse_Setup request during pulse dialing sequence to disengage holding circuit.
319 uint8_t support_aux_request : 1; ///< Device supports the request combination of Set_Aux_Line_State, Ring_Aux_Jack, and notification Aux_Jack_Hook_State.
320 uint8_t support_pulse_request : 1; ///< Device supports the request combination of Pulse_Setup, Send_Pulse, and Set_Pulse_Time.
321 uint8_t TU_RESERVED : 5;
322 } bmCapabilities;
323}cdc_desc_func_direct_line_management_t;
324
325/// \brief Telephone Ringer Functional Descriptor
326/// \details The Telephone Ringer functional descriptor describes the ringer capabilities supported by the Communications Class interface,
327/// with the SubClass code of \ref CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL
328typedef struct TU_ATTR_PACKED
329{
330 uint8_t bLength ; ///< Size of this descriptor in bytes.
331 uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
332 uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
333 uint8_t bRingerVolSteps ;
334 uint8_t bNumRingerPatterns ;
335}cdc_desc_func_telephone_ringer_t;
336
337/// \brief Telephone Operational Modes Functional Descriptor
338/// \details The Telephone Operational Modes functional descriptor describes the operational modes supported by
339/// the Communications Class interface, with the SubClass code of \ref CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL
340typedef struct TU_ATTR_PACKED
341{
342 uint8_t bLength ; ///< Size of this descriptor in bytes.
343 uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
344 uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
345 struct {
346 uint8_t simple_mode : 1;
347 uint8_t standalone_mode : 1;
348 uint8_t computer_centric_mode : 1;
349 uint8_t TU_RESERVED : 5;
350 } bmCapabilities;
351}cdc_desc_func_telephone_operational_modes_t;
352
353/// \brief Telephone Call and Line State Reporting Capabilities Descriptor
354/// \details The Telephone Call and Line State Reporting Capabilities functional descriptor describes the abilities of a
355/// telephone device to report optional call and line states.
356typedef struct TU_ATTR_PACKED
357{
358 uint8_t bLength ; ///< Size of this descriptor in bytes.
359 uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
360 uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
361 struct {
362 uint32_t interrupted_dialtone : 1; ///< 0 : Reports only dialtone (does not differentiate between normal and interrupted dialtone). 1 : Reports interrupted dialtone in addition to normal dialtone
363 uint32_t ringback_busy_fastbusy : 1; ///< 0 : Reports only dialing state. 1 : Reports ringback, busy, and fast busy states.
364 uint32_t caller_id : 1; ///< 0 : Does not report caller ID. 1 : Reports caller ID information.
365 uint32_t incoming_distinctive : 1; ///< 0 : Reports only incoming ringing. 1 : Reports incoming distinctive ringing patterns.
366 uint32_t dual_tone_multi_freq : 1; ///< 0 : Cannot report dual tone multi-frequency (DTMF) digits input remotely over the telephone line. 1 : Can report DTMF digits input remotely over the telephone line.
367 uint32_t line_state_change : 1; ///< 0 : Does not support line state change notification. 1 : Does support line state change notification
368 uint32_t TU_RESERVED : 26;
369 } bmCapabilities;
370}cdc_desc_func_telephone_call_state_reporting_capabilities_t;
371
372// TODO remove
373static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
374{
375 return p_desc[2];
376}
377
378//--------------------------------------------------------------------+
379// Requests
380//--------------------------------------------------------------------+
381typedef struct TU_ATTR_PACKED
382{
383 uint32_t bit_rate;
384 uint8_t stop_bits; ///< 0: 1 stop bit - 1: 1.5 stop bits - 2: 2 stop bits
385 uint8_t parity; ///< 0: None - 1: Odd - 2: Even - 3: Mark - 4: Space
386 uint8_t data_bits; ///< can be 5, 6, 7, 8 or 16
387} cdc_line_coding_t;
388
389TU_VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");
390
391typedef struct TU_ATTR_PACKED
392{
393 uint16_t dte_is_present : 1; ///< Indicates to DCE if DTE is presentor not. This signal corresponds to V.24 signal 108/2 and RS-232 signal DTR.
394 uint16_t half_duplex_carrier_control : 1;
395 uint16_t : 14;
396} cdc_line_control_state_t;
397
398TU_VERIFY_STATIC(sizeof(cdc_line_control_state_t) == 2, "size is not correct");
399
400TU_ATTR_PACKED_END // End of all packed definitions
401TU_ATTR_BIT_FIELD_ORDER_END
402
403#ifdef __cplusplus
404 }
405#endif
406
407#endif
408
409/** @} */