你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【经验分享】STM32 -- Multiple USB CDC (USB IAD)

[复制链接]
STMCU小助手 发布时间:2022-2-6 22:31
One CDC function requires 2 IN / 1 OUT endpoints (interrupt IN/ bulk IN/ bulk OUT), other than the default EP.
Available endpoints of each STM32F family are,

STM32F102/103 - FS Device core: 7 IN / 7 OUT
STM32F105/107 - OTG_FS: 3 IN / 3 OUT
STM32F2xx/4xx - OTG_FS: 3 IN / 3 OUT
STM32F2xx/4xx - OTG_HS: 5 IN / 5 OUT

STM32F102/103 - 3x CDC composite [ 6 IN - 3 OUT ]
STM32F105/107 - just one CDC [ 2 IN - 1 OUT ]
STM32F2xx/4xx - 2x CDC composite on OTG_HS [ 4 IN - 2 OUT ]

080100415652602.png

Starting from ST's example, it isn't so hard, to make them a CDC composite device,
if you would know where and how to touch on the source code :-)
OK, then let's start here on this thread.

The agenda of modification is,
1) Descriptors and INF file
2) Bulk IN/OUT endpoints
3) Class requests

The base ST example is STM32F10x and STM32L1xx USB full-speed device library v3.4.0

\STM32_USB-FS-Device_Lib_V3.4.0\Project\Virtual_COM_Port

We'll make 3x CDC composite device.

1) Descriptors

First the device descriptor is modified at class/subclass/protocol and VID/PID (idVendor/idProduct) fields.
We assign temporary VID/PID just for this development. Get official VID/PID afterward.
Virtual_Com_Port_DeviceDescriptor() is replaced, as follows.

usb_desc.c
  1. /* USB Standard Device Descriptor */

  2. const uint8_t Virtual_Com_Port_DeviceDescriptor[] =
  3.   {
  4.     0x12,   /* bLength */
  5.     USB_DEVICE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  6.     0x00,
  7.     0x02,   /* bcdUSB = 2.00 */
  8.     0xEF,   /* bDeviceClass    (Misc)   */
  9.     0x02,   /* bDeviceSubClass (common) */
  10.     0x01,   /* bDeviceProtocol (IAD)    */
  11.     0x40,   /* bMaxPacketSize0 */
  12.     0x83,
  13.     0x02,   /* idVendor = 0xFF02 */
  14.     0xFF,
  15.     0x01,   /* idProduct = 0x0001 */
  16.     0x00,
  17.     0x02,   /* bcdDevice = 2.00 */
  18.     1,              /* Index of string descriptor describing manufacturer */
  19.     2,              /* Index of string descriptor describing product */
  20.     3,              /* Index of string descriptor describing the device's serial number */
  21.     0x01    /* bNumConfigurations */
  22.   };
复制代码

Next, the Configuration descriptor set is heavy, because we have to repeat three sets of IAD / CDC interfaces. We make them macros
  1. #define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF)

  2. #define USB_CONFIGUARTION_DESC_SIZE             9
  3. #define USB_INTERFACE_DESC_SIZE                 9
  4. #define USB_ENDPOINT_DESC_SIZE                  7
  5. #define USB_ENDPOINT_TYPE_BULK                  0x02
  6. #define USB_ENDPOINT_TYPE_INTERRUPT             0x03

  7. #define USB_CONFIG_BUS_POWERED                 0x80
  8. #define USB_CONFIG_SELF_POWERED                0xC0
  9. #define USB_CONFIG_POWER_MA(mA)                ((mA)/2)

  10. #define CDC_COMMUNICATION_INTERFACE_CLASS       0x02
  11. #define CDC_DATA_INTERFACE_CLASS                0x0A
  12. #define CDC_ABSTRACT_CONTROL_MODEL              0x02
  13. #define CDC_CS_INTERFACE                        0x24
  14. #define CDC_HEADER                              0x00
  15. #define CDC_CALL_MANAGEMENT                     0x01
  16. #define CDC_ABSTRACT_CONTROL_MANAGEMENT         0x02
  17. #define CDC_UNION                               0x06

  18. #define CDC_IF_DESC_SET_SIZE                    \( USB_INTERFACE_DESC_SIZE + 0x05 + 0x05 + 0x04 + 0x05 + USB_ENDPOINT_DESC_SIZE + USB_INTERFACE_DESC_SIZE + 2 * USB_ENDPOINT_DESC_SIZE )

  19. #define CDC_IF_DESC_SET( comIfNum, datIfNum, comInEp, datOutEp, datInEp )   \
  20. /* CDC Communication Interface Descriptor */                            \
  21.     USB_INTERFACE_DESC_SIZE,                /* bLength */               \
  22.     USB_INTERFACE_DESCRIPTOR_TYPE,          /* bDescriptorType */       \
  23.     comIfNum,                               /* bInterfaceNumber */      \
  24.     0x00,                                   /* bAlternateSetting */     \
  25.     0x01,                                   /* bNumEndpoints */         \
  26.     CDC_COMMUNICATION_INTERFACE_CLASS,      /* bInterfaceClass */       \
  27.     CDC_ABSTRACT_CONTROL_MODEL,             /* bInterfaceSubClass */    \
  28.     0x01,                                   /* bInterfaceProtocol */    \
  29.     0x00,                                   /* iInterface */            \
  30. /* Header Functional Descriptor */                                      \
  31.     0x05,                                   /* bLength */               \
  32.     CDC_CS_INTERFACE,                       /* bDescriptorType */       \
  33.     CDC_HEADER,                             /* bDescriptorSubtype */    \
  34.     WBVAL(CDC_V1_10), /* 1.10 */            /* bcdCDC */                \
  35. /* Call Management Functional Descriptor */                             \
  36.     0x05,                                   /* bFunctionLength */       \
  37.     CDC_CS_INTERFACE,                       /* bDescriptorType */       \
  38.     CDC_CALL_MANAGEMENT,                    /* bDescriptorSubtype */    \
  39.     0x03,                                   /* bmCapabilities */        \
  40.     datIfNum,                               /* bDataInterface */        \
  41. /* Abstract Control Management Functional Descriptor */                 \
  42.     0x04,                                   /* bFunctionLength */       \
  43.     CDC_CS_INTERFACE,                       /* bDescriptorType */       \
  44.     CDC_ABSTRACT_CONTROL_MANAGEMENT,        /* bDescriptorSubtype */    \
  45.     0x02,                                   /* bmCapabilities */        \
  46. /* Union Functional Descriptor */                                       \
  47.     0x05,                                   /* bFunctionLength */       \
  48.     CDC_CS_INTERFACE,                       /* bDescriptorType */       \
  49.     CDC_UNION,                              /* bDescriptorSubtype */    \
  50.     comIfNum,                               /* bMasterInterface */      \
  51.     datIfNum,                               /* bSlaveInterface0 */      \
  52. /* Endpoint, Interrupt IN */                /* event notification */    \
  53.     USB_ENDPOINT_DESC_SIZE,                 /* bLength */               \
  54.     USB_ENDPOINT_DESCRIPTOR_TYPE,           /* bDescriptorType */       \
  55.     comInEp,                                /* bEndpointAddress */      \
  56.     USB_ENDPOINT_TYPE_INTERRUPT,            /* bmAttributes */          \
  57.     WBVAL(0x000A),                          /* wMaxPacketSize */        \
  58.     0x01,                                   /* bInterval */             \
  59.                                                                         \
  60. /* CDC Data Interface Descriptor */                                     \
  61.     USB_INTERFACE_DESC_SIZE,                /* bLength */               \
  62.     USB_INTERFACE_DESCRIPTOR_TYPE,          /* bDescriptorType */       \
  63.     datIfNum,                               /* bInterfaceNumber */      \
  64.     0x00,                                   /* bAlternateSetting */     \
  65.     0x02,                                   /* bNumEndpoints */         \
  66.     CDC_DATA_INTERFACE_CLASS,               /* bInterfaceClass */       \
  67.     0x00,                                   /* bInterfaceSubClass */    \
  68.     0x00,                                   /* bInterfaceProtocol */    \
  69.     0x00,                                   /* iInterface */            \
  70. /* Endpoint, Bulk OUT */                                                \
  71.     USB_ENDPOINT_DESC_SIZE,                 /* bLength */               \
  72.     USB_ENDPOINT_DESCRIPTOR_TYPE,           /* bDescriptorType */       \
  73.     datOutEp,                               /* bEndpointAddress */      \
  74.     USB_ENDPOINT_TYPE_BULK,                 /* bmAttributes */          \
  75.     WBVAL(VIRTUAL_COM_PORT_DATA_SIZE),      /* wMaxPacketSize */        \
  76.     0x00,                                   /* bInterval */             \
  77. /* Endpoint, Bulk IN */                                                 \
  78.     USB_ENDPOINT_DESC_SIZE,                 /* bLength */               \
  79.     USB_ENDPOINT_DESCRIPTOR_TYPE,           /* bDescriptorType */       \
  80.     datInEp,                                /* bEndpointAddress */      \
  81.     USB_ENDPOINT_TYPE_BULK,                 /* bmAttributes */          \
  82.     WBVAL(VIRTUAL_COM_PORT_DATA_SIZE),      /* wMaxPacketSize */        \
  83.     0x00                                    /* bInterval */


  84. #define IAD_CDC_IF_DESC_SET_SIZE    ( 8 + CDC_IF_DESC_SET_SIZE )

  85. #define IAD_CDC_IF_DESC_SET( comIfNum, datIfNum, comInEp, datOutEp, datInEp )   \
  86. /* Interface Association Descriptor */                                  \
  87.     0x08,                                   /* bLength */               \
  88.     0x0B,                                   /* bDescriptorType */       \
  89.     comIfNum,                               /* bFirstInterface */       \
  90.     0x02,                                   /* bInterfaceCount */       \
  91.     CDC_COMMUNICATION_INTERFACE_CLASS,      /* bFunctionClass */        \
  92.     CDC_ABSTRACT_CONTROL_MODEL,             /* bFunctionSubClass */     \
  93.     0x01,                                   /* bFunctionProcotol */     \
  94.     0x00,                                   /* iInterface */            \
  95. /* CDC Interface descriptor set */                                      \
  96.     CDC_IF_DESC_SET( comIfNum, datIfNum, comInEp, datOutEp, datInEp )
