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

📄 windrvr.bas

📁 用VB通过并口控制I2C总线
💻 BAS
📖 第 1 页 / 共 4 页
字号:
    charPtr As Long
End Type

Type WD_DEBUG_DUMP
    pcBuffer As PChar ' buffer to receive debug messages
    dwSize As Long    ' size of buffer in bytes
End Type

Type WD_DEBUG_ADD
    pcBuffer(0 To 256 - 1) As Byte
    dwLevel As Long
    dwSection As Long
End Type

Type WD_KERNEL_PLUGIN
    hKernelPlugIn As Long
    pcDriverName As PChar
    pcDriverPath As PChar ' if NULL the driver will be searched in the windows system directory
    pOpenData As PVOID
End Type

Global Const PIPE_TYPE_CONTROL = 0
Global Const PIPE_TYPE_ISOCHRONOUS = 1
Global Const PIPE_TYPE_BULK = 2
Global Const PIPE_TYPE_INTERRUPT = 3

Global Const WD_USB_MAX_PIPE_NUMBER = 32
Global Const WD_USB_MAX_ENDPOINTS = 32
Global Const WD_USB_MAX_INTERFACES = 30
Global Const WD_USB_MAX_DEVICE_NUMBER = 30

Global Const WDU_DIR_IN = 1
Global Const WDU_DIR_OUT = 2
Global Const WDU_DIR_IN_OUT = 3

Type WD_USB_ID
    dwVendorID  As Long
    dwProductID As Long
End Type

Type WD_USB_PIPE_INFO
    dwNumber As Long        ' Pipe 0 is the default pipe
    dwMaximumPacketSize As Long
    type As Long            ' USB_PIPE_TYPE
    direction As Long       ' WDU_DIR
                            ' Isochronous, Bulk, Interrupt are either WDU_DIR_IN or WDU_DIR_OUT
                            ' Control are WDU_DIR_IN_OUT
    dwInterval As Long      ' interval in ms relevant to Interrupt pipes
End Type

Type WD_USB_CONFIG_DESC
    dwNumInterfaces As Long
    dwValue         As Long
    dwAttributes    As Long
    MaxPower        As Long
End Type

Type WD_USB_INTERFACE_DESC
    dwNumber           As Long
    dwAlternateSetting As Long
    dwNumEndpoints     As Long
    dwClass            As Long
    dwSubClass         As Long
    dwProtocol         As Long
    dwIndex            As Long
End Type

Type WD_USB_ENDPOINT_DESC
    dwEndpointAddress As Long
    dwAttributes      As Long
    dwMaxPacketSize   As Long
    dwInterval        As Long
End Type

Type WD_USB_INTERFACE
    Interface As WD_USB_INTERFACE_DESC
    Endpoints(0 To WD_USB_MAX_ENDPOINTS - 1) As WD_USB_ENDPOINT_DESC
End Type

Type WD_USB_CONFIGURATION
    uniqueId As Long
    dwConfigurationIndex As Long
    configuration As WD_USB_CONFIG_DESC
    dwInterfaceAlternatives As Long
    Interface(0 To WD_USB_MAX_INTERFACES - 1) As WD_USB_INTERFACE
    dwStatus As Long  ' Configuration status code - see WD_USB_ERROR_CODES enum definition.
                      ' WD_USBD_STATUS_SUCCESS for a successful configuration.
End Type

Type WD_USB_HUB_GENERAL_INFO
    fBusPowered          As Long
    dwPorts              As Long  ' number of ports on this hub
    dwCharacteristics    As Long  ' Hub Characteristics
    dwPowerOnToPowerGood As Long  ' port power on till power good in 2ms
    dwHubControlCurrent  As Long  ' max current in mA
End Type

Global Const WD_SINGLE_INTERFACE As Long = &HFFFFFFFF

Type WD_USB_DEVICE_GENERAL_INFO
    deviceId            As WD_USB_ID
    dwHubNum            As Long
    dwPortNum           As Long
    fHub                As Long
    fFullSpeed          As Long
    dwConfigurationsNum As Long
    deviceAddress       As Long
    hubInfo             As WD_USB_HUB_GENERAL_INFO
    deviceClass         As Long
    deviceSubClass      As Long
    dwInterfaceNum      As Long ' For a single device WinDriver sets this
                                ' value to WD_SINGLE_INTERFACE
