最近的项目中需要使用
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_CONFIGURA
tiON: // 设置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设备。
在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的地址就什么都好了!
一周热门 更多>