STM32F4 USB总结以及 同时支持键盘 鼠标 U盘和usb hub

经过实验STM32F4的USB口可以按下列方法使用

1,两个USB口可同时单独使用 比如FS口接键盘   HS口接u盘

2,每个usb口可同时兼容鼠标键盘 U盘 和usb hub  每次插入一个设备 能正常使用

3,每个usb口可以外扩usb hub,但是需要写驱动。目前用FS口外接四口hub 插入键盘 鼠标和u盘 工作正常

4,HS高速口可以不外扩phy而用内置phy用作全速口此时D+ D-为PB14  PB15

APP RUNNING...

APP RUNNING...
---system start printf----------

HAL_HCD_MspInit
phost->ClassNumber=1
phost->ClassNumber=2
phost->ClassNumber=3
***USBH_FS HOST_USER_CONNECTION

USB Device Attached
USBH_LL_GetSpeed 1 (LOW=2,FULL=1)
addrd: 0x00, pipe: 0
addrd: 0x80, pipe: 1
USBH_ParseDevDesc
12 01 00 02 09 00 00 40 
Enum mps: 64, addr: 0
USBH_ParseDevDesc
12 01 00 02 09 00 00 40 40 1A 01 01 11 01 00 01 00 01 
PID  : 101h
VID  : 1a40h
Address (#5) assigned.
USBH_ParseCfgDesc, number of interfaces: 1
itfclass 0x09
USBH_ParseInterfaceDesc, itf 0, class 0x09, subclass: 0x00, proto: 0x00, numep 1
Manufacturer : N/A
Product : USB 2.0 Hub
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
class macthed pClass[idx] index=1
Switching to Interface (#0)
device POLL 255, LEN 1
addrd: 0x81, pipe: 2
HUB class started.
4 HUB PORTS ENABLED
=============================================
HUB_CurPort 1
HUB_DEV_ATTACHED 1, lowspeed? 0
attach 1
PROCESSING ATTACH 1
USBH_ParseDevDesc
12 01 00 02 00 00 00 40 
Enum mps: 64, addr: 0
USBH_ParseDevDesc
12 01 00 02 00 00 00 40 8F 05 87 63 05 01 01 02 03 01 
PID  : 6387h
VID  : 58fh
Address (#1) assigned.
USBH_ParseCfgDesc, number of interfaces: 1
itfclass 0x08
USBH_ParseInterfaceDesc, itf 0, class 0x08, subclass: 0x06, proto: 0x50, numep 2
Manufacturer : Generic
Product : Mass Storage
Serial Number : A44BC940
Enumeration done.
This device has only 1 configuration.
Default configuration set.
class macthed pClass[idx] index=1
Switching to Interface (#0)
addrd: 0x01, pipe: 3
addrd: 0x82, pipe: 4
MSC class started.
Number of supported LUN: 1
LUN #0: 
HUB_CurPort 3
HUB_DEV_ATTACHED 3, lowspeed? 1
attach 3
PROCESSING ATTACH 3
USBH_ParseDevDesc
12 01 10 01 00 00 00 08 
Enum mps: 8, addr: 0
USBH_ParseDevDesc
12 01 10 01 00 00 00 08 3A 09 10 25 00 01 01 02 00 01 
PID  : 2510h
VID  : 93ah
Address (#3) assigned.
USBH_ParseCfgDesc, number of interfaces: 1
itfclass 0x03
USBH_ParseInterfaceDesc, itf 0, class 0x03, subclass: 0x01, proto: 0x02, numep 1
Manufacturer : PixArt
Product : USB Optical Mouse
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
class macthed pClass[idx] index=0
INTERFACES: 1
class macthed pClass[idx] index=0
Switching to Interface (#0)
Class    : 3h
SubClass : 1h
Protocol : 2h
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
HID LEN 52 - 0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
Mouse found.
class macthed pClass[idx] index=0
addrd: 0x81, pipe: 5
IN  size=4, num 5, addr 0x81, pool 10, lowspeed? 1
class macthed pClass[idx] index=0
Switching to Interface (#0)
HID class started.
***USBH_FS HOST_USER_CLASS_ACTIVE

HUB_CurPort 4
HUB_DEV_ATTACHED 4, lowspeed? 1
attach 4
PROCESSING ATTACH 4
USBH_ParseDevDesc
12 01 00 02 00 00 00 08 
Enum mps: 8, addr: 0
USBH_ParseDevDesc
12 01 00 02 00 00 00 08 45 0C 63 76 01 00 01 02 00 01 
PID  : 7663h
VID  : c45h
Address (#4) assigned.
USBH_ParseCfgDesc, number of interfaces: 2
itfclass 0x03
USBH_ParseInterfaceDesc, itf 0, class 0x03, subclass: 0x01, proto: 0x01, numep 1
itfclass 0x03
USBH_ParseInterfaceDesc, itf 1, class 0x03, subclass: 0x00, proto: 0x00, numep 1
Manufacturer : SONiX
Product : USB Keyboard
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
class macthed pClass[idx] index=0
INTERFACES: 2
class macthed pClass[idx] index=0
Switching to Interface (#0)
Class    : 3h
SubClass : 1h
Protocol : 1h
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
HID LEN 65 - 0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
KeyBoard found.
class macthed pClass[idx] index=0
addrd: 0x81, pipe: 6
IN  size=8, num 6, addr 0x81, pool 10, lowspeed? 1
class macthed pClass[idx] index=0
Switching to Interface (#1)
Class    : 3h
SubClass : 0h
Protocol : 0h
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
HID LEN 52 - 1
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
class macthed pClass[idx] index=0
Switching to Interface (#0)
HID class started.
***USBH_FS HOST_USER_CLASS_ACTIVE

Inquiry Vendor  : Generic 
Inquiry Product : Flash Disk      
Inquiry Version : 8.00
MSC Device ready
MSC Device capacity : 3737124352 Bytes
Block number : 15687679
Block Size   : 512
***USBH_FS HOST_USER_CLASS_ACTIVE

FATFS_LinkDriver USBH_Driver USBDISKPath...

FATFS_LinkDriver USBH_Driver USBDISKPath finished

> APPLI_MSC_EXPLORER

> Appli_FS_state == APPLICATION_FS_READY

> Explore_Disk == hUSBHost_FS

> Explore_Disk.

> f_opendir.

> f_opendir. OK

> USBH_MSC_IsReady(&phost) YES

   |__
SYSTEM~1

> Explore_Disk.

> f_opendir.

> f_opendir. OK

> USBH_MSC_IsReady(&phost) YES

   |   |__
WPSETT~1.DAT

> USBH_MSC_IsReady(&phost) YES

   |   |__
INDEXE~1

> USBH_MSC_IsReady(&phost) YES

> Select an operation to Continue.

> USBH_MSC_IsReady(&phost) YES

   |__
1.TXT

> USBH_MSC_IsReady(&phost) YES

   |__
TEST_U~1.C

> USBH_MSC_IsReady(&phost) YES

   |__
NEW

> Explore_Disk.

> f_opendir.

> f_opendir. OK

> USBH_MSC_IsReady(&phost) YES

> Select an operation to Continue.

> USBH_MSC_IsReady(&phost) YES

   |__
USBHOST.TXT

> USBH_MSC_IsReady(&phost) YES

> Select an operation to Continue.

  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 18
    评论
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值