⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windrvr.bas

📁 用VB通过并口控制I2C总线
💻 BAS
📖 第 1 页 / 共 4 页
字号:
Attribute VB_Name = "windrvr"
'
' ----------------------------------------------------------------
'
'  W i n D r i v e r
'
'  This file may not be distributed, it is only for evaluation & development purposes.
'
'  Web site: http://www.jungo.com
'  Email:    support@jungo.com
'
' Copyright (c) 2003 - 2005 Jungo Ltd. 
' ----------------------------------------------------------------
'

Option Explicit

Global Const WD_VER = 700

Global Const WD_VER_STR = "WinDriver V7.00 Jungo (c) 1999 - 2005"
Global Const WD_VER_MODULE = WD_VER_STR

Global Const CMD_NONE = 0         ' No command
Global Const CMD_END = 1          ' End command

Global Const RP_BYTE = 10         ' Read port byte
Global Const RP_WORD = 11         ' Read port word
Global Const RP_DWORD = 12        ' Read port dword
Global Const WP_BYTE = 13         ' Write port byte
Global Const WP_WORD = 14         ' Write port word
Global Const WP_DWORD = 15        ' Write port dword
Global Const RP_QWORD = 16        ' Read port qword
Global Const WP_QWORD = 17        ' Write port qword

Global Const RP_SBYTE = 20        ' Read port string byte
Global Const RP_SWORD = 21        ' Read port string word
Global Const RP_SDWORD = 22       ' Read port string dword
Global Const WP_SBYTE = 23        ' Write port string byte
Global Const WP_SWORD = 24        ' Write port string word
Global Const WP_SDWORD = 25       ' Write port string dword

Global Const RM_BYTE = 30         ' Read memory byte
Global Const RM_WORD = 31         ' Read memory word
Global Const RM_DWORD = 32        ' Read memory dword
Global Const WM_BYTE = 33         ' Write memory byte
Global Const WM_WORD = 34         ' Write memory word
Global Const WM_DWORD = 35        ' Write memory dword
Global Const RM_QWORD = 36        ' Read memory qword
Global Const WM_QWORD = 37        ' Write memory qword

Global Const RM_SBYTE = 40        ' Read memory string byte
Global Const RM_SWORD = 41        ' Read memory string word
Global Const RM_SDWORD = 42       ' Read memory string dword
Global Const WM_SBYTE = 43        ' Write memory string byte
Global Const WM_SWORD = 44        ' Write memory string word
Global Const WM_SDWORD = 45       ' Write memory string dword
Global Const RM_SQWORD = 46       ' Read memory string quad word
Global Const WM_SQWORD = 47       ' Write memory string quad word

Global Const WM_APP As Long = &H8000&    ' Platform SDK constant

Global Const WD_DMA_PAGES = 256

Global Const DMA_KERNEL_BUFFER_ALLOC = 1 ' the system allocates a contiguous buffer
                                         ' the user does not need to supply linear_address
Global Const DMA_KBUF_BELOW_16M = 2      ' if DMA_KERNEL_BUFFER_ALLOC if used,
                                         ' this will make sure it is under 16M
Global Const DMA_LARGE_BUFFER = 4        ' if DMA_LARGE_BUFFER if used,
                                 ' the maximum number of pages are dwPages, and not
                                 ' WD_DMA_PAGES. if you lock a user buffer (not a kernel
                                 ' allocated buffer) that is larger than 1MB, then use this
                                 ' option, and allocate memory for pages.


Type PVOID
    ptr As Long
End Type



Type WD_DMA_PAGE
    pPhysicalAddr As PVOID        ' physical address of page
    dwBytes       As Long        ' size of page
End Type


Type WD_DMA
    hDMA       As Long      ' handle of DMA buffer
    pUserAddr  As PVOID     ' beginning of buffer
    pKernelAddr As Long     ' Kernel mapping of kernel allocated buffer
    dwBytes    As Long      ' size of buffer
    dwOptions  As Long      ' allocation options
    dwPages    As Long      ' number of pages in buffer
    dwPad1     As Long      ' Reserved for internal use
    Page(0 To WD_DMA_PAGES - 1) As WD_DMA_PAGE
End Type

