DSI_SiUSBXp_3_1.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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_SIUSBXP_3_1_H)
  9. #define DSI_SIUSBXP_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 SI_USB_XP_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. // SI_USB_XP_API functions as being imported from a DLL, wheras this DLL sees symbols
  15. // defined with this macro as being exported.
  16. #ifdef SI_USB_XP_EXPORTS
  17. #define SI_USB_XP_API __declspec(dllexport)
  18. #else
  19. #define SI_USB_XP_API __declspec(dllimport)
  20. #endif
  21. // Return codes
  22. #define SI_SUCCESS 0x00
  23. #define SI_DEVICE_NOT_FOUND 0xFF
  24. #define SI_INVALID_HANDLE 0x01
  25. #define SI_READ_ERROR 0x02
  26. #define SI_RX_QUEUE_NOT_READY 0x03
  27. #define SI_WRITE_ERROR 0x04
  28. #define SI_RESET_ERROR 0x05
  29. #define SI_INVALID_PARAMETER 0x06
  30. #define SI_INVALID_REQUEST_LENGTH 0x07
  31. #define SI_DEVICE_IO_FAILED 0x08
  32. #define SI_INVALID_BAUDRATE 0x09
  33. #define SI_FUNCTION_NOT_SUPPORTED 0x0a
  34. #define SI_GLOBAL_DATA_ERROR 0x0b
  35. #define SI_SYSTEM_ERROR_CODE 0x0c
  36. #define SI_READ_TIMED_OUT 0x0d
  37. #define SI_WRITE_TIMED_OUT 0x0e
  38. #define SI_IO_PENDING 0x0f
  39. // GetProductString() function flags
  40. #define SI_RETURN_SERIAL_NUMBER 0x00
  41. #define SI_RETURN_DESCRIPTION 0x01
  42. #define SI_RETURN_LINK_NAME 0x02
  43. #define SI_RETURN_VID 0x03
  44. #define SI_RETURN_PID 0x04
  45. // RX Queue status flags
  46. #define SI_RX_NO_OVERRUN 0x00
  47. #define SI_RX_EMPTY 0x00
  48. #define SI_RX_OVERRUN 0x01
  49. #define SI_RX_READY 0x02
  50. // Buffer size limits
  51. #define SI_MAX_DEVICE_STRLEN 256
  52. #define SI_MAX_READ_SIZE 4096*16
  53. #define SI_MAX_WRITE_SIZE 4096
  54. // Type definitions
  55. typedef int SI_STATUS;
  56. typedef char SI_DEVICE_STRING[SI_MAX_DEVICE_STRLEN];
  57. // Input and Output pin Characteristics
  58. #define SI_HELD_INACTIVE 0x00
  59. #define SI_HELD_ACTIVE 0x01
  60. #define SI_FIRMWARE_CONTROLLED 0x02
  61. #define SI_RECEIVE_FLOW_CONTROL 0x02
  62. #define SI_TRANSMIT_ACTIVE_SIGNAL 0x03
  63. #define SI_STATUS_INPUT 0x00
  64. #define SI_HANDSHAKE_LINE 0x01
  65. // Mask and Latch value bit definitions
  66. #define SI_GPIO_0 0x01
  67. #define SI_GPIO_1 0x02
  68. #define SI_GPIO_2 0x04
  69. #define SI_GPIO_3 0x08
  70. // GetDeviceVersion() return codes
  71. #define SI_CP2101_VERSION 0x01
  72. #define SI_CP2102_VERSION 0x02
  73. #define SI_CP2103_VERSION 0x03
  74. #ifdef __cplusplus
  75. extern "C" {
  76. #endif
  77. SI_USB_XP_API
  78. SI_STATUS WINAPI SI_GetNumDevices(
  79. LPDWORD lpdwNumDevices
  80. );
  81. SI_USB_XP_API
  82. SI_STATUS WINAPI SI_GetProductString(
  83. DWORD dwDeviceNum,
  84. LPVOID lpvDeviceString,
  85. DWORD dwFlags
  86. );
  87. SI_USB_XP_API
  88. SI_STATUS WINAPI SI_Open(
  89. DWORD dwDevice,
  90. HANDLE* cyHandle
  91. );
  92. SI_USB_XP_API
  93. SI_STATUS WINAPI SI_Close(
  94. HANDLE cyHandle
  95. );
  96. SI_USB_XP_API
  97. SI_STATUS WINAPI SI_Read(
  98. HANDLE cyHandle,
  99. LPVOID lpBuffer,
  100. DWORD dwBytesToRead,
  101. LPDWORD lpdwBytesReturned,
  102. OVERLAPPED* o
  103. #if defined(__cplusplus)
  104. = NULL
  105. #endif
  106. );
  107. SI_USB_XP_API
  108. SI_STATUS WINAPI SI_Write(
  109. HANDLE cyHandle,
  110. LPVOID lpBuffer,
  111. DWORD dwBytesToWrite,
  112. LPDWORD lpdwBytesWritten,
  113. OVERLAPPED* o
  114. #if defined(__cplusplus)
  115. = NULL
  116. #endif
  117. );
  118. SI_USB_XP_API
  119. SI_STATUS WINAPI SI_DeviceIOControl(
  120. HANDLE cyHandle,
  121. DWORD dwIoControlCode,
  122. LPVOID lpInBuffer,
  123. DWORD dwBytesToRead,
  124. LPVOID lpOutBuffer,
  125. DWORD dwBytesToWrite,
  126. LPDWORD lpdwBytesSucceeded
  127. );
  128. SI_USB_XP_API
  129. SI_STATUS WINAPI SI_FlushBuffers(
  130. HANDLE cyHandle,
  131. BYTE FlushTransmit,
  132. BYTE FlushReceive
  133. );
  134. SI_USB_XP_API
  135. SI_STATUS WINAPI SI_SetTimeouts(
  136. DWORD dwReadTimeout,
  137. DWORD dwWriteTimeout
  138. );
  139. SI_USB_XP_API
  140. SI_STATUS WINAPI SI_GetTimeouts(
  141. LPDWORD lpdwReadTimeout,
  142. LPDWORD lpdwWriteTimeout
  143. );
  144. SI_USB_XP_API
  145. SI_STATUS WINAPI SI_CheckRXQueue(
  146. HANDLE cyHandle,
  147. LPDWORD lpdwNumBytesInQueue,
  148. LPDWORD lpdwQueueStatus
  149. );
  150. SI_USB_XP_API
  151. SI_STATUS WINAPI SI_SetBaudRate(
  152. HANDLE cyHandle,
  153. DWORD dwBaudRate
  154. );
  155. SI_USB_XP_API
  156. SI_STATUS WINAPI SI_SetBaudDivisor(
  157. HANDLE cyHandle,
  158. WORD wBaudDivisor
  159. );
  160. SI_USB_XP_API
  161. SI_STATUS WINAPI SI_SetLineControl(
  162. HANDLE cyHandle,
  163. WORD wLineControl
  164. );
  165. SI_USB_XP_API
  166. SI_STATUS WINAPI SI_SetFlowControl(
  167. HANDLE cyHandle,
  168. BYTE bCTS_MaskCode,
  169. BYTE bRTS_MaskCode,
  170. BYTE bDTR_MaskCode,
  171. BYTE bDSR_MaskCode,
  172. BYTE bDCD_MaskCode,
  173. BOOL bFlowXonXoff
  174. );
  175. SI_USB_XP_API
  176. SI_STATUS WINAPI SI_GetModemStatus(
  177. HANDLE cyHandle,
  178. PBYTE ModemStatus
  179. );
  180. SI_USB_XP_API
  181. SI_STATUS WINAPI SI_SetBreak(
  182. HANDLE cyHandle,
  183. WORD wBreakState
  184. );
  185. SI_USB_XP_API
  186. SI_STATUS WINAPI SI_ReadLatch(
  187. HANDLE cyHandle,
  188. LPBYTE lpbLatch
  189. );
  190. SI_USB_XP_API
  191. SI_STATUS WINAPI SI_WriteLatch(
  192. HANDLE cyHandle,
  193. BYTE bMask,
  194. BYTE bLatch
  195. );
  196. SI_USB_XP_API
  197. SI_STATUS WINAPI SI_GetPartNumber(
  198. HANDLE cyHandle,
  199. LPBYTE lpbPartNum
  200. );
  201. SI_USB_XP_API
  202. SI_STATUS WINAPI SI_GetDLLVersion(
  203. DWORD* HighVersion,
  204. DWORD* LowVersion
  205. );
  206. SI_USB_XP_API
  207. SI_STATUS WINAPI SI_GetDriverVersion(
  208. DWORD* HighVersion,
  209. DWORD* LowVersion
  210. );
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214. #endif // !defined(DSI_SIUSBXP_3_1_H)