DSI_CP210xManufacturingDLL_3_1.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. #if !defined(DSI_CP210XMANUFACTURINGDLL_3_1_H)
  2. #define DSI_CP210XMANUFACTURINGDLL_3_1_H
  3. // The following ifdef block is the standard way of creating macros which make exporting
  4. // from a DLL simpler. All files within this DLL are compiled with the CP210xDLL_EXPORTS
  5. // symbol defined on the command line. this symbol should not be defined on any project
  6. // that uses this DLL. This way any other project whose source files include this file see
  7. // CP210xDLL_API functions as being imported from a DLL, wheras this DLL sees symbols
  8. // defined with this macro as being exported.
  9. #ifdef CP210xMANUFACTURINGDLL_EXPORTS
  10. #define CP210xDLL_API __declspec(dllexport)
  11. #else
  12. #define CP210xDLL_API __declspec(dllimport)
  13. #endif
  14. // GetProductString() function flags
  15. #define CP210x_RETURN_SERIAL_NUMBER 0x00
  16. #define CP210x_RETURN_DESCRIPTION 0x01
  17. #define CP210x_RETURN_FULL_PATH 0x02
  18. #ifndef _CP210x_STANDARD_DEF_
  19. #define _CP210x_STANDARD_DEF_
  20. // GetDeviceVersion() return codes
  21. #define CP210x_CP2101_VERSION 0x01
  22. #define CP210x_CP2102_VERSION 0x02
  23. #define CP210x_CP2103_VERSION 0x03
  24. // Return codes
  25. #define CP210x_SUCCESS 0x00
  26. #define CP210x_DEVICE_NOT_FOUND 0xFF
  27. #define CP210x_INVALID_HANDLE 0x01
  28. #define CP210x_INVALID_PARAMETER 0x02
  29. #define CP210x_DEVICE_IO_FAILED 0x03
  30. #define CP210x_FUNCTION_NOT_SUPPORTED 0x04
  31. #define CP210x_GLOBAL_DATA_ERROR 0x05
  32. #define CP210x_FILE_ERROR 0x06
  33. #define CP210x_COMMAND_FAILED 0x08
  34. #define CP210x_INVALID_ACCESS_TYPE 0x09
  35. // Type definitions
  36. typedef int CP210x_STATUS;
  37. #endif /*_CP210x_STANDARD_DEF_*/
  38. // Buffer size limits
  39. #define CP210x_MAX_DEVICE_STRLEN 256
  40. #define CP210x_MAX_PRODUCT_STRLEN 126
  41. #define CP210x_MAX_SERIAL_STRLEN 63
  42. #define CP210x_MAX_MAXPOWER 250
  43. // Type definitions
  44. typedef char CP210x_DEVICE_STRING[CP210x_MAX_DEVICE_STRLEN];
  45. typedef char CP210x_PRODUCT_STRING[CP210x_MAX_PRODUCT_STRLEN];
  46. typedef char CP210x_SERIAL_STRING[CP210x_MAX_SERIAL_STRLEN];
  47. //Baud Rate Aliasing definitions
  48. #define NUM_BAUD_CONFIGS 32
  49. typedef struct
  50. {
  51. WORD BaudGen;
  52. WORD Timer0Reload;
  53. BYTE Prescaler;
  54. DWORD BaudRate;
  55. } BAUD_CONFIG;
  56. #define BAUD_CONFIG_SIZE 10
  57. typedef BAUD_CONFIG BAUD_CONFIG_DATA[NUM_BAUD_CONFIGS];
  58. //Port Config definitions
  59. typedef struct
  60. {
  61. WORD Mode; // Push-Pull = 1, Open-Drain = 0
  62. WORD Reset_Latch; // Logic High = 1, Logic Low = =0
  63. WORD Suspend_Latch; // Logic High = 1, Logic Low = =0
  64. unsigned char EnhancedFxn;
  65. } PORT_CONFIG;
  66. // Define bit locations for Mode/Latch for Reset and Suspend structures
  67. #define PORT_RI_ON 0x0001
  68. #define PORT_DCD_ON 0x0002
  69. #define PORT_DTR_ON 0x0004
  70. #define PORT_DSR_ON 0x0008
  71. #define PORT_TXD_ON 0x0010
  72. #define PORT_RXD_ON 0x0020
  73. #define PORT_RTS_ON 0x0040
  74. #define PORT_CTS_ON 0x0080
  75. #define PORT_GPIO_0_ON 0x0100
  76. #define PORT_GPIO_1_ON 0x0200
  77. #define PORT_GPIO_2_ON 0x0400
  78. #define PORT_GPIO_3_ON 0x0800
  79. #define PORT_SUSPEND_ON 0x4000 // Can't configure latch value
  80. #define PORT_SUSPEND_BAR_ON 0x8000 // Can't configure latch value
  81. // Define bit locations for EnhancedFxn
  82. #define EF_GPIO_0_TXLED 0x01 // Under device control
  83. #define EF_GPIO_1_RXLED 0x02 // Under device control
  84. #define EF_GPIO_2_RS485 0x04 // Under device control
  85. #define EF_RESERVED_0 0x08 // Reserved, leave bit 3 cleared
  86. #define EF_WEAKPULLUP 0x10 // Weak Pull-up on
  87. #define EF_RESERVED_1 0x20 // Reserved, leave bit 5 cleared
  88. #define EF_SERIAL_DYNAMIC_SUSPEND 0x40 // For 8 UART/Modem signals
  89. #define EF_GPIO_DYNAMIC_SUSPEND 0x80 // For 4 GPIO signals
  90. #ifdef __cplusplus
  91. extern "C" {
  92. #endif
  93. CP210xDLL_API
  94. CP210x_STATUS WINAPI CP210x_GetNumDevices(
  95. LPDWORD lpdwNumDevices
  96. );
  97. CP210xDLL_API
  98. CP210x_STATUS WINAPI CP210x_GetProductString(
  99. DWORD dwDeviceNum,
  100. LPVOID lpvDeviceString,
  101. DWORD dwFlags
  102. );
  103. CP210xDLL_API
  104. CP210x_STATUS WINAPI CP210x_Open(
  105. DWORD dwDevice,
  106. HANDLE* cyHandle
  107. );
  108. CP210xDLL_API
  109. CP210x_STATUS WINAPI CP210x_Close(
  110. HANDLE cyHandle
  111. );
  112. CP210xDLL_API
  113. CP210x_STATUS
  114. WINAPI
  115. CP210x_GetPartNumber( HANDLE cyHandle,
  116. LPBYTE lpbPartNum
  117. );
  118. CP210xDLL_API
  119. CP210x_STATUS
  120. WINAPI
  121. CP210x_SetVid(
  122. HANDLE cyHandle,
  123. WORD wVid
  124. );
  125. CP210xDLL_API
  126. CP210x_STATUS
  127. WINAPI
  128. CP210x_SetPid(
  129. HANDLE cyHandle,
  130. WORD wPid
  131. );
  132. CP210xDLL_API
  133. CP210x_STATUS
  134. WINAPI
  135. CP210x_SetProductString(
  136. HANDLE cyHandle,
  137. LPVOID lpvProduct,
  138. BYTE bLength,
  139. BOOL bConvertToUnicode
  140. #if defined(__cplusplus)
  141. = TRUE
  142. #endif
  143. );
  144. CP210xDLL_API
  145. CP210x_STATUS
  146. WINAPI
  147. CP210x_SetSerialNumber(
  148. HANDLE cyHandle,
  149. LPVOID lpvSerialNumber,
  150. BYTE bLength,
  151. BOOL bConvertToUnicode
  152. #if defined(__cplusplus)
  153. = TRUE
  154. #endif
  155. );
  156. CP210xDLL_API
  157. CP210x_STATUS
  158. WINAPI
  159. CP210x_SetSelfPower(
  160. HANDLE cyHandle,
  161. BOOL bSelfPower
  162. );
  163. CP210xDLL_API
  164. CP210x_STATUS
  165. WINAPI
  166. CP210x_SetMaxPower(
  167. HANDLE cyHandle,
  168. BYTE bMaxPower
  169. );
  170. CP210xDLL_API
  171. CP210x_STATUS
  172. WINAPI
  173. CP210x_SetDeviceVersion(
  174. HANDLE cyHandle,
  175. WORD wVersion
  176. );
  177. CP210xDLL_API
  178. CP210x_STATUS
  179. WINAPI
  180. CP210x_SetBaudRateConfig(
  181. HANDLE cyHandle,
  182. BAUD_CONFIG* baudConfigData
  183. );
  184. CP210xDLL_API
  185. CP210x_STATUS
  186. WINAPI
  187. CP210x_SetLockValue(
  188. HANDLE cyHandle
  189. );
  190. CP210xDLL_API
  191. CP210x_STATUS
  192. WINAPI
  193. CP210x_GetDeviceProductString(
  194. HANDLE cyHandle,
  195. LPVOID lpProduct,
  196. LPBYTE lpbLength,
  197. BOOL bConvertToASCII
  198. #if defined(__cplusplus)
  199. = TRUE
  200. #endif
  201. );
  202. CP210xDLL_API
  203. CP210x_STATUS
  204. WINAPI
  205. CP210x_GetDeviceSerialNumber(
  206. HANDLE cyHandle,
  207. LPVOID lpSerialNumber,
  208. LPBYTE lpbLength,
  209. BOOL bConvertToASCII
  210. #if defined(__cplusplus)
  211. = TRUE
  212. #endif
  213. );
  214. CP210xDLL_API
  215. CP210x_STATUS
  216. WINAPI
  217. CP210x_GetDeviceVid(
  218. HANDLE cyHandle,
  219. LPWORD lpwVid
  220. );
  221. CP210xDLL_API
  222. CP210x_STATUS
  223. WINAPI
  224. CP210x_GetDevicePid(
  225. HANDLE cyHandle,
  226. LPWORD lpwPid
  227. );
  228. CP210xDLL_API
  229. CP210x_STATUS
  230. WINAPI
  231. CP210x_GetSelfPower(
  232. HANDLE cyHandle,
  233. LPBOOL lpbSelfPower
  234. );
  235. CP210xDLL_API
  236. CP210x_STATUS
  237. WINAPI
  238. CP210x_GetMaxPower(
  239. HANDLE cyHandle,
  240. LPBYTE lpbPower
  241. );
  242. CP210xDLL_API
  243. CP210x_STATUS
  244. WINAPI
  245. CP210x_GetDeviceVersion(
  246. HANDLE cyHandle,
  247. LPWORD lpwVersion
  248. );
  249. CP210xDLL_API
  250. CP210x_STATUS
  251. WINAPI
  252. CP210x_GetBaudRateConfig(
  253. HANDLE cyHandle,
  254. BAUD_CONFIG* baudConfigData
  255. );
  256. CP210xDLL_API
  257. CP210x_STATUS
  258. WINAPI
  259. CP210x_GetLockValue(
  260. HANDLE cyHandle,
  261. LPBYTE lpbLockValue
  262. );
  263. CP210xDLL_API
  264. CP210x_STATUS
  265. WINAPI
  266. CP210x_CreateHexFile(
  267. HANDLE cyHandle,
  268. LPCSTR lpvFileName
  269. );
  270. CP210xDLL_API
  271. CP210x_STATUS
  272. WINAPI
  273. CP210x_Reset(
  274. HANDLE cyHandle
  275. );
  276. CP210xDLL_API
  277. CP210x_STATUS
  278. WINAPI
  279. CP210x_GetPortConfig(
  280. HANDLE cyHandle,
  281. PORT_CONFIG* PortConfig
  282. );
  283. CP210xDLL_API
  284. CP210x_STATUS
  285. WINAPI
  286. CP210x_SetPortConfig(
  287. HANDLE cyHandle,
  288. PORT_CONFIG* PortConfig
  289. );
  290. #ifdef __cplusplus
  291. }
  292. #endif
  293. #endif // !defined(DSI_CP210XMANUFACTURINGDLL_3_1_H)