打印

请问stm32的usb可以同时做虚拟串口和u盘

[复制链接]
7779|14
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
清风致影|  楼主 | 2012-10-28 11:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请问stm32的usb可以同时做虚拟串口和u盘?u盘是使用外部spi存储器的。
沙发
JasonWangFAE| | 2012-10-29 15:55 | 只看该作者
You can use interface association descriptor(IAD) to implement this.

使用特权

评论回复
板凳
JasonWangFAE| | 2012-10-29 15:59 | 只看该作者
You can use interface association descriptor(IAD) to implement this.

使用特权

评论回复
地板
IJK| | 2012-10-29 16:41 | 只看该作者
stm32的usb可以同时做虚拟串口和u盘。再多模拟个鼠标,也可以

使用特权

评论回复
5
清风致影|  楼主 | 2012-10-30 08:07 | 只看该作者
4# IJK 请问有没有相关例程参考?

使用特权

评论回复
6
figo20042005| | 2012-10-30 08:48 | 只看该作者
这个可以做,好像没有同时做的例程,有单独的例程,综合下

使用特权

评论回复
7
IJK| | 2012-10-30 11:06 | 只看该作者
ST的DEMO 似乎有把 U盘和鼠标合起来的例子,可以参考一下。

使用特权

评论回复
8
清风致影|  楼主 | 2012-10-30 11:12 | 只看该作者
7# IJK
好的 谢谢

使用特权

评论回复
9
xqscu| | 2012-10-30 16:22 | 只看该作者
const uint8_t MASS_DeviceDescriptor[MASS_SIZ_DEVICE_DESC] =
  {
    0x12,   // bLength  
    USB_DEVICE_DESCRIPTOR_TYPE,   // bDescriptorType
    0x00,   // bcdUSB, version 2.00
    0x02,
    0xef,   // bDeviceClass : each interface define the device class
    0x02,   // bDeviceSubClass
    0x01,   // bDeviceProtocol
    0x40,   // bMaxPacketSize0 0x40 = 64
    0x83,   // idVendor     (0483)
    0x02,
    0x40,   // idProduct
    0x57,
    0x00,   // bcdDevice 2.00
    0x02,
    1,              // index of string Manufacturer  
    //
    2,              // index of string descriptor of product
    //
    3,              //
    //
    //
    0x01    //bNumConfigurations
  };