复制代码


Now that the configuration descriptor set is simplified. Virtual_Com_Port_ConfigDescriptor[] is replaced as follows,

usb_desc.c
  1. // Interface numbers
  2. enum {
  3.     USB_CDC_CIF_NUM0,
  4.     USB_CDC_DIF_NUM0,
  5.     USB_CDC_CIF_NUM1,
  6.     USB_CDC_DIF_NUM1,
  7.     USB_CDC_CIF_NUM2,
  8.     USB_CDC_DIF_NUM2,
  9.    
  10.     USB_NUM_INTERFACES        // number of interfaces
  11. };

  12. const uint8_t Virtual_Com_Port_ConfigDescriptor[] =
  13.   {
  14. /* Configuration 1 */
  15.   USB_CONFIGUARTION_DESC_SIZE,       /* bLength */
  16.   USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
  17.   WBVAL(                             /* wTotalLength */
  18.       USB_CONFIGUARTION_DESC_SIZE
  19.     + 3 * IAD_CDC_IF_DESC_SET_SIZE
  20.   ),
  21.   USB_NUM_INTERFACES,                /* bNumInterfaces */
  22.   0x01,                              /* bConfigurationValue: 0x01 is used to select this configuration */
  23.   0x00,                              /* iConfiguration: no string to describe this configuration */
  24.   USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes USB_CONFIG_REMOTE_WAKEUP*/,
  25.   USB_CONFIG_POWER_MA(100),          /* bMaxPower, device power consumption is 100 mA */

  26.   IAD_CDC_IF_DESC_SET( USB_CDC_CIF_NUM0, USB_CDC_DIF_NUM0, USB_ENDPOINT_IN(1), USB_ENDPOINT_OUT(2), USB_ENDPOINT_IN(2) ),
  27.   IAD_CDC_IF_DESC_SET( USB_CDC_CIF_NUM1, USB_CDC_DIF_NUM1, USB_ENDPOINT_IN(3), USB_ENDPOINT_OUT(4), USB_ENDPOINT_IN(4) ),
  28.   IAD_CDC_IF_DESC_SET( USB_CDC_CIF_NUM2, USB_CDC_DIF_NUM2, USB_ENDPOINT_IN(5), USB_ENDPOINT_OUT(6), USB_ENDPOINT_IN(6) ),
  29. };
复制代码


Auu, I remember that the packet buffer of STM32F102/103 is limited to 512 bytes.
To pack all of endpoint packet buffers into this size,
we have to shrink EP0 bMaxPacketSize0 on the Device Descriptor from 0x40 to 0x08 (minimum)
  1. /* USB Standard Device Descriptor */

  2. const uint8_t Virtual_Com_Port_DeviceDescriptor[] =
  3.   {
  4.     0x12,   /* bLength */
  5.     USB_DEVICE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  6.     0x00,
  7.     0x02,   /* bcdUSB = 2.00 */
  8.     0xEF,   /* bDeviceClass    (Misc)   */
  9.     0x02,   /* bDeviceSubClass (common) */
  10.     0x01,   /* bDeviceProtocol (IAD)    */
  11.     0x08,   /* bMaxPacketSize0 */        // <-----------
  12.     0x83,
  13.     0x02,   /* idVendor = 0xFF02 */
  14.     0xFF,
  15.     0x01,   /* idProduct = 0x0001 */
  16.     0x00,
  17.     0x02,   /* bcdDevice = 2.00 */
  18.     1,              /* Index of string descriptor describing manufacturer */
  19.     2,              /* Index of string descriptor describing product */
  20.     3,              /* Index of string descriptor describing the device's serial number */
  21.     0x01    /* bNumConfigurations */
  22.   };
