Home
STM32F105xx and STM32F107xx USB on-the-go
Contents
1. 0a 16 5 1 3 Host controller driver HCD 0000 e eee eee 16 5 1 4 OTG controller driver OTG ccc eens 16 5 2 OTG controller configuration ose xm w eed NAG 16 5 3 Driver interfacing cee eens 17 5 4 Driver integration 2 2 0 eee 17 5 5 Core initialization llle 17 5 5 1 Common initialization lle 17 5 5 2 Device initialization 0 00 02 18 5 5 3 Host initialization x ra HK A 0 5 9 N R A NN M Ra ee 18 5 5 4 Device programming model liliis 19 5 5 5 Host programming model 000 eee eee 20 5 5 6 OTG programming model ees 21 6 USB OTG FS demonstration description 23 2 35 Doc ID 15857 Rev 1 ky UM0721 Contents 6 1 Introduction RR I I nee 23 6 1 1 Hardware requirements e x eae 23 6 1 2 Jumper settings 0 0 0 RI n 24 6 2 Firmware architecture overview eee eee ee eee 24 6 3 USB Device mode demonstrations llle 25 6 4 USB Host mode demonstrations 0 00 c eee eee eee 26 6 5 USB OTG dual role device demonstration eee ee 29 6 5 1 Hardware configuration liliis 29 6 5 2 HyperTerminal settings llli 29 6 5 3 Demo description eee 29 6 5 4 Starting SRP requests lese 30 6 5 5 Starting HNP requests esee 31 7 USB OTG FS demonstration package Lsss 32 8 Revision history a seu kn Qn wala n C nC Ne ee a 3
2. INFORM UPPER LAYER otgfs devl1 OTG State B PERIPHERAL j else USB OTG DisableGlobalInt amp otgfs dev1 USB OTG CoreInitHost amp otgfs dev1 USB OTG EnableGlobalInt amp otgfs dev1 INFORM UPPER LAYER otgfs devi OTG State A HOST aasa a Doc ID 15857 Rev 1 UM0721 USB OTG FS demonstration description 6 6 1 USB OTG FS demonstration description Introduction All the USB demonstration applications are designed for the STM3210C EVAL board and use the following firmware components STM32F 10xxx standard peripheral drivers uC OSII RTOS v 2 86 uC USB Host stack v3 0 uC USB Device stack v3 0 uC USB OTG stack v3 0 File System emFile V4 16 from Segger MPEG audio decoder libmad 0 15 1b The demonstration applications are provided in binary format Figure 8 STM3210C EVAL board Hardware requirements The demonstration is designed for the STM3210C Eval board and requires the following accessories USB Flash disk Headphone with male jack connector For device demos a Micro B to Standard A plug cable For host demos a Micro A to Standard A receptacle host mode is forced by software and not by USB ID line For OTG mode demos a Micro AB cable Included in the STM3210C EVAL board package Doc ID 15857 Rev 1 23 35 USB OTG FS demonstration description UM0721 6 1 2 6 2 24 35 Jumper setting
3. UM0721 NJ User manual STM32F 105xx and STM32F107xx USB on the go OTG FS library June 2009 Introduction The USB OTG FS library is a firmware package supporting the USB on the go OTG full speed FS peripheral of the STM32F105xx and STM32F107xx connectivity line microcontrollers It provides a low level driver to easily connect any USB stack plus a rich set of demonstrations available in binary format This user manual presents a description of all the components of the STM32F105xx STM32F 107xx USB OTG FS library e USBOTG FS Core e Low level driver Host device and OTG DRD dual role device demonstrations Doc ID 15857 Rev 1 1 35 www st com Contents UM0721 Contents 1 STL T ama AA AG KALA NAA AA AA eee 6 2 Related documents ici sss ee e c RG ER ua ce dere ieee eee 7 3 USB OTG FS overview lt e eee 8 3 1 Session request protocol 0 00 ee 8 3 2 Host negotiation protocol rx RE RR eve ans 8 3 3 ORG OSOUDIOE oncccuoctavedues ogee pee MP EG PEIPER dh dpi 8 3 4 SetFeature command 000 eee 9 3 5 OTG device state machine 0 cc es 10 4 STM32F105xx STM32F107xx USB OTG FS interface 12 4 1 FOALUICS LUTTE 12 4 2 USB hardware connections 00 cece eee eens 14 5 USB OTG FS low level driver an 16 5 1 Driver architecture liliis 16 5 1 1 Core interface layer CIL cee 16 5 1 2 Peripheral controller driver PCD
4. UM0721 STM32F105xx STM32F107xx USB OTG FS interface al Figure 5 USB host mode connection STM32F105xx STM32F 107xx USB full speed low speed transceiver USB OTG Full speed core Current limited GPIO power distribution switch rio Io STMPS2141STR 8 o 0 c c 9 o lt q B a m e 3 ai15654b 1 STMPS2141STR needed only if the application has to support bus powered devices 2 Vpp ranges between 2 V and 3 6 V Doc ID 15857 Rev 1 15 35 USB OTG FS low level driver UM0721 5 5 1 5 2 Note 16 35 USB OTG FS low level driver Driver architecture Figure 6 Driver architecture overview Host OTG Device Upper layer stack and high T T level software HCD PCD Low level driver usb hcd c h usb pcd c h usb core c h CIL Core Interface Layer Core interface layer CIL This layer provides common APIs for device host and OTG modes the core initialization in each mode and the control of the transfer flow Peripheral controller driver PCD This layer provides an API for device mode access and the main interrupt routine for this mode Host controller driver HCD This layer provides an API for host mode access and the main interrupt routine for this mode OTG controller driver OTG This layer provides an API for OTG mode access and the main interrupt routine for this mode OTG controller configu
5. Data length 8 16 bits A Audio frequency 8 to 96 kHz Channel number Stereo Mono MP3 player This demo plays mp3 files stored in the root directory of the USB Flash disk and can operate with an external 25 MHz crystal STM3210C EVAL board default setting or audio quality 14 7456 MHz crystal The MPEG audio decoder ibmad is used for MP3 file decoding supporting only a limited number of file formats Only mp3 audio samples with the following configuration are supported DataChannel number Mono Audio frequency 22 kHz Doc ID 15857 Rev 1 ky UM0721 USB OTG FS demonstration description 6 5 USB OTG dual role device demonstration 6 5 1 Hardware configuration Figure 15 Dual role device hardware configuration Serial link 1 Serial link 2 USB OTG cable Micro A plug Micro B plug 6 5 2 HyperTerminal settings Baudrate 115200 Data bits 8 Parity None Stop bits 1 Flow control None 6 5 3 Demo description The OTG stack demo is composed of an OTG device which has three modes Idle USB bus turned off Device and Host The OTG stack uses the uC USB Device or the uC USB Host working with the Mass Storage Class The USB cable ends determine who is going to be the Host and the Device for the OTG enumeration The A plug series A or mini A end of the cable identifies a USB Host called A Device and the B plug series B or mini B end of the
6. cable identifies a USB Device called B Device The left connection PC Host Target board shows the OTG stack used as a USB Device uC USB Device activated The right connection Target board Peripheral or OTG Device shows the OTG stack used as a USB Host uC USB Host activated ky Doc ID 15857 Rev 1 29 35 USB OTG FS demonstration description UM0721 6 5 4 30 35 When starting the OTG demo the HyperTerminal displays the activated mode of the OTG stack and a menu for switching between the modes Depending on the activated mode the menu is Idle mode 1 Host switch to Host mode Device mode 1 Idle switch to Idle mode 2 Host switch to Host mode Host mode Idle switch to Idle mode Device Note First Select HOST Mode In Other Side switch to Device mode File Create create a file in the mass storage class USB device MSC Show All Files display the file s created in the mass storage class USB device MSC Format If Require format the mass storage class USB device MSC gu Re uU E When the user switches the OTG stack mode the other menu choices change accordingly Starting SRP requests The SRP is used when the Device needs to request the host to activate the VBus During the startup of the two boards and after the configuration of the USB cable mini A connector or mini B connector the following messages are displayed Figure 16 SRP start menu Board A 1 Host mode
7. 4 ky Doc ID 15857 Rev 1 3 35 List of tables UM0721 List of tables Table 1 Table 2 Table 3 Table 4 Table 5 Table 6 4 35 List of acronyms cesse Saw ge ye eed caw ae pero LED Gane RA R Ra Rom 6 OTG descriptor od Paget ee a ed age ed Saeed au ene Gea ok ated Rug re don 9 SetFeature command auaa enea 9 Feature selector values een 9 Required jumper configuration Ren 24 Document revision history rr 34 Doc ID 15857 Rev 1 ky UM0721 List of figures List of figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 Figure 13 Figure 14 Figure 15 Figure 16 Figure 17 Figure 18 B Device state machine aa 10 A Device state machine 2 11 USB OTG FS interface aaa RAK KG PE c POON PAG ROSE ORI CR TAKANG NG 13 USB device mode connection a 14 USB host mode connection ha 15 Driver architecture OVErVvieW a 16 Driverless R AA ANAND AN MANGAN a PDA JD Akap Bia Aer eer aso ada 17 STM3210C EVAL board 23 Demo firmware layers mr 24 USB Device mass storage demonstration ccc ccc eens 25 USB Device HID demonstration ee eee eee 25 USB Host mass storage demonstration 0000s 26 USB Host HID host demonstration eee eee 27 USB Host mass storage with audio support demonstration aa 28 Dual role
8. 721 USB OTG FS demonstration description Note Figure 13 USB Host HID host demonstration USB hes H10 demo USB Host Start Manufar Product Demo Deuce Correcied MOUSE CONNECTED This demonstration supports both mouse and keyboard subclasses The demo handles keyboard and mouse HID devices dynamically once they are connected If a keyboard is connected the user can type the characters on the LCD screen the supported key board layout is QWERTY If a mouse is connected the user can move a pointer inside the displayed pointer area and the pressed button is highlighted on the screen 1 The Host demonstration does not support multi interface devices such as composite devices 2 The Host demonstration does not support hubs Doc ID 15857 Rev 1 27 35 USB OTG FS demonstration description UM0721 Figure 14 USB Host mass storage with audio support demonstration LI USB WAV MGC demo USB Host Start Strirg WAV Tes Playing Y may gt Slrirg WAV fes HL LE B LE Two sets of audio demonstrations built on the USB Host mass storage application are available 1 Wav player e This demo plays wav files stored in the root directory of the USB Flash disk and can 28 35 operate with an external 25 MHz crystal STM3210C EVAL board default setting or audio quality 14 7456 MHz crystal This demo supports PCM wav audio files with the following configuration
9. Board B 1 Host mode Procedure 1 In Board B select 1 Host mode The message State B SRP Init is displayed 2 In Board A select 1 Host mode The A device moves to A Host state and the following menu is displayed in the HyperTerminal window to select the appropriate Host function Doc ID 15857 Rev 1 ky UM0721 USB OTG FS demonstration description 6 5 5 Figure 17 SRP host mode menu Current Mode HOST A DEVICE Select Your Choice 1 Idle 2 Device Note First Select HOST Mode on the other side 3 File Create 4 Show All Files 5 Format If Require Enter Your Choice Starting HNP requests The HNP protocol is used to invert OTG roles To start the HNP process you must select host mode in the A device until the following message is displayed 1 ar OD M Idle Device Note First Select HOST Mode on the other side File Create Show All Files Format If Require Select Host in the B Device choice 2 and then select Device in the A device choice 2 switch to device mode The switch will be done and the A Host becomes an A device while the B Device becomes a B Host Doc ID 15857 Rev 1 31 35 USB OTG FS demonstration package UM0721 7 32 35 USB OTG FS demonstration package The OTG FS library is supplied in a single zip file The extraction of the zip file generates a folder STM32 USB OTG FS Lib V1 0 0 which contains the subfolders shown in Figure 18 and descr
10. OLE MODE ENABLED define has been uncommented in the usb conf h file These elementary functions can then be used to initiate the default mode USB OTG Status USB OTG CoreInitHost USB OTG CORE DEVICE pdev USB OTG Status USB OTG CorelnitDev USB OTG CORE DEVICE pdev Starting SRP protocol To initiate the session request protocol use this call void USB OTG InitiateSRP void Starting HNP protocol To initiate the session host negotiation protocol use this call void USB OTG InitiateHNP uint8 t state uint8 t mode Where state is O to deactivate 1 to activate and mode is the current role mode device or host Doc ID 15857 Rev 1 21 35 USB OTG FS low level driver UM0721 22 35 USB Host device interrupt subroutine Depending on the selected mode in the usb conf h see Section 5 2 the main ISR calls the corresponding ISR handler void USB OTGFS1 GlobalHandler void OTG event control The USB OTG FS core informs the upper layer of the success or failure of the SRP or HNP and also of any change to the ID line status in the OTG ISR You must implement callbacks to tie these events into the OTG stacks Example static uint32 t USB OTG HandleConnectorIDStatusChange ISR void f asana if gotgctl b conidsts micro B connector USB OTG DisableGlobalInt amp otgfs dev1 USB OTG CoreInitDev amp otgfs dev1 USB OTG EnableGlobalInt amp otgfs dev1
11. RTOS ticker and human interface devices LED joystick etc Doc ID 15857 Rev 1 UM0721 USB OTG FS demonstration description 6 3 USB Device mode demonstrations Figure 10 USB Device mass storage demonstration USB Device MSC demo MSD Flash corrected CPU Mar The connected micro SD Flash is used as storage medium once connected to a host the STM32 device should appear in Windows explorer as a removable disk and the user can have read and write access to it Figure 11 USB Device HID demonstration USB Device HID demo USB Coifgired Pease ase the Joystick br tie demo _ CPU Mar Once connected to the host the embedded joystick is used as pointing device Note For device demos a Micro A to Standard A plug cable should be used a Doc ID 15857 Rev 1 25 35 USB OTG FS demonstration description UM0721 6 4 26 35 USB Host mode demonstrations Figure 12 USB Host mass storage demonstration USB Host MSC demo Once a mass storage device is connected to the board the application recognizes the connected USB Flash disk writes a dummy file and displays all the content of the Flash disk directory on the LCD screen The user can unplug and plug the USB Flash disk only after the dummy file operation has completed on the connection and disconnection events the messages on the LCD are updated to display the detected events Doc ID 15857 Rev 1 ky UM0
12. SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVE GRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements and or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2009 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com ky Doc ID 15857 Rev 1 35 35
13. TG FS demonstration package To program the binary images of the demonstration firmware into the internal Flash memory you have to proceed as follows EWARMv5 Open the Flash Loader eww project In the workspace toolbar select the project config corresponding to the demonstration to be loaded The name of each project config refers to the demonstration binary image Load the project image Project gt Download and Debug CTRL D Restart the evaluation board Press B1 reset button RVMDK Open the Flash Loader uv2 project In the build toolbar select the project config corresponding to the demonstration to be loaded The name of each project config refers to the demonstration binary image Load the project image Debug gt Start Stop Debug Session Restart the evaluation board Press B1 reset button Doc ID 15857 Rev 1 33 35 Revision history UM0721 8 34 35 Revision history Table 6 Document revision history Date Revision Changes 25 Jun 2009 1 Initial release Doc ID 15857 Rev 1 UM0721 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant to ST s terms and condition
14. device hardware configuration ere 29 SRP start menu eee Rhe 30 SRP host mode Men en sde ierni Gwen dOp ed Sade is dad bie Baby acd a Fac aC GA 4 31 USB OTG demonstration package directories 000 c eee eee 32 Doc ID 15857 Rev 1 5 35 Glossary 6 35 UM0721 Glossary Table 1 List of acronyms CIL Core interface layer DRD Dual role device FS Full speed IP Intellectual property HCD Host controller driver HNP Host negotiation protocol MSC Mass storage class OSI Open system interconnection OTG USB on the go PCD Peripheral controller driver PHY Physical layer as described in the OSI model RTOS Real time operating system SRP Session request protocol USB Universal serial bus uC Microcontroller Doc ID 15857 Rev 1 a UM0721 Related documents 2 Related documents e DesignWare Cores Hi Speed USB On The Go OTG Controller Subsystem Data book e On The Go Supplement to the USB 2 0 Specification Revision 1 3 e Universal Serial Bus Specification Revision 2 0 ky Doc ID 15857 Rev 1 7 35 USB OTG FS overview UM0721 3 3 1 3 2 3 3 8 35 USB OTG FS overview In addition to being a fully compliant USB 2 0 peripheral an on the go device must include the following features and characteristics e A limited Host capability Full speed operation as a peripheral high speed optional Full speed support as a Host low speed and high
15. ibed below Figure 18 USB OTG demonstration package directories 3 STM32 USB OTG FS Lib C3 _htmresc Libraries 1 STM32 USB OTG FS Driver Project C EWARMv5 RVMDK Utilities 1 Binary Release Notes html stm32_usb otgs html e Libraries folder contains the STM32F105xx STM32F107xx USB OTG FS low level driver e Project folder contains the binary image of the USB demonstrations plus preconfigured projects for the EWARM and RVMEK toolchains that can be used to program the binary images into the internal Flash memory e Utilities folder contains the binary images of the USB demonstrations to be used with the EWARM and RVMDK provided as backup The following binary images are available e STM32F10 USBH HID OS USB Host HID host demonstration STM32F10 USBH MSC OS USB Host mass storage demonstration STM32F10 USBF HID OS USB Device HID demonstration STM32F10 USBF MSC OS USB Device mass storage demonstration STM32F10 MSC MP3 14 7456MHz USB Host MP3 demonstration running with 14 7456 MHz crystal STM32F10 MSC MP3 25MHz USB Host MP3 demonstration running with 25 MHz crystal e STMS32F10 MSC WAV 14 7456MHz USB Host Wav demonstration running with 14 7456 MHz crystal e STM32F10 MSC WAV 25MHz USB Host Wav demonstration running with 25 MHz crystal e STM32F10 USBO DRD OS USB OTG dual role device demonstration Doc ID 15857 Rev 1 ky UM0721 USB O
16. mpl Clear the bit in DOEPINTn for this interrupt CLEAR_OUT_EP_INTR epnum xfercomp1 Inform upper layer data ready 11 CODE TO BE ADDED BY USER Host programming model Initialization When the USB OTG FS driver is called in host mode only the core and host initialization are done in the usb_hcd c file by void HOST Init USB OTG CORE DEVICE pdev Host channel initialization To prepare and initialize a host channel for transfer use the following function HOST ChannelInit USB OTG CORE DEVICE pdev USB OTG HC pHostChannel Starting transfer The upper layer must have a process to start a transfer on the activated host channel for example to submit the USB request block URB to the host channel The Submit URB could call the following function to start the process uint32 t HOST StartXfer USB OTG CORE DEVICE pdev USB OTG HC pHostChannel Doc ID 15857 Rev 1 ky UM0721 USB OTG FS low level driver USB host device interrupt subroutine Depending on the selected mode in the usb conf h see Section 5 2 the main ISR calls the corresponding ISR handler void USB OTGFS1 GlobalHandler void You must modify the ISR subroutines to use the APIs given by the upper layer 5 5 6 OTG programming model Initialization OTG feature support is enabled once the core is initialized if the DUAL R
17. oviding this descriptor in the group of descriptors returned in response to a GetDescriptor Configuration command When present the OTG descriptor must be present in all configurations This three byte descriptor consists of three fields bLength bDescriptorType and bmAttributes with bits as defined in Table 2 Doc ID 15857 Rev 1 ky UM0721 USB OTG FS overview 3 4 Note Table 2 OTG descriptor Offset Field Size Value Description 0 blength 1 Number 3 Size of descriptor 1 bDescriptorType 1 Constant OTG type 9 Attribute fields D7 2 Reserved rest to zero D1 HNP support DO SRP support 2 bm Attributes 1 Bitmap SetFeature command An A device may use the SetFeature command to configure the B device or to indicate certain capabilities of the A device to the B device Any HNP capable device is required to accept the SetFeature commands for these features If the device is not HNP capable it must return STALL if it receives a SetFeature command for any of these features A B device that supports HNP features must be able to accept the SetFeature command in the Default Address and Configured states The USB 2 0 specification USB2 0 does not specify features other than test mode that can be requested by the SetFeature command when the Device is in the Default state The OTG supplement adds to the list of features that can be set in the Default state Setting one of these featu
18. ration The configuration of the low level driver is done using the usb conf h file define DUAL ROLE MODE ENABLED Select dual role mode OTG define HOST MODE ENABLED Select Host mode only define DEVICE MODE ENABLED Select Device mode only The USB mode must be selected by using one of the above listed defines When DUAL ROLE MODE ENABLED mode is selected HOST MODE ENABLED and DEVICE MODE ENABLED are automatically selected Doc ID 15857 Rev 1 ky UM0721 USB OTG FS low level driver 5 3 5 4 5 5 5 5 1 Driver interfacing The low level driver connects the USB OTG FS core with the high level USB OTG stack To interface the low level driver with a specific stack a user developed interface layer may be used to provide the required APIs Driver integration Figure 7 Driver file CJuc USB a USBLib usb core c _jusb_hed c usb_otg c usb pcd c To integrate the driver in an application e Include the library files needed by the project e Exclude any unused layers e Then configure the library by modifying the usb conf h file according to the features that are used see Section 5 2 Core initialization Common initialization To use the USB OTG FS core the driver must be initialized by setting the start address of the core structure This by calling the following function declared in the usb core c USB OTG Status USB OTG SetAddress USB OTG CORE DEVICE pdev uint32 t BaseAddre
19. res when it is already set is not an error The device receiving such a command will acknowledge the command indicating successful completion A SetFeature command for these features must be executed on receipt of an uncorrupted command packet Table 3 SetFeature command bmRequestType bRequest wValue windex wLength Data ooooo000B_ SET_FEATURE Feature Zero Zero None Selector Table 4 Feature selector values Feature Selector Values b_hnp_enable 3 a_hnp_support 4 a_alt_hnp_support 5 Doc ID 15857 Rev 1 9 35 USB OTG FS overview UM0721 3 5 10 35 OTG device state machine Figure 1 8 B Device state machine a idle START drv_vbus b_idle chrg_vbus id drv_vbus ine cona n loc sof b sess vld chrg vbus Ea loc conn loc sof b host id b bus req amp b sess vld b sess end amp chrg vbus b se0 srp loc conn loc sof id b sess vld id b srp done b srp init pulse loc conn pulse chrg vbus loc sof b bus req b sess vld a conn a conn a bus resume b ase0 brst tmout b wait acon b peripheral chrg vbus chrg vbus loc conn loc conn loc sof loc sof b bus req amp b hnp en amp a bus suspend a Doc ID 15857 Rev 1 UM0721 USB OTG FS overview Figure 2 A Device s
20. s The jumpers on the STM3210C Eval board should be configured as follows Table 5 Required jumper configuration Jumper Usage Configuration JP17 I2C Fitted SW1 Boot 1 lt gt 2 sw2 Boot 1 lt gt 2 JP26 SD Card detect fitted JP15 SDCS fitted Firmware architecture overview Figure 9 Demo firmware layers Applications Audio codecs high level software components uC USB Stack File system stack Host OTG Device HC APIs OTG Device APIs APIs BSP i SOON so1u HCD PCD CIL Core interface layer i StdFwLib i C USB OTG FS core ai15701 The applications with the USB OTG FS core are built using the architecture shown in Figure 9 e The RTOS uC OS Il is used to control the uC USB stack internal machine application tasks and internal flow events e The uC USB stack device host and OTG is interfaced with the generic low level driver to provide access to the USB core e The file system is used when the Host mass storage demo is running to translate the logical addresses from the upper layer into physical ones understood by the USB stack e The BSP and the standard firmware library are used to access the standard STM32 IPs and onboard features e The BSP also performs the clock settings and provides all the functions needed by the
21. s PHY and data FIFO power management Dedicated 1 25 Kbyte RAM with advanced FIFO control Configurable partitioning in different FIFOs for flexible and efficient use of RAM Each FIFO can hold multiple packets Dynamic memory allocation and configurable FIFO sizes not limited to powers of 2 to allow the use of contiguous memory locations Guaranteed max USB bandwidth for up to one frame 1ms without system intervention Doc ID 15857 Rev 1 ky UM0721 STM32F105xx STM32F107xx USB OTG FS interface Figure 3 USB OTG FS interface N K Cortex M3 E Fc o S 5 Jose interrupt a z USB 2 0 Power K K OTG FS DP and M core clock OTG FS gt DM UTMIFS PHY NK UID 6 50 VBUS UNIVERSAL SERIAL us control 4 USB suspend USB Clock 48 MHZ System clock USB clock domain domain 1 25 Kbyte USB data FIFOs ky Doc ID 15857 Rev 1 13 35 STM32F105xx STM32F107xx USB OTG FS interface UM0721 4 2 14 35 USB hardware connections Figure 4 USB device mode connection STM32F 105xx STM32F 107xx r USB e Full speed transceiver To host USB OTG Full speed coe USB Micro B connector Regulator 2 ai15653b 1 Vpp ranges between 2 V and 3 6 V 2 Usea regulator if you want to build a bus powered device Doc ID 15857 Rev 1 ky
22. s of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY DEATH OR
23. s the addressed Endpoint The second function disables the already activated Endpoint after finishing the transfer USB data transfer flow The PCD layer provides all the APIs needed to start and control a transfer flow through the following set of functions uint32 t USB OTG USBD EP Read USB OTG CORE DEVICE pdev uint8 t ep addr uint8 t pbuf uint32 t buf len uint32 t USB OTG USBD EP Write USB OTG CORE DEVICE pdev uint8 t ep addr uint8 t pbuf uint32 t buf len g lt Q uint32 t USB OTG USBD EP Stall USB OTG CORE epnum E pdev uint8 t uint32 t USB OTG USBD EP ClrStall USB OTG CORE DEVICE pdev uint8 t epnum I uint32 t USB OTG USBD EP Flush USB OTG COR epnum DEVICE pdev uint8 t Doc ID 15857 Rev 1 19 35 USB OTG FS low level driver UM0721 5 5 5 20 35 USB device interrupt subroutine Following the selected mode in the usb conf h see Section 5 2 the main ISR calls the corresponding ISR handler void USB OTGFS1 GlobalHandler void You must modify the ISR subroutines to use the APIs given by the upper layer Example In the end of transfer of an OUT EP call the upper layer to receive or decode the received data Static uint32 t USB OTG USBD HandleOutEP ISR USB OTG CORE DEVICE pdev f if doepint b xferco
24. size b depth DEV NP TX FIFO SIZE nptxfifosize b startaddr RX FIFO SIZE WRITE REG32 amp pdev regs common regs np tx fifo siz nptxfifosize d32 txfifosize b depth DEV NP TX FIFO SIZE WRITE REG32 amp pdev regs common regs dev p tx fsiz dieptxf N txfifosize d32 N NDPOINT index E Host initialization The host initialization is done by using the following function USB OTG Status USB OTG CoreInitHost USB OTG CORE DEVICE pdev a Doc ID 15857 Rev 1 UM0721 USB OTG FS low level driver 5 5 4 al Device programming model Initialization When the USB OTG FS driver is called in device mode only the core and device initialization are done in the usb pcd c file by void USB OTG USBD Init USB OTG CORE DEVICE pdev Endpoint configuration Once the USB OTG FS core is initialized device mode is selected The upper layer may call the low level driver to open or close an Endpoint to start transfer The two following APIs are used USB OTG USBD EP Open USB OTG CORE DEVICE pdev EP DESCRIPTOR epdesc uint32 t USB OTG USBD EP Close USB OTG CORE DEVICE pdev uint8 t ep addr The first function retrieves the Endpoint settings EP address direction Transfer type and Max Data transfer from the epdesc structure and configure
25. speed optional Targeted peripheral list Session request protocol Host negotiation protocol One and only one connection a Micro AB receptacle Minimum of 8 mA output on VBUS Means for communicating messages to the user Session request protocol The Session Request Protocol SRP allows a B device to request the A device to turn on VBUS and start a session This protocol allows the A device which may be battery powered to conserve power by turning VBUS off when there is no bus activity while still providing a means for the B device to initiate bus activity Any A device including a PC or laptop is allowed to respond to SRP Any B device including a standard USB peripheral is allowed to initiate SRP An On The Go device is required to be able to initiate and respond to SRP Host negotiation protocol The Host Negotiation Protocol HNP allows the Host function to be transferred between two directly connected On The Go devices and eliminates the need for a user to switch the cable connections in order to allow a change in control of communications between the devices HNP will typically be initiated in response to input from the user or an Application on the On The Go B device HNP may only be implemented through the Micro AB receptacle on a device OTG descriptor During enumeration an On The Go A device must request the OTG configuration descriptor from the B device Any B device that supports either HNP or SRP must respond by pr
26. ss The BaseAddress is defined in the usbh regs h file Then the core is configured by the USB OTG core cfg structure through the function USB OTG Status USB OTG Corelnit USB OTG CORE DEVICE pdev Initialialize the base address of the memory mapped registers USB OTG SetAddress pdev USB OTG FS1 BASE ADDR Disable the global interrupt in AHB Configuration register USB OTG DisableGlobalInt pdev Initialize all the required registers for the Core USB OTG Corelnit pdev cxa USB OTG EnableGlobalInt pdev Doc ID 15857 Rev 1 17 35 USB OTG FS low level driver UM0721 5 5 2 5 5 3 18 35 The last step is to call the general USB OTG handler from the USB_OTG interrupt subroutine void USB OTGFS1 GlobalHandler void Device initialization The device initialization is done by using the following function USB OTG Status USB OTG CorelnitDev USB OTG CORE DEVICE pdev The Rx and Tx FIFOs size and start address are set by this function to use one more Endpoint in addition to the control Endpoint 0 You can change the FIFO settings by modifying the default values and changing the FIFO depth for each Tx FIFO set Rx FIFO size WRITE REG32 amp pdev regs common regs rx fifo siz pdev gt cfgs host rx fifo size Non periodic Tx FIFO nptxfifo
27. t can also be configured as a host only or device only controller fully compliant with the USB 2 0 Specification In host mode the OTG FS supports full speed FS 12 Mbits s and low speed LS 1 5 Mbits s transfers whereas in device mode it only supports full speed FS 12 Mbits s transfers The OTG FS supports both HNP and SRP The only external device required is a charge pump for VBUS in Host mode Features USB IF certified compliant with Universal Serial Bus Specification Rev 2 0 Includes full support PHY for the optional On The Go OTG protocol as described in the On The Go Supplement Rev 1 3 specification Integrated support for A B Device Identification ID line Integrated support for Host Negotiation Protocol HNP and Session Request Protocol SRP A Allows host to turn VBUS off to conserve battery power in OTG applications Supports OTG monitoring of VBUS levels with internal comparators Supports dynamic Host Peripheral role switching Software configurable as SRP capable USB FS Peripheral B Device SRP capable USB FS LS Host A Device USB On The Go Full Speed Dual Role Device Supports FS SOF and LS Keep alives with SOF pulse PAD connectivity SOF pulse internal connection to timer2 TIM2 Configurable framing period and end of frame interrupt threshold Includes power saving features such as system stop during USB Suspend optional switch off of internal clock domain
28. tate machine START b idle a idle id a bus req a sess vld amp dw vbus a bus drop amp loc sof b conn gt chrg vbus a bus req loc conn A wait va loc sof a srp det is a_wait_vrise drv_vbus ELEM B Y ade Ee a a wait bcon tmout drv vbus loc conn o boa ary vous loc sof ae oe com id a bus drop a vbus vld a wait vrise tmout b bus suspend id a bus drop a_vbus_err i a peripheral drv vbus E a wait beon loc conn ee loc sof dry vbus y a vbus vid ma a vbus vld E loc conn loc_sof ses loc sof n id a b conn amp 4 a bus drop a set b hnp en prede id b conn amp b conn bicon a set b hnp en a bus drop z m a bus req b bus resume a host a suspend loc conn maa TO drv vbus M pom drv vbus loc conn SS Se loc sof a bus req loc sof a suspend req Doc ID 15857 Rev 1 11 35 a STM32F105xx STM32F107xx USB OTG FS interface UM0721 4 4 1 12 35 STM32F105xx STM32F107xx USB OTG FS interface The USB OTG FS peripheral is one of the major peripherals embedded in STM32 Connectivity line microcontrollers it is a dual role device DRD controller that supports both device and host functions and is fully compliant with the On The Go Supplement to the USB 2 0 Specification I
Download Pdf Manuals
Related Search
Related Contents
14 mm and 30 mm - Banner Engineering BP-302 取扱説明書 ホローファイバー ダイアライザー KF−201 Copyright © All rights reserved.
Failed to retrieve file