Application guide for developers using the CP210x USB to UART Bridge Controller, covering COM port setup and data transfer.
This application guide is for developers creating products based on the CP210x USB to UART Bridge Controller. It explains how to obtain the port number for a specific CP210x device and provides code samples for opening, closing, configuring, reading, and writing to a COM port.
The guide walks through opening a COM port with CreateFile(), purging it with PurgeComm(), saving and restoring its original state with GetCommState(), and configuring a DCB structure for baud rate, parity, byte size, and stop bits. It also covers writing data with WriteFile() and includes a GetPortNum function that determines the port number using the device's Vendor ID (VID), Product ID (PID), and serial number.
| Baud rate | 57600 bps |
|---|---|
| Parity | NOPARITY |
| Byte size | 8 data bits |
| Stop bits | ONESTOPBIT |
| Supported devices | CP2101, CP2102, CP2103, CP2104, CP2105, CP2108 |
The guide applies to the CP2101, CP2102, CP2103, CP2104, CP2105, and CP2108 devices.
A GetPortNum function is included that determines the port number using the device's Vendor ID (VID), Product ID (PID), and serial number.
The example sets the baud rate to 57600 bps, though any baud rate supported by the CP210x can be used.