复制代码

Next, enable all endpoints in Virtual_Com_Port_Reset() Here, packet buffer is allocated for each endpoint.
\inc\usb_conf.h
  1. /*-------------------------------------------------------------*/
  2. /* --------------   Buffer Description Table  -----------------*/
  3. /*-------------------------------------------------------------*/
  4. /* buffer table base address */
  5. /* buffer table base address */
  6. #define BTABLE_ADDRESS      (0x00)

  7. /* EP0  */
  8. /* rx/tx buffer base address */
  9. #define ENDP0_RXADDR        (0x40)
  10. #define ENDP0_TXADDR        (0x48)

  11. /* EP1  */
  12. /* tx buffer base address */
  13. #define ENDP1_TXADDR        (0x50)
  14. #define ENDP2_TXADDR        (0x60)
  15. #define ENDP2_RXADDR        (0xA0)
  16. #define ENDP3_TXADDR        (0xE0)
  17. #define ENDP4_TXADDR        (0xF0)
  18. #define ENDP4_RXADDR        (0x130)
  19. #define ENDP5_TXADDR        (0x170)
  20. #define ENDP6_TXADDR        (0x180)
  21. #define ENDP6_RXADDR        (0x1C0)
复制代码

usb_prop.c
  1. /*******************************************************************************
  2. * Function Name  : Virtual_Com_Port_Reset
  3. * Description    : Virtual_Com_Port Mouse reset routine
  4. * Input          : None.
  5. * Output         : None.
  6. * Return         : None.
  7. *******************************************************************************/
  8. void Virtual_Com_Port_Reset(void)
  9. {
  10.   /* Set Virtual_Com_Port DEVICE as not configured */
  11.   pInformation->Current_Configuration = 0;

  12.   /* Current Feature initialization */
  13.   pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7];

  14.   /* Set Virtual_Com_Port DEVICE with the default Interface*/
  15.   pInformation->Current_Interface = 0;

  16.   SetBTABLE(BTABLE_ADDRESS);

  17.   /* Initialize Endpoint 0 */
  18.   SetEPType(ENDP0, EP_CONTROL);
  19.   SetEPTxStatus(ENDP0, EP_TX_STALL);
  20.   SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  21.   SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  22.   Clear_Status_Out(ENDP0);
  23.   SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  24.   SetEPRxValid(ENDP0);

  25.   /* Initialize Endpoint 1 */
  26.   SetEPType(ENDP1, EP_INTERRUPT);
  27.   SetEPTxAddr(ENDP1, ENDP1_TXADDR);
  28.   SetEPTxStatus(ENDP1, EP_TX_NAK);
  29.   SetEPRxStatus(ENDP1, EP_RX_DIS);

  30.   /* Initialize Endpoint 2 */
  31.   SetEPType(ENDP2, EP_BULK);
  32.   SetEPTxAddr(ENDP2, ENDP2_TXADDR);
  33.   SetEPTxStatus(ENDP2, EP_TX_NAK);
  34.   SetEPRxAddr(ENDP2, ENDP2_RXADDR);
  35.   SetEPRxCount(ENDP2, VIRTUAL_COM_PORT_DATA_SIZE);
  36.   SetEPRxStatus(ENDP2, EP_RX_VALID);

  37.   /* Initialize Endpoint 3 */
  38.   SetEPType(ENDP3, EP_INTERRUPT);
  39.   SetEPTxAddr(ENDP3, ENDP3_TXADDR);
  40.   SetEPTxStatus(ENDP3, EP_TX_NAK);
  41.   SetEPRxStatus(ENDP3, EP_RX_DIS);

  42.   /* Initialize Endpoint 4 */
  43.   SetEPType(ENDP4, EP_BULK);
  44.   SetEPTxAddr(ENDP4, ENDP4_TXADDR);
  45.   SetEPTxStatus(ENDP4, EP_TX_NAK);
  46.   SetEPRxAddr(ENDP4, ENDP4_RXADDR);
  47.   SetEPRxCount(ENDP4, VIRTUAL_COM_PORT_DATA_SIZE);
  48.   SetEPRxStatus(ENDP4, EP_RX_VALID);

  49.   /* Initialize Endpoint 5 */
  50.   SetEPType(ENDP5, EP_INTERRUPT);
  51.   SetEPTxAddr(ENDP5, ENDP5_TXADDR);
  52.   SetEPTxStatus(ENDP5, EP_TX_NAK);
  53.   SetEPRxStatus(ENDP5, EP_RX_DIS);

  54.   /* Initialize Endpoint 6 */
  55.   SetEPType(ENDP6, EP_BULK);
  56.   SetEPTxAddr(ENDP6, ENDP6_TXADDR);
  57.   SetEPTxStatus(ENDP6, EP_TX_NAK);
  58.   SetEPRxAddr(ENDP6, ENDP6_RXADDR);
  59.   SetEPRxCount(ENDP6, VIRTUAL_COM_PORT_DATA_SIZE);
  60.   SetEPRxStatus(ENDP6, EP_RX_VALID);

  61.   /* Set this device to response on default address */
  62.   SetDeviceAddress(0);

  63.   bDeviceState = ATTACHED;
  64. }
复制代码

