AN223
2 Rev. 0.5
2. Creating Custom Applications using CP210xRuntime.DLL
Custom applications can use the CP210x Runtime API implemented in CP210xRuntime.DLL. To use functions
implemented in CP210xRuntime.DLL, link CP210xRuntime.LIB with your Visual C++ 6.0 application. Include
CP210xRuntimeDLL.h in any file that calls functions implemented in CP210xRuntime.DLL.
3. CP210x Runtime API Functions
The CP210x Runtime API provides access to the GPIO port latch, and is meant for distribution with the product
containing a CP210x device.
CP210xRT_ReadLatch()—Returns the GPIO port latch of a CP210x device.
CP210xRT_WriteLatch()—Sets the GPIO port latch of a CP210x device.
CP210xRT_GetPartNumber()—Returns the 1-byte Part Number of a CP210x device.
CP210xRT_GetProductString ()—Returns the product str ing programmed to the device.
CP210xRT_GetDeviceSerialNumber ()—Returns the serial number programmed to the device.
CP210xRT_GetDeviceInterfaceString ()—Returns the interface string programmed to the device.
Typically, the user initiates communication with the target CP210x device by opening a handle to a COM p ort using
CreateFile() (See AN197: “Serial Communication Guide for CP210x”). The handle returned allows the user to call
the API functions listed above. Each of these functions is described in the following sections. Ty pe definitions and
constants are defined in the file CP210xRuntimeDLL.h.
Note: Functions calls into this API are blocked until completed. This can take several milliseconds depending on USB traffic.
3.1. CP210xRT_ReadLatch
Description: Gets the current port latch value from the device.
Supported Devices: CP2103, CP2104, CP2105, CP2108
Location: CP210x Runtime DLL
Prototype: CP210x_STATUS CP210xRT_ReadLatch(HANDLE Handle, LPWORD Latch)
Parameters: 1. Handle—Handle to the Com port returned by CreateFile().
2. Latch—Pointer for 4-byte return GPIO latch value [Logic High = 1, Logic Low = 0].
Return Value: CP210x_STATUS = CP210x_SUCCESS,
CP210x_INVALID_HANDLE,
CP210x_DEVICE_IO_FAILED
CP210x_FUNCTION_NOT_SUPPORTED