USB Component  
MDK Middleware for USB Device and Host Communication
 
Loading...
Searching...
No Matches
USB Device Virtual COM Port

This example implements a USB Device that exchanges data with a USB Host using CDC: Communication Device Class as virtual communication port.

The USB bridge between a Virtual COM Port on the USB Host Computer and a UART port on the evaluation board.

The following picture shows an exemplary connection of the development board and the USB Host Computer.

USB Device Virtual COM port example hardware setup

Project Organization

The USB Device Virtual COM Port project is available as part of the USB Device Reference examples.

Application Source Files

Following files implement application-specific logic in the example:

  • VirtualCOM.c: contains the application main thread which initializes the USB Device Component.
  • USBD_User_CDC_ACM_UART_0.c: adapted code template that implements USB to UART bridge functionality. Refer to CDC: Communication Device Class (ACM) for details.

Software Components Configuration Files

Configuration files for the software components used in the project are available in the ./RTE/ directory and can be modified by users to adjust the operation of related components. Section RTE Components gives an overview about the components and their dependencies.

Following configuration files are provided with this example:

When a board layer is added to the project, corresponding configuration files for the board and device components will become available in the local ./Board/ directory.

Board Layer

In order to build the project it shall be extended with a compatible board layer that provides following interfaces as connections:

  • CMSIS_USB_Device: CMSIS-Driver for USB Device interface.
  • CMSIS_VIO: CMSIS-Driver for Virtual I/O interface.
  • CMSIS_USART: CMSIS-Driver for USART interface.

Build the Project

Working with MDK-Middleware Examples explains the workflow for accessing, configuring and building an MDK-Middleware example project for your target hardware.

  1. Open the USB_Device MDK-Middleware reference example.
  2. Make sure the compatible board layer is configured.
  3. Select VirtualCOM as an active project for the build process.
  4. Build the project and observe that no errors are reported.

Run the Example

Setup

Board-specific hardware setup such as jumpers, USB ports, power supply, etc. is documented in the board layer description (README.md) of your selected target.

  1. Load the executable image to the target development board.
  2. Connect the UART on the development board to your PC (you might need an USB to serial RS232 adapter). Use an USB cable to connect your development board to the Host PC and power up your board.
  3. The device should appear as Port - USB Serial Device.

Example execution

The USB Device Virtual COM example can be tested using a terminal emulation program. Please download an appropriate program for this purpose (such as PuTTY for example). Open the two COM ports "COMx" and "COMy". Any data from "COMx" will be echoed on "COMy" and visa versa:

VCOM terminals