End Type

Type WD_USB_DEVICE_INFO
    dwPipes As Long
    Pipe(0 To WD_USB_MAX_PIPE_NUMBER - 1) As WD_USB_PIPE_INFO
End Type

Type WD_USB_SCAN_DEVICES
    searchId  As WD_USB_ID ' if dwVendorID==0 - scan all vendor IDs
                           ' if dwProductID==0 - scan all product IDs
    dwDevices As Long
    uniqueId(0 To WD_USB_MAX_DEVICE_NUMBER - 1) As Long         ' a unique id to identify the device
    deviceGeneralInfo(0 To WD_USB_MAX_DEVICE_NUMBER - 1) As WD_USB_DEVICE_GENERAL_INFO
    dwStatus As Long  ' Configuration status code - see WD_USB_ERROR_CODES enum definition.
                      ' WD_USBD_STATUS_SUCCESS for a successful configuration.
End Type

' WD_USB_ERROR_CODES returned values:
    ' The following statuses are returned by WinDriver:
Global Const WD_STATUS_SUCCESS As Long = &H0
Global Const WD_STATUS_INVALID_WD_HANDLE As Long = &HFFFFFFFF
Global Const WD_WINDRIVER_STATUS_ERROR As Long = &H20000000

Global Const WD_INVALID_HANDLE As Long = &H20000001
Global Const WD_INVALID_PIPE_NUMBER As Long = &H20000002
Global Const WD_READ_WRITE_CONFLICT As Long = &H20000003  ' request to read from an OUT (write) pipe or
                                                  ' request to write to an IN (read) pipe
Global Const WD_ZERO_PACKET_SIZE As Long = &H20000004     ' maximum packet size is zero
Global Const WD_INSUFFICIENT_RESOURCES As Long = &H20000005
Global Const WD_UNKNOWN_PIPE_TYPE As Long = &H20000006
Global Const WD_SYSTEM_INTERNAL_ERROR As Long = &H20000007
Global Const WD_DATA_MISMATCH As Long = &H20000008
Global Const WD_NO_LICENSE As Long = &H20000009
Global Const WD_NOT_IMPLEMENTED As Long = &H2000000A
Global Const WD_KERPLUG_FAILURE As Long = &H2000000B
Global Const WD_FAILED_ENABLING_INTERRUPT As Long = &H2000000C
Global Const WD_INTERRUPT_NOT_ENABLED As Long = &H2000000D
Global Const WD_RESOURCE_OVERLAP As Long = &H2000000E
Global Const WD_DEVICE_NOT_FOUND As Long = &H2000000F
Global Const WD_WRONG_UNIQUE_ID As Long = &H20000010
Global Const WD_OPERATION_ALREADY_DONE As Long = &H20000011
Global Const WD_INTERFACE_DESCRIPTOR_ERROR As Long = &H20000012
Global Const WD_SET_CONFIGURATION_FAILED As Long = &H20000013
Global Const WD_CANT_OBTAIN_PDO As Long = &H20000014
Global Const WD_TIME_OUT_EXPIRED As Long = &H20000015
Global Const WD_IRP_CANCELED As Long = &H20000016
Global Const WD_FAILED_USER_MAPPING As Long = &H20000017
Global Const WD_FAILED_KERNEL_MAPPING As Long = &H20000018
Global Const WD_NO_RESOURCES_ON_DEVICE As Long = &H20000019
Global Const WD_NO_EVENTS As Long = &H2000001A
Global Const WD_INVALID_PARAMETER As Long = &H2000001B
Global Const WD_INCORRECT_VERSION As Long = &H2000001C
Global Const WD_TRY_AGAIN As Long = &H2000001D
Global Const WD_WINDRIVER_NOT_FOUND As Long = &H2000001E

' The following statuses are returned by USBD:
    ' USBD status types:
Global Const WD_USBD_STATUS_SUCCESS As Long = &H0
Global Const WD_USBD_STATUS_PENDING As Long = &H40000000
Global Const WD_USBD_STATUS_ERROR As Long = &H80000000
Global Const WD_USBD_STATUS_HALTED As Long = &HC0000000

    ' USBD status codes:
    ' NOTE: The following status codes are comprised of one of the status types above and an
    ' error code [i.e. XYYYYYYY - where: X = status type; YYYYYYY = error code].
    ' The same error codes may also appear with one of the other status types as well.

    ' HC (Host Controller) status codes.
    ' [NOTE: These status codes use the WD_USBD_STATUS_HALTED status type]:
