打印
[应用相关]

如果下面**的内容都是正确的话

[复制链接]
5477|15
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
cpufan|  楼主 | 2008-9-9 13:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
要做一个HID和MSD的复合设备,stm32f103在发送完config descriptor后出现问题。bushond如下:
  21.0  CTL    80 06 00 01  00 00 12 00                                                                                GET DESCRIPTOR           1.1.0        
  21.0  DI     12 01 00 02  00 00 00 40  83 04 50 57  00 02 01 02  03 01                                               .......@..PW....         1.2.0        
  21.0  CTL    80 06 00 02  00 00 09 00                                                                                GET DESCRIPTOR           2.1.0        
  21.0  DI     09 02 40 00  02 01 00 c0  32                                                                            ..@.....2                2.2.0        
  21.0  CTL    80 06 00 02  00 00 40 00                                                                                GET DESCRIPTOR           3.1.0        
  21.0  DI     09 02 40 00  02 01 00 c0  32 09 04 00  00 02 03 00  00 00 09 21  10 01 00 01  22 26 00 07  05 81 03 40  ..@.....2.......         3.2.0        
               00 20 07 05  01 03 40 00  20 09 04 01  00 02 08 06  50 04 07 05  83 02 40 00  00 07 05 02  02 40 00 00  . ....@. .......         3.2.32       
  21.0  CTL    00 09 01 00  00 00 00 00                                                                                SET CONFIG               4.1.0        

config descriptor如下:

const u8 CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC] =
  {
    0x09,         /* bLength: Configuation Descriptor size */
    USB_CONFIGURATION_DESCRIPTOR_TYPE,  /* bDescriptorType: Configuration */
    CUSTOMHID_SIZ_CONFIG_DESC,          /* wTotalLength: Bytes returned */                 
    0x00,
    0x02,         /* bNumInterfaces: 2 interface */
    0x01,         /* bConfigurationValue: Configuration value */
    0x00,         /* iConfiguration: Index of string descriptor describing
                                 the configuration*/
    0xC0,         /* bmAttributes: Bus powered */
    0x32,         /* MaxPower 100 mA: this current is used for detecting Vbus */
    /* 09 */

    /************** Descriptor of Custom HID interface ****************/
    
    0x09,         /* bLength: Interface Descriptor size */
    USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */
    0x00,         /* bInterfaceNumber: Number of Interface */
    0x00,         /* bAlternateSetting: Alternate setting */
    0x02,         /* bNumEndpoints */
    0x03,         /* bInterfaceClass: HID */
    0x00,         /* bInterfaceSubClass : 1=BOOT, 0=no boot */
    0x00,         /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
    0,            /* iInterface: Index of string descriptor */
    /* 18 */
    /******************** Descriptor of Custom HID HID ********************/
    
    0x09,         /* bLength: HID Descriptor size */
    HID_DESCRIPTOR_TYPE,          /* bDescriptorType: HID */
    0x10,         /* bcdHID: HID Class Spec release number */
    0x01,
    0x00,         /* bCountryCode: Hardware target country */
    0x01,         /* bNumDescriptors: Number of HID class descriptors to follow */
    0x22,         /* bDescriptorType */
    CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */
    0x00,
    /* 27 */
    /******************** Descriptor of Custom HID endpoints ******************/

    0x07,          /* bLength: Endpoint Descriptor size */
    USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: */
    0x81,          /* bEndpointAddress: Endpoint Address (IN) */
    0x03,          /* bmAttributes: Interrupt endpoint */
    0x40,          /* wMaxPacketSize: 64 Bytes max  */
    0x00,
    0x20,          /* bInterval: Polling Interval (32 ms) */
    /* 34 */
    0x07,      /* bLength: Endpoint Descriptor size */
    USB_ENDPOINT_DESCRIPTOR_TYPE,    /* bDescriptorType: Endpoint descriptor type */
    0x01,      /* bEndpointAddress: Endpoint Address (OUT) */
    0x03,      /* bmAttributes: Interrupt endpoint */
    0x40,         /* wMaxPacketSize: 2 Bytes max  */
    0x00,
    0x20,      /* bInterval: Polling Interval (32 ms) */
    /* 41 */
    /************** Descriptor of MSD interface ****************/

    0x09,         /* bLength: Interface Descriptor size */
    USB_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType: Interface descriptor type*/
    0x01,         /* bInterfaceNumber: Number of Interface */
    0x00,         /* bAlternateSetting: Alternate setting */
    0x02,         /* bNumEndpoints*/
    0x08,         /* bInterfaceClass: MASS STORAGE Class */
    0x06,         /* bInterfaceSubClass : SCSI transparent*/
    0x50,         /* nInterfaceProtocol */
    4,            /* iInterface: */
    /* 50 */
    /******************** Descriptor of MSD endpoints ******************/

    0x07,         /* Endpoint descriptor length = 7*/
    0x05,         /* Endpoint descriptor type */
    0x83,         /* Endpoint address (IN, address 3) */
    0x02,         /* Bulk endpoint type */
    0x40,         /* Maximum packet size (64 bytes) */
    0x00,
    0x00,         /* Polling interval in milliseconds */
    /* 57 */
    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*/
    /* 64 */
  }

