|
发表于 2015-8-28 18:11:16
|
显示全部楼层
D:\Administrator\STM32Cube\Repository\STM32Cube_FW_F4_V1.7.0\Projects\STM324x9I_EVAL\Applications\USB_Device
This application is a part of the USB Device Library package using STM32Cube firmware. It describes how to use
USB device application based on the STM32F4xx multi core support feature integrating Mass Storage (MSC)
and Human Interface (HID) in the same project.
This is a typical application on how to use the STM32F4xx USB OTG Device peripheral, where STM32 is
enumerated as a CDC device in the High Speed mode, and also as a HID device in the Full Speed mode,
using the native PC Host HID/CDC drivers to which the STM324x9I-EVAL board is connected.
At the beginning of the main program the HAL_Init() function is called to reset all the peripherals,
initialize the Flash interface and the systick. The user is provided with the SystemClock_Config()
function to configure the system clock (SYSCLK) to run at 168 MHz. The Full Speed (FS) USB module uses
internally a 48-MHz clock, which is generated from an integrated PLL. In the High Speed (HS) mode the
USB clock (60 MHz) is driven by the ULPI.
It's worth noting that the system clock (SYSCLK) can be configured, depending on the used USB Core:
- SYSCLK is set to 168 MHz: for FS Core, because used embedded PHY requires 48 MHz clock,
achieved only when system clock is set to 168 MHz.
- SYSCLK is set to 180 MHz: for only HS Core, since no embedded PHY is used.
When the application is started, the user has just to plug the two USB cables into a PC host and two
USB devices (CDC/HID) are automatically detected. When the VCP application is started, the STM32 MCU is
enumerated as serial communication port and is configured in the same way (baudrate, data format, parity, stop bit)
as it would configure a standard COM port. The 7-bit data length with no parity control is NOT supported.
When HID Mouse device is detected, and the Joystick buttons mounted on the STM324x9I-EVAL board, allow
to user to emulate the Mouse directions.
@note Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds)
based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from
a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower)
than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.
@note The application needs to ensure that the SysTick time base is always set to 1 millisecond
to have correct HAL operation.
For more details about the STM32Cube USB Device library, please refer to UM1734
"STM32Cube USB Device library".
@par USB Library Configuration
To select the appropriate USB Core to work with, user must add the following macro defines within the
compiler preprocessor (already done in the preconfigured projects provided with this application):
- "USE_USB_HS" and "USE_USB_FS" when using USB Dual Core Mode
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|