Transcription of STM32Cube USB Device Library STMicroelectronics ...
1 February 2019UM1734 Rev 41/601UM1734 User manualSTM32 Cube USB Device libraryIntroductionThe STM32 Cube is an STMicroelectronics original initiative to make developers lives easier by reducing development effort, time and cost. STM32 Cube covers the whole STM32 includes: STM32 CubeMX, a graphical software configuration tool that allows the generation of C initialization code using graphical wizards. A comprehensive embedded software platform, delivered per Series (such as STM32 CubeF4 for STM32F4 Series) The STM32 Cube HAL, STM32 abstraction layer embedded software ensuring maximized portability across the STM32 portfolio, A consistent set of middleware components such as RTOS, USB, TCP/IP, Graphics, All embedded software utilities, delivered with a full set of Universal Serial Bus (USB) is the most successful interconnect in the history of personal computing which is used to connect devices like mouse, game-pads and joysticks, scanners, digital cameras, and printers.
2 USB has also migrated into consumer electronics and mobile user manual describes the STM32 Cube USB Device Library which is part of the STM32 Cube MCU Package that can be downloaded free from ST website ( ). It is intended for developers who use STM32 Cube MCU Package on STM32 microcontrollers. It describes how to start and implement a USB Device applications for most common USB Device classes (HID, MSC, audio , ) based on the USB Device stack that supports all STM32 microcontroller Series. Note:This document is applicable to all STM32 Series that feature an USB peripheral. However for simplicity reason, the STM32F4xx devices and STM32 CubeF4 are used as reference platform.
3 To know more about the examples implementation on your STM32 Device , refer to the readme file provided within the associated STM32 Cube MCU package. Table 1. Application productsTypePart numbers STM32 Cube MCU PackagesSTM32 CubeF0, STM32 CubeF1, STM32 CubeF2, STM32 CubeF3, STM32 CubeF4, STM32 CubeF7, STM32 CubeL0, STM32 CubeL1, STM32 CubeL4, STM32 CubeG0, STM32 CubeH7, Rev 4 Contents1 Overview .. and abbreviations .. information .. Information .. 72 USB Device Library description .. 93 USB Device Library architecture .. overview .. 104 USB OTG Hardware Abstraction Layer.
4 Architecture .. driver programming manual .. USB driver structure .. 135 USB Device Library overview .. Device Library description .. Device Library flow .. Device data flow .. interface with low level driver .. Device Library interfacing model .. the USB Device firmware Library .. control functions .. Device Library functions .. Device class interface .. 286 USB Device Library class module .. class .. class implementation .. user interface .. 32UM1734 Rev 43 Class Driver APIs .. storage class .. storage class implementation.
5 Max MUN (class-specific request) .. Core files .. operation structure definition .. operation functions .. firmware upgrade (DFU) class .. firmware upgrade (DFU) class implementation .. firmware upgrade (DFU) Class core files .. class .. class implementation .. core files .. to use this driver .. known limitations .. Device class (CDC) .. IN transfer management (from Device to host) .. OUT transfer management (from host to Device ) .. request management .. Device class (CDC) core files .. to use .. known limitations .. a custom class.
6 Footprint optimization .. 547 Frequently-asked questions .. 578 Revision history .. 59 List of tablesUM17344/60UM1734 Rev 4 List of tablesTable products .. 1 Table of terms .. 6 Table Device status .. 15 Table requests .. 17 Table description .. 21 Table level Event Callback functions .. 23 Table Library configuration .. 23 Table Device core files .. 25 Table drivers files .. 25 Table (.c,.h) files .. 25 Table (.c,.h) files functions .. 26 Table (.c,.h) files functions .. 27 Table Device class files .. 31 Table ,h files .. 33 Table commands.
7 35 Table (.c,.h) files .. 36 Table (.c,.h) files .. 36 Table (.c,.h) .. 37 Table operation functions .. 39 Table states .. 40 Table requests .. 42 Table (.c,.h) files .. 42 Table control requests .. 45 Table (.c,.h) files.. 45 Table (.c,.h) files .. 47 Table player states .. 47 Table (.c,.h) files .. 50 Table CDC parameters .. 51 Table (.c,.h) files .. 51 Table used by .. 52 Table revision history .. 59UM1734 Rev 45/60UM1734 List of figures5 List of figuresFigure USB Device Library .. 9 Figure Device Library architecture .. 11 Figure architecture overview.
8 12 Figure .. 14 Figure Device Library directory structure .. 16 Figure structure for SETUP packet .. 17 Figure Device Library process flowchart .. 19 Figure Device data flow .. 21 Figure Device Library interfacing model .. 22 Figure Class callback structure .. 28 Figure Device descriptors structure .. 29 Figure of USBD_HID_SendReport function .. 32 Figure Protocol architecture .. 34 Figure operation structure description .. 38 Figure of standard inquiry definition .. 38 Figure Interface state transitions diagram .. 41 Figure core structures .. 46 Figure core structures.
9 50 Figure interface callback structure .. 51 Figure of USB descriptors declared as constants .. 55 Figure of dynamic memory allocation for class structure .. 56 OverviewUM17346/60UM1734 Rev 41 Overview Acronyms and abbreviationsTa b l e 2 gives a brief definition of acronyms and abbreviations used in this document. General informationSTM32 Cube USB Device middleware runs on STM32 32-bit microcontrollers based on the Arm (1) Cortex -M Additional InformationIn addition to this document STMicroelectronics provides several other resources related to the USB: USB Host Library user manual (UM1720) Description of STM32F4xx HAL drivers (UM1725) where you can find the two USB generic drivers description (HCD for Host and PCD for Device )Table 2.
10 List of termsTermMeaningAPIA pplication programming interfaceCDCC ommunication Device classDFUD evice firmware upgradeFSFull speed (12 Mbps)HIDH uman interface deviceMbpsMegabit per secondMSCMass storage classOTGOn-The-Go: An OTG peripheral can switch Host/ Device role on the flyPIDUSB product identifierSCSIS mall computer system interfaceSOFS tart of frameVIDUSB vendor identifierUSBU niversal serial bus1. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and or Rev 47 References Universal Serial Bus Specification, Revision , http: USB Device class specifications ( audio , HID, MSC, etc.)