bushond显示host发送了set config,但跟踪发现mcu中没收到该命令,怀疑config descriptor设置有问题。但查不出来,请高手们帮忙解惑啦:)
沙发
computer00| | 2008-9-9 14:00 | 只看该作者

没看出什么问题

使用特权

评论回复
板凳
simon21ic| | 2008-9-9 14:22 | 只看该作者

如果下面**的内容都是正确的话

那么LZ所说的应该是组合设备,我也准备弄个玩玩,在偶的开发工具上集成一个CDC串口
相关链接:http://www.61ic.com/Technology/Industry/200701/11582.html

使用特权

评论回复
地板
vigia| | 2008-9-9 15:01 | 只看该作者

set config没收到和descriptor没有关系吧

如果HOST没有发,那倒可能有关系

使用特权

评论回复
5
cpufan|  楼主 | 2008-9-9 17:00 | 只看该作者

set config 没有进中断

host 发set config的时候,没有进中断。原因查不出来。。。。

使用特权

评论回复
6
cpufan|  楼主 | 2008-9-9 17:38 | 只看该作者

再贴上hub发的bushond log

   7.0  CTL    a3 00 00 00  01 00 04 00                                                                                GET STATUS               1.1.0(2)     
   7.0  DI     01 01 01 00                                                                                             ....                     1.2.0        
   7.0  CTL    23 01 10 00  01 00 00 00                                                                                CLEAR FEATURE            3.1.0        
   7.0  CTL    a3 00 00 00  01 00 04 00                                                                                GET STATUS               4.1.0(2)     
   7.0  DI     01 01 00 00                                                                                             ....                     4.2.0        
   7.0  CTL    23 03 04 00  01 00 00 00                                                                                SET FEATURE              6.1.0        
   7.0  CTL    a3 00 00 00  01 00 04 00                                                                                GET STATUS               7.1.0        
   7.0  DI     03 01 10 00                                                                                             ....                     7.2.0        
   7.0  CTL    23 01 14 00  01 00 00 00                                                                                CLEAR FEATURE            8.1.0        
   7.0  CTL    a3 00 00 00  01 00 04 00                                                                                GET STATUS               9.1.0(2)     
   7.0  DI     03 01 00 00                                                                                             ....                     9.2.0        
   7.0  CTL    23 03 04 00  01 00 00 00                                                                                SET FEATURE             11.1.0        
   7.0  CTL    a3 00 00 00  01 00 04 00                                                                                GET STATUS              12.1.0        
   7.0  DI     03 01 10 00                                                                                             ....                    12.2.0        
   7.0  CTL    23 01 14 00  01 00 00 00                                                                                CLEAR FEATURE           13.1.0        
   7.0  CTL    80 06 00 03  00 00 ff 00                                                                                GET DESCRIPTOR          14.1.0        
   7.0  DI     04 03 09 04                                                                                             ....                    14.2.0        
   7.0  CTL    80 06 03 03  09 04 ff 00                                                                                GET DESCRIPTOR          15.1.0        
   7.0  DI     1a 03 32 00  ff 00 ff 00  ff 00 36 00  39 00 32 00  35 00 47 00  50 00 01 00  43 00                     ..2.......6.9.2.        15.2.0        
   7.0  CTL    80 06 00 02  00 00 ff 00                                                                                GET DESCRIPTOR          16.1.0        
   7.0  DI     09 02 40 00  02 01 00 c0  32 09 04 00  00 02 03 00  00 00 09 21  10 01 00 01  22 26 00 07  05 81 03 40  ..@.....2.......        16.2.0        
               00 20 07 05  01 03 40 00  20 09 04 01  00 02 08 06  50 04 07 05  83 02 40 00  00 07 05 02  02 40 00 00  . ....@. .......        16.2.32       
   7.0  CTL    80 06 00 06  00 00 0a 00                                                                                GET DESCRIPTOR          17.1.0        
   7.0  CTL    a3 00 00 00  02 00 04 00                                                                                GET STATUS              18.1.0        
   7.0  DI     03 01 00 00                                                                                             ....                    18.2.0        
  21.0  CTL    80 06 00 01  00 00 12 00                                                                                GET DESCRIPTOR          19.1.0        
  21.0  DI     12 01 00 02  00 00 00 40  83 04 50 57  00 02 01 02  03 01                                               .......@..PW....        19.2.0        
  21.0  CTL    80 06 00 02  00 00 09 00                                                                                GET DESCRIPTOR          20.1.0        
  21.0  DI     09 02 40 00  02 01 00 c0  32                                                                            ..@.....2               20.2.0        
  21.0  CTL    80 06 00 02  00 00 40 00                                                                                GET DESCRIPTOR          21.1.0        
  21.0  DI     09 02 40 00  02 01 00 c0  32 09 04 00  00 02 03 00  00 00 09 21  10 01 00 01  22 26 00 07  05 81 03 40  ..@.....2.......        21.2.0        
               00 20 07 05  01 03 40 00  20 09 04 01  00 02 08 06  50 04 07 05  83 02 40 00  00 07 05 02  02 40 00 00  . ....@. .......        21.2.32       
  21.0  CTL    00 09 01 00  00 00 00 00                                                                                SET CONFIG              22.1.0        
   7.0  CTL    23 01 01 00  01 00 00 00                                                                                CLEAR FEATURE           23.1.0        

