UM0290
User manual
STR7/STR9 USB developer kit
Introduction
The STR7/9 USB developer 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 ST 32-bit USB microcontrollers (STR71x, STR75x and STR91x).
The aim of the STR7/9 USB developer kit is to use the same certified USB library across the
STR7/STR9 microcontroller families and present for each at least one firmware demo per
USB transfer type.
This document presents a description of all the components of the STR7/9 USB Developer
kit, including:
■
■
■
■
■
■
■
Common STR7/9 USB library: All processes related to default endpoint and standard
requests
Joystick mouse demo: Interrupt transfer
Custom HID: interrupt transfer
Device Firmware Upgrade (DFU): control transfer
Mass storage demo: Bulk transfer
Virtual COM port: Bulk transfer
USB voice demo (speaker and microphone): Isochronous transfer
November 2008
Rev 2
1/76
www.st.com
Contents
UM0290
Contents
1
STR7/STR9 USB firmware library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1
1.2
USB application hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
USB library core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.1
1.2.2
1.2.3
1.2.4
usb_type.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
usb_reg(.c, .h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
usb_int (.c , .h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
usb_core (.c , .h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3
Application interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.3.1
1.3.2
1.3.3
1.3.4
1.3.5
usb_istr(.c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
usb_conf(.h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
usb_endp (.c) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
usb_prop (.c , .h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
usb_pwr (.c , .h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.4
Implementing a USB application using the STR7/9 USB library . . . . . . . 21
1.4.1
1.4.2
1.4.3
Implementing a no data class specific request . . . . . . . . . . . . . . . . . . . 21
How to implement a data class specific request . . . . . . . . . . . . . . . . . . 21
How to manage data transfers in a non-control endpoint . . . . . . . . . . . 22
2
3
Joystick mouse demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Custom HID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.1
3.2
3.3
General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Descriptor topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Custom HID implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3.1
3.3.2
3.3.3
LEDs control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Push button states report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
ADC converted data transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4
Device firmware upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.1
4.2
General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
DFU extension protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.2.1
4.2.2
4.2.3
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Phases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2/76
UM0290
Contents
4.3
DFU mode selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.3.1
4.3.2
Run-time descriptor set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
DFU mode descriptor set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.4
4.5
Reconfiguration phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Transfer phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.5.1
4.5.2
4.5.3
4.5.4
4.5.5
Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Special command/protocol descriptions . . . . . . . . . . . . . . . . . . . . . . . . 34
DFU state diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Downloading and uploading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Manifestation phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.6
DFU implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.6.1
4.6.2
4.6.3
DFU mode entry mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Available DFU images in the STR7/9 USB development kit . . . . . . . . . 37
How to create a DFU Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5
Mass storage demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.1
5.2
Mass storage demo overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Mass storage protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.2.1
5.2.2
Bulk Only Transfer (BOT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Small Computer System Interface (SCSI) . . . . . . . . . . . . . . . . . . . . . . . 42
5.3
Mass storage demo implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3.1
5.3.2
5.3.3
5.3.4
5.3.5
5.3.6
5.3.7
Hardware configuration interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Endpoint configurations and data management . . . . . . . . . . . . . . . . . . 44
Class specific requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Standard request requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
BOT state machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
SCSI protocol implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Memory management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.4
How to customize the mass storage demo . . . . . . . . . . . . . . . . . . . . . . . 49
6
Virtual COM port demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
6.1
6.2
6.3
Virtual COM port demo proposal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Software driver installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
6.3.1
6.3.2
Hardware implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Firmware implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3/76
Contents
UM0290
7
USB voice demos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.1
7.2
7.3
Isochronous transfer overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Audio device class overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
STR7/9 USB audio speaker demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.3.1
7.3.2
7.3.3
General characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
STR91x USB audio speaker using the DMA . . . . . . . . . . . . . . . . . . . . . 62
7.4
STR7/9 USB microphone (only for STR75x and STR91x families) . . . . . 63
7.4.1
7.4.2
General characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
8
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4/76
UM0290
STR7/STR9 USB firmware library
1
STR7/STR9 USB firmware library
This section describes the firmware interface (called USB Library) used to manage the
STR7/9 USB 2.0 full-speed macrocell.
The main purpose of this firmware library is to provide resources to ease the development of
applications using the USB macrocell in all STR7/9 microcontrollers (STR71x, STR75x and
the STR91x families).
1.1
USB application hierarchy
Figure 1
shows the interaction between the different components of a typical USB
application and the USB library.
Figure 1.
USB application hierarchy
USB Application
Standard
usb_desc
usb_pwr
Application Interface
Library
usb_istr
usb_prop
usb_endp
USB Library
Core
usb_core
usb_init
usb_int
usb_regs
usb_mem
USB IP
The USB library is divided into two layers:
●
Hardware (STR microcontroller + Board)
USB Library Core layer:
This layer manages the direct communication with the USB
IP hardware and the USB standard protocol. The USB Library Core is compliant with
the USB 2.0 specification and doesn’t have dependences with any Standard Software
Library of STR7/9 microcontrollers.
Application Interface layer:
This layer presents to the user a complete interface
between the library core and the final application.
●
Note:
The application interface layer and the final application can communicate with the Standard
Software Library to manage the hardware needs of the application.
5/76