Type WD_Transfer
    dwPort      As Long  ' IO port for transfer or user memory address
    cmdTrans    As Long  ' Transfer command WD_TRANSFER_CMD
    dwBytes     As Long  ' For string transfer
    fAutoInc    As Long  ' Transfer from one port/address or
                         ' use incremental range of addresses
    dwOptions   As Long  ' Must be 0
    dwPad1 As Long       ' Padding for internal uses
    dwLowDataTransfer As Long 
    dwHighDataTransfer As Long 'Must be zero for data size smaller then 64 bits
End Type

Type PWD_TRANSFER    ' pointer to WD_TRANSFER
    cmd As Long
End Type

Public Type WDU_INTERFACE_DESCRIPTOR
    bLength As Byte
    bDescriptorType As Byte
    bInterfaceNumber As Byte
    bAlternateSetting As Byte
    bNumEndpoints As Byte
    bInterfaceClass As Byte
    bInterfaceSubClass As Byte
    bInterfaceProtocol As Byte
    iInterface As Byte
End Type

Public Type WDU_ENDPOINT_DESCRIPTOR
    bLength As Byte
    bDescriptorType As Byte
    bEndpointAddress As Byte
    bmAttributes As Byte
    wMaxPacketSize As Integer
    bInterval As Byte
End Type

Public Type WDU_CONFIGURATION_DESCRIPTOR
    bLength As Byte
    bDescriptorType As Byte
    wTotalLength As Integer
    bNumInterfaces As Byte
    bConfigurationValue As Byte
    iConfiguration As Byte
    bmAttributes As Byte
    MaxPower As Byte
End Type

Public Type WDU_DEVICE_DESCRIPTOR
    bLength As Byte
    bDescriptorType As Byte
    bcdUSB As Integer
    bDeviceClass As Byte
    bDeviceSubClass As Byte
    bDeviceProtocol As Byte
    bMaxPacketSize0 As Byte
    idVendor As Integer
    idProduct As Integer
    bcdDevice As Integer
    iManufacturer As Byte
    iProduct As Byte
    iSerialNumber As Byte
    bNumConfigurations As Byte
End Type

Public Type WDU_PIPE_INFO
    dwNumber As Long
    dwMaximumPacketSize As Long
    type As Long
    direction As Long
    dwInterval As Long
End Type

Public Type WDU_ALTERNATE_SETTING
    Descriptor As WDU_INTERFACE_DESCRIPTOR
    pEndpointDescriptors As Long
    pPipes As Long
End Type

Public Type WDU_INTERFACE
    pAlternateSettings As Long
    dwNumAltSettings As Long
    pActiveAltSetting As Long
End Type

Public Type WDU_CONFIGURATION
    Descriptor As WDU_CONFIGURATION_DESCRIPTOR
    dwNumInterfaces As Long
    pInterfaces As Long
End Type

Public Type WDU_DEVICE
    Descriptor As WDU_DEVICE_DESCRIPTOR
    Pipe0 As WDU_PIPE_INFO
    pConfigs As Long
    pActiveConfig As Long
    pActiveInterface As Long
End Type

Public Type WDU_MATCH_TABLE
    wVendorId As Integer
    wProductId As Integer
    bDeviceClass As Byte
    bDeviceSubClass As Byte
    bInterfaceClass As Byte
    bInterfaceSubClass As Byte
    bInterfaceProtocol As Byte
End Type

Public Type WDU_EVENT_TABLE
    pfDeviceAttach As Long
    pfDeviceDetach As Long
    pfPowerChange As Long
    pUserData As Long
End Type

Public Type WDU_GET_DEVICE_DATA
    dwUniqueID As Long
    pBuf As Long
    dwBytes As Long
    dwOptions As Long
End Type

Public Type WDU_SET_INTERFACE
    dwUniqueID As Long
    dwInterfaceNum As Long
    dwAlternateSetting As Long
    dwOptions As Long
End Type

Public Type WDU_RESET_PIPE
    dwUniqueID As Long
    dwPipeNum As Long
    dwOptions As Long
End Type

Global Const WDU_WAKEUP_ENABLE = &H1
Global Const WDU_WAKEUP_DISABLE = &H2

Public Type WDU_HALT_TRANSFER
    dwUniqueID As Long
    dwPipeNum As Long
    dwOptions As Long
