Silicon Labs Host Libraries
CP210xRuntimeDLL.h
1 #ifndef HOST_LIB_RUNTIME_INCLUDE_CP210XRUNTIMEDLL_H_INCLUDED_QU4N7WC20W
2 #define HOST_LIB_RUNTIME_INCLUDE_CP210XRUNTIMEDLL_H_INCLUDED_QU4N7WC20W
3 
39 
40 #include <stdint.h> // For C99 fixed sized types
41 #include <stdbool.h> // For C99 _Bool
42 
43 #include "silabs_defs.h"
44 #include "silabs_sal.h"
45 
46 #ifdef _WIN32
47 // The following ifdef block is the standard way of creating macros which make exporting
48 // from a DLL simpler. All files within this DLL are compiled with the CP210xRUNTIMEDLL_EXPORTS
49 // symbol defined on the command line. this symbol should not be defined on any project
50 // that uses this DLL. This way any other project whose source files include this file see
51 // CP210xRUNTIMEDLL_API functions as being imported from a DLL, wheras this DLL sees symbols
52 // defined with this macro as being exported.
53 #ifdef CP210xRUNTIMEDLL_EXPORTS
54 #define CP210xRUNTIMEDLL_API
55 #else
56 #if defined(SILABS_STATIC_LINK)
57 #define CP210xRUNTIMEDLL_API extern
58 #pragma comment (lib, "CP210xRuntime.static.lib")
59 #else // defined(SILABS_STATIC_LINK)
60 #define CP210xRUNTIMEDLL_API __declspec(dllimport)
61 #pragma comment (lib, "CP210xRuntime.lib")
62 #endif // defined(SILABS_STATIC_LINK)
63 #endif
64 #else // !_WIN32
65 #define CP210xDLL_API
66 #define WINAPI
67 #define CP210xRUNTIMEDLL_API
68 #endif // !_WIN32
69 
70 
74 #define CP210x_CP2101_VERSION CP210x_PARTNUM_CP2101
75 #define CP210x_CP2102_VERSION CP210x_PARTNUM_CP2102
76 #define CP210x_CP2103_VERSION CP210x_PARTNUM_CP2103
77 #define CP210x_CP2104_VERSION CP210x_PARTNUM_CP2104
78 #define CP210x_CP2105_VERSION CP210x_PARTNUM_CP2105
79 #define CP210x_CP2108_VERSION CP210x_PARTNUM_CP2108
80 #define CP210x_CP2109_VERSION CP210x_PARTNUM_CP2109
81 #define CP210x_CP2102N_QFN28_VERSION CP210x_PARTNUM_CP2102N_QFN28
82 #define CP210x_CP2102N_QFN24_VERSION CP210x_PARTNUM_CP2102N_QFN24
83 #define CP210x_CP2102N_QFN20_VERSION CP210x_PARTNUM_CP2102N_QFN20
84 
86 
88 #if defined(NOT_YET)
89 typedef enum _CP210x_STATUS {
91  , CP210x_INVALID_HANDLE = 0x01
92  , CP210x_INVALID_PARAMETER = 0x02
93  , CP210x_DEVICE_IO_FAILED = 0x03
95  , CP210x_GLOBAL_DATA_ERROR = 0x05
96  , CP210x_FILE_ERROR = 0x06
97  , CP210x_COMMAND_FAILED = 0x08
99 
100  , CP210x_DEVICE_NOT_FOUND = 0xFF
101 } CP210x_STATUS, *PCP210x_STATUS;
102 #else // defined(NOT_YET)
103 #define CP210x_SUCCESS SILABS_STATUS_SUCCESS
106 #define CP210x_INVALID_HANDLE 0x01
107 #define CP210x_INVALID_PARAMETER 0x02
108 #define CP210x_DEVICE_IO_FAILED 0x03
109 #define CP210x_FUNCTION_NOT_SUPPORTED 0x04
110 #define CP210x_GLOBAL_DATA_ERROR 0x05
111 #define CP210x_FILE_ERROR 0x06
112 #define CP210x_COMMAND_FAILED 0x08
113 #define CP210x_INVALID_ACCESS_TYPE 0x09
114 #define CP210x_DEVICE_NOT_FOUND 0xFF
115 typedef int CP210x_STATUS;
116 #endif // defined(NOT_YET)
118 
119 // Buffer size limits TODO: Enstone: cut'n'paste dups of CP210xManufacturingDLL.h's defines of same name
120 #define CP210x_MAX_PRODUCT_STRLEN 126
121 #define CP210x_MAX_SERIAL_STRLEN_S 126
122 #define CP210x_MAX_SETUP_STRING_SIZE 246
123 // Type definitions
126 
130 #define CP210x_GPIO_0 0x0001
131 #define CP210x_GPIO_1 0x0002
132 #define CP210x_GPIO_2 0x0004
133 #define CP210x_GPIO_3 0x0008
134 #define CP210x_GPIO_4 0x0010
135 #define CP210x_GPIO_5 0x0020
136 #define CP210x_GPIO_6 0x0040
137 #define CP210x_GPIO_7 0x0080
138 #define CP210x_GPIO_8 0x0100
139 #define CP210x_GPIO_9 0x0200
140 #define CP210x_GPIO_10 0x0400
141 #define CP210x_GPIO_11 0x0800
142 #define CP210x_GPIO_12 0x1000
143 #define CP210x_GPIO_13 0x2000
144 #define CP210x_GPIO_14 0x4000
145 #define CP210x_GPIO_15 0x8000
146 
148 #ifdef __cplusplus
149 extern "C" {
150 #endif // __cplusplus
151 _Check_return_
160 _Success_(return == CP210x_SUCCESS)
163  _Out_writes_bytes_(sizeof(uint32_t)) _Pre_defensive_ uint32_t *lpdwNumDevices
164  );
165 
180 _Check_return_
182 _Success_(return == CP210x_SUCCESS)
185  _In_ _Pre_defensive_ const uint32_t DeviceIndex,
186  _Out_writes_bytes_(sizeof(HANDLE)) _Pre_defensive_ PHANDLE pcyHandle
187 );
188 
197 _Success_(return == CP210x_SUCCESS)
200  _In_ _Pre_defensive_ const HANDLE cyHandle
201 );
202 
219 _Check_return_
221 _Success_(return == CP210x_SUCCESS)
223 CP210xRT_ReadLatch(_In_ _Pre_defensive_ const HANDLE cyHandle,
224  _Out_writes_bytes_(sizeof(WORD)) _Pre_defensive_ LPWORD lpwLatch);
225 
240 _Check_return_
242 _Success_(return == CP210x_SUCCESS)
244 CP210xRT_WriteLatch(_In_ _Pre_defensive_ const HANDLE cyHandle,
245  _In_ _Pre_defensive_ const WORD mask,
246  _In_ _Pre_defensive_ const WORD latch);
247 
258 _Check_return_
260 _Success_(return == CP210x_SUCCESS)
262 CP210xRT_GetPartNumber(_In_ _Pre_defensive_ const HANDLE cyHandle,
263  _Out_writes_bytes_(1) _Pre_defensive_ LPBYTE lpbPartNum);
264 
284 _Check_return_
286 _Success_(return == CP210x_SUCCESS)
288 CP210xRT_GetDeviceProductString(_In_ _Pre_defensive_ const HANDLE cyHandle,
289  _Out_writes_bytes_(*lpbProductStringLengthInBytes) _Pre_defensive_ LPVOID lpProductString,
290  _Out_writes_bytes_(1) _Pre_defensive_ LPBYTE lpbProductStringLengthInBytes,
291  _In_ _Pre_defensive_ const BOOL bConvertToASCII = TRUE
292  );
293 
313 _Check_return_
315 _Success_(return == CP210x_SUCCESS)
317 CP210xRT_GetDeviceSerialNumber(_In_ _Pre_defensive_ const HANDLE cyHandle,
318  _Out_writes_bytes_(*lpbSerialNumberStringLengthInBytes) _Pre_defensive_ LPVOID lpSerialNumberString,
319  _Out_writes_bytes_(1) _Pre_defensive_ LPBYTE lpbSerialNumberStringLengthInBytes,
320  _In_ _Pre_defensive_ const BOOL bConvertToASCII = TRUE
321  );
322 
344 _Check_return_
346 _Success_(return == CP210x_SUCCESS)
348 CP210xRT_GetDeviceInterfaceString(_In_ _Pre_defensive_ const HANDLE cyHandle,
349  _Out_writes_bytes_(*lpbInterfaceStringLengthInBytes) _Pre_defensive_ LPVOID lpInterfaceString,
350  _Out_writes_bytes_(1) _Pre_defensive_ LPBYTE lpbInterfaceStringLengthInBytes,
351  _In_ _Pre_defensive_ const BOOL bConvertToASCII);
352 
353 
366 _Check_return_
368 _Success_(return == CP210x_SUCCESS)
370 CP210xRT_GetReceiverMaxTimeout(_In_ _Pre_defensive_ const HANDLE cyHandle,
371  _Out_writes_bytes_(2) _Pre_defensive_ uint16_t *pReceiverMaxTimeoutInMicroseconds);
372 
373 
386 _Check_return_
388 _Success_(return == CP210x_SUCCESS)
390 CP210xRT_SetReceiverMaxTimeout(_In_ _Pre_defensive_ const HANDLE cyHandle,
391  _In_ _Pre_defensive_ const uint16_t ReceiverMaxTimeoutInMicroseconds);
392 
393 #ifdef __cplusplus
394 }
395 #endif // __cplusplus
396 
398 
399 #endif // !HOST_LIB_RUNTIME_INCLUDE_CP210XRUNTIMEDLL_H_INCLUDED_QU4N7WC20W
400 
401 
#define WINAPI
WINAPI defination.
Definition: CP210xRuntimeDLL.h:66
char CP210x_PRODUCT_STRING[126]
cp210x product string
Definition: CP210xRuntimeDLL.h:124
CP210x_STATUS CP210xRT_GetDeviceProductString(const HANDLE cyHandle, LPVOID lpProductString, LPBYTE lpbProductStringLengthInBytes, const BOOL bConvertToASCII=TRUE)
Reads and returns the Product string directly from the device.
#define CP210x_GLOBAL_DATA_ERROR
global data error
Definition: CP210xRuntimeDLL.h:110
CP210x_STATUS CP210xRT_GetDeviceSerialNumber(const HANDLE cyHandle, LPVOID lpSerialNumberString, LPBYTE lpbSerialNumberStringLengthInBytes, const BOOL bConvertToASCII=TRUE)
Reads and returns the Serial Number String directly from the device.
no error
Definition: silabs_defs.h:262
CP210x_STATUS CP210xRT_ReadLatch(const HANDLE cyHandle, LPWORD lpwLatch)
CP210x_STATUS CP210xRT_Close(const HANDLE cyHandle)
Closes an open handle to the device.
#define CP210x_SUCCESS
Success.
Definition: CP210xRuntimeDLL.h:105
#define CP210x_INVALID_PARAMETER
a parameter was not valid
Definition: CP210xRuntimeDLL.h:107
int CP210x_STATUS
CP210x_STATUS.
Definition: CP210xRuntimeDLL.h:115
CP210x_STATUS CP210xRT_GetReceiverMaxTimeout(const HANDLE cyHandle, uint16_t *pReceiverMaxTimeoutInMicroseconds)
Reads and returns the Receiver Max Timeout directly from the device.
char CP210x_SERIAL_STRING_S[126]
cp210x serial string
Definition: CP210xRuntimeDLL.h:125
CP210x_STATUS CP210xRT_GetDeviceInterfaceString(const HANDLE cyHandle, LPVOID lpInterfaceString, LPBYTE lpbInterfaceStringLengthInBytes, const BOOL bConvertToASCII)
Reads and returns the Interface String directly from the device.
#define CP210x_MAX_PRODUCT_STRLEN
Max Product string length.
Definition: CP210xRuntimeDLL.h:120
int CP210x_STATUS
CP210x_STATUS.
Definition: CP210xManufacturingDLL.h:131
CP210x_STATUS CP210xRT_WriteLatch(const HANDLE cyHandle, const WORD mask, const WORD latch)
Sets a new current GPIO port latch value for the device.
#define CP210x_INVALID_ACCESS_TYPE
invalid access type
Definition: CP210xRuntimeDLL.h:113
#define CP210x_DEVICE_IO_FAILED
device I/O failed
Definition: CP210xRuntimeDLL.h:108
CP210x_STATUS CP210xRT_GetNumDevices(uint32_t *lpdwNumDevices)
Determines the number of CP210x devices connected to the system.
CP210x_STATUS CP210xRT_SetReceiverMaxTimeout(const HANDLE cyHandle, const uint16_t ReceiverMaxTimeoutInMicroseconds)
Sets the Receiver Max Timeout directly to the device.
#define CP210x_INVALID_HANDLE
an handle parameter was not valid
Definition: CP210xRuntimeDLL.h:106
#define CP210x_FILE_ERROR
file error
Definition: CP210xRuntimeDLL.h:111
#define CP210x_DEVICE_NOT_FOUND
the specified device was not found
Definition: CP210xRuntimeDLL.h:114
#define CP210xRUNTIMEDLL_API
CP210xRUNTIMEDLL_API defination.
Definition: CP210xRuntimeDLL.h:67
CP210x_STATUS CP210xRT_GetPartNumber(const HANDLE cyHandle, LPBYTE lpbPartNum)
Reads and returns the Part Number from the device.
#define CP210x_COMMAND_FAILED
command failed
Definition: CP210xRuntimeDLL.h:112
CP210x_STATUS CP210xRT_Open(const uint32_t DeviceIndex, PHANDLE pcyHandle)
Opens a handle to the device.
#define CP210x_FUNCTION_NOT_SUPPORTED
the specified function is not supported
Definition: CP210xRuntimeDLL.h:109
#define CP210x_MAX_SERIAL_STRLEN_S
Max Serial Number string length.
Definition: CP210xRuntimeDLL.h:121