937 views|2 replies

2866

Posts

4

Resources
The OP
 

【STM32U5A5ZJ development board】USB device and VCP communication test [Copy link]

The USB on the STM32U5A5ZJ is an OTG USB device with its own PHY. It not only has power management but also device management functions, and the interface used is also a Type C interface.

The use of USB devices is much more complicated than other serial buses. In addition to initialization and enumeration registration during the communication process, it is also necessary to perform the communication process asynchronously. Therefore, ST has launched the relevant functions of the supporting HAL and LL libraries to cooperate with the development. It is especially complicated in the case of operating systems, but at the same time RTOS also brings convenience to programming and use. This test uses THREADX and the supporting USBX and USBPD middleware.

1. USB device driver settings

The USB device settings consist of two parts: power management and USB communication pin settings. There are two groups of settings: UCPD and USB_OTG_HS.

UCPD1 is the related pin setting of OTG power management specified by ST toolkit. It is mainly used to cooperate with USBPD middleware.

USB_OTG_HS is a setting related to the USB device driver, and it also needs to be set in conjunction with USBX. For settings, please refer to the relevant routines.

These two sets of settings are required for ST drivers.

2. USBX Settings

After selecting THREADX support, if you need USB device support, you need to use the supporting USBX library. USBX is the management library of USB devices supporting THREADX, which supports a variety of USB devices. In this test, CDC_ACM support is used. This device is a USB to serial port device. The converted serial port can work just by using the driver of the host computer.

You can refer to the settings in the picture above.

3. USB PD settings

USBPD is USB power management middleware used to simplify USB power management and provide drivers.

For specific settings, please refer to the relevant routine (Ux_Device_CDC_ACM).

4. Program code and usage

The program code consists of two parts: application and device management and initialization.

The device programming program can refer to the relevant routines. It is in a fixed format and can be used without modification.

This program will internally associate UART1 with the USB VPC, so that UART programming can be converted to VPC.

Testing process

After inserting the USB Type C cable, two serial ports, COM8 and COM5, can be enumerated. COM8 is the UART1 serial port for debugging, and USB5 is the VCP serial port of this OTG.

1. Send a message through COM5.

This message can be received on COM8.

Messages sent on COM8 can also be received on UART1's COM8 serial port.

This post is from stm32/stm8

Latest reply

Is this to directly virtualize USB into a serial port? Can the USB device recognize the communication directly?   Details Published on 2024-3-14 09:03
 

6027

Posts

6

Resources
2
 

Is this to directly virtualize USB into a serial port? Can the USB device recognize the communication directly?

This post is from stm32/stm8

Comments

This is to convert the USB device into a serial port device. Both ends of the communication are serial ports, and the driver is a bridge in the conversion process. Otherwise, you need to write your own private USB driver, which increases the complexity of programming.  Details Published on 2024-3-14 11:06
 
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 

2866

Posts

4

Resources
3
 
Qintianqintian0303 posted on 2024-3-14 09:03 Is this to directly virtualize the USB into a serial port? Directly USB devices can recognize the communication

This is to convert the USB device into a serial port device. Both ends of the communication are serial ports, and the driver is a bridge in the conversion process. Otherwise, you need to write your own private USB driver, which increases the complexity of programming.

This post is from stm32/stm8
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list