USB-FS-Device, STM32

[ Pobierz całość w formacie PDF ]
UM0424
User manual
STM32
USB-FS-Device development kit
Introduction
The STM32 USB-FS-Device development kit is a complete firmware and software package
including examples and demos for all USB transfer types (control, interrupt, bulk and
isochronous). It supports all STM32 microcontroller families.
The aim of the STM32 USB-FS-Device development kit is to use the STM32 USB-FS-
Device library with at least one firmware demo per USB transfer type.
This document presents a description of all the components of the STM32 USB-FS-Device
development kit, including:

STM32 USB-FS-Device library: All processes related to default endpoint and standard
requests

Device firmware upgrade (DFU) demo: Control transfer

Joystick mouse demo: Interrupt transfer

Custom HID demo: Interrupt transfer

Mass storage demo: Bulk transfer

Virtual COM port: Interrupt and bulk transfer

USB voice speaker demo (USB speaker): Isochronous transfer

USB audio streaming demo: Isochronous transfer
In this document, STM32 refers to the following devices:

Low-density devices
: STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
where the Flash memory density ranges between 16 and 32 Kbytes.

Medium-density devices
: STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes.

High-density devices
: STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 256 and 512 Kbytes.

XL-density devices:
STM32F101xx and STM32F103xx microcontrollers where the Flash
memory density ranges between 512 and 1024 Kbytes.

Connectivity line devices
: STM32F105xx and STM32F107xx microcontrollers.

Medium-density Low-Power devices
: STM32L15xx microcontrollers where the Flash
memory density ranges between 64 and 128 Kbytes.
March 2011
Doc ID 13465 Rev 10
1/81
 Contents
UM0424
Contents
1
STM32 USB-FS-Device firmware library . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1
USB application hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2
USB-FS_Device peripheral interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2.1
usb_reg(.h, .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2.2
usb_int (.h , .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.2.3
usb_mem (.h , .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3
OTG-FS_Device peripheral interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.1
otgd_fs_dev(.h, .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.2
otgd_fs_int(.h, .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.3.3
otgd_fs_pcd(.h, .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.3.4
otgd_fs_cal(.h, .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.3.5
otgd_fs_regs.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4
USB-FS-Device_Driver medium layer . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4.1
usb_init(.h,.c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4.2
usb_core (.h , .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4.3
usb_sil(.h, .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.4.4
usb_type.h / usb_def.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.5
Application interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.5.1
usb_conf(.h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.5.2
usb_desc (.h, .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.5.3
usb_prop (.h , .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.5.4
usb_endp (.c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.5.5
usb_istr(.c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
1.5.6
usb_pwr (.h , .c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
1.6
Implementing a USB-FS_Device application using the
STM32 USB-FS-Device library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
1.6.1
Implementing a no-data class-specific request . . . . . . . . . . . . . . . . . . . 24
1.6.2
How to implement a data class-specific request . . . . . . . . . . . . . . . . . . 24
1.6.3
How to manage data transfers in non-control endpoint . . . . . . . . . . . . . 25
2
Joystick mouse demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.1
General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.2
STM32 low-power management in suspend mode . . . . . . . . . . . . . . . . . 26
2.3
Remote Wakeup implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2/81
Doc ID 13465 Rev 10
UM0424
Contents
3
Custom HID demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1
General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.2
Descriptor topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3
Custom HID implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.3.1
LED control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.3.2
Push-button state report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.3.3
ADC-converted data transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4
Device firmware upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.1
General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.2
DFU extension protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.2.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.2.2
Phases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.2.3
Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.3
DFU mode selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.3.1
Run-time descriptor set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.3.2
DFU mode descriptor set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.4
Reconfiguration phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.5
Transfer phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.5.1
Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.5.2
Special command/protocol descriptions . . . . . . . . . . . . . . . . . . . . . . . . 39
4.5.3
DFU state diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.5.4
Downloading and uploading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.5.5
Manifestation phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.6
STM32 DFU implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.6.1
Supported memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.6.2
DFU mode entry mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.6.3
DFU firmware architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.6.4
Available DFU image for the STM32 . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.6.5
How to create a DFU Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5
Mass storage demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.1
General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.2
Mass storage demo overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3
Mass storage protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.3.1
Bulk-only transfer (BOT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Doc ID 13465 Rev 10
3/81
Contents
UM0424
5.3.2
Small computer system interface (SCSI) . . . . . . . . . . . . . . . . . . . . . . . . 48
5.4
Mass storage demo implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.4.1
Hardware configuration interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.4.2
Endpoint configurations and data management . . . . . . . . . . . . . . . . . . 50
5.4.3
Class-specific requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.4.4
Standard request requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.4.5
BOT state machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.4.6
SCSI protocol implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.4.7
Memory management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.4.8
Medium access management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.5
How to customize the mass storage demo . . . . . . . . . . . . . . . . . . . . . . . 55
6
Virtual COM port demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
6.1
General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
6.2
Virtual COM port demo proposal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
6.3
Software driver installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
6.4
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6.4.1
Hardware implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6.4.2
Firmware implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7
USB voice speaker demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.1
General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.2
Isochronous transfer overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.3
Audio device class overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.4
STM32 USB audio speaker demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.4.1
General characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.4.2
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
8
USB audio streaming demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
8.1
General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
8.2
STM32 USB audio streaming demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
8.2.1
General characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
8.2.2
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
9
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4/81
Doc ID 13465 Rev 10
UM0424
List of tables
List of tables
Doc ID 13465 Rev 10
5/81
[ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • emaginacja.xlx.pl
  •