Attribute VB_Name = "modDppDetect" Option Explicit Public Sub InitDppApi() DppDevice = DPPPX4 Dpp80MHzMode = 1 'default is 80MHz clock DppFirmwareRev = 4 'set default firmware rev DppFPGARev = 4 'set default fpga rev DppSerialNumber = 0 objDppApi = 0 End Sub Public Function FPGAClockDisplayStr(isFPGAClock As Boolean, FPGAClockSpeed As Integer) As String If (isFPGAClock) Then If (FPGAClockSpeed = 1) Then FPGAClockDisplayStr = "80MHz" ElseIf (FPGAClockSpeed = 0) Then FPGAClockDisplayStr = "20MHz" Else FPGAClockDisplayStr = "UNKNOWN" End If Else FPGAClockDisplayStr = "NONE" End If End Function '================================================================================== 'a quick way to get the serial number and device type is to use GetUSBDppDeviceInfo '---------------------------------------------------------------------------------- '================================================================================== 'Run GetStatusStruct or GetStatusString before running Get80MHzMode Public Sub SetDppApiGlobalVars(objDppApi As Long, USBDevNum As Integer) If (objDppApi = 0) Then Exit Sub 'exit sub if api is not present DppDevice = GetUSBDppDeviceInfo(objDppApi, USBDevNum, DppSerialNumber) ' get device information If ((DppDevice = DPPDP4EMUL) Or (DppDevice = DPPDP5)) Then Dpp80MHzMode = Get80MHzMode(objDppApi) 'global setting SetFPGAClockDefault objDppApi, Dpp80MHzMode, DppDevice End If End Sub Public Function GetDppDeviceList(ByRef strDppDeviceList() As String, ByRef strStatusOut As String) As Integer Dim numdev As Integer 'number of usb devices Dim Res As Integer 'number of usb devices for extended function Dim objDppApi As Long 'pointer to dpp api Dim strStatus As String 'status text Dim iDeviceType As Integer 'device type indicator Dim strDeviceType As String 'device type name Dim SerNum As Long 'current dpp serial number Dim idxDpp As Long 'current dpp device indicator ' On Error Resume Next GetDppDeviceList = 0 If (objDppApi > 0) Then CloseDppApi (objDppApi) objDppApi = 0 End If objDppApi = OpenDppApi() ' create/open DPPAPI numdev = OpenUSBDevice(objDppApi) ' open communications default USB device CloseUSBDevice (objDppApi) ' close usb default device If (numdev > 0) Then ReDim strDppDeviceList(numdev - 1) For idxDpp = 1 To numdev Res = OpenUSBDeviceEx(objDppApi, idxDpp) ' open selected USB device iDeviceType = GetUSBDppDeviceInfo(objDppApi, idxDpp, SerNum) ' get device information strDeviceType = DPPTypeString(iDeviceType) If ((iDeviceType > DPPNONE) And (iDeviceType <= DPPDP5)) Then strDppDeviceList(idxDpp - 1) = "[" & strDeviceType & "] " & Str(SerNum) Else strStatus = strStatus & Str(idxDpp) & " " & "Device Error" & vbNewLine strStatusOut = strStatus End If CloseUSBDevice (objDppApi) ' close usb Next End If strStatus = strStatus & numdev & " USB DPP Devices Read" strStatusOut = strStatus CloseDppApi (objDppApi) objDppApi = 0 GetDppDeviceList = numdev End Function