'==============================================================
'Declarations for the EEPROM-accessing functions in FTD2XX.dll:
'==============================================================
Public Declare Function FT_EE_Program Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByRef lpData As FT_PROGRAM_DATA) As Long
Public Declare Function FT_EE_Read Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByRef lpData As FT_PROGRAM_DATA) As Long
Public Declare Function FT_EE_UASize Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByRef lpdwSize As Long) As Long
Public Declare Function FT_EE_UAWrite Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal pucData As String, ByVal dwDataLen As Long) As Long
Public Declare Function FT_EE_UARead Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal pucData As String, ByVal dwDataLen As Long, ByRef lpdwBytesRead As Long) As Long
Public Type LPSECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Public Type lpOverlapped
Internal As Long
InternalHigh As Long
Offset As Long
OffsetHigh As Long
hEvent As Long
End Type
Public Type FTDCB
DCBlength As Long 'sizeof (FTDCB)
BaudRate As Long '9600
' fBinary As Long '= 1 Binary mode (skip EOF check)
' fParity As Long '= 1 Enable parity checking
' fOutxCtsFlow As Long '= 1 CTS handshaking on output
' fOutxDsrFlow As Long '= 1 DSR handshaking on output
' fDtrControl As Long '= 2 DTR flow control
' fDsrSensitivity As Long '= 1 DSR Sensitivity
' fTXContinueOnXoff As Long '= 1 Continue TX when Xoff sent
' fOutX As Long '= 1 Enable output X-on/X-off
' fInX As Long '= 1 Enable input X-on/X-off
' fErrorChar As Long '= 1 Enable error replacement
' fNull As Long '= 1 Enable null stripping
' fRtsControl As Long '= 2 RTS flow control
' fAbortOnError As Long '= 1 Abort all reads and writes on error
' fDummy2 As Long '= 17 Reserved
' wReserved As Integer 'Not currently used
' XonLim As Integer 'Transmit X-on threshold
' XoffLim As Integer 'Transmit X-off threshold
' ByteSize As Byte 'Number of bits/ byte, 7-8
' Parity As Byte '0-4= None, Odd, Even, Mark, Space
' StopBits As Byte '0, 2 = 1, 2
' XonChar As Byte 'TX and RX X-ON character
' XoffChar As Byte 'TX and RX X-OFF character
' ErrorChar As Byte 'Eror replacement char
' EofChar As Byte 'End of input Character
' EvtChar As Byte 'Received event character
' wReserved1 As Integer 'BCD (0x0200 => USB2)
End Type
'====================================================================
'Type definition as equivalent for C-structure "ft_program_data" used
'in FT_EE_READ and FT_EE_WRITE;
'ATTENTION! The variables "Manufacturer", "ManufacturerID",
'"Description" and "SerialNumber" are passed as POINTERS to
'locations of Bytearrays. Each Byte in these arrays will be
'filled with one character of the whole string.
'(See below, calls to "agGetAddressForObject")
'=====================================================================
Public Type FT_PROGRAM_DATA
signature1 As Long '0x00000000
signature2 As Long '0xFFFFFFFF
version As Long '0
VendorId As Integer '0x0403
ProductId As Integer '0x6001
Manufacturer As Long '32 "FTDI"
ManufacturerId As Long '16 "FT"
Description As Long '64 "USB HS Serial Converter"
SerialNumber As Long '16 "FT000001" if fixed, or NULL
MaxPower As Integer ' // 0 < MaxPower <= 500
PnP As Integer ' // 0 = disabled, 1 = enabled
SelfPowered As Integer ' // 0 = bus powered, 1 = self powered
RemoteWakeup As Integer ' // 0 = not capable, 1 = capable
'Rev4 extensions:
Rev4 As Byte ' // true if Rev4 chip, false otherwise
IsoIn As Byte ' // true if in endpoint is isochronous
IsoOut As Byte ' // true if out endpoint is isochronous
PullDownEnable As Byte ' // true if pull down enabled
SerNumEnable As Byte ' // true if serial number to be used
USBVersionEnable As Byte ' // true if chip uses USBVersion
USBVersion As Integer ' // BCD (0x0200 => USB2)
'FT2232C extensions:
Rev5 As Byte 'non-zero if Rev5 chip, zero otherwise
IsoInA As Byte 'non-zero if in endpoint is isochronous
IsoInB As Byte 'non-zero if in endpoint is isochronous
IsoOutA As Byte 'non-zero if out endpoint is isochronous
IsoOutB As Byte 'non-zero if out endpoint is isochronous
PullDownEnable5 As Byte 'non-zero if pull down enabled
SerNumEnable5 As Byte 'non-zero if serial number to be used
USBVersionEnable5 As Byte 'non-zero if chip uses USBVersion
USBVersion5 As Integer 'BCD 0x110 = USB 1.1, BCD 0x200 = USB 2.0
AlsHighCurrent As Byte 'non-zero if interface is high current
BlsHighCurrent As Byte 'non-zero if interface is high current
IFAlsFifo As Byte 'non-zero if interface is 245 FIFO
IFAlsFifoTar As Byte 'non-zero if interface is 245 FIFO CPU target
IFAlsFastSer As Byte 'non-zero if interface is Fast Serial
AlsVCP As Byte 'non-zero if interface is to use VCP drivers
IFBlsFifo As Byte 'non-zero if interface is 245 FIFO
IFBlsFifoTar As Byte 'non-zero if interface is 245 FIFO CPU target
IFBlsFastSer As Byte 'non-zero if interface is Fast Serial
BlsVCP As Byte 'non-zero if interface is to use VCP drivers
'FT232R extensions
UseExtOSC As Byte 'non-zero use ext osc
HighDriveIOs As Byte 'non-zero to use High Drive IO's
EndPointSize As Byte '64 Do not change
PullDownEnableR As Byte 'non-zeero if pull down enabled
SerNumEnableR As Byte 'non-zero if pull serial number enabled
InvertTXD As Byte 'non-zero if invert TXD
InvertRXD As Byte 'non-zero if invert RXD
InvertRTS As Byte 'non-zero if invert RTS
InvertCTS As Byte 'non-zero if invert CTS
InvertDTR As Byte 'non-zero if invert DTR
InvertDSR As Byte 'non-zero if invert DSR
InvertDCD As Byte 'non-zero if invert DCD
InvertRI As Byte 'non-zero if invert RI
Cbus0 As Byte 'Cbus Mux control
Cbus1 As Byte 'Cbus Mux control
Cbus2 As Byte 'Cbus Mux control
Cbus3 As Byte 'Cbus Mux control
Cbus4 As Byte 'Cbus Mux control
RIsVCP As Byte 'non-zero if using VCP driver
End Type
' Return codes
Public Const FT_OK = 0
Public Const FT_INVALID_HANDLE = 1
Public Const FT_DEVICE_NOT_FOUND = 2
Public Const FT_DEVICE_NOT_OPENED = 3
Public Const FT_IO_ERROR = 4
Public Const FT_INSUFFICIENT_RESOURCES = 5
Public Const FT_INVALID_PARAMETER = 6
Public Const FT_INVALID_BAUD_RATE = 7
Public Const FT_DEVICE_NOT_OPENED_FOR_ERASE = 8
Public Const FT_DEVICE_NOT_OPENED_FOR_WRITE = 9
Public Const FT_FAILED_TO_WRITE_DEVICE = 10
Public Const FT_EEPROM_READ_FAILED = 11
Public Const FT_EEPROM_WRITE_FAILED = 12
Public Const FT_EEPROM_ERASE_FAILED = 13
Public Const FT_EEPROM_NOT_PRESENT = 14
Public Const FT_EEPROM_NOT_PROGRAMMED = 15
Public Const FT_INVALID_ARGS = 16
Public Const FT_NOT_SUPPORTED = 17
Public Const FT_OTHER_ERROR = 18
' Word Lengths
Public Const FT_BITS_8 = 8
Public Const FT_BITS_7 = 7
' Stop Bits
Public Const FT_STOP_BITS_1 = 0
Public Const FT_STOP_BITS_1_5 = 1
Public Const FT_STOP_BITS_2 = 2
' Parity
Public Const FT_PARITY_NONE = 0
Public Const FT_PARITY_ODD = 1
Public Const FT_PARITY_EVEN = 2
Public Const FT_PARITY_MARK = 3
Public Const FT_PARITY_SPACE = 4
' Flow Control
Public Const FT_FLOW_NONE = &H0
Public Const FT_FLOW_RTS_CTS = &H100
Public Const FT_FLOW_DTR_DSR = &H200
Public Const FT_FLOW_XON_XOFF = &H400
' Purge rx and tx buffers
Public Const FT_PURGE_RX = 1
Public Const FT_PURGE_TX = 2
' Modem Status
Public Const FT_MODEM_STATUS_CTS = &H10
Public Const FT_MODEM_STATUS_DSR = &H20
Public Const FT_MODEM_STATUS_RI = &H40
Public Const FT_MODEM_STATUS_DCD = &H80
Public Const FT_EVENT_RXCHAR As Long = 1
Public Const FT_EVENT_MODEM_STATUS = 2
Const WAIT_ABANDONED As Long = &H80
Const WAIT_FAILD As Long = &HFFFFFFFF
Const WAIT_OBJECT_0 As Long = &H0
Const WAIT_TIMEOUT As Long = &H102
' Flags for FT_ListDevices
Public Const FT_LIST_BY_NUMBER_ONLY = &H80000000
Public Const FT_LIST_BY_INDEX = &H40000000
Public Const FT_LIST_ALL = &H20000000
' Flags for FT_OpenEx
Public Const FT_OPEN_BY_SERIAL_NUMBER = 1
Public Const FT_OPEN_BY_DESCRIPTION = 2
Private Const INFINITE As Long = 1000 '&HFFFFFFFF
Global hThread As Long
Global hThreadID As Long
Global hEvent As Long
Global EventMask As Long
Global lngHandle As Long
Sub Main()
Set fMainForm = New DEMO_EEPROM
fMainForm.Show
End Sub