Global Const WD_USBD_STATUS_CRC As Long = &HC0000001
Global Const WD_USBD_STATUS_BTSTUFF As Long = &HC0000002
Global Const WD_USBD_STATUS_DATA_TOGGLE_MISMATCH As Long = &HC0000003
Global Const WD_USBD_STATUS_STALL_PID As Long = &HC0000004
Global Const WD_USBD_STATUS_DEV_NOT_RESPONDING As Long = &HC0000005
Global Const WD_USBD_STATUS_PID_CHECK_FAILURE As Long = &HC0000006
Global Const WD_USBD_STATUS_UNEXPECTED_PID As Long = &HC0000007
Global Const WD_USBD_STATUS_DATA_OVERRUN As Long = &HC0000008
Global Const WD_USBD_STATUS_DATA_UNDERRUN As Long = &HC0000009
Global Const WD_USBD_STATUS_RESERVED1 As Long = &HC000000A
Global Const WD_USBD_STATUS_RESERVED2 As Long = &HC000000B
Global Const WD_USBD_STATUS_BUFFER_OVERRUN As Long = &HC000000C
Global Const WD_USBD_STATUS_BUFFER_UNDERRUN As Long = &HC000000D
Global Const WD_USBD_STATUS_NOT_ACCESSED As Long = &HC000000F
Global Const WD_USBD_STATUS_FIFO As Long = &HC0000010

    ' Returned by HCD (Host Controller Driver) if a transfer is submitted to an endpoint that is
    ' stalled:
Global Const WD_USBD_STATUS_ENDPOINT_HALTED As Long = &HC0000030

    ' Software status codes
    ' [NOTE: The following status codes have only the error bit set]:
Global Const WD_USBD_STATUS_NO_MEMORY As Long = &H80000100
Global Const WD_USBD_STATUS_INVALID_URB_FUNCTION As Long = &H80000200
Global Const WD_USBD_STATUS_INVALID_PARAMETER As Long = &H80000300

    ' Returned if client driver attempts to close an endpoint/interface
    ' or configuration with outstanding transfers:
Global Const WD_USBD_STATUS_ERROR_BUSY As Long = &H80000400

    ' Returned by USBD if it cannot complete a URB request. Typically this
    ' will be returned in the URB status field when the Irp is completed
    ' with a more specific NT error code. [The Irp statuses are indicated in
    ' WinDriver's Monitor Debug Messages (wddebug_gui) tool]:
Global Const WD_USBD_STATUS_REQUEST_FAILED As Long = &H80000500

Global Const WD_USBD_STATUS_INVALID_PIPE_HANDLE As Long = &H80000600

    ' Returned when there is not enough bandwidth available
    ' to open a requested endpoint:
Global Const WD_USBD_STATUS_NO_BANDWIDTH As Long = &H80000700

    ' Generic HC (Host Controller) error:
Global Const WD_USBD_STATUS_INTERNAL_HC_ERROR As Long = &H80000800

    ' Returned when a short packet terminates the transfer
    ' i.e. USBD_SHORT_TRANSFER_OK bit not set:
Global Const WD_USBD_STATUS_ERROR_SHORT_TRANSFER As Long = &H80000900

    ' Returned if the requested start frame is not within
    ' USBD_ISO_START_FRAME_RANGE of the current USB frame,
    ' NOTE: that the stall bit is set:
Global Const WD_USBD_STATUS_BAD_START_FRAME As Long = &HC0000A00

    ' Returned by HCD (Host Controller Driver) if all packets in an iso transfer complete with
    ' an error:
Global Const WD_USBD_STATUS_ISOCH_REQUEST_FAILED As Long = &HC0000B00

    ' Returned by USBD if the frame length control for a given
    ' HC (Host Controller) is already taken by another driver:
Global Const WD_USBD_STATUS_FRAME_CONTROL_OWNED As Long = &HC0000C00

    ' Returned by USBD if the caller does not own frame length control and
    ' attempts to release or modify the HC frame length:
