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