📄 form1.frm
字号:
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_VENDOR_REQUEST, _
myRequest, _
10, _
ReData(0), _
8, _
nBytes, _
0)
If (bResult = True) Then
MsgBox "I/O Address" + IoAddress + "'s Value:0x" + Hex(ReData(1)), , "CY7C63001"
CloseHandle (HidDevice)
Else
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "I/O Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
End If
End Sub
Private Sub Command11_Click()
Dim bResult As Boolean
Dim ReData(18) As Byte
Dim nBytes As Long
Dim HidDevice As Long
Dim DevicePathName As String
DevicePathName = "\\.\Cyusb-0"
If (OpenDevice(HidDevice, DevicePathName) = True) Then
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_GET_CONFIGURATION_DESCRIPTOR, _
0, _
0, _
ReData(0), _
18, _
nBytes, _
0)
If (bResult = True) Then
MsgBox " Interface Descriptor" + _
Chr(13) & Chr(10) + _
Chr(13) & Chr(10) + _
"bLength: 0x" + Hex(ReData(9)) + _
Chr(13) & Chr(10) + _
"bDecriptorType: 0x" + Hex(ReData(10)) + _
Chr(13) & Chr(10) + _
"bInterfaceNumber: 0x" + Hex(ReData(11)) + _
Chr(13) & Chr(10) + _
"bAlternateSetting: 0x" + Hex(ReData(12)) + _
Chr(13) & Chr(10) + _
"bNumEndpoints: 0x" + Hex(ReData(13)) + _
Chr(13) & Chr(10) + _
"bInterfaceClass: 0x" + Hex(ReData(14)) + _
Chr(13) & Chr(10) + _
"bInterfaceSubClass: 0x" + Hex(ReData(15)) + _
Chr(13) & Chr(10) + _
"bInterfaceProtocol: 0x" + Hex(ReData(16)) + _
Chr(13) & Chr(10) + _
"iInterface: 0x" + Hex(ReData(17)), , "USB"
CloseHandle (HidDevice)
Else
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "Interface Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
End If
End Sub
Private Sub Command12_Click()
Dim bResult As Boolean
Dim ReData(32) As Byte
Dim nBytes As Long
Dim HidDevice As Long
Dim DevicePathName As String
Dim DataInput As GET_STRING_DESCRIPTOR_IN
DevicePathName = "\\.\Cyusb-0"
If (OpenDevice(HidDevice, DevicePathName) = True) Then
DataInput.Index = 1
DataInput.LanguageId = 0
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_GET_STRING_DESCRIPTOR, _
DataInput, _
3, _
ReData(0), _
8, _
nBytes, _
0)
If (bResult = False) Then
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "String1 Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
DataInput.Index = 2
DataInput.LanguageId = 0
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_GET_STRING_DESCRIPTOR, _
DataInput, _
3, _
ReData(8), _
24, _
nBytes, _
0)
If (bResult = False) Then
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "String2 Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
MsgBox "String Descriptor 1" + _
Chr(13) & Chr(10) + _
"bLength: 0x" + Hex(ReData(0)) + _
Chr(13) & Chr(10) + _
"bDecriptorType: 0x" + Hex(ReData(1)) + _
Chr(13) & Chr(10) + _
"bString: " + Chr(ReData(2)) + Chr(ReData(4)) + Chr(ReData(6)) + _
Chr(13) & Chr(10) + Chr(13) & Chr(10) + _
"String Descriptor 2" + _
Chr(13) & Chr(10) + _
"bLength: 0x" + Hex(ReData(8)) + _
Chr(13) & Chr(10) + _
"bDecriptorType: 0x" + Hex(ReData(9)) + _
Chr(13) & Chr(10) + _
"bString: " + Chr(ReData(10)) + Chr(ReData(12)) + Chr(ReData(14)) + _
Chr(ReData(16)) + Chr(ReData(18)) + Chr(ReData(20)) + Chr(ReData(22)) + _
Chr(ReData(24)) + Chr(ReData(26)) + Chr(ReData(28)) + Chr(ReData(30)) _
, , "USB"
CloseHandle (HidDevice)
End If
End Sub
Private Sub Command13_Click()
Dim bResult As Boolean
Dim ReData(9) As Byte
Dim nBytes As Long
Dim HidDevice As Long
Dim DevicePathName As String
DevicePathName = "\\.\Cyusb-0"
If (OpenDevice(HidDevice, DevicePathName) = True) Then
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_GET_CONFIGURATION_DESCRIPTOR, _
0, _
0, _
ReData(0), _
9, _
nBytes, _
0)
If (bResult = True) Then
MsgBox " Configuration Descriptor" + _
Chr(13) & Chr(10) + _
Chr(13) & Chr(10) + _
"bLength: 0x" + Hex(ReData(0)) + _
Chr(13) & Chr(10) + _
"bDecriptorType: 0x" + Hex(ReData(1)) + _
Chr(13) & Chr(10) + _
"wTotalLength: 0x" + Hex(ReData(3) * 256 + ReData(2)) + _
Chr(13) & Chr(10) + _
"bnumInterfaces: 0x" + Hex(ReData(4)) + _
Chr(13) & Chr(10) + _
"bConfigurationValue: 0x" + Hex(ReData(5)) + _
Chr(13) & Chr(10) + _
"iConfiguration: 0x" + Hex(ReData(6)) + _
Chr(13) & Chr(10) + _
"bmAttributes: 0x" + Hex(ReData(7)) + _
Chr(13) & Chr(10) + _
"MaxPower: 0x" + Hex(ReData(8)), , "USB"
CloseHandle (HidDevice)
Else
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "Configuration Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
End If
End Sub
Private Sub Command14_Click()
Dim bResult As Boolean
Dim ReData(18) As Byte
Dim nBytes As Long
Dim HidDevice As Long
Dim DevicePathName As String
DevicePathName = "\\.\Cyusb-0"
If (OpenDevice(HidDevice, DevicePathName) = True) Then
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_GET_DEVICE_DESCRIPTOR, _
0, _
0, _
ReData(0), _
18, _
nBytes, _
0)
If (bResult = True) Then
MsgBox " Device Descriptor" + _
Chr(13) & Chr(10) + _
Chr(13) & Chr(10) + _
"bLength: 0x" + Hex(ReData(0)) + " " + "idVendor: 0x" + Hex(ReData(9) * 256 + ReData(8)) + _
Chr(13) & Chr(10) + _
"bDecriptorType: 0x" + Hex(ReData(1)) + " " + "idProduct: 0x" + Hex(ReData(11) * 256 + ReData(10)) + _
Chr(13) & Chr(10) + _
"bcdUSB: 0x" + Hex(ReData(3) * 256 + ReData(2)) + " " + "bcdDevice: 0x" + Hex(ReData(13) * 256 + ReData(12)) + _
Chr(13) & Chr(10) + _
"bDeviceClass: 0x" + Hex(ReData(4)) + " " + "iManufacturer: 0x" + Hex(ReData(14)) + _
Chr(13) & Chr(10) + _
"bDeviceSubClass: 0x" + Hex(ReData(5)) + " " + "iProduct: 0x" + Hex(ReData(15)) + _
Chr(13) & Chr(10) + _
"bDevicePortocol: 0x" + Hex(ReData(6)) + " " + "iSerialNumber: 0x" + Hex(ReData(16)) + _
Chr(13) & Chr(10) + _
"bMaxPacketSize0: 0x" + Hex(ReData(7)) + " " + "bnumConfigurations: 0x" + Hex(ReData(17)), , "USB"
CloseHandle (HidDevice)
Else
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "Device Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
End If
End Sub
Private Sub Command15_Click()
Form2.Show 1
End Sub
Private Sub Command16_Click()
End
End Sub
Private Sub Command17_Click()
Dim myRequest As VENDOR_REQUEST_IN
Dim bResult As Boolean
Dim ReData(8) As Byte
Dim nBytes As Long
Dim HidDevice As Long
Dim DevicePathName As String
Dim Brightness As String
Brightness = InputBox(" Please Input LED2's Lightness Value: " + _
Chr(13) & Chr(10) + _
" (Range:0-255)", "LED2 Setting", "127")
If (Brightness = "") Then
Exit Sub
Else
If (Not IsNumeric(Brightness) Or Val(Brightness) < 0 Or Val(Brightness) > 255) Then
MsgBox "LED2's lightness Range:0-255", 16, "LED2 Error"
Exit Sub
End If
End If
DevicePathName = "\\.\Cyusb-0"
If (OpenDevice(HidDevice, DevicePathName) = True) Then
myRequest.bRequest = &H7
myRequest.wValue = Val(Brightness)
myRequest.wIndex = &H0
myRequest.wLength = &H8
myRequest.bData = &H0
myRequest.direction = &H1
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_VENDOR_REQUEST, _
myRequest, _
10, _
ReData(0), _
8, _
nBytes, _
0)
If (bResult = True) Then
CloseHandle (HidDevice)
Else
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "LED2 Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
End If
End Sub
Private Sub Command18_Click()
Dim myRequest As VENDOR_REQUEST_IN
Dim bResult As Boolean
Dim ReData(8) As Byte
Dim nBytes As Long
Dim HidDevice As Long
Dim DevicePathName As String
DevicePathName = "\\.\Cyusb-0"
If (OpenDevice(HidDevice, DevicePathName) = True) Then
myRequest.bRequest = &H5
myRequest.wValue = &H1
myRequest.wIndex = &HFF
myRequest.wLength = &H8
myRequest.bData = &H0
myRequest.direction = &H1
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_VENDOR_REQUEST, _
myRequest, _
10, _
ReData(0), _
8, _
nBytes, _
0)
If (bResult = True) Then
Command18.Enabled = False
Command19.Enabled = True
Command17.Enabled = False
CloseHandle (HidDevice)
Else
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "LED2 Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
End If
End Sub
Private Sub Command19_Click()
Dim myRequest As VENDOR_REQUEST_IN
Dim bResult As Boolean
Dim ReData(8) As Byte
Dim nBytes As Long
Dim HidDevice As Long
Dim DevicePathName As String
DevicePathName = "\\.\Cyusb-0"
If (OpenDevice(HidDevice, DevicePathName) = True) Then
myRequest.bRequest = &H5
myRequest.wValue = &H1
myRequest.wIndex = &HFD
myRequest.wLength = &H8
myRequest.bData = &H0
myRequest.direction = &H1
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_VENDOR_REQUEST, _
myRequest, _
10, _
ReData(0), _
8, _
nBytes, _
0)
If (bResult = True) Then
Command18.Enabled = True
Command19.Enabled = False
Command17.Enabled = True
CloseHandle (HidDevice)
Else
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "LED2 Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
End If
End Sub
Private Sub Command2_Click()
Form1.Width = 1960
Command1.Visible = True
Command2.Visible = False
End Sub
Private Sub Command3_Click()
Dim myRequest As VENDOR_REQUEST_IN
Dim bResult As Boolean
Dim ReData(8) As Byte
Dim nBytes As Long
Dim HidDevice As Long
Dim DevicePathName As String
DevicePathName = "\\.\Cyusb-0"
If (OpenDevice(HidDevice, DevicePathName) = True) Then
myRequest.bRequest = &H8
myRequest.wValue = &H0
myRequest.wIndex = &H0
myRequest.wLength = &H8
myRequest.bData = &H0
myRequest.direction = &H1
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_VENDOR_REQUEST, _
myRequest, _
10, _
ReData(0), _
8, _
nBytes, _
0)
If (bResult = True) Then
THightemper = ReData(2) / 2
MsgBox "THIGH =" + Str(ReData(2) / 2) + "℃", 0, "DS1620"
CloseHandle (HidDevice)
Else
MsgBox " USB Communication Fail!" + _
Chr(13) & Chr(10) + _
"USB Data Transfer,Please Reset Device!", _
16, "THigh Error"
CloseHandle (HidDevice)
Unload Form1
End
End If
End If
End Sub
Private Sub Command4_Click()
Dim myRequest As VENDOR_REQUEST_IN
Dim bResult As Boolean
Dim ReData(8) As Byte
Dim nBytes As Long
Dim HidDevice As Long
Dim DevicePathName As String
Dim RomAddress As String
RomAddress = InputBox(" Please Input CY7C63001 ROM's Offset: " + _
Chr(13) & Chr(10) + _
" (Range:0-79)", "CY7C63001 Setting", "0")
If (RomAddress = "") Then
Exit Sub
Else
If (Not IsNumeric(RomAddress) Or Val(RomAddress) < 0 Or Val(RomAddress) > 79) Then
MsgBox "CY7C63001 ROM Address's Range:0-79", 16, "ROM Error"
Exit Sub
End If
End If
DevicePathName = "\\.\Cyusb-0"
If (OpenDevice(HidDevice, DevicePathName) = True) Then
myRequest.bRequest = &H1
myRequest.wValue = Val(RomAddress)
myRequest.wIndex = &H0
myRequest.wLength = &H8
myRequest.bData = &H0
myRequest.direction = &H1
bResult = DeviceIoControl _
(HidDevice, _
IOCTL_Cyusb_VENDOR_REQUEST, _
myRequest, _
10, _
ReData(0), _
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -