AN571
CP210
X
V
IRTUAL
COM P
ORT
I
NTERFACE
1. Introduction
This document describes the CP210x Virtual COM Port interface between the host and CP210x device for the
purposes of creating custom drivers that interface with the CP210x. For more information on how to customize the
CP210x hardware, see “AN144: CP210x/CP211x Device Customization Guide” on the Silicon Labs Application
Notes webpage:
https://www.silabs.com/products/mcu/Pages/ApplicationNotes.aspx
1.1. Related Documents
Universal Serial Bus Specification:
version 2.0 (also referred to as the USB Specification). This specification is
available at
http://www.usb.org.
Universal Serial Bus Class Definitions for Communication Devices:
version 1.1 (also referred to as the CDC
Specification, where “CDC” stands for “Communication Device Class”. This specification is available at
http://
www.usb.org.
ANSI/TIA-602:
Serial Asynchronous Automatic Dialing and Control - available at
http://www.eia.org.
1.2. Terms
end device:
refers to the hardware connected to the CP210x UART pins.
host:
refers to the PC driver and host controller.
2. Interface Architecture
The CP210x device implements one or more communications interfaces implemented using the Bulk protocol.
These USB Bulk pipes transport data only and any status information must be obtained from the control pipe.
To configure and control the port, the host sends requests to the device via the control pipe. The host uses these
requests to perform such functions as setting the baud rate, setting handshaking modes, and configuring special
characters.
To send data from the host to the port, the host queues BULK-OUT packets to the endpoint of the interface
associated with the port. The data from these packets will be loaded into the interface’s data buffers and passed on
to the external device.
To move data from the port to the host, the host issues IN requests to the port’s data IN endpoint.
Rev. 0.1 12/10
Copyright © 2010 by Silicon Laboratories
AN571
AN571
3. Flow Control
The Virtual COM Port protocol is designed to allow ports to perform the same handshaking that is performed by
PCs when running Windows with a real serial port. To do this, the device is required to follow detailed rules for flow
control.
The Virtual COM Port protocol provides full-duplex data streams. The transmit stream is used for data from the
host to the serial port; the receive stream is used for data from the serial port to the host. Each stream has
provisions for flow control.
Transmit flow control allows the end device to ask the port to stop transmitting data. The CP210x will continue
to accept OUT data from the host until its internal buffers are full, and then will NACK further OUT packets to the
transmit endpoint. When the end device has accepted enough data from the CP210x buffers, the CP210x will
accept more OUT packets from the host.
Receive flow control allows the port to ask the end device to stop transmitting data to the host. The CP210x
device holds the data received from the end device in buffers until the host asks for it. If the host does not ask
for data in a timely fashion (usually because the application is busy), the CP210x’s buffers may start to fill up,
and the CP210x uses receive flow control to ask the end device to stop sending data. When the host catches
up and empties the CP210x’s buffers, the CP210x then uses receive flow control to ask the end device to
resume sending data.
All flow-control handling is performed in the CP210x device. This is done for two reasons:
To reduce overhead at the host.
To eliminate latency for responding to flow-control events.
The host’s only involvement with flow control is to set the device into the desired flow control mode.
3.1. XON/XOFF Flow Control
Two characters are defined by the “set special characters” mechanism (SET_CHARS): XON (normally 0x11,
CTRL/Q), and XOFF (normally 0x13, CTRL/S). The same values are used for XON and XOFF for both transmit
and receive flow control. XON and XOFF may be set to the same character, but usually are different.
The CP210x device follows “OS/2 rules:” if transmit flow control says “don’t transmit”, the port prevents any
characters from being transmitted, including the flow control characters. The device normally stops transmitting
whenever it sends XOFF for receive flow control. The port resumes transmitting only when it sends XON to allow
the remote device to send data. This prevents a potential buffer overflow because the flow control characters
cannot be transmitted while XOFF is in effect.
3.2. Flow Control Rules
The CP210x uses a bit pattern similar to the ulHoldReasons mask from the Serial Status response (see Table 8)
to control transmission. If any of the hold reasons are set, the CP210x will not send (except that certain
characters, such as XON for receive flow control, can always be sent).
If the CP210x sends an XOFF special character in order to stop reception, the device will transmitting until the
device decides to send XON. While transmission is halted, the CP210x will set bit 4 in ulHoldReasons (see
Table 8).
If the CP210x receives an XOFF special character and is configured to XON/XOFF flow control mode, then the
CP210x will stop transmitting characters. While stopped, the CP210x sets bit 3 in ulHoldReasons. When an
XON is received, the CP210x clears bit 3 in ulHoldReasons and resumes transmission if ulHoldReasons [5..0]
is now zero.
If the CP210x is instructed to send a BREAK, it will stop sending normal characters while BREAK is asserted
and set bit 5 of ulHoldReasons.
If the CP210x is waiting for any of the modem control signals CTS, DSR or DCD, the CP210x sets the
appropriate bits in ulHoldReasons when the corresponding signal is causing a delay; the device will clear those
bits when the hold condition is removed, either because the flow-control programming was changed, or
because the signal changed state externally.
Immediate characters are not blocked by software flow control (either due to XOFF sent or due to XOFF
received). However, they are held off by BREAK, CTS handshaking, DSR handshaking or DCD handshaking (if
enabled and holding off traffic).
After sending an XOFF, the CP210x sends XON to start receiving data only if output is not being held, or
otherwise if either a sent XOFF or a received XOFF is the only reason that output is being held.
Rev. 0.1
2
AN571
4. CP210x Hardware Descriptors
The CP210x device descriptor contains zero in the bDeviceClass, bDeviceSubClass, and bDeviceProtocol fields.
All other fields are set as defined in Section 9.6.1 "Device" of the USB Specification.
Table 1. CP210x Default Device Descriptor
Offset
0
1
2
Field
bLength
bDescriptorType
bcdUSB
Size
1
1
2
Value
0x12
0x01
0x0110 or 0x0200
Description
Size of the descriptor in bytes.
Device descriptor type code.
Claimed version compliance, where the
LSB is the low order and the MSB is the
high order (0x0100 is version 1.0).
Indicates that this device is of no partic-
ular device class.
Inidicates that there’s no particular sub-
class.
No device-specific protocol.
Indicates the maximum packet size for
Endpoint0.
Manufacturer’s Vendor ID.
4
5
6
7
8
10
12
14
15
16
17
bDeviceClass
bDeviceSubClass
bDeviceProtocol
bMaxPacketSize
idVendor
idProduct
bcdDevice
iManufacturer
iProduct
iSerialNumber
bNumConfigurations
1
1
1
1
2
2
2
1
1
1
1
0x00
0x00
0x00
0x40
0x10C4
0xEA60 or 0xEA70 Manufacturer’s Product ID.
0x0100
0x01
0x02
0x03 or 0x05
0x01
Product version in BCD.
Manufacturer string descriptor index.
Product string descriptor index.
Serial string descriptor index.
Number of possible configurations.
Rev. 0.1
3
AN571
Table 2. CP210x Default Configuration Descriptor
Offset
0
1
2
4
5
Field
bLength
bDescriptorType
wTotalLength
bNumInterfaces
bConfigurationValue
Size
1
1
2
1
1
Value
0x09
0x02
0x0020 or 0x0037
0x01 or 0x02
0x01
Description
Size of the descriptor in bytes.
Configuration descriptor type code.
Total length of data returned for configu-
ration 0 (stored in little-endian order).
Number of interfaces in this configura-
tion (CP2105 has two interfaces).
Indicates the value to be used in a Set
Configuration packet to activate this
configuration.
Index of the string descriptor describing
this configuration.
Indicates the characteristics of the
device when this configuration is
selected:
bit 7 set: Device is bus powered.
bit 6 set: Device is self powered.
bit 5-0: reserved.
8
MaxPower
1
0x32
Maximum power consumption in 2mA
units. For self-powered devices, this
field is zero.
6
7
iConfiguration
bmAttributes
1
1
0x00
0x80
4
Rev. 0.1
AN571
Table 3. CP210x Default Interface Descriptor
Offset
0
1
2
Field
bLength
bDescriptorType
bInterfaceNumber
Size
1
1
1
Value
0x09
0x04
0x00 or 0x01
Description
Size of the descriptor in bytes.
Interface descriptor type code.
The interface described by this descrip-
tor (CP2105 devices have two inter-
faces).
Indicates the alternate setting which
enables the interface to operate as
described.
This interface has 2 Endpoints.
Indicates that this is a vendor-specific
interface.
No particular subclass.
The interface uses no specific protocol.
3
bAlternateSetting
1
0x00
4
5
6
7
8
bNumEndpoints
bInterfaceClass
bInterfaceSubClass
bInterfaceProtocol
iInterface
1
1
1
1
1
0x02
0xFF
0x00
0x00
0x02, 0x03, or 0x04 Index of the string descriptor describing
this interface.
Table 4. CP210x Default IN Endpoint Descriptor
Offset
0
1
2
3
4
5
Field
bLength
bDescriptorType
bEndpointAddress
bmAttributes
wMaxPacketSize
bInterval
Size
1
1
1
1
2
1
Value
0x07
0x05
0x81 or 0x82
0x02
0x0040 or 0x0020
0x00
Description
Size of the descriptor in bytes.
Endpoint descriptor type code.
IN Endpoint (either Endpoint 1 or End-
point 2).
Bulk Endpoint.
The maximum packet size is 64 or 32
bytes.
Not used for Bulk Endpoints.
Rev. 0.1
5