01-27-2016, 04:44 PM
Here is the code I used in Visual Basic for opening and closing the FTDI device, using the .dll:
Code:
Public Sub OpenFTDI()
strDescription = "SuperCard Pro" + Chr$(0) ' null terminated name string
ftStatus = FT_OpenEx(strDescription, FT_OPEN_BY_DESCRIPTION, lngHandle) ' open device with specified name and store handle
If ftStatus = FT_OK Then
HasSCP = True
If FT_SetTimeouts(lngHandle, 100, 0) <> FT_OK Then GoTo BadFTDI ' set timeout to 100ms
ftStatus = FT_SetLatencyTimer(lngHandle, 2) ' set lowest latency possible
If ftStatus <> FT_OK Then GoTo BadFTDI
ftStatus = FT_SetUSBParameters(lngHandle, &H10000, &H10000) ' set USB receive/transmit buffer to 64K * 2
If ftStatus <> FT_OK Then GoTo BadFTDI
End If
Exit Sub
BadFTDI:
Call CloseFTDI
End Sub
' This routine closes the FTDI device driver, if it was opened.
Public Sub CloseFTDI()
If lngHandle <> 0 Then FT_Close (lngHandle) ' close device if open
HasSCP = False ' no SuperCard Pro
lngHandle = 0 ' release handle
End Sub