STM32/STM8技术论坛
直播中

李艳

8年用户 1567经验值
私信 关注
[问答]

STM32 USB HUB 求助

最近的项目中需要使用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设备。

回帖(6)

华农武

2019-3-26 16:04:55
我也想弄个,但无从下手.对这个HUB 不了解如何工作的.
举报

李艳

2019-3-26 16:24:46
自问自答吧:问题解决了
在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的地址就什么都好了!
举报

李艳

2019-3-26 16:40:01
本帖最后由 louisignal 于 2018-1-18 15:18 编辑

大家在研究STM USB主机 USB设备 CH340等遇到问题的时候请参阅USB协议2.0或询问厂商技术支持
举报

周炳胤

2019-3-26 16:50:14
可以参考vsfu***h协议栈,里面有hub驱动
https://github.com/versaloon/vsf ... /u***/class/host/HUB
举报

戚歆敦

2019-3-26 17:09:32
请问你有这个包的说明文档吗,里面有stm32f4的库,可是里面的文件有点乱,不知道怎么用
举报

Christian777

2021-8-24 10:36:22
受到警告
提示: 作者被禁止或删除 内容自动屏蔽
举报

更多回帖

发帖
×
20
完善资料,
赚取积分