End Type

Public Type WDU_GET_DESCRIPTOR
    dwUniqueID As Long
    bType As Byte
    bIndex As Byte
    wLength As Integer
    pBuffer As Long
    wLanguage As Integer
End Type

Private IOCTL_WD_DMA_LOCK As Long
Private IOCTL_WD_DMA_UNLOCK As Long
Private IOCTL_WD_TRANSFER As Long
Private IOCTL_WD_MULTI_TRANSFER As Long
Private IOCTL_WD_PCI_SCAN_CARDS As Long
Private IOCTL_WD_PCI_GET_CARD_INFO As Long
Private IOCTL_WD_VERSION As Long
Private IOCTL_WD_LICENSE As Long
Private IOCTL_WD_PCI_CONFIG_DUMP As Long
Private IOCTL_WD_KERNEL_PLUGIN_OPEN As Long
Private IOCTL_WD_KERNEL_PLUGIN_CLOSE As Long
Private IOCTL_WD_KERNEL_PLUGIN_CALL As Long
Private IOCTL_WD_INT_ENABLE As Long
Private IOCTL_WD_INT_DISABLE As Long
Private IOCTL_WD_INT_COUNT As Long
Private IOCTL_WD_INT_WAIT As Long
Private IOCTL_WD_ISAPNP_SCAN_CARDS As Long
Private IOCTL_WD_ISAPNP_GET_CARD_INFO As Long
Private IOCTL_WD_ISAPNP_CONFIG_DUMP As Long
Private IOCTL_WD_PCMCIA_SCAN_CARDS As Long
Private IOCTL_WD_PCMCIA_GET_CARD_INFO As Long
Private IOCTL_WD_PCMCIA_CONFIG_DUMP As Long
Private IOCTL_WD_SLEEP As Long
Private IOCTL_WD_DEBUG As Long
Private IOCTL_WD_DEBUG_DUMP As Long
Private IOCTL_WD_CARD_UNREGISTER As Long
Private IOCTL_WD_CARD_REGISTER As Long
Private IOCTL_WD_EVENT_REGISTER As Long
Private IOCTL_WD_EVENT_UNREGISTER As Long
Private IOCTL_WD_EVENT_PULL As Long
Private IOCTL_WD_EVENT_SEND As Long
Private IOCTL_WD_DEBUG_ADD As Long


Global Const INTERRUPT_LEVEL_SENSITIVE = 1
Global Const INTERRUPT_CMD_COPY = 2

Type WD_KERNEL_PLUGIN_CALL
    hKernelPlugIn As Long
    dwMessage     As Long
    pData         As PVOID
    dwResult      As Long
End Type

Type WD_INTERRUPT
    hInterrupt As Long ' handle of interrupt
    dwOptions  As Long ' interrupt options as INTERRUPT_CMD_COPY
    cmd        As PWD_TRANSFER ' commands to do on interrupt
    dwCmds     As Long         ' number of commands for WD_IntEnable()
    kpCall    As WD_KERNEL_PLUGIN_CALL ' kernel plugin call
    fEnableOk As Long     ' did WD_IntEnable() succeed
                          ' For WD_IntWait() and WD_IntCount()
    dwCounter As Long ' number of interrupts received
    dwLost    As Long ' number of interrupts not yet dealt with
    fStopped  As Long ' was interrupt disabled during wait
End Type

Type WD_VERSION
    dwVer As Long
    cVer As String * 128
End Type

Global Const LICENSE_DEMO As Long = &H1
Global Const LICENSE_WD   As Long = &H4
Global Const LICENSE_KD   As Long = &H400000
Global Const LICENSE_IO   As Long = &H8
Global Const LICENSE_MEM  As Long = &H10
Global Const LICENSE_INT  As Long = &H20
Global Const LICENSE_PCI  As Long = &H40
Global Const LICENSE_DMA  As Long = &H80
Global Const LICENSE_NT   As Long = &H100
Global Const LICENSE_95   As Long = &H200
Global Const LICENSE_ISAPNP   As Long = &H400
Global Const LICENSE_PCMCIA   As Long = &H800
Global Const LICENSE_PCI_DUMP As Long = &H1000

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -