1 /*----------------------------------------------------------------------------
3 *----------------------------------------------------------------------------
5 * Purpose: USB Communication Device Class Definitions
7 *----------------------------------------------------------------------------
8 * This software is supplied "AS IS" without any warranties, express,
9 * implied or statutory, including but not limited to the implied
10 * warranties of fitness for purpose, satisfactory quality and
11 * noninfringement. Keil extends you a royalty-free right to reproduce
12 * and distribute executable files created using this software for use
13 * on NXP Semiconductors LPC family microcontroller devices only. Nothing
14 * else gives you the right to use this software.
16 * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17 *---------------------------------------------------------------------------*/
21 #include "lpc_types.h"
23 #if defined ( __GNUC__ )
24 #define __packed __attribute__((__packed__))
26 /*----------------------------------------------------------------------------
27 * Definitions based on usbcdc11.pdf (www.usb.org)
28 *---------------------------------------------------------------------------*/
29 // Communication device class specification version 1.10
30 #define CDC_V1_10 0x0110
32 // Communication interface class code
33 // (usbcdc11.pdf, 4.2, Table 15)
34 #define CDC_COMMUNICATION_INTERFACE_CLASS 0x02
36 // Communication interface class subclass codes
37 // (usbcdc11.pdf, 4.3, Table 16)
38 #define CDC_DIRECT_LINE_CONTROL_MODEL 0x01
39 #define CDC_ABSTRACT_CONTROL_MODEL 0x02
40 #define CDC_TELEPHONE_CONTROL_MODEL 0x03
41 #define CDC_MULTI_CHANNEL_CONTROL_MODEL 0x04
42 #define CDC_CAPI_CONTROL_MODEL 0x05
43 #define CDC_ETHERNET_NETWORKING_CONTROL_MODEL 0x06
44 #define CDC_ATM_NETWORKING_CONTROL_MODEL 0x07
46 // Communication interface class control protocol codes
47 // (usbcdc11.pdf, 4.4, Table 17)
48 #define CDC_PROTOCOL_COMMON_AT_COMMANDS 0x01
50 // Data interface class code
51 // (usbcdc11.pdf, 4.5, Table 18)
52 #define CDC_DATA_INTERFACE_CLASS 0x0A
54 // Data interface class protocol codes
55 // (usbcdc11.pdf, 4.7, Table 19)
56 #define CDC_PROTOCOL_ISDN_BRI 0x30
57 #define CDC_PROTOCOL_HDLC 0x31
58 #define CDC_PROTOCOL_TRANSPARENT 0x32
59 #define CDC_PROTOCOL_Q921_MANAGEMENT 0x50
60 #define CDC_PROTOCOL_Q921_DATA_LINK 0x51
61 #define CDC_PROTOCOL_Q921_MULTIPLEXOR 0x52
62 #define CDC_PROTOCOL_V42 0x90
63 #define CDC_PROTOCOL_EURO_ISDN 0x91
64 #define CDC_PROTOCOL_V24_RATE_ADAPTATION 0x92
65 #define CDC_PROTOCOL_CAPI 0x93
66 #define CDC_PROTOCOL_HOST_BASED_DRIVER 0xFD
67 #define CDC_PROTOCOL_DESCRIBED_IN_PUFD 0xFE
69 // Type values for bDescriptorType field of functional descriptors
70 // (usbcdc11.pdf, 5.2.3, Table 24)
71 #define CDC_CS_INTERFACE 0x24
72 #define CDC_CS_ENDPOINT 0x25
74 // Type values for bDescriptorSubtype field of functional descriptors
75 // (usbcdc11.pdf, 5.2.3, Table 25)
76 #define CDC_HEADER 0x00
77 #define CDC_CALL_MANAGEMENT 0x01
78 #define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02
79 #define CDC_DIRECT_LINE_MANAGEMENT 0x03
80 #define CDC_TELEPHONE_RINGER 0x04
81 #define CDC_REPORTING_CAPABILITIES 0x05
82 #define CDC_UNION 0x06
83 #define CDC_COUNTRY_SELECTION 0x07
84 #define CDC_TELEPHONE_OPERATIONAL_MODES 0x08
85 #define CDC_USB_TERMINAL 0x09
86 #define CDC_NETWORK_CHANNEL 0x0A
87 #define CDC_PROTOCOL_UNIT 0x0B
88 #define CDC_EXTENSION_UNIT 0x0C
89 #define CDC_MULTI_CHANNEL_MANAGEMENT 0x0D
90 #define CDC_CAPI_CONTROL_MANAGEMENT 0x0E
91 #define CDC_ETHERNET_NETWORKING 0x0F
92 #define CDC_ATM_NETWORKING 0x10
94 // CDC class-specific request codes
95 // (usbcdc11.pdf, 6.2, Table 46)
96 // see Table 45 for info about the specific requests.
97 #define CDC_SEND_ENCAPSULATED_COMMAND 0x00
98 #define CDC_GET_ENCAPSULATED_RESPONSE 0x01
99 #define CDC_SET_COMM_FEATURE 0x02
100 #define CDC_GET_COMM_FEATURE 0x03
101 #define CDC_CLEAR_COMM_FEATURE 0x04
102 #define CDC_SET_AUX_LINE_STATE 0x10
103 #define CDC_SET_HOOK_STATE 0x11
104 #define CDC_PULSE_SETUP 0x12
105 #define CDC_SEND_PULSE 0x13
106 #define CDC_SET_PULSE_TIME 0x14
107 #define CDC_RING_AUX_JACK 0x15
108 #define CDC_SET_LINE_CODING 0x20
109 #define CDC_GET_LINE_CODING 0x21
110 #define CDC_SET_CONTROL_LINE_STATE 0x22
111 #define CDC_SEND_BREAK 0x23
112 #define CDC_SET_RINGER_PARMS 0x30
113 #define CDC_GET_RINGER_PARMS 0x31
114 #define CDC_SET_OPERATION_PARMS 0x32
115 #define CDC_GET_OPERATION_PARMS 0x33
116 #define CDC_SET_LINE_PARMS 0x34
117 #define CDC_GET_LINE_PARMS 0x35
118 #define CDC_DIAL_DIGITS 0x36
119 #define CDC_SET_UNIT_PARAMETER 0x37
120 #define CDC_GET_UNIT_PARAMETER 0x38
121 #define CDC_CLEAR_UNIT_PARAMETER 0x39
122 #define CDC_GET_PROFILE 0x3A
123 #define CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
124 #define CDC_SET_ETHERNET_PMP_FILTER 0x41
125 #define CDC_GET_ETHERNET_PMP_FILTER 0x42
126 #define CDC_SET_ETHERNET_PACKET_FILTER 0x43
127 #define CDC_GET_ETHERNET_STATISTIC 0x44
128 #define CDC_SET_ATM_DATA_FORMAT 0x50
129 #define CDC_GET_ATM_DEVICE_STATISTICS 0x51
130 #define CDC_SET_ATM_DEFAULT_VC 0x52
131 #define CDC_GET_ATM_VC_STATISTICS 0x53
133 // Communication feature selector codes
134 // (usbcdc11.pdf, 6.2.2..6.2.4, Table 47)
135 #define CDC_ABSTRACT_STATE 0x01
136 #define CDC_COUNTRY_SETTING 0x02
138 // Feature Status returned for ABSTRACT_STATE Selector
139 // (usbcdc11.pdf, 6.2.3, Table 48)
140 #define CDC_IDLE_SETTING (1 << 0)
141 #define CDC_DATA_MULTPLEXED_STATE (1 << 1)
144 // Control signal bitmap values for the SetControlLineState request
145 // (usbcdc11.pdf, 6.2.14, Table 51)
146 #define CDC_DTE_PRESENT (1 << 0)
147 #define CDC_ACTIVATE_CARRIER (1 << 1)
149 // CDC class-specific notification codes
150 // (usbcdc11.pdf, 6.3, Table 68)
151 // see Table 67 for Info about class-specific notifications
152 #define CDC_NOTIFICATION_NETWORK_CONNECTION 0x00
153 #define CDC_RESPONSE_AVAILABLE 0x01
154 #define CDC_AUX_JACK_HOOK_STATE 0x08
155 #define CDC_RING_DETECT 0x09
156 #define CDC_NOTIFICATION_SERIAL_STATE 0x20
157 #define CDC_CALL_STATE_CHANGE 0x28
158 #define CDC_LINE_STATE_CHANGE 0x29
159 #define CDC_CONNECTION_SPEED_CHANGE 0x2A
161 // UART state bitmap values (Serial state notification).
162 // (usbcdc11.pdf, 6.3.5, Table 69)
163 #define CDC_SERIAL_STATE_OVERRUN (1 << 6) // receive data overrun error has occurred
164 #define CDC_SERIAL_STATE_PARITY (1 << 5) // parity error has occurred
165 #define CDC_SERIAL_STATE_FRAMING (1 << 4) // framing error has occurred
166 #define CDC_SERIAL_STATE_RING (1 << 3) // state of ring signal detection
167 #define CDC_SERIAL_STATE_BREAK (1 << 2) // state of break detection
168 #define CDC_SERIAL_STATE_TX_CARRIER (1 << 1) // state of transmission carrier
169 #define CDC_SERIAL_STATE_RX_CARRIER (1 << 0) // state of receiver carrier
172 /*----------------------------------------------------------------------------
173 * Structures based on usbcdc11.pdf (www.usb.org)
174 *---------------------------------------------------------------------------*/
176 // Header functional descriptor
177 // (usbcdc11.pdf, 5.2.3.1)
178 // This header must precede any list of class-specific descriptors.
180 #if defined ( __CC_ARM )
181 typedef __packed struct _CDC_HEADER_DESCRIPTOR{
182 #elif defined ( __GNUC__ )
183 typedef struct __packed _CDC_HEADER_DESCRIPTOR{
184 #elif defined ( __IAR_SYSTEMS_ICC__ )
186 typedef struct _CDC_HEADER_DESCRIPTOR {
188 uint8_t bFunctionLength; // size of this descriptor in bytes
189 uint8_t bDescriptorType; // CS_INTERFACE descriptor type
190 uint8_t bDescriptorSubtype; // Header functional descriptor subtype
191 uint16_t bcdCDC; // USB CDC specification release version
192 } CDC_HEADER_DESCRIPTOR;
194 //Call management functional descriptor
195 // (usbcdc11.pdf, 5.2.3.2)
196 // Describes the processing of calls for the communication class interface.
197 #if defined ( __CC_ARM )
198 typedef __packed struct _CDC_CALL_MANAGEMENT_DESCRIPTOR{
199 #elif defined ( __GNUC__ )
200 typedef struct __packed _CDC_CALL_MANAGEMENT_DESCRIPTOR{
201 #elif defined ( __IAR_SYSTEMS_ICC__ )
203 typedef struct _CDC_CALL_MANAGEMENT_DESCRIPTOR {
205 uint8_t bFunctionLength; // size of this descriptor in bytes
206 uint8_t bDescriptorType; // CS_INTERFACE descriptor type
207 uint8_t bDescriptorSubtype; // call management functional descriptor subtype
208 uint8_t bmCapabilities; // capabilities that this configuration supports
209 uint8_t bDataInterface; // interface number of the data class interface used for call management (optional)
210 } CDC_CALL_MANAGEMENT_DESCRIPTOR;
212 // Abstract control management functional descriptor
213 // (usbcdc11.pdf, 5.2.3.3)
214 // Describes the command supported by the communication interface class with the Abstract Control Model subclass code.
215 #if defined ( __CC_ARM )
216 typedef __packed struct _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR{
217 #elif defined ( __GNUC__ )
218 typedef struct __packed _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR{
219 #elif defined ( __IAR_SYSTEMS_ICC__ )
221 typedef struct _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR {
223 uint8_t bFunctionLength; // size of this descriptor in bytes
224 uint8_t bDescriptorType; // CS_INTERFACE descriptor type
225 uint8_t bDescriptorSubtype; // abstract control management functional descriptor subtype
226 uint8_t bmCapabilities; // capabilities supported by this configuration
227 } CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR;
229 // Union functional descriptors
230 // (usbcdc11.pdf, 5.2.3.8)
231 // Describes the relationship between a group of interfaces that can be considered to form a functional unit.
232 #if defined ( __CC_ARM )
233 typedef __packed struct _CDC_UNION_DESCRIPTOR{
234 #elif defined ( __GNUC__ )
235 typedef struct __packed _CDC_UNION_DESCRIPTOR{
236 #elif defined ( __IAR_SYSTEMS_ICC__ )
238 typedef struct _CDC_UNION_DESCRIPTOR {
240 uint8_t bFunctionLength; // size of this descriptor in bytes
241 uint8_t bDescriptorType; // CS_INTERFACE descriptor type
242 uint8_t bDescriptorSubtype; // union functional descriptor subtype
243 uint8_t bMasterInterface; // interface number designated as master
244 } CDC_UNION_DESCRIPTOR;
246 // Union functional descriptors with one slave interface
247 // (usbcdc11.pdf, 5.2.3.8)
248 #if defined ( __CC_ARM )
249 typedef __packed struct _CDC_UNION_1SLAVE_DESCRIPTOR{
250 #elif defined ( __GNUC__ )
251 typedef struct __packed _CDC_UNION_1SLAVE_DESCRIPTOR{
252 #elif defined ( __IAR_SYSTEMS_ICC__ )
254 typedef struct _CDC_UNION_1SLAVE_DESCRIPTOR {
256 CDC_UNION_DESCRIPTOR sUnion; // Union functional descriptor
257 uint8_t bSlaveInterfaces[1]; // Slave interface 0
258 } CDC_UNION_1SLAVE_DESCRIPTOR;
260 // Line coding structure
261 // Format of the data returned when a GetLineCoding request is received
262 // (usbcdc11.pdf, 6.2.13)
263 #if defined ( __CC_ARM )
264 typedef __packed struct _CDC_LINE_CODING{
265 #elif defined ( __GNUC__ )
266 typedef struct __packed _CDC_LINE_CODING{
267 #elif defined ( __IAR_SYSTEMS_ICC__ )
269 typedef struct _CDC_LINE_CODING {
271 uint32_t dwDTERate; // Data terminal rate in bits per second
272 uint8_t bCharFormat; // Number of stop bits
273 uint8_t bParityType; // Parity bit type
274 uint8_t bDataBits; // Number of data bits
277 // Notification header
278 // Data sent on the notification endpoint must follow this header.
279 // see USB_SETUP_PACKET in file usb.h
280 typedef USB_SETUP_PACKET CDC_NOTIFICATION_HEADER;