1 /*
2  * @brief Virtual Comm port USB descriptors
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2013
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 #include "app_usbd_cfg.h"
33 
34 /*****************************************************************************
35  * Private types/enumerations/variables
36  ****************************************************************************/
37 
38 /*****************************************************************************
39  * Public types/enumerations/variables
40  ****************************************************************************/
41 
42 /**
43  * USB Standard Device Descriptor
44  */
45 ALIGNED(4) const uint8_t USB_DeviceDescriptor[] = {
46 	USB_DEVICE_DESC_SIZE,				/* bLength */
47 	USB_DEVICE_DESCRIPTOR_TYPE,			/* bDescriptorType */
48 	WBVAL(0x0200),						/* bcdUSB */
49 	0xEF,								/* bDeviceClass */
50 	0x02,								/* bDeviceSubClass */
51 	0x01,								/* bDeviceProtocol */
52 	USB_MAX_PACKET0,					/* bMaxPacketSize0 */
53 	WBVAL(0x1FC9),						/* idVendor */
54 	WBVAL(0x0083),						/* idProduct */
55 	WBVAL(0x0100),						/* bcdDevice */
56 	0x01,								/* iManufacturer */
57 	0x02,								/* iProduct */
58 	0x03,								/* iSerialNumber */
59 	0x01								/* bNumConfigurations */
60 };
61 
62 /**
63  * USB FSConfiguration Descriptor
64  * All Descriptors (Configuration, Interface, Endpoint, Class, Vendor)
65  */
66 ALIGNED(4) uint8_t USB_FsConfigDescriptor[] = {
67 	/* Configuration 1 */
68 	USB_CONFIGURATION_DESC_SIZE,			/* bLength */
69 	USB_CONFIGURATION_DESCRIPTOR_TYPE,		/* bDescriptorType */
70 	WBVAL(									/* wTotalLength */
71 		USB_CONFIGURATION_DESC_SIZE     +
72 		USB_INTERFACE_ASSOC_DESC_SIZE   +	/* interface association descriptor */
73 		USB_INTERFACE_DESC_SIZE         +	/* communication control interface */
74 		0x0013                          +	/* CDC functions */
75 		1 * USB_ENDPOINT_DESC_SIZE      +	/* interrupt endpoint */
76 		USB_INTERFACE_DESC_SIZE         +	/* communication data interface */
77 		2 * USB_ENDPOINT_DESC_SIZE      +	/* bulk endpoints */
78 		0
79 		),
80 	0x02,									/* bNumInterfaces */
81 	0x01,									/* bConfigurationValue */
82 	0x00,									/* iConfiguration */
83 	USB_CONFIG_SELF_POWERED,				/* bmAttributes  */
84 	USB_CONFIG_POWER_MA(500),				/* bMaxPower */
85 
86 	/* Interface association descriptor IAD*/
87 	USB_INTERFACE_ASSOC_DESC_SIZE,		/* bLength */
88 	USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE,	/* bDescriptorType */
89 	USB_CDC_CIF_NUM,					/* bFirstInterface */
90 	0x02,								/* bInterfaceCount */
91 	CDC_COMMUNICATION_INTERFACE_CLASS,	/* bFunctionClass */
92 	CDC_ABSTRACT_CONTROL_MODEL,			/* bFunctionSubClass */
93 	0x00,								/* bFunctionProtocol */
94 	0x04,								/* iFunction */
95 
96 	/* Interface 0, Alternate Setting 0, Communication class interface descriptor */
97 	USB_INTERFACE_DESC_SIZE,			/* bLength */
98 	USB_INTERFACE_DESCRIPTOR_TYPE,		/* bDescriptorType */
99 	USB_CDC_CIF_NUM,					/* bInterfaceNumber: Number of Interface */
100 	0x00,								/* bAlternateSetting: Alternate setting */
101 	0x01,								/* bNumEndpoints: One endpoint used */
102 	CDC_COMMUNICATION_INTERFACE_CLASS,	/* bInterfaceClass: Communication Interface Class */
103 	CDC_ABSTRACT_CONTROL_MODEL,			/* bInterfaceSubClass: Abstract Control Model */
104 	0x00,								/* bInterfaceProtocol: no protocol used */
105 	0x04,								/* iInterface: */
106 	/* Header Functional Descriptor*/
107 	0x05,								/* bLength: CDC header Descriptor size */
108 	CDC_CS_INTERFACE,					/* bDescriptorType: CS_INTERFACE */
109 	CDC_HEADER,							/* bDescriptorSubtype: Header Func Desc */
110 	WBVAL(CDC_V1_10),					/* bcdCDC 1.10 */
111 	/* Call Management Functional Descriptor*/
112 	0x05,								/* bFunctionLength */
113 	CDC_CS_INTERFACE,					/* bDescriptorType: CS_INTERFACE */
114 	CDC_CALL_MANAGEMENT,				/* bDescriptorSubtype: Call Management Func Desc */
115 	0x01,								/* bmCapabilities: device handles call management */
116 	USB_CDC_DIF_NUM,					/* bDataInterface: CDC data IF ID */
117 	/* Abstract Control Management Functional Descriptor*/
118 	0x04,								/* bFunctionLength */
119 	CDC_CS_INTERFACE,					/* bDescriptorType: CS_INTERFACE */
120 	CDC_ABSTRACT_CONTROL_MANAGEMENT,	/* bDescriptorSubtype: Abstract Control Management desc */
121 	0x02,								/* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */
122 	/* Union Functional Descriptor*/
123 	0x05,								/* bFunctionLength */
124 	CDC_CS_INTERFACE,					/* bDescriptorType: CS_INTERFACE */
125 	CDC_UNION,							/* bDescriptorSubtype: Union func desc */
126 	USB_CDC_CIF_NUM,					/* bMasterInterface: Communication class interface is master */
127 	USB_CDC_DIF_NUM,					/* bSlaveInterface0: Data class interface is slave 0 */
128 	/* Endpoint 1 Descriptor*/
129 	USB_ENDPOINT_DESC_SIZE,				/* bLength */
130 	USB_ENDPOINT_DESCRIPTOR_TYPE,		/* bDescriptorType */
131 	USB_CDC_INT_EP,						/* bEndpointAddress */
132 	USB_ENDPOINT_TYPE_INTERRUPT,		/* bmAttributes */
133 	WBVAL(0x0010),						/* wMaxPacketSize */
134 	0x02,			/* 2ms */           /* bInterval */
135 
136 	/* Interface 1, Alternate Setting 0, Data class interface descriptor*/
137 	USB_INTERFACE_DESC_SIZE,			/* bLength */
138 	USB_INTERFACE_DESCRIPTOR_TYPE,		/* bDescriptorType */
139 	USB_CDC_DIF_NUM,					/* bInterfaceNumber: Number of Interface */
140 	0x00,								/* bAlternateSetting: no alternate setting */
141 	0x02,								/* bNumEndpoints: two endpoints used */
142 	CDC_DATA_INTERFACE_CLASS,			/* bInterfaceClass: Data Interface Class */
143 	0x00,								/* bInterfaceSubClass: no subclass available */
144 	0x00,								/* bInterfaceProtocol: no protocol used */
145 	0x04,								/* iInterface: */
146 	/* Endpoint, EP Bulk Out */
147 	USB_ENDPOINT_DESC_SIZE,				/* bLength */
148 	USB_ENDPOINT_DESCRIPTOR_TYPE,		/* bDescriptorType */
149 	USB_CDC_OUT_EP,						/* bEndpointAddress */
150 	USB_ENDPOINT_TYPE_BULK,				/* bmAttributes */
151 	WBVAL(USB_FS_MAX_BULK_PACKET),		/* wMaxPacketSize */
152 	0x00,								/* bInterval: ignore for Bulk transfer */
153 	/* Endpoint, EP Bulk In */
154 	USB_ENDPOINT_DESC_SIZE,				/* bLength */
155 	USB_ENDPOINT_DESCRIPTOR_TYPE,		/* bDescriptorType */
156 	USB_CDC_IN_EP,						/* bEndpointAddress */
157 	USB_ENDPOINT_TYPE_BULK,				/* bmAttributes */
158 	WBVAL(64),							/* wMaxPacketSize */
159 	0x00,								/* bInterval: ignore for Bulk transfer */
160 	/* Terminator */
161 	0									/* bLength */
162 };
163 
164 /**
165  * USB String Descriptor (optional)
166  */
167 ALIGNED(4) const uint8_t USB_StringDescriptor[] = {
168 	/* Index 0x00: LANGID Codes */
169 	0x04,								/* bLength */
170 	USB_STRING_DESCRIPTOR_TYPE,			/* bDescriptorType */
171 	WBVAL(0x0409),	/* US English */    /* wLANGID */
172 	/* Index 0x01: Manufacturer */
173 	(3 * 2 + 2),						/* bLength (13 Char + Type + lenght) */
174 	USB_STRING_DESCRIPTOR_TYPE,			/* bDescriptorType */
175 	'N', 0,
176 	'X', 0,
177 	'P', 0,
178 	/* Index 0x02: Product */
179 	(9 * 2 + 2),						/* bLength */
180 	USB_STRING_DESCRIPTOR_TYPE,			/* bDescriptorType */
181 	'V', 0,
182 	'C', 0,
183 	'O', 0,
184 	'M', 0,
185 	' ', 0,
186 	'P', 0,
187 	'o', 0,
188 	'r', 0,
189 	't', 0,
190 	/* Index 0x03: Serial Number */
191 	(6 * 2 + 2),						/* bLength (8 Char + Type + lenght) */
192 	USB_STRING_DESCRIPTOR_TYPE,			/* bDescriptorType */
193 	'N', 0,
194 	'X', 0,
195 	'P', 0,
196 	'-', 0,
197 	'7', 0,
198 	'7', 0,
199 	/* Index 0x04: Interface 1, Alternate Setting 0 */
200 	( 4 * 2 + 2),						/* bLength (4 Char + Type + lenght) */
201 	USB_STRING_DESCRIPTOR_TYPE,			/* bDescriptorType */
202 	'V', 0,
203 	'C', 0,
204 	'O', 0,
205 	'M', 0,
206 };
207