STM32 USB DUAL CDC

  1 /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
  2 * File Name          : usb_desc.c
  3 * Author             : MCD Application Team
  4 * Version            : V3.1.1
  5 * Date               : 04/07/2010
  6 * Description        : Descriptors for Virtual Com Port Demo
  7 ********************************************************************************
  8 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  9 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
 10 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
 11 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
 12 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
 13 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
 14 *******************************************************************************/
 15 
 16 /* Includes ------------------------------------------------------------------*/
 17 #include "usb_lib.h"
 18 #include "usb_desc.h"
 19 
 20 /* USB Standard Device Descriptor */
 21 const uint8_t Virtual_Com_Port_DeviceDescriptor[] =
 22   {
 23     0x12,   /* bLength */
 24     USB_DEVICE_DESCRIPTOR_TYPE,     /* bDescriptorType */
 25     0x00,
 26     0x02,   /* bcdUSB = 2.00 */
 27             /* Multi-Interface Function Class Code : 0xEF 0x02 0x01 */   
 28     0xEF,   /* bDeviceClass    : Miscellaneous Device Class : CDC */
 29     0x02,   /* bDeviceSubClass : Common Class */
 30     0x01,   /* bDeviceProtocol : IAD : Interface Association Descriptor */
 31 
 32     0x40,   /* bMaxPacketSize0 */
 33     0xEB,
 34     0x03,   /* idVendor = 0x03EB */
 35     0x33,
 36     0x61,   /* idProduct = 0x6133 */
 37     
 38     0x00,
 39     0x02,   /* bcdDevice = 2.00 */
 40     1,      /* Index of string descriptor describing manufacturer */
 41     2,      /* Index of string descriptor describing product */
 42     3,      /* Index of string descriptor describing the device's serial number */
 43     0x01    /* bNumConfigurations */
 44   };
 45 
 46 const uint8_t Virtual_Com_Port_ConfigDescriptor[] =
 47   {
 48     /*Configuation Descriptor*/
 49     0x09,   /* bLength: Configuation Descriptor size */
 50     USB_CONFIGURATION_DESCRIPTOR_TYPE,      /* bDescriptorType: Configuration */
 51     VIRTUAL_COM_PORT_SIZ_CONFIG_DESC,       /* wTotalLength:no of returned bytes */
 52     0x00,
 53     0x04,   /* bNumInterfaces: 4 interface */
 54     0x01,   /* bConfigurationValue: Configuration value */
 55     0x00,   /* iConfiguration: Index of string descriptor describing the configuration */
 56     0xC0,   /* bmAttributes: self powered */
 57     0x32,   /* MaxPower 100 mA */
 58 
 59 // IAD
 60     0x08,    // bLength: Interface Descriptor size
 61     0x0B,        // bDescriptorType: IAD
 62     0x00,    // bFirstInterface
 63     0x02,    // bInterfaceCount
 64     0x02,    // bFunctionClass: CDC
 65     0x02,    // bFunctionSubClass
 66     0x01,    // bFunctionProtocol 
 67     0x02,    // iFunction
 68     
 69     /*Interface Descriptor*/
 70     0x09,   /* bLength: Interface Descriptor size */
 71     USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: Interface */
 72     /* Interface descriptor type */
 73     0x00,   /* bInterfaceNumber: Number of Interface */
 74     0x00,   /* bAlternateSetting: Alternate setting */
 75     0x01,   /* bNumEndpoints: One endpoints used */
 76     0x02,   /* bInterfaceClass: Communication Interface Class */
 77     0x02,   /* bInterfaceSubClass: Abstract Control Model */
 78     0x01,   /* bInterfaceProtocol: Common AT commands */
 79     0x00,   /* iInterface: */
80 /*Header Functional Descriptor*/ 81 0x05, /* bLength: Endpoint Descriptor size */ 82 0x24, /* bDescriptorType: CS_INTERFACE */ 83 0x00, /* bDescriptorSubtype: Header Func Desc */ 84 0x10, /* bcdCDC: spec release number */ 85 0x01,
86 /*Call Managment Functional Descriptor*/ 87 0x05, /* bFunctionLength */ 88 0x24, /* bDescriptorType: CS_INTERFACE */ 89 0x01, /* bDescriptorSubtype: Call Management Func Desc */ 90 0x00, /* bmCapabilities: D0+D1 */ 91 0x01, /* bDataInterface: 1 */

92 /*ACM Functional Descriptor*/ 93 0x04, /* bFunctionLength */ 94 0x24, /* bDescriptorType: CS_INTERFACE */ 95 0x02, /* bDescriptorSubtype: Abstract Control Management desc */ 96 0x02, /* bmCapabilities */
 97     /*Union Functional Descriptor*/
 98     0x05,   /* bFunctionLength */
 99     0x24,   /* bDescriptorType: CS_INTERFACE */
100     0x06,   /* bDescriptorSubtype: Union func desc */
101     0x00,   /* bMasterInterface: Communication class interface */
102     0x01,   /* bSlaveInterface0: Data Class Interface */

103 /*Endpoint 2 Descriptor*/ 104 0x07, /* bLength: Endpoint Descriptor size */ 105 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 106 0x82, /* bEndpointAddress: (IN2) */ 107 0x03, /* bmAttributes: Interrupt */ 108 VIRTUAL_COM_PORT_INT_SIZE, /* wMaxPacketSize: */ 109 0x00, 110 0xFF, /* bInterval: */

111 /*Data class interface descriptor*/ 112 0x09, /* bLength: Endpoint Descriptor size */ 113 USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */ 114 0x01, /* bInterfaceNumber: Number of Interface */ 115 0x00, /* bAlternateSetting: Alternate setting */ 116 0x02, /* bNumEndpoints: Two endpoints used */ 117 0x0A, /* bInterfaceClass: CDC */ 118 0x00, /* bInterfaceSubClass: */ 119 0x00, /* bInterfaceProtocol: */ 120 0x00, /* iInterface: */

121 /*Endpoint 3 Descriptor*/ 122 0x07, /* bLength: Endpoint Descriptor size */ 123 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 124 0x03, /* bEndpointAddress: (OUT3) */ 125 0x02, /* bmAttributes: Bulk */ 126 VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */ 127 0x00, 128 0x00, /* bInterval: ignore for Bulk transfer */

129 /*Endpoint 1 Descriptor*/ 130 0x07, /* bLength: Endpoint Descriptor size */ 131 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 132 0x81, /* bEndpointAddress: (IN1) */ 133 0x02, /* bmAttributes: Bulk */ 134 VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */ 135 0x00, 136 0x00, /* bInterval */ 137 138 // IAD 139 0x08, // bLength: Interface Descriptor size 140 0x0B, // bDescriptorType: IAD 141 0x02, // bFirstInterface 142 0x02, // bInterfaceCount 143 0x02, // bFunctionClass: CDC 144 0x02, // bFunctionSubClass 145 0x01, // bFunctionProtocol
1460x02, // iFunction

147 /*Interface Descriptor*/ 148 0x09, /* bLength: Interface Descriptor size */ 149 USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */ 150 /* Interface descriptor type */ 151 0x02, /* bInterfaceNumber: Number of Interface */ 152 0x00, /* bAlternateSetting: Alternate setting */ 153 0x01, /* bNumEndpoints: One endpoints used */ 154 0x02, /* bInterfaceClass: Communication Interface Class */ 155 0x02, /* bInterfaceSubClass: Abstract Control Model */ 156 0x01, /* bInterfaceProtocol: Common AT commands */ 157 0x00, /* iInterface: */

158 /*Header Functional Descriptor*/ 159 0x05, /* bLength: Endpoint Descriptor size */ 160 0x24, /* bDescriptorType: CS_INTERFACE */ 161 0x00, /* bDescriptorSubtype: Header Func Desc */ 162 0x10, /* bcdCDC: spec release number */ 163 0x01,
164 /*Call Managment Functional Descriptor*/ 165 0x05, /* bFunctionLength */ 166 0x24, /* bDescriptorType: CS_INTERFACE */ 167 0x01, /* bDescriptorSubtype: Call Management Func Desc */ 168 0x00, /* bmCapabilities: D0+D1 */ 169 0x03, /* !! bDataInterface: */

170 /*ACM Functional Descriptor*/ 171 0x04, /* bFunctionLength */ 172 0x24, /* bDescriptorType: CS_INTERFACE */ 173 0x02, /* bDescriptorSubtype: Abstract Control Management desc */ 174 0x02, /* bmCapabilities */

175 /*Union Functional Descriptor*/ 176 0x05, /* bFunctionLength */ 177 0x24, /* bDescriptorType: CS_INTERFACE */ 178 0x06, /* bDescriptorSubtype: Union func desc */ 179 0x02, /* !! bMasterInterface: Communication class interface */ 180 0x03, /* !! bSlaveInterface0: Data Class Interface */

181 /*Endpoint 2 Descriptor*/ 182 0x07, /* bLength: Endpoint Descriptor size */ 183 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 184 0x85, /* bEndpointAddress: (IN2) */ 185 0x03, /* bmAttributes: Interrupt */ 186 VIRTUAL_COM_PORT_INT_SIZE, /* wMaxPacketSize: */ 187 0x00, 188 0xFF, /* bInterval: */ 189 190 /*Data class interface descriptor*/ 191 0x09, /* bLength: Endpoint Descriptor size */ 192 USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */ 193 0x03, /* bInterfaceNumber: Number of Interface */ 194 0x00, /* bAlternateSetting: Alternate setting */ 195 0x02, /* bNumEndpoints: Two endpoints used */ 196 0x0A, /* bInterfaceClass: CDC */ 197 0x00, /* bInterfaceSubClass: */ 198 0x00, /* bInterfaceProtocol: */ 199 0x00, /* iInterface: */

200 /*Endpoint 3 Descriptor*/ 201 0x07, /* bLength: Endpoint Descriptor size */ 202 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 203 0x06, /* bEndpointAddress: (OUT3) */ 204 0x02, /* bmAttributes: Bulk */ 205 VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */ 206 0x00, 207 0x00, /* bInterval: ignore for Bulk transfer */

208 /*Endpoint 1 Descriptor*/ 209 0x07, /* bLength: Endpoint Descriptor size */ 210 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 211 0x84, /* bEndpointAddress: (IN1) */ 212 0x02, /* bmAttributes: Bulk */ 213 VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */ 214 0x00, 215 0x00 /* bInterval */ 216 }; 217 218 /* USB String Descriptors */ 219 const uint8_t Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID] = 220 { 221 VIRTUAL_COM_PORT_SIZ_STRING_LANGID, 222 USB_STRING_DESCRIPTOR_TYPE, 223 0x09, 224 0x04 /* LangID = 0x0409: U.S. English */ 225 }; 226 227 const uint8_t Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR] = 228 { 229 VIRTUAL_COM_PORT_SIZ_STRING_VENDOR, /* Size of Vendor string */ 230 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType*/ 231 /* Manufacturer: "STMicroelectronics" */ 232 'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0, 233 'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0, 234 'c', 0, 's', 0 235 }; 236 237 const uint8_t Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT] = 238 { 239 VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT, /* bLength */ 240 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 241 /* Product name: "STM32 Virtual COM Port" */ 242 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'V', 0, 'i', 0, 243 'r', 0, 't', 0, 'u', 0, 'a', 0, 'l', 0, ' ', 0, 'C', 0, 'O', 0, 244 'M', 0, ' ', 0, 'P', 0, 'o', 0, 'r', 0, 't', 0, ' ', 0, ' ', 0 245 }; 246 247 uint8_t Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_SIZ_STRING_SERIAL] = 248 { 249 VIRTUAL_COM_PORT_SIZ_STRING_SERIAL, /* bLength */ 250 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 251 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, '1', 0, '0', 0 252 }; 253 254 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
 1 ; 
 2 ; STMicroelectronics Comunication Device Class driver instalation file
 3 ; (C)2006 Copyright STMicroelectronics
 4 ;
 5 
 6 [Version] 
 7 Signature="$Windows NT$" 
 8 Class=Ports
 9 ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} 
