DSI_CP210xManufacturingDLL_3_1.h 7.6 KB

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