DSI_SiUSBXp_3_1.h 5.6 KB

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