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设备。
我也想弄个,但无从下手.对这个HUB 不了解如何工作的. 自问自答吧:问题解决了
在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 于 2018-1-18 15:18 编辑
大家在研究STM USB主机 USB设备 CH340等遇到问题的时候请参阅USB协议2.0或询问厂商技术支持:)
可以参考vsfusbh协议栈,里面有hub驱动
http://github.com/versaloon/vsf/tree/master/vsf/stack/usb/class/host/HUB le062 发表于 2015-12-3 12:38
可以参考vsfusbh协议栈,里面有hub驱动
http://github.com/versaloon/vsf/tree/master/vsf/stack/usb/clas ...
请问你有这个包的说明文档吗,里面有stm32f4的库,可是里面的文件有点乱,不知道怎么用 楼主,可以学习一下你怎么通过USB host枚举挂载在HUB上的设备吗?
我自己已经搞定,USB HOST枚举和控制HUB,但是不知道怎么通过HOST去枚举HUB上的设备。 请问有做出来么
页:
[1]