STM32的USB如何能枚举出多个设备?

[复制链接]
8417|13
 楼主| lmp 发表于 2009-10-19 14:23 | 显示全部楼层 |阅读模式
各位高手:

       我现在在做一个USB的读卡器,因读卡器上有三个插糟,想三个插糟对应在主机上显示出三个设备,请问该如何配置,现在只能显示一个设备,
{
   0x12,   /* bLength  */
    0x01,   /* bDescriptorType */
    0x01,   /* bcdUSB, version 2.00 */
    0x10,
    0x00,   /* bDeviceClass : each interface define the device class */
    0x00,   /* bDeviceSubClass */
    0x00,   /* bDeviceProtocol */
    0x40,   /* bMaxPacketSize0 0x40 = 64 */
    0x3C,   /* idVendor  */   
    0x16,     
    0x03,   /* idProduct */
    0x0A,   //W5181  Reader
    0x00,   /* bcdDevice 1.00*/
    0x01,
    1,              /* index of string Manufacturer  */
    /**/
    2,              /* index of string descriptor of product*/
    /* */
    3,              /* */
    /* */
    /* */
    0x01    /*bNumConfigurations */
}

{
    0x09,   /* bLength: Configuation Descriptor size */
    0x02,   /* bDescriptorType: Configuration */
    0x5D,
    0x00,
    0x01,   /* bNumInterfaces: 1 interface */
    0x01,   /* bConfigurationValue: */
    /*      Configuration value */
    0x00,   /* iConfiguration: */
    /*      Index of string descriptor */
    /*      describing the configuration */
    0x80,
    0x46,    // 140=70*2 mA power consumption.
   
    /******************** Descriptor of Mass Storage interface ********************/
    /* 09 */
    0x09,   /* bLength: Interface Descriptor size */
    0x04,   /* bDescriptorType: */
    /*      Interface descriptor type */
    0x00,   /* bInterfaceNumber: Number of Interface */
    0x00,   /* bAlternateSetting: Alternate setting */
//   0x02,   /* bNumEndpoints*/
    0x03,   //by lmp BUIK_OUT Endpoint,BUIK_IN Endpoint, Interrupt_IN Endpoint
    0x0B,         //by LMP bInterfaceClass: Smart Card Device Class
    0x00,   /* bInterfaceSubClass : without SubClass*/
    0x00,   // bInterfaceProtocol: CCID
    0x00,   // iInterface: Index of string descriptor
    /* 18 */
    //CCID class descriptor
0x36,  // bLength: CCID Descriptor size 54Bytes
0x21,  // bDescriptorType
0x10,0x01, // bcdCCID: CCID Class Spec release number (1.1)
0x02,  // bMaxSlotIndex  Sim_card,Contactless_Card ,Non-contact card
0x06,  // bVoltageSupport: 5v,3v,1.8v only support Contactless_Card
0x03,0x00,0x00,0x00,  // dwProtocols: supports T=0
0xFC,0x0D,0x00,0x00,  // dwDefaultClock: 3.58Mhz
0xF0,0x37,0x00,0x00,  // dwMaximumClock: 14.32Mhz
0x00,    // bNumClockSupported => no manual setting
0x80,0x25,0x00,0x00,  // dwDataRate: 9600 bps (0x00002580)
0x29,0x40,0x29,0x00,  // dwMaxDataRate: 344105 bps (0x00054029)
0x00,    // bNumDataRatesSupported => no manual setting
0xFc,0x00,0x00,0x00,  // dwMaxIFSD: 255 (T=1 ) Information Field Size For The Terminal
0x00,0x00,0x00,0x00,  // dwSynchProtocols
0x00,0x00,0x00,0x00,  // dwMechanical: no special characteristics
0xBA,0x00,0x01,0x00,  // dwFeatures:TPDU Level
0x0F,0x01,0x00,0x00,  // dwMaxCCIDMessageLength 10+261 : header+Maximun block size
0xFF,   // bClassGetResponse
0xFF,   // bClassEnvelope
0x00,0x00,  // wLcdLayout
0x00,   // bPINSupport : no PIN verif and modif
0x03,   // bMaxCCIDBusySlots
   
    /* 0x49  73 */
    0x07,   /*Endpoint descriptor length = 7*/
    0x05,   /*Endpoint descriptor type */
    0x81,   /*Endpoint address (IN, address 1) */
    0x02,   /*Bulk endpoint type */
    0x40,   /*Maximum packet size (64 bytes) */
    0x00,
    0x00,   /*Polling interval in milliseconds */
   // /* 25 */
    /* 0x50  80*/
    0x07,   /*Endpoint descriptor length = 7 */
    0x05,   /*Endpoint descriptor type */
    0x02,   /*Endpoint address (OUT, address 2) */
    0x02,   /*Bulk endpoint type */
    0x40,   /*Maximum packet size (64 bytes) */
    0x00,
    0x00,     /*Polling interval in milliseconds*/
      
    0x07,   /*Endpoint descriptor length = 7 */
    0x05,   /*Endpoint descriptor type */
    0x83,   /*Endpoint address (IN, address 3) */
    0x03,   /*Bulk endpoint type Interrupt */
    0x04,   /*Maximum packet size (4 bytes) */
    0x00,
    0x20,     /*Polling interval in milliseconds*/  
   
    /*32*/
  };

郁闷了好几天了.一直没解决,请高手指点迷津!谢谢啦
香水城 发表于 2009-10-19 14:59 | 显示全部楼层
首先,枚举出多个USB设备与枚举出USB读卡器上的多个插槽,完全是2回事。枚举出多个USB设备,是复合设备的概念,而枚举出多个插槽是在大容量存储协议层面上的问题。

其次,请参考USB大容量存储协议中的Get_MAXLUN命令,实现枚举出多个插槽的操作。
 楼主| lmp 发表于 2009-10-19 15:36 | 显示全部楼层
2楼你好,

       我的设备是按照CCID协议配置的,按照协议已经配置成3个插糟的读卡器,采用的是中断方式.向主机发50 03,表示0#插糟有卡插入,主机会向0#插糟发一系列命令, 但是我向主机发 50 C0,表示1#插糟有卡插入,主机便不响应.不知该如何解决,请高手指点.谢谢!

25.3  DI     50 03                                               P.                       1.1.0        2.7sc  
  25.2  DO     63 00 00 00  00 00 01 00  00 00                     c.........               2.1.0        1.9ms  
  25.1  DI     81 00 00 00  00 00 01 00  00 00                     ..........               3.1.0        1.9ms  
  25.2  DO     62 00 00 00  00 00 02 00  00 00                     b.........               4.1.0        1.9ms  
  25.1  DI     80 11 00 00  00 00 02 00  00 00 3b 6d  00 00 57 44  ..........;m..WD         5.1.0         16ms  
               29 32 86 86  43 0e 9a 01  05 11 24                  )2..C.....$              5.1.16              
  25.2  DO     61 05 00 00  00 00 03 00  00 00 11 00  00 0a 00     a..............          6.1.0        969us  
  25.1  DI     82 05 00 00  00 00 03 00  00 00 11 00  00 0a 00     ...............          7.1.0        1.9ms  
  25.3  DI     50 02                                               P.                       8.1.0        3.9sc  
  25.3  DI     50 03                                               P.                       9.1.0        1.4sc  
  25.2  DO     63 00 00 00  00 00 04 00  00 00                     c.........              10.1.0        1.9ms  
  25.1  DI     81 00 00 00  00 00 04 00  00 00                     ..........              11.1.0        2.0ms  
  25.2  DO     62 00 00 00  00 00 05 00  00 00                     b.........              12.1.0        2.0ms  
  25.1  DI     80 11 00 00  00 00 05 00  00 00 3b 6d  00 00 57 44  ..........;m..WD        13.1.0         16ms  
               29 32 86 86  43 0e 9a 01  05 11 24                  )2..C.....$             13.1.16              
  25.2  DO     61 05 00 00  00 00 06 00  00 00 11 00  00 0a 00     a..............         14.1.0        997us  
  25.1  DI     82 05 00 00  00 00 06 00  00 00 11 00  00 0a 00     ...............         15.1.0        1.9ms  

  25.3  DI     50 c0                                               P.                       1.1.0        2.0sc  
  25.3  DI     50 80                                               P.                       2.1.0        1.3sc  
  25.3  DI     50 c0                                               P.                       3.1.0        864ms  
  25.3  DI     50 80                                               P.                       4.1.0        992ms  
  25.3  DI     50 c0                                               P.                       5.1.0        607ms  
  25.3  DI     50 80                                               P.                       6.1.0        896ms
 楼主| lmp 发表于 2009-10-19 17:13 | 显示全部楼层
顶一下

     我做的是智能卡读写器.
香水城 发表于 2009-10-19 18:40 | 显示全部楼层
       我的设备是按照CCID协议配置的,按照协议已经配置成3个插糟的读卡器,采用的是中断方式.向主机发50 03,表示0#插糟有卡插入,主机会向0#插糟发一系列命令, 但是我向主机发 50 C0,表示1#插糟有卡插入,主机便不响应.不知该如何解决 ...
lmp 发表于 2009-10-19 15:36


这个问题你只能从主机端的软件或驱动方面找原因了,你要找开发主机端软件和驱动的人询问。
无冕之王 发表于 2009-10-19 22:13 | 显示全部楼层
应该是驱动方面的问题。。。
 楼主| lmp 发表于 2009-10-20 09:03 | 显示全部楼层
各位好,
        CCID设备的驱动是Vista自带的驱动,应该是标准驱动.
香水城 发表于 2009-10-20 09:10 | 显示全部楼层
你能确定这个所谓的“标准驱动”支持多个插槽的操作吗?有什么证据?
 楼主| lmp 发表于 2009-10-20 09:47 | 显示全部楼层
CCID中规定插糟最多可以达到00-0F(16个),
smart card.JPG
香水城 发表于 2009-10-20 10:09 | 显示全部楼层
CCID中规定插糟最多可以达到00-0F(16个),
lmp 发表于 2009-10-20 09:47


我知道CCID的规定,问题是“Vista自带的驱动能否支持多个插槽的操作?有什么证据?”
 楼主| lmp 发表于 2009-10-20 10:43 | 显示全部楼层
香水城,你好!

       现在还不知道Vista是否支持多个插糟,所以想用枚举多个设备的方法解决这个难题目.我们近来一直用STM32芯片做产品,望能给些建设,谢谢!
香水城 发表于 2009-10-20 10:59 | 显示全部楼层
我在2楼已经说了“枚举出多个USB设备,是复合设备的概念”,你需要通过定义多个Interface实现一个复合设备。但我们没有做个具有多个相同功能的复合设备,不知道这个方案是否可行,但值得尝试。
 楼主| lmp 发表于 2009-10-20 11:32 | 显示全部楼层
谢谢!

       这按这个方法试一下.
zhongvv 发表于 2011-3-10 10:27 | 显示全部楼层
最后结果怎样了?请楼主说明,谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

lmp

11

主题

30

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部