10 Provider=%STM% 
11 LayoutFile=layout.inf
12 DriverVer=10/02/06
13 
14 [Manufacturer] 
15 %STM%=DeviceList
16 
17 [DestinationDirs] 
18 DefaultDestDir=12 
19 
20 [SourceDisksFiles]
21 
22 [SourceDisksNames]
23 
24 [DeviceList] 
25 %DESCRIPTION%=STMUSB, USB\VID_03EB&PID_6133&MI_00 
26 %DESCRIPTION%=STMUSB, USB\VID_03EB&PID_6133&MI_02 
27 ;------------------------------------------------------------------------------
28 ;  Windows 2000/XP Sections
29 ;------------------------------------------------------------------------------
30 
31 [STMUSB.nt] 
32 include=mdmcpq.inf
33 CopyFiles=DriverCopyFiles
34 AddReg=STMUSB.nt.AddReg 
35 
36 [DriverCopyFiles]
37 usbser.sys,,,0x20
38 
39 [STMUSB.nt.AddReg] 
40 HKR,,DevLoader,,*ntkern 
41 HKR,,NTMPDriver,,usbser.sys 
42 HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 
43 
44 [STMUSB.nt.Services] 
45 AddService=usbser, 0x00000002, DriverService
46 
47 
48 [STMUSB.nt.HW]
49 include=mdmcpq.inf
50 
51 [DriverService] 
52 DisplayName=%DESCRIPTION% 
53 ServiceType=1
54 StartType=3
55 ErrorControl=1
56 ServiceBinary=%12%\usbser.sys 
57 
58 ;------------------------------------------------------------------------------
59 ;  String Definitions
60 ;------------------------------------------------------------------------------
61 
62 [Strings] 
63 STM="STMicroelectronics"
64 DESCRIPTION="STM32F10x DUAL CDC" 

你可能感兴趣的:(stm32)