TM STM32Fxxx HAL Libraries
v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle
|
USB library for STM32Fxxx devices - http://stm32f4-discovery.com/2015/08/hal-library-21-multi-purpose-usb-library-for-stm32fxxx/. More...
Modules | |
TM_USB_Macros | |
Library defines. | |
TM_USB_Typedefs | |
Library Typedefs. | |
TM_USB_Functions | |
Library Functions. | |
USB library for STM32Fxxx devices - http://stm32f4-discovery.com/2015/08/hal-library-21-multi-purpose-usb-library-for-stm32fxxx/.
This library is main library for all my other USB implementations. Its main purpose is to handle all common settings, like initializing GPIO pins and handling interrupts
This library is used to set some settings for your USB work when needed. These are:
- Enabling USB pins when needed - Setting up configuration for specific board used for USB - Driving VBUS when device acts like HOST - Handling USB interrupts - Library supports different USB configurations: - Both FS and HS ports defined as HOST mode - Both FS and HS ports defined as DEVICE mode - FS port device, HS port HOST - HS port device, FS port HOST
By default, you will have to enable some configurations in order to use USB properly. This can be done in defines.h project settings. Open file, copy/edit things you need.
For example, you want to use FS port for USB HID host and HS port for USB CDC device. You will need at least these defines:
When using USB FS mode, STM32Fxxx needs 48MHz clock, provided from PLL, so you have to make sure that your PLL clock is set correct. PLL_M
parameter should be the same as value of external crystal frequency in MHz. For example, if HSE_VALUE is 25000000, then PLL_M should be set to 25
For USB HS mode with external ULPI PHY, you don't need any specific clock settings, because ULPI will do this for you. However, if you are using HS in FS mode, you have to setup 48MHz clock the same as when using FS mode.
You will need to set bottom defines in case you don't use my TM_DISCO library configuration for board used.
Micro USB connector is on USB FS mode
PA12 <-> Data + PA11 <-> Data - PA10 <-> ID PA9 <-> VBUS PC0 <-> VBUS_EN
Micro USB connector is on USB HS in FS mode, because there is no external PHY for real USB HS mode
PB15 <-> Data + PB14 <-> Data - PB12 <-> ID PB13 <-> VBUS PC4 <-> VBUS_EN
Micro USB connectors are on USB FS mode and on real USB HS mode with external PHY chip
USB FS mode | USB HS mode | PA12 <-> Data + | PA3 <-> D0 | PB10 <-> D4 | PC0 <-> STP PA11 <-> Data - | PB0 <-> D1 | PB11 <-> D5 | PA5 <-> CLK PA10 <-> ID | PB1 <-> D2 | PB12 <-> D6 | PH4 <-> NXT PA9 <-> VBUS | PB5 <-> D3 | PB13 <-> D7 | PC2 <-> DIR PD5 <-> VBUS_EN |
When USB port is declared as HOST mode, then you has ability to control (if you have external control for that) if external componentas allows you that. All discovery board has STMPS2151 chip which is designed for USB purposes. It has enable pin and allows up to 500mA current. If more current want to flow, chip will automaticall disable output and output pin will go low to indicate short circuit.
So, when using discovery board in USB port without external PHY, you have to enable USB output to give power on USB pin.
As mentioned above, library has feature to control this output. When you enable USB with TM_USB_Init function, output is also enabled if needed. To tell library, which output should be used, some defines should be set. Open defines.h file and copy/edit settings.
Version 1.0 - First release
- STM32Fxxx HAL - defines.h - TM GPIO - USB CORE