Module PCI2312 '######################## 常量定义 ################################# ' CreateFileObject所用的文件操作方式控制字(可通过或指令实现多种方式并操作) Public Const PCI2312_modeRead = &H0 ' 只读文件方式 Public Const PCI2312_modeWrite = &H1 ' 只写文件方式 Public Const PCI2312_modeReadWrite = &H2 ' 既读又写文件方式 Public Const PCI2312_modeCreate = &H3 ' 如果文件不存可以创建该文件,如果存在,则重建此文件,并清0 Public Const PCI2312_typeText = &H4 ' 以文本方式操作文件 '######################## 常规通用函数 ################################# ' 适用于本设备的最基本操作 Declare Function PCI2312_CreateDevice Lib "PCI2312_32" (ByVal DeviceID As Int32) As IntPtr ' create device object Declare Function PCI2312_GetDeviceCount Lib "PCI2312_32" (ByVal hDevice As IntPtr) As Int32 ' get the amount of this kind of device from this system Declare Function PCI2312_GetDeviceCurrentID Lib "PCI2312_32" (ByVal hDevice As IntPtr, ByRef DeviceLgcID As Int32, ByRef DevicePhysID As Int32) As Boolean Declare Function PCI2312_ListDeviceDlg Lib "PCI2312_32" (ByVal hDevice As IntPtr) As Boolean ' list all PCI devices in the system Declare Function PCI2312_ReleaseDevice Lib "PCI2312_32" (ByVal hDevice As IntPtr) As Boolean ' reset the whole PCI device '####################### 数字I/O输入输出函数 ################################# ' Applicable to the equipment control that is more direct and specific, low-level, more complex. ' For example, if it needs special control process and control efficiency in accordance with the special control object , users can achieve by using these interfaces. Declare Function PCI2312_SetDeviceDO Lib "PCI2312_32" ( _ ByVal hDevice As IntPtr, _ ByVal bDOSts() As Byte) As IntPtr ' Get on/off status Declare Function PCI2312_GetDeviceDI Lib "PCI2312_32" ( _ ByVal hDevice As IntPtr, _ ByVal bDISts() As Byte) As IntPtr ' Get on/off status '####################### 中断函数 ################################# ' 它由硬件信号的状态变化引起CPU产生中断事件hEventInt。 Declare Function PCI2312_InitDeviceInt Lib "PCI2312_32" ( _ ByVal hDevice As IntPtr, _ ByVal hEventInt As IntPtr) As Boolean Declare Function PCI2312_GetDeviceIntCount Lib "PCI2312_32" (ByVal hDevice As IntPtr) As Int32 ' In interrupt is initialized, using it to get the interrupt service routine produce number of times Declare Function PCI2312_ReleaseDeviceInt Lib "PCI2312_32" (ByVal hDevice As IntPtr) As Boolean ' Release interruption resource ' ################# 内存映射寄存器直接操作及读写函数 ######################## ' 适用于用户对本设备更直接、更特殊、更低层、更复杂的控制。比如根据特殊的 ' 控制对象需要特殊的控制流程和控制效率时,则用户可以使用这些接口予以实现。 Declare Function PCI2312_GetDeviceBar Lib "PCI2312_32" ( _ ByVal hDevice As IntPtr, _ ByVal pbPCIBar() As Int64) As Boolean ' 取得指定的指定设备寄存器组BAR地址 Declare Function PCI2312_WritePortByte Lib "PCI2312_32" (ByVal hDevice As IntPtr, ByVal pPort As Int64, ByVal Value As Byte) As Boolean Declare Function PCI2312_WritePortWord Lib "PCI2312_32" (ByVal hDevice As IntPtr, ByVal pPort As Int64, ByVal Value As UInt16) As Boolean Declare Function PCI2312_WritePortULong Lib "PCI2312_32" (ByVal hDevice As IntPtr, ByVal pPort As Int64, ByVal Value As UInt32) As Boolean Declare Function PCI2312_ReadPortByte Lib "PCI2312_32" (ByVal hDevice As IntPtr, ByVal pPort As Int64) As Byte Declare Function PCI2312_ReadPortWord Lib "PCI2312_32" (ByVal hDevice As IntPtr, ByVal pPort As Int64) As UInt16 Declare Function PCI2312_ReadPortULong Lib "PCI2312_32" (ByVal hDevice As IntPtr, ByVal pPort As Int64) As UInt32 '########################### Thread operation function ###################################### Declare Function PCI2312_CreateSystemEvent Lib "PCI2312_32" () As IntPtr ' create the (kernel) system event object Declare Function PCI2312_ReleaseSystemEvent Lib "PCI2312_32" (ByVal hEvent As IntPtr) As Boolean ' release (kernel) system event object End Module