And the last of this section, INF file for windows. Now that our device should appear on Windows. :-)
STM32-CDC-Composite.inf
  1. ;
  2. ; STM32-CDC-Composite.inf  Communication Device Class driver installation file
  3. ;

  4. [Version]
  5. Signature="$Windows NT$"
  6. Class=Ports
  7. ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
  8. Provider=%MICHELE%
  9. ;;; LayoutFile=layout.inf ;; not supported in Vista and later
  10. DriverVer =04/14/2008, 5.1.2600.5512
  11. ; CatalogFile=STM32-CDC-Composite.cat

  12. [Manufacturer]
  13. %MICHELE%=DeviceList,ntamd64

  14. ;------------------------------------------------------------------------------
  15. ;  Device list
  16. ;------------------------------------------------------------------------------

  17. [DeviceList]
  18. %DESCRIPTION1% = STM32CDCCMP, USB¥VID_FF02&PID_0001&MI_00
  19. %DESCRIPTION2% = STM32CDCCMP, USB¥VID_FF02&PID_0001&MI_02
  20. %DESCRIPTION3% = STM32CDCCMP, USB¥VID_FF02&PID_0001&MI_04

  21. [DeviceList.ntamd64]
  22. %DESCRIPTION1% = STM32CDCCMP, USB¥VID_FF02&PID_0001&MI_00
  23. %DESCRIPTION2% = STM32CDCCMP, USB¥VID_FF02&PID_0001&MI_02
  24. %DESCRIPTION3% = STM32CDCCMP, USB¥VID_FF02&PID_0001&MI_04

  25. ;------------------------------------------------------------------------------
  26. ;  Installation
  27. ;------------------------------------------------------------------------------

  28. [SourceDisksNames]
  29. ;;; this blank section satisfies chkinf
  30. [SourceDisksFiles]
  31. ;;; this blank section satisfies chkinf

  32. [DestinationDirs]
  33. FakeModemCopyFileSection=12
  34. DefaultDestDir = 12

  35. [STM32CDCCMP]
  36. include=mdmcpq.inf
  37. CopyFiles=FakeModemCopyFileSection
  38. AddReg= STM32CDCCMP.AddReg

  39. [STM32CDCCMP.AddReg]
  40. HKR,,DevLoader,,*ntkern
  41. HKR,,NTMPDriver,,usbser.sys
  42. HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

  43. [STM32CDCCMP.Services]
  44. AddService=usbser, 0x00000002, DriverService

  45. [DriverService]
  46. DisplayName=%DRIVER.SVC%
  47. ServiceType=1
  48. StartType=3
  49. ErrorControl=1
  50. ServiceBinary=%12%¥usbser.sys

  51. ;------------------------------------------------------------------------------
  52. ;  String Definitions
  53. ;------------------------------------------------------------------------------

  54. [Strings]
  55. MICHELE     = "Michele"
  56. DRIVER.SVC  = "STM32 CDC Composite Driver"
  57. DESCRIPTION1= "STM32 CDC Composite Port 1"
  58. DESCRIPTION2= "STM32 CDC Composite Port 2"
  59. DESCRIPTION3= "STM32 CDC Composite Port 3"
复制代码

I have a test today.Set the Virtual_Com_Port_ConfigDescriptor EP like:

  IAD_CDC_IF_DESC_SET( USB_CDC_CIF_NUM0, USB_CDC_DIF_NUM0, USB_ENDPOINT_IN(2), USB_ENDPOINT_OUT(1), USB_ENDPOINT_IN(1) ),
  IAD_CDC_IF_DESC_SET( USB_CDC_CIF_NUM1, USB_CDC_DIF_NUM1, USB_ENDPOINT_IN(2), USB_ENDPOINT_OUT(3), USB_ENDPOINT_IN(3) ),
  IAD_CDC_IF_DESC_SET( USB_CDC_CIF_NUM2, USB_CDC_DIF_NUM2, USB_ENDPOINT_IN(2), USB_ENDPOINT_OUT(4), USB_ENDPOINT_IN(4) ),
  IAD_CDC_IF_DESC_SET( USB_CDC_CIF_NUM3, USB_CDC_DIF_NUM3, USB_ENDPOINT_IN(2), USB_ENDPOINT_OUT(5), USB_ENDPOINT_IN(5) ),
  IAD_CDC_IF_DESC_SET( USB_CDC_CIF_NUM4, USB_CDC_DIF_NUM4, USB_ENDPOINT_IN(2), USB_ENDPOINT_OUT(6), USB_ENDPOINT_IN(6) ),

Then the PC can detector the virtual coms like:

080101068625039.jpg

Transfer data as the style of demo.
I tested the first two coms,they worked ok.
I will test the others,and change the transfer style to improve the transfer speed.
As all coms will work at the same time.
The way upon is not conform the CDC rules,but can be used by some special application.
Maybe the test way is not entire. What is your comment, or  some good methods?
Yangfeng

STM32F103 Dual CDC
080059466594342.png

STM32F105实现的USB转双串口
USB转双串口,核心技术就在于组合设备(USB Composite)的实现,组合设备的实现,其核心技术在于描述符的实现,下面我们先给出描述符:(出处: 嵌入式以太网社区)
  1. __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END =
  2.   {
  3.     0x12,                       /*bLength */
  4.     USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
  5.     0x00,                       /*bcdUSB */
  6.     0x02,
  7. #ifdef DUAL_COM
  8.     0xEF,                       /*bDeviceClass*/
  9.     0x02,                       /*bDeviceSubClass*/
  10.     0x01,                       /*bDeviceProtocol*/
  11. #else
  12.     0x00,                       /*bDeviceClass*/
  13.     0x00,                       /*bDeviceSubClass*/
  14.     0x00,                       /*bDeviceProtocol*/      
  15. #endif
  16.     USB_OTG_MAX_EP0_SIZE,      /*bMaxPacketSize*/
  17.     LOBYTE(USBD_VID),           /*idVendor*/
  18.     HIBYTE(USBD_VID),           /*idVendor*/
  19.     LOBYTE(USBD_PID),           /*idVendor*/
  20.     HIBYTE(USBD_PID),           /*idVendor*/
  21.     0x00,                       /*bcdDevice rel. 2.00*/
  22.     0x02,
  23.     USBD_IDX_MFC_STR,           /*Index of manufacturer  string*/
  24.     USBD_IDX_PRODUCT_STR,       /*Index of product string*/
  25.     USBD_IDX_SERIAL_STR,        /*Index of serial number string*/
  26.     USBD_CFG_MAX_NUM            /*bNumConfigurations*/
  27.   } ; /* USB_DeviceDescriptor */
复制代码