const uint8_t MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] =
  {

    0x09,   // bLength: Configuation Descriptor size
    USB_CONFIGURATION_DESCRIPTOR_TYPE,   // bDescriptorType: Configuration
    MASS_SIZ_CONFIG_DESC,

    0x00,
    0x03,   // bNumInterfaces: 3 interface
    0x01,   // bConfigurationValue:
    //      Configuration value
    0x00,   // iConfiguration:
    //      Index of string descriptor
    //      describing the configuration
    0xC0,   // bmAttributes:
    //      bus powered
    0x32,   // MaxPower 100 mA

    // IAD
    0x08,        //描述符大小
    0x0B,        //IAD描述符类型
    0x00,        // bFirstInterface
    0x01,        // bInterfaceCount
    0x08,        // bFunctionClass: MASS STORAGE Class
    0x06,        // bFunctionSubClass
    0x50,        // bFunctionProtocol
    0x04,        // iFunction        

    //******************* Descriptor of Mass Storage interface *******************
    // 09
    0x09,   // bLength: Interface Descriptor size
    USB_INTERFACE_DESCRIPTOR_TYPE,   // bDescriptorType:
    //      Interface descriptor type
    0x00,   // bInterfaceNumber: Number of Interface
    0x00,   // bAlternateSetting: Alternate setting
    0x02,   // bNumEndpoints
    0x08,   // bInterfaceClass: MASS STORAGE Class
    0x06,   // bInterfaceSubClass : SCSI transparent
    0x50,   // nInterfaceProtocol
    4,          // iInterface:
    // 18
    0x07,   //Endpoint descriptor length = 7
    USB_ENDPOINT_DESCRIPTOR_TYPE,   //Endpoint descriptor type
    0x84,   //Endpoint address (IN, address 1)
    0x02,   //Bulk endpoint type
    0x40,   //Maximum packet size (64 bytes)
    0x00,
    0x00,   //Polling interval in milliseconds
    // 25
    0x07,   //Endpoint descriptor length = 7
    USB_ENDPOINT_DESCRIPTOR_TYPE,   //Endpoint descriptor type
    0x05,   //Endpoint address (OUT, address 2)
    0x02,   //Bulk endpoint type
    0x40,   //Maximum packet size (64 bytes)
    0x00,
    0x00,   //Polling interval in milliseconds
    //32

    // IAD
    0x08,        //描述符大小
    0x0B,        //IAD描述符类型
    0x01,        // bFirstInterface
    0x02,        // bInterfaceCount
    0x02,        // bFunctionClass: MASS STORAGE Class
    0x02,        // bFunctionSubClass
    0x01,        // bFunctionProtocol
    0x05,        // iFunction        

    //Interface Descriptor
    0x09,   // bLength: Interface Descriptor size
    USB_INTERFACE_DESCRIPTOR_TYPE,  // bDescriptorType: Interface
    // Interface descriptor type
    0x01,   // bInterfaceNumber: Number of Interface
    0x00,   // bAlternateSetting: Alternate setting
    0x01,   // bNumEndpoints: One endpoints used
    0x02,   // bInterfaceClass: Communication Interface Class
    0x02,   // bInterfaceSubClass: Abstract Control Model
    0x01,   // bInterfaceProtocol: Common AT commands
    0x05,   // iInterface:
    //Header Functional Descriptor
    0x05,   // bLength: Endpoint Descriptor size
    0x24,   // bDescriptorType: CS_INTERFACE
    0x00,   // bDescriptorSubtype: Header Func Desc
    0x10,   // bcdCDC: spec release number
    0x01,
    //Call Managment Functional Descriptor
    0x05,   // bFunctionLength
    0x24,   // bDescriptorType: CS_INTERFACE
    0x01,   // bDescriptorSubtype: Call Management Func Desc
    0x00,   // bmCapabilities: D0+D1
    0x01,   // bDataInterface: 1
    //ACM Functional Descriptor
    0x04,   // bFunctionLength
    0x24,   // bDescriptorType: CS_INTERFACE
    0x02,   // bDescriptorSubtype: Abstract Control Management desc
    0x02,   // bmCapabilities
    //Union Functional Descriptor
    0x05,   // bFunctionLength
    0x24,   // bDescriptorType: CS_INTERFACE
    0x06,   // bDescriptorSubtype: Union func desc
    0x00,   // bMasterInterface: Communication class interface
    0x01,   // bSlaveInterface0: Data Class Interface
    //Endpoint 2 Descriptor
    0x07,   // bLength: Endpoint Descriptor size
    USB_ENDPOINT_DESCRIPTOR_TYPE,   // bDescriptorType: Endpoint
    0x84,   // bEndpointAddress: (IN3)
    0x03,   // bmAttributes: Interrupt
    VIRTUAL_COM_PORT_INT_SIZE,      // wMaxPacketSize:
    0x00,
    0xFF,   // bInterval:
   
   
    //Data class interface descriptor
    0x09,   // bLength: Endpoint Descriptor size
    USB_INTERFACE_DESCRIPTOR_TYPE,  // bDescriptorType:
    0x02,   // bInterfaceNumber: Number of Interface
    0x00,   // bAlternateSetting: Alternate setting
    0x02,   // bNumEndpoints: Two endpoints used
    0x0A,   // bInterfaceClass: CDC
    0x00,   // bInterfaceSubClass:
    0x00,   // bInterfaceProtocol:
    0x05,   // iInterface:
    //Endpoint 3 Descriptor
    0x07,   // bLength: Endpoint Descriptor size
    USB_ENDPOINT_DESCRIPTOR_TYPE,   // bDescriptorType: Endpoint
    0x81,   // bEndpointAddress: (IN3)
    0x02,   // bmAttributes: Bulk
      64,   // wMaxPacketSize:
    0x00,
    0x00,   // bInterval: ignore for Bulk transfer
    //Endpoint 1 Descriptor
    0x07,   // bLength: Endpoint Descriptor size
    USB_ENDPOINT_DESCRIPTOR_TYPE,   // bDescriptorType: Endpoint
    0x03,   // bEndpointAddress: (OUT5)
    0x02,   // bmAttributes: Bulk
      64,             // wMaxPacketSize:
    0x00,
    0x00    // bInterval
  };

USB复合设备配置,可以参考

使用特权

评论回复
评论
yang4469 2014-3-28 18:40 回复TA
thx 
10
hwl1023| | 2012-12-17 09:53 | 只看该作者
IAD 的例子么

使用特权

评论回复
11
njchenmin| | 2013-8-7 06:38 | 只看该作者
标记一下,看看哪里有例程

使用特权

评论回复
12
hwfwy| | 2014-5-28 08:37 | 只看该作者
是呀,我现在也想问这个问题,如何同时访问虚拟COM和U盘

使用特权

评论回复
13
香水城| | 2014-5-28 10:55 | 只看该作者
hwfwy 发表于 2014-5-28 08:37
是呀,我现在也想问这个问题,如何同时访问虚拟COM和U盘

复合设备。

STMCU的USB IP的设备例程库有HID+MSC的例子。

使用特权

评论回复
14
y1柯小草| | 2014-10-11 11:29 | 只看该作者
楼主!你做出来了吗?能给个例子不!非常感谢!

使用特权

评论回复
15
y1柯小草| | 2014-10-12 18:15 | 只看该作者
楼主,能给个联系方式吗?我也在做这个东西!能给我点建议或者例诚嘛!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:我在背后默默的看着你 默默的看着你渐去渐远渐无影

161

主题

1161

帖子

2

粉丝