没有合适的资源?快使用搜索试试~ 我知道了~
首页STM32-USB枚举成Audio-CCID-HID-CDC-MSC-DFU等设备的示例应用手册说明.pdf
资源详情
资源评论
资源推荐
February 2014 DocID025767 Rev 1 1/73
UM1717
User manual
STM32F0x2xx USB Full Speed Device Library
Introduction
The STM32F0x2xx USB Full Speed Device Library (STSW-STM32092) is a firmware and
application software package that includes examples based on a set of six classes (Audio,
CCID, CDC, HID, MSC and DFU), for easy development of applications using USB full
speed transfer types (control, interrupt, bulk and isochronous).
The STM32F072xx and STM32F042xx devices embed the following new features:
• The LPM (Link Power Management) to introduce a new power-save state, L1(Sleep),
with fast entry and exit times compared to traditional L2 state (Suspend)
• Analog USB Phy Transceiver with BCD (Battery Charging Device)
• Integrated CRS (Clock Recovery System) to get precise-enough clock for USB without
any external resonator component (Crystal) just using the USB traffic as timing
reference.
This new USB FS Device Library is a STM32F0x2xx devices-dedicated and is the result of
merging the current USB FS Device Library (V4.0.0) and the USB OTG Host and Device
Library (V2.1.0) ensuring a full API compatibility.
It is built with a reduced footprint to provide optimum solution for low memory STM32
products.
This document describes all the components, including examples for the following types of
devices:
Human Interface Device HID:
– HID mouse and Custom HID examples
Audio:
– Audio device Example for streaming audio data
Communication Device (CDC):
– VCP USB-to-RS232 bridge to realize a virtual COM port.
BULK:
– Mass Storage Demo based on the micro SD
Device Firmware Upgrade:
– DFU for firmware downloads and uploads
CCID: Integrated Circuits Cards Interface devices (New development)
– USB CCID device
Composite examples:
– CDC-HID and HID-MSC.
All the examples are developed and validated on the STM32072B-EVAL evaluation board
and can be easily tailored to any other hardware.
www.st.com
Contents UM1717
2/73 DocID025767 Rev 1
Contents
1 Reference information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 USB device library overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 Main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 USB device library folder structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4 USB low level driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.1 USB low level driver architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 USB low level driver files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.3 USB driver programming manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.3.1 Low level driver structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.3.2 Programming device drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5 USB device library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.1 USB device library overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.2 USB device library description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2.1 USB device library flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2.2 USB device library process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.2.3 USB device data flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.2.4 USB device library configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.2.5 USB control functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3 USB device library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.4 USB device class interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.5 USB device user interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.6 USB device classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.6.1 HID class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.6.2 Mass storage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.6.3 Device firmware upgrade (DFU) class . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.6.4 Audio class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.6.5 Communication device class (CDC) . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.6.6 CCID (Specification for Integrated Circuit(s) Cards Interface Devices) . 47
DocID025767 Rev 1 3/73
UM1717 Contents
3
5.6.7 Adding a custom class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.7 Application layer description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.8 Starting the USB library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.9 USB examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.9.1 USB mass storage example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.9.2 USB human interface example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.9.3 USB firmware upgrade example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.9.4 USB virtual com port (VCP) example . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.9.5 USB audio example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.9.6 USB CCID example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.9.7 USB Composite examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.9.8 Custom HID example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6 Frequently-asked questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
List of tables UM1717
4/73 DocID025767 Rev 1
List of tables
Table 1. List of terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Table 2. USB low level file descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 3. USB_Device_dev struct size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Table 4. Standard requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 5. USB device core files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 6. usbd_core (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 7. usbd_ioreq (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Table 8. usbd_req (.c, .h) functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Table 9. USB device class files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Table 10. usbd_hid_core (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Table 11. SCSI commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Table 12. usbd_msc_core (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Table 13. usbd_msc_bot (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Table 14. usbd_msc_scsi (.c, .h) functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Table 15. Disk operation functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Table 16. DFU states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Table 17. Supported requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Table 18. usbd_dfu_core (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Table 19. usbd_dfu_mal (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Table 20. usbd_flash_if (.c,.h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Table 21. Audio control requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Table 22. usbd_audio_core (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Table 23. usbd_audio_xxx_if (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Table 24. Audio player states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Table 25. usbd_cdc_core (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Table 26. Configurable CDC parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Table 27. usbd_cdc_xxx_if (.c, .h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Table 28. Variables used by usbd_cdc_xxx_if.c/.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Table 29. usbd_ccid_core(.c,.h) files functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Table 30. usbd_ccid_if.c(.c,.h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Table 31. usbd_ccid_cmd(.c,.h) files functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Table 32. Summary of supported Class Specific Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Table 33. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
DocID025767 Rev 1 5/73
UM1717 List of figures
5
List of figures
Figure 1. USB device library organization overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 2. Folder structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 3. Driver architecture overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 4. Driver files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 5. USB device library architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 6. USB device library file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 7. USB device library process flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Figure 8. USB device data flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Figure 9. BOT Protocol architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Figure 10. DFU Interface state transitions diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Figure 11. USB Audio Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Figure 12. CCID Class Driver Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Figure 13. Folder organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Figure 14. USBD_Initf unction example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Figure 15. Configuration 1a: Two different hosts for USB and USART . . . . . . . . . . . . . . . . . . . . . . . . 58
Figure 16. Configuration 1b: One single Host for USB and USART . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Figure 17. Configuration 2: Loopback mode (for test purposes) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Figure 18. CCID State machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Figure 19. Device descriptor of a composite device with single interface function . . . . . . . . . . . . . . . 63
Figure 20. Device descriptor of a composite device with single interface function . . . . . . . . . . . . . . . 63
Figure 21. Architecture of the HID MSC composite example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Figure 22. Standard Interface Association Descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Figure 23. Custom HID topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Figure 24. Data OUT format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Figure 25. Data IN Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
剩余72页未读,继续阅读
慢慢Coding
- 粉丝: 38
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0