注意:双串口需要全局定义DUAL_COM宏 配置描述符是重中之重
  1. __ALIGN_BEGIN uint8_t usbd_cdc_CfgDesc[USB_CDC_CONFIG_DESC_SIZ]  __ALIGN_END =
  2. {
  3.   /*Configuration Descriptor*/
  4.   0x09,   /* bLength: Configuration Descriptor size */
  5.   USB_CONFIGURATION_DESCRIPTOR_TYPE,      /* bDescriptorType: Configuration */
  6.   USB_CDC_CONFIG_DESC_SIZ,                /* wTotalLength:no of returned bytes */
  7.   0x00,
  8. #ifdef DUAL_COM
  9.   0x04,   /* bNumInterfaces: 4 interface */
  10. #else
  11.   0x02,   /* bNumInterfaces: 2 interface */
  12. #endif
  13.   0x01,   /* bConfigurationValue: Configuration value */
  14.   0x00,   /* iConfiguration: Index of string descriptor describing the configuration */
  15.   0x60,   /* bmAttributes: self powered */
  16.   0xFA,   /* MaxPower 0 mA */
  17.    
  18.   /*---------------------------------------------------------------------------*/
  19. #ifdef DUAL_COM
  20.         // IAD
  21.         0x08,        // bLength: Interface Descriptor size
  22.         0x0B,        // bDescriptorType: IAD
  23.         0x00,        // bFirstInterface
  24.         0x02,        // bInterfaceCount
  25.         0x02,        // bFunctionClass: CDC
  26.         0x02,        // bFunctionSubClass
  27.         0x01,        // bFunctionProtocol
  28.         0x02,        // iFunction
  29. #endif
  30.   /*Interface Descriptor */
  31.   0x09,   /* bLength: Interface Descriptor size */
  32.   USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: Interface */
  33.   /* Interface descriptor type */
  34.   0x00,   /* bInterfaceNumber: Number of Interface */
  35.   0x00,   /* bAlternateSetting: Alternate setting */
  36.   0x01,   /* bNumEndpoints: One endpoints used */
  37.   0x02,   /* bInterfaceClass: Communication Interface Class */
  38.   0x02,   /* bInterfaceSubClass: Abstract Control Model */
  39.   0x01,   /* bInterfaceProtocol: Common AT commands */
  40.   0x00,   /* iInterface: */
  41.    
  42.   /*Header Functional Descriptor*/
  43.   0x05,   /* bLength: Endpoint Descriptor size */
  44.   0x24,   /* bDescriptorType: CS_INTERFACE */
  45.   0x00,   /* bDescriptorSubtype: Header Func Desc */
  46.   0x10,   /* bcdCDC: spec release number */
  47.   0x01,
  48.    
  49.   /*Call Management Functional Descriptor*/
  50.   0x05,   /* bFunctionLength */
  51.   0x24,   /* bDescriptorType: CS_INTERFACE */
  52.   0x01,   /* bDescriptorSubtype: Call Management Func Desc */
  53.   0x00,   /* bmCapabilities: D0+D1 */
  54.   0x01,   /* bDataInterface: 1 */
  55.    
  56.   /*ACM Functional Descriptor*/
  57.   0x04,   /* bFunctionLength */
  58.   0x24,   /* bDescriptorType: CS_INTERFACE */
  59.   0x02,   /* bDescriptorSubtype: Abstract Control Management desc */
  60.   0x02,   /* bmCapabilities */
  61.    
  62.   /*Union Functional Descriptor*/
  63.   0x05,   /* bFunctionLength */
  64.   0x24,   /* bDescriptorType: CS_INTERFACE */
  65.   0x06,   /* bDescriptorSubtype: Union func desc */
  66.   0x00,   /* bMasterInterface: Communication class interface */
  67.   0x01,   /* bSlaveInterface0: Data Class Interface */
  68.    
  69.   /*Endpoint 2 Descriptor*/
  70.   0x07,                           /* bLength: Endpoint Descriptor size */
  71.   USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
  72.   CDC_CMD_EP,                     /* bEndpointAddress */
  73.   0x03,                           /* bmAttributes: Interrupt */
  74.   LOBYTE(CDC_CMD_PACKET_SZE),     /* wMaxPacketSize: */
  75.   HIBYTE(CDC_CMD_PACKET_SZE),
  76.   0xFF,                           /* bInterval: */
  77.    
  78.   /*---------------------------------------------------------------------------*/
  79.    
  80.   /*Data class interface descriptor*/
  81.   0x09,   /* bLength: Endpoint Descriptor size */
  82.   USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: */
  83.   0x01,   /* bInterfaceNumber: Number of Interface */
  84.   0x00,   /* bAlternateSetting: Alternate setting */
  85.   0x02,   /* bNumEndpoints: Two endpoints used */
  86.   0x0A,   /* bInterfaceClass: CDC */
  87.   0x00,   /* bInterfaceSubClass: */
  88.   0x00,   /* bInterfaceProtocol: */
  89.   0x00,   /* iInterface: */
  90.    
  91.   /*Endpoint OUT Descriptor*/
  92.   0x07,   /* bLength: Endpoint Descriptor size */
  93.   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType: Endpoint */
  94.   CDC_OUT_EP,                        /* bEndpointAddress */
  95.   0x02,                              /* bmAttributes: Bulk */
  96.   LOBYTE(CDC_DATA_MAX_PACKET_SIZE),  /* wMaxPacketSize: */
  97.   HIBYTE(CDC_DATA_MAX_PACKET_SIZE),
  98.   0x00,                              /* bInterval: ignore for Bulk transfer */
  99.    
  100.   /*Endpoint IN Descriptor*/
  101.   0x07,   /* bLength: Endpoint Descriptor size */
  102.   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType: Endpoint */
  103.   CDC_IN_EP,                         /* bEndpointAddress */
  104.   0x02,                              /* bmAttributes: Bulk */
  105.   LOBYTE(CDC_DATA_MAX_PACKET_SIZE),  /* wMaxPacketSize: */
  106.   HIBYTE(CDC_DATA_MAX_PACKET_SIZE),
  107.   0x00,                              /* bInterval: ignore for Bulk transfer */
  108.          
  109. #ifdef DUAL_COM
  110.         // IAD
  111.         0x08,        // bLength: Interface Descriptor size
  112.         0x0B,        // bDescriptorType: IAD
  113.         0x02,        // bFirstInterface
  114.         0x02,        // bInterfaceCount
  115.         0x02,        // bFunctionClass: CDC
  116.         0x02,        // bFunctionSubClass
  117.         0x01,        // bFunctionProtocol
  118.         0x02,        // iFunction
  119.   /*Interface Descriptor */
  120.   0x09,   /* bLength: Interface Descriptor size */
  121.   USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: Interface */
  122.   /* Interface descriptor type */
  123.   0x02,   /* bInterfaceNumber: Number of Interface */
  124.   0x00,   /* bAlternateSetting: Alternate setting */
  125.   0x01,   /* bNumEndpoints: One endpoints used */
  126.   0x02,   /* bInterfaceClass: Communication Interface Class */
  127.   0x02,   /* bInterfaceSubClass: Abstract Control Model */
  128.   0x01,   /* bInterfaceProtocol: Common AT commands */
  129.   0x00,   /* iInterface: */
  130.    
  131.   /*Header Functional Descriptor*/
  132.   0x05,   /* bLength: Endpoint Descriptor size */
  133.   0x24,   /* bDescriptorType: CS_INTERFACE */
  134.   0x00,   /* bDescriptorSubtype: Header Func Desc */
  135.   0x10,   /* bcdCDC: spec release number */
  136.   0x01,
  137.    
  138.   /*Call Management Functional Descriptor*/
  139.   0x05,   /* bFunctionLength */
  140.   0x24,   /* bDescriptorType: CS_INTERFACE */
  141.   0x01,   /* bDescriptorSubtype: Call Management Func Desc */
  142.   0x00,   /* bmCapabilities: D0+D1 */
  143.   0x01,   /* bDataInterface: 1 */
  144.    
  145.   /*ACM Functional Descriptor*/
  146.   0x04,   /* bFunctionLength */
  147.   0x24,   /* bDescriptorType: CS_INTERFACE */
  148.   0x02,   /* bDescriptorSubtype: Abstract Control Management desc */
  149.   0x02,   /* bmCapabilities */
  150.    
  151.   /*Union Functional Descriptor*/
  152.   0x05,   /* bFunctionLength */
  153.   0x24,   /* bDescriptorType: CS_INTERFACE */
  154.   0x06,   /* bDescriptorSubtype: Union func desc */
  155.   0x00,   /* bMasterInterface: Communication class interface */
  156.   0x01,   /* bSlaveInterface0: Data Class Interface */
  157.    
  158.   /*Endpoint 2 Descriptor*/
  159.   0x07,                           /* bLength: Endpoint Descriptor size */
  160.   USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
  161.   CDC_CMD_EP,                  /* bEndpointAddress */
  162.   0x03,                           /* bmAttributes: Interrupt */
  163.   LOBYTE(CDC_CMD_PACKET_SZE),     /* wMaxPacketSize: */
  164.   HIBYTE(CDC_CMD_PACKET_SZE),
  165.   0xFF,                           /* bInterval: */
  166.    
  167.   /*---------------------------------------------------------------------------*/
  168.    
  169.   /*Data class interface descriptor*/
  170.   0x09,   /* bLength: Endpoint Descriptor size */
  171.   USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: */
  172.   0x03,   /* bInterfaceNumber: Number of Interface */
  173.   0x00,   /* bAlternateSetting: Alternate setting */
  174.   0x02,   /* bNumEndpoints: Two endpoints used */
  175.   0x0A,   /* bInterfaceClass: CDC */
  176.   0x00,   /* bInterfaceSubClass: */
  177.   0x00,   /* bInterfaceProtocol: */
  178.   0x00,   /* iInterface: */
  179.    
  180.   /*Endpoint OUT Descriptor*/
  181.   0x07,   /* bLength: Endpoint Descriptor size */
  182.   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType: Endpoint */
  183.   CDC_OUT_EP_EX,                     /* bEndpointAddress */
  184.   0x02,                              /* bmAttributes: Bulk */
  185.   LOBYTE(CDC_DATA_MAX_PACKET_SIZE),  /* wMaxPacketSize: */
  186.   HIBYTE(CDC_DATA_MAX_PACKET_SIZE),
  187.   0x00,                              /* bInterval: ignore for Bulk transfer */
  188.    
  189.   /*Endpoint IN Descriptor*/
  190.   0x07,   /* bLength: Endpoint Descriptor size */
  191.   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType: Endpoint */
  192.   CDC_IN_EP_EX,                      /* bEndpointAddress */
  193.   0x02,                              /* bmAttributes: Bulk */
  194.   LOBYTE(CDC_DATA_MAX_PACKET_SIZE),  /* wMaxPacketSize: */
  195.   HIBYTE(CDC_DATA_MAX_PACKET_SIZE),
  196.   0x00                               /* bInterval: ignore for Bulk transfer */
  197. #endif
  198. } ;
