[STM32F1] STM32 USB HUB 求助

[复制链接]
3095|7
 楼主| louisignal 发表于 2015-12-2 16:42 | 显示全部楼层 |阅读模式
最近的项目中需要使用STM32F105通过USB HUB连接多个USB Key。
HUB芯片选用台湾汤铭科技的FE2.1
STM32F105已经成功枚举了HUB芯片,设置了地址、读出了设备描述字、配置描述字、接口描述字、端点描述字。
枚举过程如下:

case ENUM_IDLE:                                 // 初始化,读端点0的MPS
case ENUM_GET_FULL_DEV_DESC:      // 读完整的设备描述字
case ENUM_SET_ADDR:                        // 设置地址
case ENUM_GET_CFG_DESC:                //  读配置描述字前8字节
case ENUM_GET_FULL_CFG_DESC:       //  读全部配置描述字  
case ENUM_GET_MFC_STRING_DESC:  //  读字符串
case ENUM_GET_MFC_STRING_DESC:  //  读字符串
case ENUM_GET_SERIALNUM_STRING_DESC:    //   读字符串
case ENUM_SET_CONFIGURATION:       //  设置HUB配置------卡住
case ENUM_GET_HUB_DESC:                 //  读HUB描述字------卡住
case ENUM_DEV_CONFIGURED:             //  枚举结束

USB2.0标准上说HUB需要使用USB 标准配置命令Set Configuration配置以后才能正常工作,我配置如下:
       phost->Control.setup.b.bmRequestType = 0;
       phost->Control.setup.b.bRequest = USB_REQ_SET_CONFIGURATION;
       phost->Control.setup.b.wValue.w = 1;
       phost->Control.setup.b.wIndex.w = 0;
       phost->Control.setup.b.wLength.w = 0;  

HUB芯片给我的回复是STALL,意思是不支持此项配置!同样是USB 标准命令,为什么Set Address就可以,Set Configuration不可以。

我又试着读取HUB描述字,结果回来都是0!

FE2.1搞死我算了,枚举就卡在倒数第2、3项设置HUB配置、读HUB描述字。

插上USB KEY以后,读HUB的变化字,也是都是0,根本检测不出端口插上的USB设备。
 楼主| louisignal 发表于 2015-12-2 21:15 | 显示全部楼层
自问自答吧:问题解决了
在USB2.0协议文档中,关于Set Address和Set configuration是这么说的:
关于地址设置:设为0,则设备处于Default state;设成非0地址,则设备处于Address state
>>Default state: If the address specified is non-zero, then the device shall enter the Address state;
otherwise, the device remains in the Default state (this is not an error condition).
>>Address state: If the address specified is zero, then the device shall enter the Default state;
otherwise, the device remains in the Address state but uses the newly-specified
address.
>>Configured state: Device behavior when this request is received while the device is in the Configured
state is not specified.

关于Set Configuration:对处于Default state下的设备Set Configuration是错误的。
>>Default state: Device behavior when this request is received while the device is in the Default state
is not specified.
>>Address state: If the specified configuration value is zero, then the device remains in the Address
state. If the specified configuration value matches the configuration value from a
configuration descriptor, then that configuration is selected and the device enters the
Configured state. Otherwise, the device responds with a Request Error.
>>Configured state: If the specified configuration value is zero, then the device enters the Address state.
If the specified configuration value matches the configuration value from a
configuration descriptor, then that configuration is selected and the device remains in
the Configured state. Otherwise, the device responds with a Request Error.

SO,只要设置一个非0的地址就什么都好了!
 楼主| louisignal 发表于 2015-12-2 21:17 | 显示全部楼层
大家速速回复,我要结贴撒分了!
香水城 发表于 2015-12-3 12:06 | 显示全部楼层
自己找到问题所在更能学到东西!
加油!
小小强112 发表于 2016-5-4 17:40 | 显示全部楼层
楼主我也正用唐铭的FE2.1S  能把你代码参考一下吗
vakite 发表于 2017-5-2 17:55 | 显示全部楼层
请问楼主hub枚举完了如何读设备的描述符
yqdz2005 发表于 2017-5-2 18:10 | 显示全部楼层
有需要用到ST MCU的,都可以加我聊下,我们专注这块10多年了,常备现货!或许能帮到你降低成本!   270129716
18784506782 发表于 2022-1-28 17:19 | 显示全部楼层
楼主,新年好,想问下 我现在HUb枚举成功了,插上设备都能识别是哪个口 但是不知道怎么去枚举HUB上的设备,你能给点提示吗
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

14

帖子

0

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