| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usbd_cdc.h
Go to the documentation of this file.
1 /*
2 * @brief Boot ROM drivers/library USB Communication Device Class Definitions
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * All rights reserved.
7 *
8 * @par
9 * Software that is described herein is for illustrative purposes only
10 * which provides customers with programming information regarding the
11 * LPC products. This software is supplied "AS IS" without any warranties of
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
13 * all warranties, express or implied, including all implied warranties of
14 * merchantability, fitness for a particular purpose and non-infringement of
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
16 * or liability for the use of the software, conveys no license or rights under any
17 * patent, copyright, mask work right, or any other intellectual property rights in
18 * or to any products. NXP Semiconductors reserves the right to make changes
19 * in the software without notification. NXP Semiconductors also makes no
20 * representation or warranty that such application will be suitable for the
21 * specified use without further testing or modification.
22 *
23 * @par
24 * Permission to use, copy, modify, and distribute this software and its
25 * documentation is hereby granted, under NXP Semiconductors' and its
26 * licensor's relevant copyrights in the software, without fee, provided that it
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
28 * copyright, permission, and disclaimer notice must appear in all copies of
29 * this code.
30 */
31
32 #ifndef __CDC_H
33 #define __CDC_H
34
35 #include "usbd.h"
36
37 /*----------------------------------------------------------------------------
38 * Definitions based on usbcdc11.pdf (www.usb.org)
39 *---------------------------------------------------------------------------*/
40 /* Communication device class specification version 1.10 */
41 #define CDC_V1_10 0x0110
42
43 /* Communication interface class code */
44 /* (usbcdc11.pdf, 4.2, Table 15) */
45 #define CDC_COMMUNICATION_INTERFACE_CLASS 0x02
46
47 /* Communication interface class subclass codes */
48 /* (usbcdc11.pdf, 4.3, Table 16) */
49 #define CDC_DIRECT_LINE_CONTROL_MODEL 0x01
50 #define CDC_ABSTRACT_CONTROL_MODEL 0x02
51 #define CDC_TELEPHONE_CONTROL_MODEL 0x03
52 #define CDC_MULTI_CHANNEL_CONTROL_MODEL 0x04
53 #define CDC_CAPI_CONTROL_MODEL 0x05
54 #define CDC_ETHERNET_NETWORKING_CONTROL_MODEL 0x06
55 #define CDC_ATM_NETWORKING_CONTROL_MODEL 0x07
56
57 /* Communication interface class control protocol codes */
58 /* (usbcdc11.pdf, 4.4, Table 17) */
59 #define CDC_PROTOCOL_COMMON_AT_COMMANDS 0x01
60
61 /* Data interface class code */
62 /* (usbcdc11.pdf, 4.5, Table 18) */
63 #define CDC_DATA_INTERFACE_CLASS 0x0A
64
65 /* Data interface class protocol codes */
66 /* (usbcdc11.pdf, 4.7, Table 19) */
67 #define CDC_PROTOCOL_ISDN_BRI 0x30
68 #define CDC_PROTOCOL_HDLC 0x31
69 #define CDC_PROTOCOL_TRANSPARENT 0x32
70 #define CDC_PROTOCOL_Q921_MANAGEMENT 0x50
71 #define CDC_PROTOCOL_Q921_DATA_LINK 0x51
72 #define CDC_PROTOCOL_Q921_MULTIPLEXOR 0x52
73 #define CDC_PROTOCOL_V42 0x90
74 #define CDC_PROTOCOL_EURO_ISDN 0x91
75 #define CDC_PROTOCOL_V24_RATE_ADAPTATION 0x92
76 #define CDC_PROTOCOL_CAPI 0x93
77 #define CDC_PROTOCOL_HOST_BASED_DRIVER 0xFD
78 #define CDC_PROTOCOL_DESCRIBED_IN_PUFD 0xFE
79
80 /* Type values for bDescriptorType field of functional descriptors */
81 /* (usbcdc11.pdf, 5.2.3, Table 24) */
82 #define CDC_CS_INTERFACE 0x24
83 #define CDC_CS_ENDPOINT 0x25
84
85 /* Type values for bDescriptorSubtype field of functional descriptors */
86 /* (usbcdc11.pdf, 5.2.3, Table 25) */
87 #define CDC_HEADER 0x00
88 #define CDC_CALL_MANAGEMENT 0x01
89 #define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02
90 #define CDC_DIRECT_LINE_MANAGEMENT 0x03
91 #define CDC_TELEPHONE_RINGER 0x04
92 #define CDC_REPORTING_CAPABILITIES 0x05
93 #define CDC_UNION 0x06
94 #define CDC_COUNTRY_SELECTION 0x07
95 #define CDC_TELEPHONE_OPERATIONAL_MODES 0x08
96 #define CDC_USB_TERMINAL 0x09
97 #define CDC_NETWORK_CHANNEL 0x0A
98 #define CDC_PROTOCOL_UNIT 0x0B
99 #define CDC_EXTENSION_UNIT 0x0C
100 #define CDC_MULTI_CHANNEL_MANAGEMENT 0x0D
101 #define CDC_CAPI_CONTROL_MANAGEMENT 0x0E
102 #define CDC_ETHERNET_NETWORKING 0x0F
103 #define CDC_ATM_NETWORKING 0x10
104
105 /* CDC class-specific request codes */
106 /* (usbcdc11.pdf, 6.2, Table 46) */
107 /* see Table 45 for info about the specific requests. */
108 #define CDC_SEND_ENCAPSULATED_COMMAND 0x00
109 #define CDC_GET_ENCAPSULATED_RESPONSE 0x01
110 #define CDC_SET_COMM_FEATURE 0x02
111 #define CDC_GET_COMM_FEATURE 0x03
112 #define CDC_CLEAR_COMM_FEATURE 0x04
113 #define CDC_SET_AUX_LINE_STATE 0x10
114 #define CDC_SET_HOOK_STATE 0x11
115 #define CDC_PULSE_SETUP 0x12
116 #define CDC_SEND_PULSE 0x13
117 #define CDC_SET_PULSE_TIME 0x14
118 #define CDC_RING_AUX_JACK 0x15
119 #define CDC_SET_LINE_CODING 0x20
120 #define CDC_GET_LINE_CODING 0x21
121 #define CDC_SET_CONTROL_LINE_STATE 0x22
122 #define CDC_SEND_BREAK 0x23
123 #define CDC_SET_RINGER_PARMS 0x30
124 #define CDC_GET_RINGER_PARMS 0x31
125 #define CDC_SET_OPERATION_PARMS 0x32
126 #define CDC_GET_OPERATION_PARMS 0x33
127 #define CDC_SET_LINE_PARMS 0x34
128 #define CDC_GET_LINE_PARMS 0x35
129 #define CDC_DIAL_DIGITS 0x36
130 #define CDC_SET_UNIT_PARAMETER 0x37
131 #define CDC_GET_UNIT_PARAMETER 0x38
132 #define CDC_CLEAR_UNIT_PARAMETER 0x39
133 #define CDC_GET_PROFILE 0x3A
134 #define CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
135 #define CDC_SET_ETHERNET_PMP_FILTER 0x41
136 #define CDC_GET_ETHERNET_PMP_FILTER 0x42
137 #define CDC_SET_ETHERNET_PACKET_FILTER 0x43
138 #define CDC_GET_ETHERNET_STATISTIC 0x44
139 #define CDC_SET_ATM_DATA_FORMAT 0x50
140 #define CDC_GET_ATM_DEVICE_STATISTICS 0x51
141 #define CDC_SET_ATM_DEFAULT_VC 0x52
142 #define CDC_GET_ATM_VC_STATISTICS 0x53
143
144 /* Communication feature selector codes */
145 /* (usbcdc11.pdf, 6.2.2..6.2.4, Table 47) */
146 #define CDC_ABSTRACT_STATE 0x01
147 #define CDC_COUNTRY_SETTING 0x02
148
149 /* Feature Status returned for ABSTRACT_STATE Selector */
150 /* (usbcdc11.pdf, 6.2.3, Table 48) */
151 #define CDC_IDLE_SETTING (1 << 0)
152 #define CDC_DATA_MULTPLEXED_STATE (1 << 1)
153
154
155 /* Control signal bitmap values for the SetControlLineState request */
156 /* (usbcdc11.pdf, 6.2.14, Table 51) */
157 #define CDC_DTE_PRESENT (1 << 0)
158 #define CDC_ACTIVATE_CARRIER (1 << 1)
159
160 /* CDC class-specific notification codes */
161 /* (usbcdc11.pdf, 6.3, Table 68) */
162 /* see Table 67 for Info about class-specific notifications */
163 #define CDC_NOTIFICATION_NETWORK_CONNECTION 0x00
164 #define CDC_RESPONSE_AVAILABLE 0x01
165 #define CDC_AUX_JACK_HOOK_STATE 0x08
166 #define CDC_RING_DETECT 0x09
167 #define CDC_NOTIFICATION_SERIAL_STATE 0x20
168 #define CDC_CALL_STATE_CHANGE 0x28
169 #define CDC_LINE_STATE_CHANGE 0x29
170 #define CDC_CONNECTION_SPEED_CHANGE 0x2A
171
172 /* UART state bitmap values (Serial state notification). */
173 /* (usbcdc11.pdf, 6.3.5, Table 69) */
174 #define CDC_SERIAL_STATE_OVERRUN (1 << 6) /* receive data overrun error has occurred */
175 #define CDC_SERIAL_STATE_PARITY (1 << 5) /* parity error has occurred */
176 #define CDC_SERIAL_STATE_FRAMING (1 << 4) /* framing error has occurred */
177 #define CDC_SERIAL_STATE_RING (1 << 3) /* state of ring signal detection */
178 #define CDC_SERIAL_STATE_BREAK (1 << 2) /* state of break detection */
179 #define CDC_SERIAL_STATE_TX_CARRIER (1 << 1) /* state of transmission carrier */
180 #define CDC_SERIAL_STATE_RX_CARRIER (1 << 0) /* state of receiver carrier */
181
182
183 /*----------------------------------------------------------------------------
184 * Structures based on usbcdc11.pdf (www.usb.org)
185 *---------------------------------------------------------------------------*/
186
187 /* Header functional descriptor */
188 /* (usbcdc11.pdf, 5.2.3.1) */
189 /* This header must precede any list of class-specific descriptors. */
190 PRE_PACK struct POST_PACK _CDC_HEADER_DESCRIPTOR{
191 uint8_t bFunctionLength; /* size of this descriptor in bytes */
192 uint8_t bDescriptorType; /* CS_INTERFACE descriptor type */
193 uint8_t bDescriptorSubtype; /* Header functional descriptor subtype */
194 uint16_t bcdCDC; /* USB CDC specification release version */
195 };
196 typedef struct _CDC_HEADER_DESCRIPTOR CDC_HEADER_DESCRIPTOR;
197
198 /* Call management functional descriptor */
199 /* (usbcdc11.pdf, 5.2.3.2) */
200 /* Describes the processing of calls for the communication class interface. */
201 PRE_PACK struct POST_PACK _CDC_CALL_MANAGEMENT_DESCRIPTOR {
202 uint8_t bFunctionLength; /* size of this descriptor in bytes */
203 uint8_t bDescriptorType; /* CS_INTERFACE descriptor type */
204 uint8_t bDescriptorSubtype; /* call management functional descriptor subtype */
205 uint8_t bmCapabilities; /* capabilities that this configuration supports */
206 uint8_t bDataInterface; /* interface number of the data class interface used for call management (optional) */
207 };
208 typedef struct _CDC_CALL_MANAGEMENT_DESCRIPTOR CDC_CALL_MANAGEMENT_DESCRIPTOR;
209
210 /* Abstract control management functional descriptor */
211 /* (usbcdc11.pdf, 5.2.3.3) */
212 /* Describes the command supported by the communication interface class with the Abstract Control Model subclass code. */
213 PRE_PACK struct POST_PACK _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR {
214 uint8_t bFunctionLength; /* size of this descriptor in bytes */
215 uint8_t bDescriptorType; /* CS_INTERFACE descriptor type */
216 uint8_t bDescriptorSubtype; /* abstract control management functional descriptor subtype */
217 uint8_t bmCapabilities; /* capabilities supported by this configuration */
218 };
219 typedef struct _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR;
220
221 /* Union functional descriptors */
222 /* (usbcdc11.pdf, 5.2.3.8) */
223 /* Describes the relationship between a group of interfaces that can be considered to form a functional unit. */
224 PRE_PACK struct POST_PACK _CDC_UNION_DESCRIPTOR {
225 uint8_t bFunctionLength; /* size of this descriptor in bytes */
226 uint8_t bDescriptorType; /* CS_INTERFACE descriptor type */
227 uint8_t bDescriptorSubtype; /* union functional descriptor subtype */
228 uint8_t bMasterInterface; /* interface number designated as master */
229 };
230 typedef struct _CDC_UNION_DESCRIPTOR CDC_UNION_DESCRIPTOR;
231
232 /* Union functional descriptors with one slave interface */
233 /* (usbcdc11.pdf, 5.2.3.8) */
234 PRE_PACK struct POST_PACK _CDC_UNION_1SLAVE_DESCRIPTOR {
235 CDC_UNION_DESCRIPTOR sUnion; /* Union functional descriptor */
236 uint8_t bSlaveInterfaces[1]; /* Slave interface 0 */
237 };
238 typedef struct _CDC_UNION_1SLAVE_DESCRIPTOR CDC_UNION_1SLAVE_DESCRIPTOR;
239
240 /* Line coding structure */
241 /* Format of the data returned when a GetLineCoding request is received */
242 /* (usbcdc11.pdf, 6.2.13) */
243 PRE_PACK struct POST_PACK _CDC_LINE_CODING {
244 uint32_t dwDTERate; /* Data terminal rate in bits per second */
245 uint8_t bCharFormat; /* Number of stop bits */
246 uint8_t bParityType; /* Parity bit type */
247 uint8_t bDataBits; /* Number of data bits */
248 };
249 typedef struct _CDC_LINE_CODING CDC_LINE_CODING;
250
251 /* Notification header */
252 /* Data sent on the notification endpoint must follow this header. */
253 /* see USB_SETUP_PACKET in file usb.h */
254 typedef USB_SETUP_PACKET CDC_NOTIFICATION_HEADER;
255
256 uint32_t CALLBACK_UsbdCdc_Register_ControlInterfaceDescriptor(void);
257 uint32_t CALLBACK_UsbdCdc_Register_DataInterfaceDescriptor(void);
258 uint32_t CALLBACK_UsbdCdc_Register_LineCoding(void);
259 uint8_t CALLBACK_UsbdCdc_Register_DataInEndpointNumber(void);
260 uint8_t CALLBACK_UsbdCdc_Register_DataOutEndpointNumber(void);
261 uint8_t CALLBACK_UsbdCdc_Register_NotificationEndpointNumber(void);
262
263 uint32_t CALLBACK_UsbdCdc_Register_DataInEndpointSize(void);
264 uint32_t CALLBACK_UsbdCdc_Register_DataOutEndpointSize(void);
265 #endif /* __CDC_H */
266