复制代码

080116040026558.jpg
  1. 1 /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
  2.   2 * File Name          : usb_desc.c
  3.   3 * Author             : MCD Application Team
  4.   4 * Version            : V3.1.1
  5.   5 * Date               : 04/07/2010
  6.   6 * Description        : Descriptors for Virtual Com Port Demo
  7.   7 ********************************************************************************
  8.   8 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  9.   9 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  10. 10 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  11. 11 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  12. 12 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  13. 13 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  14. 14 *******************************************************************************/
  15. 15
  16. 16 /* Includes ------------------------------------------------------------------*/
  17. 17 #include "usb_lib.h"
  18. 18 #include "usb_desc.h"
  19. 19
  20. 20 /* USB Standard Device Descriptor */
  21. 21 const uint8_t Virtual_Com_Port_DeviceDescriptor[] =
  22. 22   {
  23. 23     0x12,   /* bLength */
  24. 24     USB_DEVICE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  25. 25     0x00,
  26. 26     0x02,   /* bcdUSB = 2.00 */
  27. 27             /* Multi-Interface Function Class Code : 0xEF 0x02 0x01 */   
  28. 28     0xEF,   /* bDeviceClass    : Miscellaneous Device Class : CDC */
  29. 29     0x02,   /* bDeviceSubClass : Common Class */
  30. 30     0x01,   /* bDeviceProtocol : IAD : Interface Association Descriptor */
  31. 31
  32. 32     0x40,   /* bMaxPacketSize0 */
  33. 33     0xEB,
  34. 34     0x03,   /* idVendor = 0x03EB */
  35. 35     0x33,
  36. 36     0x61,   /* idProduct = 0x6133 */
  37. 37     
  38. 38     0x00,
  39. 39     0x02,   /* bcdDevice = 2.00 */
  40. 40     1,      /* Index of string descriptor describing manufacturer */
  41. 41     2,      /* Index of string descriptor describing product */
  42. 42     3,      /* Index of string descriptor describing the device's serial number */
  43. 43     0x01    /* bNumConfigurations */
  44. 44   };
  45. 45
  46. 46 const uint8_t Virtual_Com_Port_ConfigDescriptor[] =
  47. 47   {
  48. 48     /*Configuation Descriptor*/
  49. 49     0x09,   /* bLength: Configuation Descriptor size */
  50. 50     USB_CONFIGURATION_DESCRIPTOR_TYPE,      /* bDescriptorType: Configuration */
  51. 51     VIRTUAL_COM_PORT_SIZ_CONFIG_DESC,       /* wTotalLength:no of returned bytes */
  52. 52     0x00,
  53. 53     0x04,   /* bNumInterfaces: 4 interface */
  54. 54     0x01,   /* bConfigurationValue: Configuration value */
  55. 55     0x00,   /* iConfiguration: Index of string descriptor describing the configuration */
  56. 56     0xC0,   /* bmAttributes: self powered */
  57. 57     0x32,   /* MaxPower 100 mA */
  58. 58
  59. 59     // IAD
  60. 60     0x08,    // bLength: Interface Descriptor size
  61. 61     0x0B,        // bDescriptorType: IAD
  62. 62     0x00,    // bFirstInterface
  63. 63     0x02,    // bInterfaceCount
  64. 64     0x02,    // bFunctionClass: CDC
  65. 65     0x02,    // bFunctionSubClass
  66. 66     0x01,    // bFunctionProtocol
  67. 67     0x02,    // iFunction
  68. 68     
  69. 69     /*Interface Descriptor*/
  70. 70     0x09,   /* bLength: Interface Descriptor size */
  71. 71     USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: Interface */
  72. 72     /* Interface descriptor type */
  73. 73     0x00,   /* bInterfaceNumber: Number of Interface */
  74. 74     0x00,   /* bAlternateSetting: Alternate setting */
  75. 75     0x01,   /* bNumEndpoints: One endpoints used */
  76. 76     0x02,   /* bInterfaceClass: Communication Interface Class */
  77. 77     0x02,   /* bInterfaceSubClass: Abstract Control Model */
  78. 78     0x01,   /* bInterfaceProtocol: Common AT commands */
  79. 79     0x00,   /* iInterface: */
  80. 80     /*Header Functional Descriptor*/
  81. 81     0x05,   /* bLength: Endpoint Descriptor size */
  82. 82     0x24,   /* bDescriptorType: CS_INTERFACE */
  83. 83     0x00,   /* bDescriptorSubtype: Header Func Desc */
  84. 84     0x10,   /* bcdCDC: spec release number */
  85. 85     0x01,
  86. 86     /*Call Managment Functional Descriptor*/
  87. 87     0x05,   /* bFunctionLength */
  88. 88     0x24,   /* bDescriptorType: CS_INTERFACE */
  89. 89     0x01,   /* bDescriptorSubtype: Call Management Func Desc */
  90. 90     0x00,   /* bmCapabilities: D0+D1 */
  91. 91     0x01,   /* bDataInterface: 1 */ 92     /*ACM Functional Descriptor*/
  92. 93     0x04,   /* bFunctionLength */
  93. 94     0x24,   /* bDescriptorType: CS_INTERFACE */
  94. 95     0x02,   /* bDescriptorSubtype: Abstract Control Management desc */
  95. 96     0x02,   /* bmCapabilities */
  96. 97     /*Union Functional Descriptor*/
  97. 98     0x05,   /* bFunctionLength */
  98. 99     0x24,   /* bDescriptorType: CS_INTERFACE */
  99. 100     0x06,   /* bDescriptorSubtype: Union func desc */
  100. 101     0x00,   /* bMasterInterface: Communication class interface */
  101. 102     0x01,   /* bSlaveInterface0: Data Class Interface */103     /*Endpoint 2 Descriptor*/
  102. 104     0x07,   /* bLength: Endpoint Descriptor size */
  103. 105     USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
  104. 106     0x82,   /* bEndpointAddress: (IN2) */
  105. 107     0x03,   /* bmAttributes: Interrupt */
  106. 108     VIRTUAL_COM_PORT_INT_SIZE,      /* wMaxPacketSize: */
  107. 109     0x00,
  108. 110     0xFF,   /* bInterval: */
  109. 111     /*Data class interface descriptor*/
  110. 112     0x09,   /* bLength: Endpoint Descriptor size */
  111. 113     USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: */
  112. 114     0x01,   /* bInterfaceNumber: Number of Interface */
  113. 115     0x00,   /* bAlternateSetting: Alternate setting */
  114. 116     0x02,   /* bNumEndpoints: Two endpoints used */
  115. 117     0x0A,   /* bInterfaceClass: CDC */
  116. 118     0x00,   /* bInterfaceSubClass: */
  117. 119     0x00,   /* bInterfaceProtocol: */
  118. 120     0x00,   /* iInterface: */
  119. 121     /*Endpoint 3 Descriptor*/
  120. 122     0x07,   /* bLength: Endpoint Descriptor size */
  121. 123     USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
  122. 124     0x03,   /* bEndpointAddress: (OUT3) */
  123. 125     0x02,   /* bmAttributes: Bulk */
  124. 126     VIRTUAL_COM_PORT_DATA_SIZE,             /* wMaxPacketSize: */
  125. 127     0x00,
  126. 128     0x00,   /* bInterval: ignore for Bulk transfer */129     /*Endpoint 1 Descriptor*/
  127. 130     0x07,   /* bLength: Endpoint Descriptor size */
  128. 131     USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
  129. 132     0x81,   /* bEndpointAddress: (IN1) */
  130. 133     0x02,   /* bmAttributes: Bulk */
  131. 134     VIRTUAL_COM_PORT_DATA_SIZE,             /* wMaxPacketSize: */
  132. 135     0x00,
  133. 136     0x00,    /* bInterval */
  134. 137
  135. 138     // IAD
  136. 139     0x08,    // bLength: Interface Descriptor size
  137. 140     0x0B,        // bDescriptorType: IAD
  138. 141     0x02,    // bFirstInterface
  139. 142     0x02,    // bInterfaceCount
  140. 143     0x02,    // bFunctionClass: CDC
  141. 144     0x02,    // bFunctionSubClass
  142. 145     0x01,    // bFunctionProtocol1460x02,    // iFunction147     /*Interface Descriptor*/
  143. 148     0x09,   /* bLength: Interface Descriptor size */
  144. 149     USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: Interface */
  145. 150     /* Interface descriptor type */
  146. 151     0x02,   /* bInterfaceNumber: Number of Interface */
  147. 152     0x00,   /* bAlternateSetting: Alternate setting */
  148. 153     0x01,   /* bNumEndpoints: One endpoints used */
  149. 154     0x02,   /* bInterfaceClass: Communication Interface Class */
  150. 155     0x02,   /* bInterfaceSubClass: Abstract Control Model */
  151. 156     0x01,   /* bInterfaceProtocol: Common AT commands */
  152. 157     0x00,   /* iInterface: */158     /*Header Functional Descriptor*/
  153. 159     0x05,   /* bLength: Endpoint Descriptor size */
  154. 160     0x24,   /* bDescriptorType: CS_INTERFACE */
  155. 161     0x00,   /* bDescriptorSubtype: Header Func Desc */
  156. 162     0x10,   /* bcdCDC: spec release number */
  157. 163     0x01,
  158. 164     /*Call Managment Functional Descriptor*/
  159. 165     0x05,   /* bFunctionLength */
  160. 166     0x24,   /* bDescriptorType: CS_INTERFACE */
  161. 167     0x01,   /* bDescriptorSubtype: Call Management Func Desc */
  162. 168     0x00,   /* bmCapabilities: D0+D1 */
  163. 169     0x03,   /* !! bDataInterface: */170     /*ACM Functional Descriptor*/
  164. 171     0x04,   /* bFunctionLength */
  165. 172     0x24,   /* bDescriptorType: CS_INTERFACE */
  166. 173     0x02,   /* bDescriptorSubtype: Abstract Control Management desc */
  167. 174     0x02,   /* bmCapabilities */175     /*Union Functional Descriptor*/
  168. 176     0x05,   /* bFunctionLength */
  169. 177     0x24,   /* bDescriptorType: CS_INTERFACE */
  170. 178     0x06,   /* bDescriptorSubtype: Union func desc */
  171. 179     0x02,   /* !! bMasterInterface: Communication class interface */
  172. 180     0x03,   /* !! bSlaveInterface0: Data Class Interface */181     /*Endpoint 2 Descriptor*/
  173. 182     0x07,   /* bLength: Endpoint Descriptor size */
  174. 183     USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
  175. 184     0x85,   /* bEndpointAddress: (IN2) */
  176. 185     0x03,   /* bmAttributes: Interrupt */
  177. 186     VIRTUAL_COM_PORT_INT_SIZE,      /* wMaxPacketSize: */
  178. 187     0x00,
  179. 188     0xFF,   /* bInterval: */
  180. 189
  181. 190     /*Data class interface descriptor*/
  182. 191     0x09,   /* bLength: Endpoint Descriptor size */
  183. 192     USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: */
  184. 193     0x03,   /* bInterfaceNumber: Number of Interface */
  185. 194     0x00,   /* bAlternateSetting: Alternate setting */
  186. 195     0x02,   /* bNumEndpoints: Two endpoints used */
  187. 196     0x0A,   /* bInterfaceClass: CDC */
  188. 197     0x00,   /* bInterfaceSubClass: */
  189. 198     0x00,   /* bInterfaceProtocol: */
  190. 199     0x00,   /* iInterface: */200     /*Endpoint 3 Descriptor*/
  191. 201     0x07,   /* bLength: Endpoint Descriptor size */
  192. 202     USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
  193. 203     0x06,   /* bEndpointAddress: (OUT3) */
  194. 204     0x02,   /* bmAttributes: Bulk */
  195. 205     VIRTUAL_COM_PORT_DATA_SIZE,             /* wMaxPacketSize: */
  196. 206     0x00,
  197. 207     0x00,   /* bInterval: ignore for Bulk transfer */208     /*Endpoint 1 Descriptor*/
  198. 209     0x07,   /* bLength: Endpoint Descriptor size */
  199. 210     USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
  200. 211     0x84,   /* bEndpointAddress: (IN1) */
  201. 212     0x02,   /* bmAttributes: Bulk */
  202. 213     VIRTUAL_COM_PORT_DATA_SIZE,             /* wMaxPacketSize: */
  203. 214     0x00,
  204. 215     0x00    /* bInterval */
  205. 216   };
  206. 217
  207. 218 /* USB String Descriptors */
  208. 219 const uint8_t Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID] =
  209. 220   {
  210. 221     VIRTUAL_COM_PORT_SIZ_STRING_LANGID,
  211. 222     USB_STRING_DESCRIPTOR_TYPE,
  212. 223     0x09,
  213. 224     0x04 /* LangID = 0x0409: U.S. English */
  214. 225   };
  215. 226
  216. 227 const uint8_t Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR] =
  217. 228   {
  218. 229     VIRTUAL_COM_PORT_SIZ_STRING_VENDOR,     /* Size of Vendor string */
  219. 230     USB_STRING_DESCRIPTOR_TYPE,             /* bDescriptorType*/
  220. 231     /* Manufacturer: "STMicroelectronics" */
  221. 232     'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,
  222. 233     'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,
  223. 234     'c', 0, 's', 0
  224. 235   };
  225. 236
  226. 237 const uint8_t Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT] =
  227. 238   {
  228. 239     VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT,          /* bLength */
  229. 240     USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
  230. 241     /* Product name: "STM32 Virtual COM Port" */
  231. 242     'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'V', 0, 'i', 0,
  232. 243     'r', 0, 't', 0, 'u', 0, 'a', 0, 'l', 0, ' ', 0, 'C', 0, 'O', 0,
  233. 244     'M', 0, ' ', 0, 'P', 0, 'o', 0, 'r', 0, 't', 0, ' ', 0, ' ', 0
  234. 245   };
  235. 246
  236. 247 uint8_t Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_SIZ_STRING_SERIAL] =
  237. 248   {
  238. 249     VIRTUAL_COM_PORT_SIZ_STRING_SERIAL,           /* bLength */
  239. 250     USB_STRING_DESCRIPTOR_TYPE,                   /* bDescriptorType */
  240. 251     'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, '1', 0, '0', 0
  241. 252   };
  242. 253
  243. 254 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