Global Const WD_USBD_STATUS_FRAME_CONTROL_NOT_OWNED As Long = &HC0000D00

' USB TRANSFER options
Global Const USB_TRANSFER_HALT As Long = 1
Global Const USB_SHORT_TRANSFER As Long = 2
Global Const USB_FULL_TRANSFER As Long = 4
Global Const USB_ISOCH_ASAP As Long = &H8
Global Const USB_ISOCH_NOASAP As Long = &H80
Global Const USB_ISOCH_FULL_PACKETS_ONLY As Long = &H20
Global Const USB_ISOCH_RESET As Long = &H10

Type WD_USB_TRANSFER
    hDevice      As Long       ' handle of USB device to read from or write to
    dwPipe       As Long       ' pipe number on device
    fRead        As Long
    dwOptions    As Long       ' USB_TRANSFER options:
                               '   USB_TRANSFER_HALT - halts the pervious transfer.
                               '   USB_SHORT_TRANSFER - the transfer will be completed if
                               '     the device sent a short packet of data.
                               '   USB_FULL_TRANSFER - the transfer will normally be completed
                               '     if all the requested data was transferred.
    pBuffer      As Long       ' pointer to buffer to read/write
    dwBytes      As Long
    dwTimeout    As Long       ' timeout for the transfer in milliseconds. 0==>no timeout.
    dwBytesTransfered As Long  ' returns the number of bytes actually read/written
    SetupPacket(0 To 8 - 1) As Byte     ' setup packet for control pipe transfer
    fOK          As Long       ' transfer succeeded
    dwStatus     As Long       ' Configuration status code - see WD_USB_ERROR_CODES enum
                               ' definition.  WD_USBD_STATUS_SUCCESS for a successful
                               ' configuration.
End Type

Type WD_USB_DEVICE_REGISTER
    uniqueId             As Long         ' the device unique ID
    dwConfigurationIndex As Long         ' the index of the configuration to register
    dwInterfaceNum       As Long         ' interface to register
    dwInterfaceAlternate As Long
    hDevice              As Long         ' handle of device
    Device               As WD_USB_DEVICE_INFO      ' description of the device
    dwOptions            As Long         ' should be zero
    cName(0 To 32 - 1)   As Byte         ' name of card
    cDescription(0 To 100 - 1) As Byte   ' description
    dwStatus             As Long         ' Configuration status code - see WD_USB_ERROR_CODES
                                         ' enum definition.  WD_USBD_STATUS_SUCCESS for a
                                         ' successful configuration.
End Type

Type WD_USB_RESET_PIPE
        hDevice As Long
        dwPipe As Long
        dwStatus     As Long       ' Configuration status code - see WD_USB_ERROR_CODES enum
                                   ' definition.  WD_USBD_STATUS_SUCCESS for a successful
                                   ' configuration.
End Type

Type WD_USB_RESET_DEVICE
        hDevice As Long
        dwOptions As Long          ' USB_RESET options:
                                   ' WD_USB_HARD_RESET - will reset the device
                                   ' even if it is not disabled.
                                   ' After using this option it is advised to
                                   ' un-register the device (WD_UsbDeviceUnregister())
                                   ' and register it again - to make sure that the
                                   ' device has all its resources.
        dwStatus As Long           ' Configuration status code - see WD_USB_ERROR_CODES enum
                                   ' definition.  WD_USBD_STATUS_SUCCESS for a successful
                                   ' configuration.
End Type

Global Const WD_INSERT = &H1
Global Const WD_REMOVE = &H2
Global Const WD_POWER_CHANGED_D0 = &H10 ' Power states for the power management.
Global Const WD_POWER_CHANGED_D1 = &H20
Global Const WD_POWER_CHANGED_D2 = &H40
Global Const WD_POWER_CHANGED_D3 = &H80
Global Const WD_POWER_SYSTEM_WORKING = &H100
Global Const WD_POWER_SYSTEM_SLEEPING1 = &H200
Global Const WD_POWER_SYSTEM_SLEEPING2 = &H400
Global Const WD_POWER_SYSTEM_SLEEPING3 = &H800
Global Const WD_POWER_SYSTEM_HIBERNATE = &H1000
Global Const WD_POWER_SYSTEM_SHUTDOWN = &H2000

⌨️ 快捷键说明

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