使用特权

评论回复
7
香水城| | 2008-9-9 22:22 | 只看该作者

楼主是否使用的是ST的USB库?

你是如何判断没有收到中断?

使用特权

评论回复
8
cpufan|  楼主 | 2008-9-10 09:13 | 只看该作者

to 香主

我在中断中打印,或者设断点都尝试了。
stm在发送完config descriptor后就没进中断了
奇怪的是第一次发送config descriptor后是正常的(响应hub的get congfig_descriptor)

使用特权

评论回复
9
cpufan|  楼主 | 2008-9-10 11:35 | 只看该作者

to 香主

补充:
stm在发送完config descriptor后(setup的state阶段完成后)
正常情况下,stm准备接收下一个setup,应该进入CTR中断,
但是跟踪发现没进CTR中断,而是SUSPEND中断。
为什么设备会挂起呢?
会不会是有个等待时间,等待host的set config超时导致SUSPEND?

使用特权

评论回复
10
香水城| | 2008-9-10 18:13 | 只看该作者

调试USB时不能随便设置断点

程序遇到断点时不会再响应PC端的请求,设备不响应主机的请求超过一段时间后,PC会中止USB通信,所以你的程序会进入SUSPEND中断。

使用特权

评论回复
11
vigia| | 2008-9-11 10:09 | 只看该作者

LZ说说你的USB复合设备是从ST哪个USB DEMO改过来的?

除了DESCRIPTOR你还改了些什么?

使用特权

评论回复
12
cpufan|  楼主 | 2008-9-11 11:43 | 只看该作者

问题找到了

idProduct没改。
晕死了,把core都跟踪了个遍都没找到问题。。。。。

使用特权

评论回复
13
henry_wu001| | 2010-8-11 13:45 | 只看该作者
ls的还在吗?我刚刚也碰到了这个问题,
修改idProduct后好了,但是为什么要改呢?

使用特权

评论回复
14
andyliji| | 2012-8-14 15:52 | 只看该作者
修改idProduct后好了?  写成什么?

使用特权

评论回复
15
andyliji| | 2012-8-14 15:53 | 只看该作者
13# henry_wu001
改成什么?
修改idProduct?把它改成什么?

使用特权

评论回复
16
putron09| | 2014-5-27 10:43 | 只看该作者

使用特权

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

本版积分规则

8

主题

66

帖子

0

粉丝