复制代码


  1. ;
  2. ; STMicroelectronics Comunication Device Class driver instalation file
  3. ; (C)2006 Copyright STMicroelectronics
  4. ;

  5. [Version]
  6. Signature="$Windows NT$"
  7. Class=Ports
  8. ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
  9. Provider=%STM%
  10. LayoutFile=layout.inf
  11. DriverVer=10/02/06

  12. [Manufacturer]
  13. %STM%=DeviceList

  14. [DestinationDirs]
  15. DefaultDestDir=12

  16. [SourceDisksFiles]

  17. [SourceDisksNames]

  18. [DeviceList]
  19. %DESCRIPTION%=STMUSB, USB\VID_03EB&PID_6133&MI_00
  20. %DESCRIPTION%=STMUSB, USB\VID_03EB&PID_6133&MI_02
  21. ;------------------------------------------------------------------------------
  22. ;  Windows 2000/XP Sections
  23. ;------------------------------------------------------------------------------

  24. [STMUSB.nt]
  25. include=mdmcpq.inf
  26. CopyFiles=DriverCopyFiles
  27. AddReg=STMUSB.nt.AddReg

  28. [DriverCopyFiles]
  29. usbser.sys,,,0x20

  30. [STMUSB.nt.AddReg]
  31. HKR,,DevLoader,,*ntkern
  32. HKR,,NTMPDriver,,usbser.sys
  33. HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

  34. [STMUSB.nt.Services]
  35. AddService=usbser, 0x00000002, DriverService


  36. [STMUSB.nt.HW]
  37. include=mdmcpq.inf

  38. [DriverService]
  39. DisplayName=%DESCRIPTION%
  40. ServiceType=1
  41. StartType=3
  42. ErrorControl=1
  43. ServiceBinary=%12%\usbser.sys

  44. ;------------------------------------------------------------------------------
  45. ;  String Definitions
  46. ;------------------------------------------------------------------------------

  47. [Strings]
  48. STM="STMicroelectronics"
  49. DESCRIPTION="STM32F10x DUAL CDC"
复制代码




收藏 评论0 发布时间:2022-2-6 22:31

举报

0个回答

所属标签

相似技术帖

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版