Implementation. STMicroelectronics STSW-STM32121
जाहिरात
जाहिरात
UM0424
7.4 Implementation
Virtual COM port demo
Note:
lists the USART connector number for each evaluation board.
Table 20.
USART connector number for each evaluation board
Eval board USART connector
STM3210E-EVAL
STM3210B-EVAL
STM32303C-EVAL
STM32L152D-EVAL
STM32L152-EVAL
STM32373C-EVAL
USART1
USART1
USART1
USART1
USART2
USART2
There is no need to add external hardware to run the demo.
In order to be considered as a COM port, the USB device has to implement two interfaces according to the Communication Device Class (CDC) specification:
● Abstract Control Model Communication, with 1 Interrupt IN endpoint: in our implementation this interface is declared in the descriptor but the related endpoint
(endpoint 2) is not used
● Abstract Control Model Data, with 1 Bulk IN and 1 Bulk OUT endpoint: this interface is represented in the demo by endpoint 1 (IN) and endpoint 3 (OUT). Endpoint 1 is used to send the data received from the UART to the PC through USB. Endpoint 3 is used to receive the data from the PC and send it through the UART.
For more information on the CDC class please refer to the Universal Serial Bus Class
Definitions for Communication Devices specification provided by the www.usb.org website.
Class-specific requests
To implement a virtual COM port, the device supports the following class-specific requests:
● SET_CONTROL_LINE_STATE : RS-232 signal used to tell the device that the Data
Terminal Equipment device is now present. This request always returns a
USB_SUCCESS status in the Virtual_Com_Port_NoData_Setup() function
( usb_prop.c
file).
●
●
SET_COMM_FEATURE : controls the settings for a particular communication feature.
This request always returns a USB_SUCCESS status in the
Virtual_Com_Port_NoData_Setup() function ( usb_prop.c file).
SET_LINE_CODING : sends the configuration of the device. It includes the baud rate, stop-bits, parity, and number-of-character bits. The received data is stored in a specific data structure called “linecoding” and used to update the UART parameters.
● GET_LINE_CODING : This command requests the device current baud rate, stop-bits, parity, and number-of-character bits. The device responds to this request with the data stored in the “linecoding” structure.
Doc ID 13465 Rev 12 51/85
Virtual COM port demo
Note:
UM0424
Hardware configuration interface
●
●
●
●
●
The hardware configuration interface ( hw_config.c
and .h
) in the Virtual COM port manages the following routines:
Configure the system and peripheral (USB & USART) clock and interrupts
Initialize the USART to default values
Configure the USART with the parameters received by the SET_LINE_CODING request
Send the data received by the USART to the PC through USB
Send the data received by the USB through USART
For the STM32, the supported data formats are 7 & 8 bits (in the HyperTerminal ), and the bandwidth range is from 1200 to 115200.
52/85 Doc ID 13465 Rev 12
डाउनलोड
जाहिरात