Home
D2XX Programmer`s Guide
Contents
1. create the device information list ftStatus FT CreateDevicelInfoList amp numDevs if ftStatus FT OK printf Number of devices is d n numDevs if numDevs gt 0 allocate storage for list based on numDevs devinfo FT DEVICE LIST INFO NODE malloc sizeof FT DEVICE LIST INFO NODE numDevs get the device information list ftStatus FT GetDeviceInfoList deviInfo amp numDevs if ftStatus FT OK for int i 0 i lt numDevs itt printf Dev d n i printf Flags 0x x n devinfo i Flags printf Type 0x x n deviInfo i Type printf ID 0x x n devinfo i ID 1 ce 7 printf LocId 0x x n devInfo i LocId 7 7 printf SerialNumber s n devInfo i SerialNumber printf Description s n devInfo i Description printf ftHandle 0x x n devinfo i ftHandle 3 5 FT_GetDeviceInfoDetail Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function returns an entry from the device information list Definition FT_STATUS FT_GetDeviceInfoDetail DWORD dwIndex LPDWORD pdwFlags LPDWORD pdwType LPDWORD pdwID LPDWORD pdwLoclId PCHAR pcSerialNumber PCHAR pcDescription FT_HANDLE ftHandle Parameters dwIndex Index of the entry in the device info list IpdwFlags Pointer to unsigned long to store the flag value IpdwType P
2. First create the event and call FT SetEventNotification FT HANDLE ftHandle FT STATUS ftStatus EVENT HANDLE eh DWORD EventMask ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return e pthread mutex_init amp eh eMutex NU pthread_cond_init amp eh eCondVar NULL EventMask FT_EVENT_RXCHAR FT_EVENT MODEM STATUS ftStatus FT SetEventNotification ftHandle EventMask PVOID amp eh Sometime later block the application thread by waiting on th vent then when th event has occurred determine the condition that caused the event and process it accordingly pthread _ mutex lock amp eh eMutex pthread cond _wait amp eh eCondVar amp eh eMutex pthread mutex unlock amp eh eMutex DWORD EventDWord DWORD RxBytes Copyright 2011 Future Technology Devices International Limited 36 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 I JA Chip Clearance No FTDI 170 DWORD TxBytes DWORD Status FT GetStatus ftHandle amp RxBytes amp TxBytes amp EventDWord if EventDWord amp FT_EVENT MODEM STATUS modem status event detected so get current modem status FT GetModemStatus ftHandle amp Status if Status amp 0x00000010 CTS is high else CTS is low if Status amp 0
3. FT Open OK use ftHandle to access device else FT Open failed 3 8 FT_OpenEx Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Open the specified device and return a handle that will be used for subsequent accesses The device can be specified by its serial number device description or location This function can also be used to open multiple devices simultaneously Multiple devices can be specified by serial number device description or location ID location information derived from the physical location of a device on USB Location IDs for specific USB ports can be obtained using the utility USBView and are given in hexadecimal format Location IDs for devices connected to a system can be obtained by calling FT GetDeviceInfoList or FT ListDevices with the appropriate flags Definition FT_STATUS FT_OpenEx PVOID pvArg1 DWORD dwFlags FT_HANDLE ftHandle Parameters pvArg1 Pointer to an argument whose type depends on the value of dwFlags It is normally be interpreted as a pointer to a null terminated string dwFlags FT OPEN BY SERIAL NUMBER FT OPEN BY DESCRIPTION or FT OPEN BY LOCATION ftHandle Pointer to a variable of type FT_HANDLE where the handle will be stored This handle must be used to access the device Return Value FT_OK if successful otherwise the return value is an FT error code Copyright 2011 F
4. Information is not available for devices which are open in other processes In this case the Flags parameter of the FT DEVICE LIST INFO NODE will indicate that the device is open but other fields will be unpopulated The flag value is a 4 byte bit map containing miscellaneous data as defined Appendix A Type Definitions Bit O least significant bit of this number indicates if the port is open 1 or closed 0 Bit 1 indicates if the device is enumerated as a high speed USB device 2 or a full speed USB device 0 The remaining bits 2 31 are reserved The array of FT DEVICE LIST INFO NODES contains all available data on each device The structure of FT DEVICE LIST INFO NODES is given in the Appendix The storage for the list must be allocated by the application The number of devices returned by FT_CreateDeviceInfoList can be used to do this When programming in Visual Basic LabVIEW or similar languages FT GetDeviceInfoDetail may be required instead of this function Please note that Linux Mac OS X and Windows CE do not support location IDs As such the Location ID parameter in the structure will be empty under these operating systems Copyright 2011 Future Technology Devices International Limited 8 sF FTDI Document Reference No FT_000071 z D2XX Programmer s Guide Version 1 3 SSN Chip Clearance No FTDI 170 Example FT STATUS ftStatus FT DEVICE LIST INFO NODE devinfo DWORD numDevs
5. Remarks The effect of this function is the same as disconnecting then reconnecting the device from USB Possible use of this function is situations where a fatal error has occurred and it is difficult or not possible to recover without unplugging and replugging the USB cable This function can also be used after re programming the EEPROM to force the FTDI device to read the new EEPROM contents which would otherwise require a physical disconnect reconnect As the current session is not restored when the driver is reloaded the application must be able to recover after calling this function It is ithe responisbility of the application to close the handle after successfully calling FT_CyclePort For FT4232H FT2232H and FT2232 devices FT_CyclePort will only work under Windows XP and later Example FT HANDLE ftHandle valid handle returned from FT _OpenEx FT STATUS ftStatus ftStatus FT CyclePort ftHandle if ftStatus FT OK Port has been cycled Close the handle ftStatus FT Close ftHandle else FT_CyclePort FAILED 3 36 FT_Rescan Supported Operating Systems Windows 2000 and later Summary This function can be of use when trying to recover devices programatically Definition FT_STATUS FT_Rescan Parameters None Return Value Copyright 2011 Future Technology Devices International Limited 43 a7 FTDI Document Reference No FT_000071 D2XX Programmer s
6. Definition BOOL FT_W32_ClearCommError FT_HANDLE ftHandle LPDWORD IpdwErrors LPFTCOMSTAT pftComstat Parameters ftHandle Handle of the device IpdwErrors Variable that contains the error mask IpftComstat Pointer to FTCOMSTAT structure Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Example static COMSTAT oldCS 0 static DWORD dwOldErrors 0 FT HANDLE ftHandle setup by FT _W32 CreateFile COMSTAT newCS DWORD dwErrors BOOL bChanged FALSE if FT _W32 ClearCommError ftHandle amp dwErrors FTCOMSTAT amp newCS FT_W32 ClearCommError failed if dwErrors dwOldErrors bChanged TRUE dwErrorsOld dwErrors if memcmp amp 0ldCS amp newCS sizeof FTCOMSTAT bChanged TRUE oldCS newCS if bChanged if dwErrors amp CE BREAK BREAK condition detected if dwErrors amp CE FRAME Framing error detected if dwErrors amp CE _RXOVER Receive buffer has overflowed if dwErrors amp CE_TXFULL Transmit buffer full if dwErrors amp CE OVERRUN Character buffer overrun if dwErrors amp CE _RXPARITY Parity error detected if newCS fCtsHold Transmitter waiting for CTS if newCS fDsrHold Transmitter is waiting for DSR if newCS fR1sdHold Transmitter is waiting for RLSD if newCS fXoffHold T
7. FTDI Chip Future Technology Devices International Ltd Software Application Development D2XX Programmer s Guide Document Reference No FT_000071 Version 1 3 Issue Date 2012 02 23 FTDI provides DLL and virtual COM port VCP application interfaces to its drivers This document provides the application programming interface API for the FTD2XX DLL function library Future Technology Devices International Ltd FTDI Unit 1 2 Seaward Place Centurion Business Park Glasgow G41 1HH United Kingdom Tel 44 0 141 429 2777 Fax 44 0 141 429 2758 E Mail Support supporti ftdichip com Web www ftdichip com Use of FTDI devices in life support and or safety applications is entirely at the user s risk and the user agrees to defend indemnify and hold harmless FTDI from any and all damages claims suits or expense resulting from such use v pow FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Chip Clearance No FTDI 170 Table of Contents MPR TAG sass ececvesse anes cececatarrieecscccebes eset asegeacecebaseeeecsecseeeteenceeasecuesecanenteeect 4 1 1 Acronyms and Abbreviations siscisiciiccesssessdsccsasanecanancsccsssscsnanasasaadacnnscasnenaaanannanns 4 2 introduction s ssssssssssnnnnnunnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn mnnn 5 3 D2XX Classic PUNGUONS cssccetsncenssscaescteteceseacecdencehsncendsscsaescosbacersadectenee 6 lt Pe gt D 0 Pe
8. Set 8 data bits 1 stop bit and no parity ftStatus FT SetDataCharacteristics ftHandle FT BITS 8 FT STOP BITS 1 FT PARITY NONE if ftStatus FT OK FT_SetDataCharacteristics OK else FT SetDataCharacteristics Failed FT Close ftHandle 3 15 FT_SetTimeouts Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the read and write timeouts for the device Definition FT_STATUS FT_SetTimeouts FT_HANDLE ftHandle DWORD dwReadTimeout Copyright 2011 Future Technology Devices International Limited DWORD dwwWriteTimeout 22 MET 4 7 FTDI SS Chip Ld Parameters ftHandle Handle of the device dwReadTimeout Read timeout in milliseconds dwWriteTimeout Write timeout in milliseconds Return Value FT_OK if successful otherwise the return value is an FT error code Example FT HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return Set read timeout of 5sec write timeout of lsec ftStatus FT SetTimeouts ftHandle 5000 1000 if ftStatus FT OK FT SetTimeouts OK else FT SetTimeouts failed FT Close ftHandle 3 16 FT_SetFlowControl Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and la
9. printf ftHandle 0x x n ftHandleTemp 3 6 FT_ListDevices Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Gets information concerning the devices currently connected This function can return information such as the number of devices connected the device serial number and device description strings and the location IDs of connected devices Definition FT_STATUS FT_ListDevices PVOID pvArg1 PVOID pvArg2 DWORD dwFlags Parameters pvArg1 Meaning depends on dwFlags pvArg2 Meaning depends on dwFlags dwFlags Determines format of returned information Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function can be used in a number of ways to return different types of information A more powerful way to get device information is to use the FT_CreateDevicelInfoList FT GetDeviceInfoList and FT GetDeviceInfoDetail functions as they return all the available information on devices In its simplest form it can be used to return the number of devices currently connected If FT_LIST NUMBER ONLY bit is set in dwFlags the parameter pvArg1 is interpreted as a pointer to a DWORD location to store the number of devices currently connected It can be used to return device information if FT OPEN BY SERIAL NUMBER bit is set in dwFlags the serial number string will be returned if FT OPEN BY DESCRIPTION
10. 0x23 ftStatus FT OpenEx dwLoc FT OPEN BY LOCATION amp ftHandlel dwLoc 0x31 ftStatus2 FT OpenEx dwLoc FT OPEN BY LOCATION amp ftHandle2 if ftStatus FT OK amp amp ftStatus2 FT OK success both devices are open else failure one or both of the devices has not been opened 3 9 FT_Close Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Close an open device Definition FT_STATUS FT_Close FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Example FT HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT _OK FT Open OK use ftHandle to access device Copyright 2011 Future Technology Devices International Limited 16 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 when finished call FT Close FT Close ftHandle else FT Open failed 3 10 FT_Read Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Read data from the device Definition FT_STATUS FT_Read FT_HANDLE ftHand e LPVOID pBuffer DWORD dwBytesToRead LPDWORD IpdwBytesReturned Parameters ftHand
11. 170 CloseHandl osRead hEvent 6 4 FT_W32_WriteFile Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Write data to the device Definition BOOL FT_W32_WriteFile FT_HANDLE ftHand e LPVOID pBuffer DWORD dwBytesToWrite LPDWORD IpdwBytesWritten LPOVERLAPPED IpOverlapped Parameters ftHandle Handle of the device lpBuffer Pointer to the buffer that contains the data to write to the device dwBytesToWrite Number of bytes to be written to the device IpdwBytesWritten Pointer to a variable that receives the number of bytes written to the device IpOverlapped Pointer to an overlapped structure Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Remarks This function supports both non overlapped and overlapped I O except under Linux Mac OS X and Windows CE where only non overlapped IO is supported Non overlapped I O The parameter pOverlapped must be NULL for non overlapped I O This function always returns the number of bytes written in pdwBytesWritten This function does not return until dwBytesToWrite have been written to the device When a write timeout has been setup in a previous call to FT_W32 SetCommTimeouts this function returns when the timer expires or dwBytesToWrite have been written whichever occurs first If a timeout occurred pdwB
12. 4 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Chip Clearance No FTDI 170 i FT_EEPROM_HEADER common common elements for all device EEPROMs Drive options UCHAR ACSlowSlew non zero if AC bus pins have slow slew UCHAR ACSchmittInput non zero if AC bus pins are Schmitt input UCHAR ACDriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR ADSlowSlew non zero if AD bus pins have slow slew UCHAR ADSchmittInput non zero if AD bus pins are Schmitt input UCHAR ADDriveCurrent valid values are 4mA 8mA 12mA 16mA CBUS options UCHAR Cbus0 Cbus Mux control UCHAR Cbus1 Cbus Mux control UCHAR Cbus2 Cbus Mux control UCHAR Cbus3 Cbus Mux control UCHAR Cbus4 Cbus Mux control UCHAR Cbus5 Cbus Mux control UCHAR Cbus6 Cbus Mux control UCHAR Cbus7 Cbus Mux control UCHAR Cbus8 Cbus Mux control UCHAR Cbus9 Cbus Mux control FT1248 options UCHAR FT1248Cpol FT1248 clock polarity clock idle high 1 or clock idle low 0 UCHAR FT1248Lsb FT1248 data is LSB 1 or MSB 0 UCHAR FT1248FlowControl FT1248 flow control enable Hardware options UCHAR IsFifo non zero if interface is 245 FIFO UCHAR IsFifoTar non zero if interface is 245 FIFO CPU target UCHAR IsFastSer non zero if interface is Fast serial UCHAR IsFT1248 non zero if interface is FT1248 UCHAR PowerSaveEnable Driver option
13. FT Close ftHandle 3 27 FT_GetStatus Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Gets the device status including number of characters in the receive queue number of characters in the transmit queue and the current event status Definition FT_STATUS FT_GetStatus FT_HANDLE ftHand le LPDWORD pdwAmountInRxQueue LPDWORD IpdwAmountInTxQueue LPDWORD IpdwEventStatus Parameters ftHandle Handle of the device IpdwAmountInRxQueue Pointer to a variable of type DWORD which receives the number of characters in the receive queue IpdwAmountInTxQueue Pointer to a variable of type DWORD which receives the number of characters in the transmit queue IpdwEventStatus Pointer to a variable of type DWORD which receives the current state of the event status Return Value FT_OK if successful otherwise the return value is an FT error code Remarks For an example of how to use this function see the sample code in FT SetEventNotification 3 28 FT_SetEventNotification Copyright 2011 Future Technology Devices International Limited 34 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Chip Clearance No FTDI 170 Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Sets conditions for event notification Definition FT_STATUS
14. ftHandle Copyright 2011 Future Technology Devices International Limited 41 T FTDI a Chip pe P 3 34 FT_ResetPort Supported Operating Systems Windows 2000 and later Summary Send a reset command to the port Definition FT_STATUS FT_ResetPort FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 This function is used to attempt to recover the port after a failure Itis not equivalent to an unplug replug event For the equivalent of an unplug replug event use FT CyclePort Example FT STATUS ftStatus ftStatus FT ResetPort ftHandle if ftStatus FT _OK Port has been reset else FT _ResetPort FAILED 3 35 FT_CyclePort Supported Operating Systems Windows 2000 and later Summary Send a cycle command to the USB port Definition FT_STATUS FT_CyclePort FT_HANDLE ftHandle FT HANDLE ftHandle valid handle returned from FT _OpenEx Copyright 2011 Future Technology Devices International Limited 42 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SS Chip Clearance No FTDI 170 Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code
15. 0 non zero if serial number to be used 0 non zero if chip uses USBVersion 0x0 BCD 0x0200 gt USB2 Oy non zero if interface is high current 0 non zero if interface is high current 0 non zero if interface is 245 FIFO 0 non zero if interface is 245 FIFO CPU target 0 non zero if interface is Fast serial 0 non zero if interface is to use VCP drivers 0 non zero if interface is 245 FIFO 0 non zero if interface is 245 FIFO CPU target 0 non zero if interface is Fast serial 0 non zero if interface is to use VCP drivers FT232R extensions Enabled if Version 2 or greater Ld 0 Use External Oscillator QO High Drive I Os 0 Endpoint size 0 non zero if pull down enabled 0 non zero if serial number to be used Os non zero if invert TXD 0 non zero if invert RXD 0 non zero if invert RTS Oe non zero if invert CTS 0 non zero if invert DTR 0y non zero if invert DSR Copyright 2011 Future Technology Devices International Limited 55 yp z FTDI Document Reference No FT_000071 z D2XX Programmer s Guide Version 1 3 ANS Chip Clearance No FTDI 170 0 non zero if invert DCD 0 non zero if invert RI 0 Cbus Mux control 0 Cbus Mux control 0 Cbus Mux control 0 Cbus Mux control 0 Cbus Mux control
16. 0x6001 Copyright 2011 Future Technology Devices International Limited 44 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 ftStatus FT Reload wVID wPID if ftStatus FT OK FT Reload failed return 2 This example shows how to call FT_Reload to reload the drivers for all USB devices FT STATUS ftstatus WORD wVID 0x0000 WORD wPID 0x0000 ftStatus FT Reload wVID wPID if ftStatus FT OK FT Reload failed return 3 38 FT_SetResetPipeRetryCount Supported Operating Systems Windows 2000 and later Windows CE 4 2 and later Summary Set the ResetPipeRetryCount value Definition FT_STATUS FT_SetResetPipeRetryCount FT_HANDLE ftHandle DWORD dwCount Parameters ftHandle Handle of the device dwCount Unsigned long containing required ResetPipeRetryCount Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function is used to set the ResetPipeRetryCount ResetPipeRetryCount controls the maximum number of times that the driver tries to reset a pipe on which an error has occurred ResetPipeRequestRetryCount defaults to 50 It may be necessary to increase this value in noisy environments where a lot of USB errors occur Example FT HANDLE ftHandle valid handle returned from FT _OpenEx FT STATUS ftStatus Copyright 2011 Future Technology Devices Internati
17. DWORD dwCreate DWORD dwaAttrsAndFlags HANDLE hTemplate Parameters pvArg1 Meaning depends on the value of dwAttrsAndFlags Can be a pointer to a null terminated string that contains the description or serial number of the device or can be the location of the device These values can be obtained from the FT_CreateDeviceInfoList FT GetDeviceInfoDetail or FT ListDevices functions dwAccess Type of access to the device Access can be GENERIC_READ GENERIC_WRITE or both Ignored in Linux dwShareMode How the device is shared This value must be set to 0 IpSecurityAttributes This parameter has no effect and should be set to NULL dwCreate This parameter must be set to OPEN_EXISTING Ignored in Linux dwAttrsAndFlags File attributes and flags This parameter is a combination of FILE_ATTRIBUTE_NORMAL FILE_FLAG_OVERLAPPED if overlapped I O is used FT OPEN BY SERIAL NUMBER if pszName is the device s serial number and FT OPEN BY DESCRIPTION if pszName is the device s description hTemplate This parameter must be NULL Return Value If the function is successful the return value is a handle If the function is unsuccessful the return value is the Win32 error code INVALID_HANDLE_VALUE Copyright 2011 Future Technology Devices International Limited 73 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAN Chip Clearance No FTDI 170 Remarks The meaning of pvArg1 depends on dwAttrsAndFlags
18. Guide Version 1 3 A SAS Chip Clearance No FTDI 170 ftStatus FT_Open 0 amp ftHandle if ftStatus FT_OK FT Open failed return ftStatus FT ClrDtr ftHandle if ftStatus FT OK FT_ClrDtr OK else FT _ClrDtr failed FT Close ftHandle 3 19 FT_SetRts Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the Request To Send RTS control signal Definition FT_STATUS FT_SetRts FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function asserts the Request To Send RTS line of the device Example FT HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return Copyright 2011 Future Technology Devices International Limited 26 a7 FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A AS Chip Clearance No FTDI 170 ftStatus FT SetRts ftHandle if ftStatus FT OK FT SetRts OK else FT SetRts failed FT Close ftHandle 3 20 FT_ClirRts Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function clears the Request To Send RTS contro
19. Guide Version 1 3 SAS Chip Clearance No FTDI 170 FT_OK if successful otherwise the return value is an FT error code Remarks Calling FT_Rescan is equivalent to clicking the Scan for hardware changes button in the Device Manager Only USB hardware is checked for new devices All USB devices are scanned not just FTDI devices Example FT_STATUS ftstatus ftStatus FT Rescan if ftStatus FT OK FT _Rescan failed return 3 37 FT_Reload Supported Operating Systems Windows 2000 and later Summary This function forces a reload of the driver for devices with a specific VID and PID combination Definition FT_STATUS FT_Reload WORD wVID WORD wPID Parameters wVID Vendor ID of the devices to reload the driver for wPID Product ID of the devices to reload the driver for Return Value FT_OK if successful otherwise the return value is an FT error code Remarks Calling FT_Reload forces the operating system to unload and reload the driver for the specified device IDs Ifthe VID and PID parameters are null the drivers for USB root hubs will be reloaded causing all USB devices connected to reload their drivers Please note that this function will not work correctly on 64 bit Windows when called from a 32 bit application Examples 1 This example shows how to call FT_Reload to reload the driver for a standard FT232R device VID 0x0403 PID 0x6001 FT_STATUS ftstatus WORD wVID 0x0403 WORD wPID
20. STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return ftStatus FT GetBitMode ftHandle amp BitMode if ftStatus FT OK BitMode contains current value else FT _GetBitMode FAILED FT Close ftHandle 5 5 FT_SetUSBParameters Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Copyright 2011 Future Technology Devices International Limited 71 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 I JA Chip Clearance No FTDI 170 Summary Set the USB request transfer size Definition FT_STATUS FT_SetUSBParameters FT_HANDLE ftHandle DWORD dwInTransferSize DWORD dwOutTransferSize Parameters ftHandle Handle of the device dwInTransferSize Transfer size for USB IN request dwOutTransferSize Transfer size for USB OUT request Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function can be used to change the transfer sizes from the default transfer size of 4096 bytes to better suit the application requirements Transfer sizes must be set to a multiple of 64 bytes between 64 bytes and 64k bytes When FT_SetUSBParameters is called the change comes into effect immediately and any data that was held in the driver at the time of the change is lost Note that at present only dwIn
21. The location ID of a device is returned if FT LIST BY INDEX and FT_ OPEN BY LOCATION bits are set in dwFlags In this case the parameter pvArg1 is interpreted as the index of the device and the parameter pvArgZ2 is interpreted as a pointer to a variable of type long to contain the location ID Indexes are zero based and the error code FT_ DEVICE NOT FOUND is returned for an invalid index Please note that Windows CE and Linux do not support location IDs The location IDs of all connected devices are returned if FT LIST ALL and FT OPEN BY LOCATION bits are set in dwFlags In this case the parameter pvArg1 is interpreted as a pointer to an array of variables of type long to contain the location IDs and the parameter pvArg2 is interpreted as a pointer to a DWORD location to store the number of devices currently connected Examples The examples that follow use these variables FT STATUS ftStatus DWORD numDevs 1 Get the number of devices currently connected ftStatus FT ListDevices amp numDevs NULL FT LIST NUMBER ONLY if ftStatus FT _OK FT _ListDevices OK number of devices connected is in numDevs else FT ListDevices failed 2 Get serial number of first device DWORD deviIndex 0 first device char Buffer 64 more than enough room ftStatus FT ListDevices PVOID devIndex Buffer FT LIST BY INDEX FT OPEN BY SERIAL NUMBER if ftStatus FT OK FT _ListDe
22. allows the maximum time in milliseconds that a USB request can remain outstanding to be set Definition FT_STATUS FT_SetDeadmanTimeout FT_HANDLE ftHandle DWORD dwDeadmanTimeout Parameters ftHandle Handle of the device dwDeadmanTimeout Deadman timeout value in milliseconds Default value is 5000 Return Value FT_OK if successful otherwise the return value is an FT error code Remarks The deadman timeout is referred to in application note AN232B 10 Advanced Driver Options from the FTDI web site as the USB timeout It is unlikely that this function will be required by most users Example FT HANDLE ftHandle FT STATUS ftStatus DWORD dwDeadmanTimeout 6000 ftStatus FT Open 0 amp ftHandle if ftStatus FT_OK FT Open failed return ftStatus FT SetDeadmanTimeout ftHandle dwDeadmanTimeout if ftStatus FT OK Copyright 2011 Future Technology Devices International Limited 48 FFA FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A EA Chip Clearance No FTDI 170 Set Deadman Timer to 6 seconds else FT_SetDeadmanTimeout FAILED FT Close ftHandle 3 42 FT_IoCtl Undocumented function 3 43 FT_SetWaitMask Undocumented function 3 44 FT_WaitOnMask Undocumented function Copyright 2011 Future Technology Devices International Limited 49 FFA FTDI Document Reference No FT_000071 D2XX Programmer s Guide Versio
23. application The size of the user area depends on the length of the Manufacturer ManufacturerId Description and SerialNumber strings programmed into the EEPROM Example FT HANDLE ftHandle FT STATUS ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open FAILED DWORD EEUA Size ftStatus FT EE UASize ftHandle amp EEUA Size if ftStatus FT OK FT_EE UASize OK EEUA Size contains the size in bytes of the E else FT_EE UASize FAILED FT Close ftHandle 4 9 FT_EE_UARead Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Read the contents of the EEPROM user area Definition EUA FT_STATUS FT_EE_UARead FT_HANDLE ftHandle PUCHAR pucData DWORD dwDataLen LPDWORD IpdwBytesRead Copyright 2011 Future Technology Devices International Limited 59 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SS Chip Clearance No FTDI 170 Parameters ftHandle Handle of the device pucData Pointer to a buffer that contains storage for data to be read dwDataLen Size in bytes of buffer that contains storage for the data to be read IpdwBytesRead Pointer to a DWORD that receives the number of bytes read Return Value FT_OK if successful otherwise the return value is an FT e
24. char 4 bytes DWORD Unsigned long 4 bytes LPDWORD Pointer to unsigned long 4 bytes FT_HANDLE DWORD FT_STATUS DWORD FT_OK 0 FT_INVALID_HANDLE 1 FT_DEVICE_NOT_FOUND 2 FT_DEVICE_NOT_OPENED 3 FT_IO_ERROR 4 FT_INSUFFICIENT_RESOURCES 5 FT_INVALID_PARAMETER 6 FT_INVALID_BAUD_RATE 7 FT_DEVICE_NOT_OPENED_FOR_ERASE FT_DEVICE_NOT_OPENED_FOR_WRITE FT_FAILED_TO_WRITE_DEVICE 10 FT_EEPROM_READ_FAILED 11 FT_EEPROM_WRITE_FAILED 12 FT_EEPROM_ERASE_FAILED 13 FT_EEPROM_NOT_PRESENT 14 FT_EEPROM_NOT_PROGRAMMED 15 FT_INVALID_ARGS 16 FT_NOT_SUPPORTED 17 FT_OTHER_ERROR 18 8 9 Flags see FT_ListDevices FT_LIST_NUMBER_ONLY 0x80000000 FT_LIST_BY_INDEX 0x40000000 FT_LIST_ALL 0x20000000 Flags see FT_OpenEx FT_OPEN_BY_SERIAL_NUMBER 1 FT_OPEN_BY_DESCRIPTION 2 FT_OPEN_BY_LOCATION 4 FT_DEVICE DWORD FT_DEVICE_232BM 0 FT_DEVICE_232AM 1 FT_DEVICE_100AX 2 FT_DEVICE_UNKNOWN 3 FT_DEVICE_2232C 4 FT_DEVICE_232R 5 FT_DEVICE_2232H FT_DEVICE_4232H FT_DEVICE_232H 8 FT_DEVICE_X_SERIES 9 6 7 Driver types FT_DRIVER_TYPE_D2XX 0 FT_DRIVER_TYPE_VCP 1 Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 Copyright 2011 Future Technology Devices International Limited 98 awh FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SS Chip Clearance No FTDI 170 Word Length see FT_SetDataChar
25. code Remarks EEPROMs for FTDI devices are organised by WORD so each value written to the EEPROM is 16 bits wide 4 3 FT_EraseEE Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Erases the device EEPROM Definition FT_STATUS FT_EraseEE FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function will erase the entire contents of an EEPROM including the user area Note that the FT232R and FT245R devices have an internal EEPROM that cannot be erased 4 4 FT_EE_Read Supported Operating Systems Copyright 2011 Future Technology Devices International Limited 51 77 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 As Chip Clearance No FTDI 170 Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Read the contents of the EEPROM Definition FT_STATUS FT_EE_Read FT_HANDLE ftHandle PFT_PROGRAM_DATA pData Parameters ftHandle Handle of the device pData Pointer to structure of type FT_PROGRAM_DATA Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function interprets the parameter pData as a pointer to a structure of type FT_PROGRAM_DATA that contains storage for the data to be read from the EEPROM The fu
26. for all existing FTDI chipset and must be used for the FT X series Definition FT_STATUS FT_EEPROM_Read FT_HANDLE ftHandle void eepromData DWORD eepromDataSize char Manufacturer char ManufacturerId char Description char SerialNumber Parameters ftHandle Handle of the device eepromData Pointer to a buffer that contains the data to be read Note This structure is different for each device type epromDataSize Size of the eepromData buffer that contains storage for the data to be read Manufacturer Pointer to a null terminated string containing the manufacturer name ManufacturerId Pointer to a null terminated string containing the manufacturer ID Description Pointer to a null terminated string containing the device description Copyright 2011 Future Technology Devices International Limited 62 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SS Chip Clearance No FTDI 170 SerialNumber Pointer to a null terminated string containing the device serial number Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function interprets the parameter eepromDATA as a pointer to a structure matching the device type being accessed e g PFT_EEPROM_232B is the structure for FT2xxB devices PFT_EEPROM_2232 is the structure for FT2232D devices PFT_EEPROM_232R is the structure for FT232R devices PFT_EEPROM_2232H is the structure for FT223
27. if FT OPEN BY SERIAL NUMBER or FT OPEN BY DESCRIPTION is set in dwAttrsAndFlags pvArg1 contains a pointer to a null terminated string that contains the device s serial number or description if FT OPEN BY LOCATION is set in dwAttrsAndFlags pvArg1 is interpreted as a value of type long that contains the location ID of the device dwAccess can be GENERIC_READ GENERIC_WRITE or both dwShareMode must be set to 0 IpSecurityAttributes must be set to NULL dwCreate must be set to OPEN_EXISTING dwAttrsAndFlags is a combination of FILE_ATTRIBUTE_NORMAL FILE_FLAG_OVERLAPPED if overlapped I O is used FT OPEN BY SERIAL NUMBER or FT_OPEN BY DESCRIPTION or FT_OPEN BY LOCATION hTemplate must be NULL Note that Linux Mac OS X and Windows CE do not support overlapped IO or location IDs Examples The examples that follow use these variables FT STATUS ftStatus FT HANDLE ftHandle char Buf 64 1 Open a device for overlapped I O using its serial number ftStatus FT ListDevices 0 Buf FT LIST BY INDEX FT OPEN BY SERIAL NUMBER ftHandle FT W32_CreateFile Buf GENERIC_READ GENERIC_WRITE 0 0 OPEN EXISTING FILE ATTRIBUTE NORMAL FILE FLAG OVERLAPPED FT OPEN BY SERIAL NUMBER 0 if ftHandle INVALID HANDLE VALUE FT_W32_CreateDevice failed 2 Open a device for non overlapped I O using its
28. is 245 FIFO CPU target UCHAR IFBIsFastSer non zero if interface is Fast serial UCHAR BIsVCP non zero if interface is to use VCP drivers Rev 6 FT232R extensions UCHAR UseExtOsc Use External Oscillator UCHAR HighDrivelOs High Drive I Os UCHAR EndpointSize Endpoint size UCHAR PullDownEnableR non zero if pull down enabled UCHAR SerNumEnableR non zero if serial number to be used UCHAR InvertTXD non zero if invert TXD UCHAR InvertRXD non zero if invert RXD UCHAR InvertRTS non zero if invert RTS UCHAR InvertCTS non zero if invert CTS UCHAR InvertDTR non zero if invert DTR UCHAR InvertDSR non zero if invert DSR UCHAR InvertDCD non zero if invert DCD UCHAR InvertRI non zero if invert RI UCHAR Cbus0 Cbus Mux control UCHAR Cbus1 Cbus Mux control UCHAR Cbus2 Cbus Mux control UCHAR Cbus3 Cbus Mux control UCHAR Cbus4 Cbus Mux control UCHAR RIsD2XX non zero if using D2XX driver Rev 7 FT2232H Extensions UCHAR PullDownEnable7 non zero if pull down enabled UCHAR SerNumEnable7 non zero if serial number to be used UCHAR ALSlowSlew non zero if AL pins have slow slew UCHAR ALSchmittInput non zero if AL pins are Schmitt input UCHAR ALDriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR AHSlowSlew non zero if AH pins have slow slew UCHAR AHSchmittInput non zero if AH pins are Schmitt input UCHAR AHDriveCurrent valid values a
29. structure This function does not return until an event that has been specified in a call to FT_ W32 SetCommMask has occurred If an event has already occurred the request completes immediately and the return code is non zero The events that occurred are stored in pdwEvent If an event has not yet occurred the request completes immediately and the return code is zero signifying an error An application should call FT W32 GetLastError to get the cause of the error If the error code is ERROR_IO_PENDING the overlapped operation is still in progress and the application can perform other processing Eventually the application checks the result of the overlapped request by calling FT W32 GetOverlappedResult The events that occurred and resulted in this function returning are stored in pdwEvent Examples 1 This example shows how to write 128 bytes to the device using non overlapped I O FT HANDLE ftHandle setup by FT _W32 CreateFile for non overlapped i o DWORD dwEvents if FT W32 WaitCommEvent ftHandle amp dwEvents NULL FT_W32 WaitCommEvents OK else FT_W32 WaitCommEvents failed 2 This example shows how to write 128 bytes to the device using overlapped I O FT HANDLE ftHandle setup by FT _W32 CreateFile for overlapped i o DWORD dwEvents DWORD dwRes OVERLAPPED osWait 0 if FT_W32 WaitCommEvent ftHandle amp dwEvents amp o0sWait if FT _W32 G
30. to a null terminated string containing the manufacturer ID Description Pointer to a null terminated string containing the device description SerialNumber Pointer to a null terminated string containing the device serial number Copyright 2011 Future Technology Devices International Limited 64 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SS Chip Clearance No FTDI 170 Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function interprets the parameter eepromDATA as a pointer to a structure matching the device type being accessed e g PFT_EEPROM_232B is the structure for FT2xxB devices PFT_EEPROM_2232 is the structure for FT2232D devices PFT_EEPROM_232R is the structure for FT232R devices PFT_EEPROM_2232H is the structure for FT2232H devices PFT_EEPROM_4232H is the structure for FT4232H devices PFT_EEPROM_232H is the structure for FT232H devices PFT_EEPROM_X_SERIES is the structure for FT2xxX devices The function does not perform any checks on buffer sizes so the buffers passed in the eepromDATA structure must be big enough to accommodate their respective strings including null terminators The sizes shown in the following example are more than adequate and can be rounded down if necessary The restriction is that the Manufacturer string length plus the Description string length is less than or equal to 40 characters Note that the D
31. www ftdichip com Branch Office Hillsboro Oregon USA Future Technology Devices International Limited USA 7235 NW Evergreen Parkway Suite 600 Hillsboro OR 97123 5803 USA Tel 1 503 547 0988 Fax 1 503 547 0987 E Mail Sales us sales ftdichip com E Mail Support us support ftdichip com E Mail General Enquiries us admin ftdichip com Web Site URL http www ftdichip com Branch Office Shanghai China Future Technology Devices International Limited China Room 408 317 Xianxia Road ChangNing District ShangHai China Tel 86 21 62351596 Fax 86 21 62351595 E Mail Sales E Mail Support E Mail General Enquiries Web Site URL cn sales ftdichip com cn support ftdichip com cn admin1 ftdichip com http www ftdichip com Distributor and Sales Representatives Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 Please visit the Sales Network page of the FTDI Web site for the contact details of our distributor s and sales representative s in your country Copyright 2011 Future Technology Devices International Limited 96 a7 FTDI Document Reference No FT_000071 u D2XX Programmer s Guide Version 1 3 A A Chip Clearance No FTDI 170 System and equipment manufacturers and designers are responsible to ensure that their systems and any Future Technology Devices International Ltd FTDI devices incorporated in their systems mee
32. zero Remarks This function has no effect It is the responsibility of the driver to allocate sufficient storage for I O requests 6 9 FT_W32_SetCommState Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the state of the device according to the contents of a device control block DCB Definition BOOL FT_W32_SetCommState FT_HANDLE ftHandle LPFTDCB pftDcb Parameters ftHandle Handle of the device IpftDcb Pointer to an FTDCB structure Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Example FT HANDLE ftHandle setup by FT_W32_CreateFile FTDCB tDCB if FT _W32 GetCommState ftHandle amp ftDCB FT _W32 GetCommState ok device state is in ftDCB ftDCB BaudRate 921600 Change the baud rate Copyright 2011 Future Technology Devices International Limited 83 zS FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A SN Chip Clearance No FTDI 170 if FT W32 SetCommState ftHandle amp tDCB FT_W32 SetCommState ok else FT_W32 SetCommState failed else FT_W32 GetCommState failed 6 10 FT_W32_GetCommsState Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function gets the cu
33. 0 non zero if using D2XX drivers Rev 7 FT2232H Extensions Enabled if Version 3 or greater 0 non zero if pull down enabled 0 non zero if serial number to be used 0 non zero if AL pins have slow slew 0 non zero if AL pins are Schmitt input 0 valid values are 4mA 8mA 12mA 16mA Oy non zero if AH pins have slow slew 0 non zero if AH pins are Schmitt input 0 valid values are 4mA 8mA 12mA 16mA 0 non zero if BL pins have slow slew 0 non zero if BL pins are Schmitt input 0 valid values are 4mA 8mA 12mA 16mA Oy non zero if BH pins have slow slew 0 non zero if BH pins are Schmitt input 0 valid values are 4mA 8mA 12mA 16mA 0 non zero if interface is 245 FIFO 0 non zero if interface is 245 FIFO CPU target 0 non zero if interface is Fast serial 0 non zero if interface is to use VCP drivers 0 non zero if interface is 245 FIFO 0 non zero if interface is 245 FIFO CPU target 0 non zero if interface is Fast serial 0 non zero if interface is to use VCP drivers 0 non zero if using BCBUS7 to save power for self powered designs Rev 8 FT4232H Extensions Enabled if Version 4 Oe non zero if pull down enabled 0 non zero if serial number to be used 0 non zero if AL pins have slow slew 0 non zero if AL pins are Schmitt input 0 valid values are 4mA 8mA 12mA 16mA 0 non zero if AH pins have slow slew 0 no
34. 1 DWORD fXoffSent 1 DWORD fEof 1 DWORD fTxim 1 DWORD fReserved 25 DWORD cbInQue DWORD cbOutQue y FTCOMSTAT LPFTCOMSTAT Copyright 2011 Future Technology Devices International Limited 110 a7 FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 a SAS Chip Clearance No FTDI 170 9 Appendix B Revision History Document Title Software Application Development D2XX Programmer s Guide Document Reference No FT_000071 Clearance No FTDI 170 Drivers Page http www ftdichip com Drivers D2XX htm Document Feedback Send Feedback Revision History Revision History Version 1 00 Initial release in new format Includes all functions in CDM driver 2 04 06 August 2008 Version 1 01 Includes FT4232H and FT2232H Updated addresses January 2009 Version 1 02 Page 65 removed FT232R and FT245R reference from MCU host emulation and Fast Opto modes January 2010 Version 1 03 Corrected section 3 32 FT_Purge 8th September 2010 Updated Contact details Version 1 04 Added 245 Synchronous FIFO mode code in section 5 3 28th October 2010 Version 1 1 Corrected previous editing errors to the document by re adding FT4232H and FT2232H extensions 4th November 2010 Version 1 2 Added references to FT232H including EEPROM format Numerous formatting fixes Expanded definitions in appendix to reflect updates in CDM 2 08 14 header file 25 April 2011 Version 1 3 Added sections 4 11 and 4 12
35. 10 ftStatus FT_Open 0 amp ftHandle if ftStatus FT OK FT Open failed return Copyright 2011 Future Technology Devices International Limited 67 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 ftStatus FT SetLatencyTimer ftHandle LatencyTimer if ftStatus FT OK LatencyTimer set to 10 milliseconds else FT SetLatencyTimer FAILED FT Close ftHandle 5 2 FT_GetLatencyTimer Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Get the current value of the latency timer Definition FT_STATUS FT_GetLatencyTimer FT_HANDLE ftHandle PUCHAR pucTimer Parameters ftHandle Handle of the device pucTimer Pointer to unsigned char to store latency timer value Return Value FT_OK if successful otherwise the return value is an FT error code Remarks In the FT8U232AM and FT8U245AM devices the receive buffer timeout that is used to flush remaining data from the receive buffer was fixed at 16 ms In all other FTDI devices this timeout is programmable and can be set at 1 ms intervals between 2ms and 255 ms This allows the device to be better optimized for protocols requiring faster response times from short data packets Example FT HANDLE ftHandle FT STATUS ftStatus UCHAR LatencyTimer ftStatus FT Ope
36. 2 PurgeComm OK else FT _W32 PurgeComm failed Copyright 2011 Future Technology Devices International Limited 92 zS FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SSN Chip Clearance No FTDI 170 6 19 FT_W32_GetLastError Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Gets the last error that occurred on the device Definition DWORD FT_W32_GetLastError FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Remarks This function is normally used with overlapped I O and so is not supported in Windows CE Fora description of its use see FT_W32 ReadFile and FT _W32 WriteFile In Linux and Mac OS X this function returns a DWORD that directly maps to the FT Errors for example the FT_INVALID_HANDLE error number 6 20 FT_W32_ClearCommeError Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Gets information about a communications error and get current status of the device Copyright 2011 Future Technology Devices International Limited 93 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A A Chip Clearance No FTDI 170
37. 232 FT2232H FT4232H and FT232H devices only 0x10 Fast Opto Isolated Serial Mode FT2232 FT2232H FT4232H and FT232H devices only 0x20 CBUS Bit Bang Mode FT232R and FT232H devices only 0x40 Single Channel Synchronous 245 FIFO Mode FT2232H and FT232H devices only Return Value Copyright 2011 Future Technology Devices International Limited 69 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A SS Chip Clearance No FTDI 170 FT_OK if successful otherwise the return value is an FT error code Remarks For a description of available bit modes for the FT232R see the application note Bit Bang Modes for the FT232R and FT245R For a description of available bit modes for the FT2232 see the application note Bit Mode Functions for the FT2232 For a description of Bit Bang Mode for the FT232B and FT245B see the application note FT232B FT245B Bit Bang Mode Application notes are available for download from the FTDI website Note that to use CBUS Bit Bang for the FT232R the CBUS must be configured for CBUS Bit Bang in the EEPROM Note that to use Single Channel Synchronous 245 FIFO mode for the FT2232H channel A must be configured for FT245 FIFO mode in the EEPROM Example FT HANDLE ftHandle FT STATUS ftStatus UCHAR Mask Oxff UCHAR Mode 1 Set asynchronous bit bang mode ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed r
38. 2H devices PFT_EEPROM_4232H is the structure for FT4232H devices PFT_EEPROM_232H is the structure for FT232H devices PFT_EEPROM_X_SERIES is the structure for FT2xxX devices The function does not perform any checks on buffer sizes so the buffers passed in the eepromDATA structure must be big enough to accommodate their respective strings including null terminators The sizes shown in the following example are more than adequate and can be rounded down if necessary The restriction is that the Manufacturer string length plus the Description string length is less than or equal to 40 characters Note that the DLL must be informed which version of the eepromDATA structure is being used This is done through the PFT_EEPROM_HEADER structure The first element of this structure is deviceType and may be FT_DEVICE_BM FT_DEVICE_AM FT_DEVICE_2232C FT_DEVICE_232R FT_DEVICE_2232H FT_DEVICE_4232H FT_DEVICE_232H or FT_DEVICE_X_SERIES as defined in FTD2XxX h Example FT HANDLE fthandle FT STATUS status char Manufacturer 64 char ManufacturerId 64 char Description 64 char SerialNumber 64 FT EEPROM HEADER ft eeprom header ft_eeprom_header deviceType FT DEVICE 2232H FTxxxx device type to b accessed FT EEPROM 2232H ft_eeprom_2232h ft_eeprom 2232h common ft_eeprom header ft_eeprom_2232h common deviceType FT DEVICE 2232H status FT O
39. 54 FA FTDI Document Reference No FT_000071 A D2XX Programmer s Guide Version 1 3 3 Chi EA lp Clearance No FTDI 170 Example This example shows how to program the EEPROM of an FT232B device Other parameters would need to be set up for other device types Version 4 structure for programming a BM device Other elements would need non zero values for FT2232 FT232R FT245R FT2232H or FT4232H devices FT PROGRAM DATA ftData 0x00000000 Header must be 0x00000000 OxFFFFFFFF Header must be Oxffffffff 0x00000004 Header FT PROGRAM DATA version 0x0403 VID 0x6001 PID ERDE Manufacturer ETH Manufacturer ID USB HS Serial Converter Description FT000001 Serial Number 44 MaxPower 1 PnP 0 SelfPowered Ly RemoteWakeup Ly non zero if Rev4 chip zero otherwise 0 non zero if in endpoint is isochronous 0 non zero if out endpoint is isochronous Os non zero if pull down enabled Ty non zero if serial number to be used 0 non zero if chip uses USBVersion 0x0110 BCD 0x0200 gt USB2 FT2232C extensions Enabled if Version 1 or greater 0 non zero if Rev5 chip zero otherwise 0 non zero if in endpoint is isochronous 0 non zero if in endpoint is isochronous 0 non zero if out endpoint is isochronous 0 non zero if out endpoint is isochronous 0 non zero if pull down enabled
40. 6 12 FT_W32_GetCommTimeouts Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function gets the current read and write request timeout parameters for the specified device Definition BOOL FT_W32_GetCommTimeouts FT_HANDLE ftHandle LPFTTIMEOUTS pftTimeouts Parameters ftHandle Handle of the device IpftTimeouts Pointer to an FTTIMEOUTS structure to store timeout information Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Remarks For an explanation of how timeouts are used see FT_W32 SetCommTimeouts Example FT HANDLE ftHandle setup by FT_W32 CreateFile FTTIMEOUTS tTS if FT _W32 GetCommTimeouts ftHandle amp ftTS FT_W32 GetCommTimeouts OK else FT _W32 GetCommTimeouts failed 6 13 FT_W32_SetCommBreak Supported Operating Systems Linux Mac OS X 10 4 and later Copyright 2011 Future Technology Devices International Limited 86 e FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A As Chip Clearance No FTDI 170 Windows 2000 and later Windows CE 4 2 and later Summary Puts the communications line in the BREAK state Definition BOOL FT_W32_SetCommBreak FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value If the function is successf
41. A ce E E Pr en nee 6 3 2 FT_GetVIDPID sea cascenerstaiacs ste banlectedsdanuntatidinscstuscauuacladisusascseulnctstiGan usted sasesiuliccwuatwaddes 6 3 3 FT Creat DevicelnfoList simiman inanan aa a aaa 7 3 4 FT GetDevicelMfoliSt wiiscscisccscstinceisnccnctxsncincexvncenctxsnciectivncanctxsmerectxvncanctawmeractueueies 8 3 9 FI GetDeviceliMoDetall siscisscssscscscstncsexcstncsencstncsaxcsducsancstacsancsdecsanestacsencstncsenestnees 9 3 0 FT RISTO VIC OS sisina a R aa 11 37 ET Open eee aE a aE EE a EE AEE A EE A EEEE EEEE 13 BB FT OPO EX A A T 14 3 9 Fl COSO ccs 16 re A 0 FT CAG ncataauinscineaunsnunsnondntnasaniencnannulnaaanseinuasnsatnsaunanesdhantetnsausaainstsneatnsaunensuganealns 17 Sek WG E a E E 19 3 12 FT SQUB au Ra E aaee aaraa aaraa aaa Eana aain anakis a asasina ineei 20 3 13 FI SetDIVISON deic raci nananana aaea aaa an aaa a Aaa aAa AAAA AA Eaa E AAEN EEEa ERES 21 3 14 FT SetDataCharacteristics isivcesicccuiisccceeeeousnancbiicnsnceavecnseadunsnunidesubeadeatsubakoudewden 21 3 15 FT et EW UMN ONE Sa gcc ct ccc ccc cc cdc cs ccna cc Aa diadanan wats 22 3 10 eed Mele 6c c i annann naana aaan aaan na kananan eaaa aa kaana 23 Sed LET E E D E 24 3 18 Fr SCI DE eonenn eeiam an deen aaa aaa Aaa aeaa ESAs aaa aeaa aada 25 Bo Ml R117 en er Se eee aE a A t Mer 26 ECS E n E aie E E E E E 27 3 221 FI GOiMO de mS tatu S i siiscicscsicincnsstcexcvassccncsactcancsanecancsenstantsanecencsanntantveneeenecacesens 28 3 22 FT CGIQuevie Stats isni a ei
42. ADriverType UCHAR BDriverType FT_EEPROM_2232 PFT_EEPROM_2232 FT232R EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program typedef struct ft_eeprom_232r Common header FT_EEPROM_HEADER common common elements for all device EEPROMs Drive options UCHAR IsHighCurrent non zero if interface is high current Hardware options UCHAR UseExtOsc Use External Oscillator UCHAR Typ F TXE Copyright 2011 Future Technology Devices International Limited 104 MET 4 E FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Chip Clearance No FTDI 170 UCHAR InvertRXD non zero if invert RXD UCHAR InvertRTS non zero if invert RTS UCHAR InvertCTS non zero if invert CTS UCHAR InvertDTR non zero if invert DTR UCHAR InvertDSR non zero if invert DSR UCHAR InvertDCD non zero if invert DCD UCHAR InvertRI non zero if invert RI UCHAR Cbus0 Cbus Mux control UCHAR Cbus1 Cbus Mux control UCHAR Cbus2 Cbus Mux control UCHAR Cbus3 Cbus Mux control UCHAR Cbus4 Cbus Mux control Driver option UCHAR DriverType FT_EEPROM_232R PFT_EEPROM_232R FT2232H EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program typedef struct ft_eeprom_2232h Common header FT_EEPROM_HEADER common common elements for all device EEPROMs Drive options UCHAR ALSlowSlew non zero if AL pins have slow slew UCHAR ALSchmittInput
43. ANDLE ftHandle handle of an open device FT STATUS ftStatus HANDLE hEvent DWORD EventMask hEvent CreateEvent NULL false auto reset event false non signalled state Copyright 2011 Future Technology Devices International Limited 35 FA FTDI Document Reference No FT_000071 z D2XX Programmer s Guide Version 1 3 iA EN Chip Clearance No FTDI 170 wee EventMask FT_EVENT_RXCHAR FT_EVENT_MODEM_STATUS ftStatus FT SetEventNotification ftHandle EventMask hEvent Sometime later block the application thread by waiting on th vent then when th event has occurred determine the condition that caused the event and process it accordingly WaitForSingleObject hEvent INFINITE DWORD EventDWord DWORD RxBytes DWORD TxBytes FT GetStatus ftHandle amp RxBytes amp TxBytes amp EventDWord if EventDWord amp FT EVENT MODEM STATUS modem status event detected so get current modem status FT GetModemStatus ftHandle amp Status if Status amp 0x00000010 CTS is high else CTS is low if Status amp 0x00000020 DSR is high else DSR is low if RxBytes gt 0 call FT _Read to get received data from device 2 This example is valid for Linux and shows how to wait for a character to be received or a change in modem status
44. BYTE StopBits 0 2 1 2 char XonChar Tx and Rx X ON character char XoffChar Tx and Rx X OFF character char ErrorChar Error replacement char char EofChar End of Input character char EvtChar Received Event character WORD wReserved1 Fill FTDCB LPFTDCB FTTIMEOUTS structure typedef struct _FTTIMEOUTS DWORD ReadiIntervalTimeout Maximum time between read chars DWORD ReadTotalTimeoutMultiplier Multiplier of characters DWORD ReadTotalTimeoutConstant Constant in milliseconds DWORD WriteTotalTimeoutMultiplier Multiplier of characters DWORD WriteTotalTimeoutConstant Constant in milliseconds y FTTIMEOUTS LPFTTIMEOUTS EV_BREAK 0x0040 BREAK condition detected EV_CTS 0x0008 Change in Clear To Send CTS EV_DSR 0x0010 Change in Data Set Ready DSR EV_ERR 0x0080 Error in line status EV_RING 0x0100 Change in Ring Indicator RI EV_RLSD 0x0020 Change in Receive Line Signal Detect RLSD EV_RXCHAR 0x0001 Character received EV_RXFLAG 0x0002 Event character received EV_TXEMPTY 0x0004 Transmitter empty PURGE_TXABORT 0x0001 Terminate outstanding overlapped writes PURGE_RXABORT 0x0002 Terminate outstanding overlapped reads PURGE_TXCLEAR 0x0004 Clear the transmit buffer PURGE_RXCLEAR 0x0008 Clear the receive buffer FTCOMSTAT structure typedef struct _FTCOMSTAT DWORD fCtsHold 1 DWORD fDsrHold 1 DWORD fRisdHold 1 DWORD fXoffHold
45. CBUS_SLEEP 0x05 FT_232R_CBUS_CLK48 0x06 FT_232R_CBUS_CLK24 0x07 FT_232R_CBUS_CLKi2 0x08 FT_232R_CBUS_CLK6 0x09 FT_232R_CBUS_IOMODE Ox0A FT_232R_CBUS_BITBANG_WR 0x0B FT_232R_CBUS_BITBANG_RD 0x0C FT232H CBUS EEPROM OPTIONS see FT_EE_Program and FT_EE_Read FT_232H_CBUS_TRISTATE 0x00 FT_232H_CBUS_RXLED 0x01 FT_232H_CBUS_TXLED 0x02 FT_232H_CBUS_TXRXLED 0x03 FT_232H_CBUS_PWREN 0x04 FT_232H_CBUS_SLEEP 0x05 FT_232H_CBUS_DRIVE_0 0x06 FT_232H_CBUS_DRIVE_1i 0x07 FT_232H_CBUS_IOMODE 0x08 FT_232H_CBUS_TXDEN 0x09 FT_232H_CBUS_CLK30 Ox0A FT_232H_CBUS_CLK15 0x0B FT_232H_CBUS_CLK7_5 0x0C FT X Series CBUS Options EEPROM values see FT_EEPROM_Read and FT_EEPROM_Program FT_X_SERIES_CBUS_TRISTATE 0x00 FT_X_SERIES_CBUS_RXLED 0x01 FT_X_SERIES_CBUS_TXLED 0x02 _X_SERIES_CBUS_TXRXLED 0x03 _SERIES_CBUS_PWREN 0x04 SERIES_CBUS_SLEEP 0x05 SERIES_CBUS_DRIVE_0O 0x06 SERIES_CBUS_DRIVE_1 0x07 SERIES_CBUS_IOMODE 0x08 7 _X_SERIES_CBUS_TXDEN 0x09 SERIES _CBUS_CLK24 Ox0A SERIES _CBUS_CLK12 0x0B X X X X X _X _X _X _X_SERIES_CBUS_CLK6 0x0C _X_SERIES_CBUS_BCD_CHARGER 0x0D _X_SERIES_CBUS_ BCD _CHARGER_N 0x0E _X_SERIES_CBUS_I2C_TXE 0x0F _X_SERIES_CBUS_I2C_RXF 0x10 _X_SERIES_CBUS_VBUS_SENSE 0x11 _X_SERIES_CBUS_ BITBANG_WR 0x12 _X_SERIES_CBUS_BITBANG_RD 0x13 _X_SERIES_CBUS_ TIMESTAMP 0x14 _X_SERIES_CBUS_KEEP_AWAKE 0x15 FT_DEVICE_LIST_INFO_NODE see FT_GetDeviceInfoLis
46. Device FT DEVICE 2232C device is FT2232C L D else if ftDevice FT DEVICE BM device is FTU232BM else if ftDevice FT DEVICE AM device is FT8U232AM else unknown device this should not happen deviceID contains encoded device ID SerialNumber Description contain O terminated strings else FT GetDeviceType FAIL FT Close ftHandle 3 24 FT_GetDriverVersion Supported Operating Systems Windows 2000 and later Windows CE 4 2 and later Summary ED LD This function returns the D2XX driver version number Definition FT_STATUS FT_GetDriverVersion FT_HANDLE ftHandle LPDWORD pdwDriverVersion Copyright 2011 Future Technology Devices International Limited 31 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SS Chip Clearance No FTDI 170 Parameters ftHandle Handle of the device IpdwDriverVersion Pointer to the driver version number Return Value FT_OK if successful otherwise the return value is an FT error code Remarks A version number consists of major minor and build version numbers contained in a 4 byte field unsigned long ByteO least significant holds the build version Byte1 holds the minor version and Byte2 holds the major version Byte3 is currently set to zero For example driver version 2 04 06 is represented as 0x00020406 Note that a device has to be opened before this function can be called Examp
47. FT OK success device with device description USB Serial Converter is open else failure 3 Open 2 devices with serial numbers FT000001 and FT999999 ftStatus FT OpenEx FT000001 FT OPEN BY SERIAL NUMBER amp ftHandlel ftStatus2 FT OpenEx FT999999 FT OPEN BY SERIAL NUMBER amp ftHandle2 if ftStatus FT OK amp amp ftStatus2 FT OK success both devices are open else failure one or both of the devices has not been opened 4 Open 2 devices with descriptions USB Serial Converter and USB Pump Controller ftStatus FT OpenEx USB Serial Converter FT OPEN BY DESCRIPTION amp ftHandlel ftStatus2 FT OpenEx USB Pump Controller FT OPEN BY DESCRIPTION amp ftHandle2 if ftStatus FT OK amp amp ftStatus2 FT _OK success both devices are open else failure one or both of the devices has not been opened Copyright 2011 Future Technology Devices International Limited 15 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A SS Chip Clearance No FTDI 170 5 Open a device at location 23 dwLoc 0x23 ftStatus FT OpenEx dwLoc FT OPEN BY LOCATION amp ftHandlel if ftStatus FT OK success device at location 23 is open else failure 6 Open 2 devices at locations 23 and 31 dwLoc
48. FTDI 170 Parameters ftHandle Handle of the device pData Pointer to structure of type FT_PROGRAM_DATA Manufacturer Pointer to a null terminated string containing the manufacturer name ManufacturerId Pointer to a null terminated string containing the manufacturer ID Description Pointer to a null terminated string containing the device description SerialNumber Pointer to a null terminated string containing the device serial number Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This variation of the FT EE Program function was included to provide support for languages such as LabVIEW where problems can occur when string pointers are contained in a structure This function interprets the parameter pData as a pointer to a structure of type FT_PROGRAM_DATA that contains the data to write to the EEPROM The data is written to EEPROM then read back and verified The string pointer parameters in the FT_PROGRAM_DATA structure should be allocated as DWORDs to avoid overlapping of parameters The string parameters are then passed in separately If the Seria Number field is NULL or Seria Number points to a NULL string a serial number based on the Manufacturerld and the current date and time will be generated The Manufacturer string length plus the Description string length must be less than or equal to 40 characters Note that the DLL must be informed which version of the FT_PROGRAM_DATA stru
49. FT_SetEventNotification FT_HANDLE ftHandle DWORD dwEventMask PVOID pvArg Parameters ftHandle Handle of the device dwEventMask Conditions that cause the event to be set pvArg Interpreted as the handle of an event Return Value FT_OK if successful otherwise the return value is an FT error code Remarks An application can use this function to setup conditions which allow a thread to block until one of the conditions is met Typically an application will create an event call this function then block on the event When the conditions are met the event is set and the application thread unblocked dwEventMask is a bit map that describes the events the application is interested in pvArg is interpreted as the handle of an event which has been created by the application If one of the event conditions is met the event is set If FT EVENT RXCHAR is set in dwEventMask the event will be set when a character has been received by the device If FT EVENT MODEM_STATUS is set in dwEventMask the event will be set when a change in the modem signals has been detected by the device If FT EVENT LINE STATUS is set in dwEventMask the event will be set when a change in the line status has been detected by the device Examples 1 This example is valid for Windows and Windows CE and shows how to wait for a character to be received or a change in modem status First create the event and call FT SetEventNotification FT H
50. I Battery Charge Detect options UCHAR BCDEnable UCHAR BCDForceCbusPWREN UCHAR BCDDisableSleep 12C options WORD I2CSlaveAddress DWORD 12CDeviceld UCHAR I2CDisableSchmitt FT1248 options UCHAR FT1248Cpol UCHAR FT1248Lsb Enable Battery Charger Detection asserts the power enable signal on CBUS when charging port detected forces the device never to go into sleep mode 12C slave device address 12C device ID Disable 12C Schmitt trigger FT1248 clock polarity clock idle high 1 or clock idle low 0 FT1248 data is LSB 1 or MSB 0 UCHAR FT1248FlowControl FT1248 flow control enable Hardware options UCHAR RS485EchoSuppress UCHAR PowerSaveEnable Driver option R aaa Copyright 2011 Future Technology Devices International Limited 108 awh FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 AS Chip Clearance No FTDI 170 DN FT_EEPROM_X_SERIES PFT_EEPROM_X_SERIES Win32 OPEN_EXISTING 3 FILE_ATTRIBUTE_NORMAL 0x00000080 FILE_FLAG_OVERLAPPED 0x40000000 GENERIC_READ 0x80000000 GENERIC_WRITE 0x40000000 OVERLAPPED structure typedef struct _OVERLAPPED ULONG_PTR Internal ULONG_PTR InternalHigh union struct DWORD Offset DWORD OffsetHigh y PVOID Pointer HANDLE hEvent OVERLAPPED LPOVERLAPPED CLRDTR 6 Clear the DTR signal CLRRTS 4 Clear the RTS signal SETDTR 5 Set th
51. I Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SSN Chip Clearance No FTDI 170 else FT_W32 WriteFIle OK 6 5 FT_W32_GetOverlappedResult Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Gets the result of an overlapped operation Definition BOOL FT_W32_GetOverlappedResult FT_HANDLE ftHandle LPOVERLAPPED pOverlapped LPDWORD IpdwBytesTransferred BOOL bWait Parameters ftHandle Handle of the device IpOverlapped Pointer to an overlapped structure IpdwBytesTransferred Pointer to a variable that receives the number of bytes transferred during the overlapped operation bWait Set to TRUE if the function does not return until the operation has been completed Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Remarks This function is used with overlapped I O and so is not supported in Linux Mac OS X or Windows CE For a description of its use see FT_ W32 ReadFile and FT _W32 WriteFile 6 6 FT_W32_EscapeComm Function Supported Operating Systems Linux Mac OS X 10 4 and later Copyright 2011 Future Technology Devices International Limited 80 zS FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A A Chip Clearance No FTDI 170 Windows CE 4 2 and later Summary Perf
52. L FT OPEN BY LOCATION if ftStatus FT OK FT _ListDevices OK location IDs are in locIdBuf and numDevs contains the number of devices connected else FT ListDevices failed Note that this example assumes that no more than 16 devices are connected If more devices are connected then the size of the array of pointers must be increased 3 7 FT_Open Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Open the device and return a handle which will be used for subsequent accesses Definition FT_STATUS FT_Open int iDevice FT_HANDLE ftHandle Parameters iDevice Index of the device to open Indices are 0 based ftHandle Pointer to a variable of type FT_HANDLE where the handle will be stored This handle must be used to access the device Return Value FT_OK if successful otherwise the return value is an FT error code Copyright 2011 Future Technology Devices International Limited 13 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 AS Chip Clearance No FTDI 170 Remarks Although this function can be used to open multiple devices by setting iDevice to 0 1 2 etc there is no ability to open a specific device To open named devices use the function FT OpenEx Example FT HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK
53. LL must be informed which version of the eepromDATA structure is being used This is done through the PFT_EEPROM_HEADER structure The first element of this structure is deviceType and may be FT_DEVICE_BM FT_DEVICE_AM FT_DEVICE_2232C FT_DEVICE_232R FT_DEVICE_2232H FT_DEVICE_4232H FT_DEVICE_232H or FT_DEVICE_X_SERIES as defined in FTD2XxX h Example FT HANDLE fthandle FT STATUS status char Manufacturer 64 char ManufacturerId 64 char Description 64 char SerialNumber 64 FT EEPROM HEADER ft eeprom header ft_eeprom_header deviceType FT DEVICE 2232H FTxxxx device type to b accessed FT EEPROM 2232H ft eeprom 2232h ft_eeprom 2232h common ft_eeprom header ft_eeprom 2232h common deviceType FT DEVICE 2232H status FT_Open 0 amp fthandle if status FT_OK printf open status not ok d n status status FT EEPROM Read fthandle amp ft_ eeprom 2232h sizeof ft_ eeprom 2232h Manufacturer ManufacturerId Description SerialNumber Copyright 2011 Future Technology Devices International Limited 65 Document Reference No FT_000071 T FTDI D2XX Programmer s Guide Version 1 3 SSN Chip Clearance No FTDI 170 strcpy SerialNumber FT000001 status FT EEPROM Program fthandle amp ft_eeprom_2232h sizeof ft_eeprom_2232h Manufacturer ManufacturerlId Description SerialNum
54. R ROM OA so ionicscnsccsssasiscanbenwtidanasteisncastuiiconastwdnvsisicnnnatalasuctsidisinustuicdaucbaiiss 62 412 FT EEPROM Progreain sccssistctctaiciatcscistatstiniiatcsaitsaisiasasaeaae ein 64 5 Extended API Functions ccccccecessseeeeeeeeeeeeeeeeneeseeeesseeeeseeeseenenees 67 5 1 FT_SetLatencylimer sissidiscsscitscsserisnesuestdacesenniasnanidenssnnndannentdauasseiianenauiiauswouidania 67 5 2 FT_GetLatencyfimer aeeeenesnnnnnnnnnennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnn nn nnmnnn nnna 68 5 3 FT SetBitMode cites sewed cand nacecaus unanini ninaa amanina aaa anada niaaa naba anaana 69 5A FT EE oTo 1 E E E S 70 5 5 FT SetUSBParameters cccccccccssssssssssssseeeeeseeeeeessseeeeeeeeseaeeoesssesseeeeeseaaoes 71 Copyright 2011 Future Technology Devices International Limited 2 z7 FTDI Document Reference No FT_000071 z D2XX Programmer s Guide Version 1 3 AN Chip Clearance No FTDI 170 6 FT Win32 API Functions sssssssssssnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nenna 73 6 1 FT W32 CreateF ileana nanma aum anamanna namana aaa iaaa aaa aeaaea aaea aaa aaa aaaea aaa aS 73 6 2 FT W32 CloseHandlEe s ssisisccicstieeisicienstxnntinseivncanctxunciectivncanctxsucrectxvecunctxeninantaees 75 6 3 FT W32 Read File vc sisciscccssicscxcsticrancstncsaxcetucrancstncsancsducsanestacvanectecsanestacsenestuqsenteent 75 6 4 FT_W32 Wire Pe ecsiccsistiacticsicasanataastiasteestivetinbiwtiassintensindiasawetanteniaaa
55. RD pdwEvent LPOVERLAPPED pOverlapped Parameters ftHandle Handle of the device IpdwEvent Pointer to a location that receives a mask that contains the events that occurred IpOverlapped Pointer to an overlapped structure Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Remarks This function supports both non overlapped and overlapped I O except under Windows CE and Linux aiherscabrereouerap ped LOS 555 li aaaaaaaaaaaaaaaaaaaaaaaaaaaaalalauaussusussssssssi i iaiaiIaIaesssososo Copyright 2011 Future Technology Devices International Limited 90 sS FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SN Chip Clearance No FTDI 170 Non overlapped I O The parameter pOverlapped must be NULL for non overlapped I O This function does not return until an event that has been specified in a call to FT_ W32 SetCommMask has occurred The events that occurred and resulted in this function returning are stored in pdwEvent Overlapped I O When the device has been opened for overlapped I O an application can issue a request and perform some additional work while the request is pending This contrasts with the case of non overlapped I O in which the application issues a request and receives control again only after the request has been completed The parameter pOverlapped must point to an initialized OVERLAPPED
56. SS Chip Clearance No FTDI 170 Do something for example purge devic ff do ftStatus FT RestartInTask ftHandle while ftStatus FT OK FT Close ftHandle 3 40 FT_RestartInTask Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Restart the driver s IN task Definition FT_STATUS FT_RestartInTask FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function is used to restart the driver s IN task read after it has been stopped by a call to FT_StopInTask Example FT HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return do ftStatus FT StopInTask ftHandle while ftStatus FT OK Seen A ee ee een ee ee eee ee Copyright 2011 Future Technology Devices International Limited 47 a7 FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A A A Chip Clearance No FTDI 170 Do something for example purge devic do ftStatus FT RestartInTask ftHandle while ftStatus FT OK FT Close ftHandle 3 41 FT_SetDeadmanTimeout Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function
57. Status FT GetLibraryVersion amp dwLibraryVer if ftStatus FT OK printf Library version 0x x n dwLibraryVer else printf error reading library version n 3 26 FT_GetComPortNumber Supported Operating Systems Windows 2000 and later Summary Retrieves the COM port associated with a device Definition FT_STATUS FT_GetComPortNumber FT_HANDLE ftHandle LPLONG p ComPortNumber Parameters ftHandle Handle of the device Ipl ComPortNumber Pointer to a variable of type LONG which receives the COM port number associated with the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function is only available when using the Windows CDM driver as both the D2XX and VCP drivers can be installed at the same time If no COM port is associated with the device p ComPortNumber will have a value of 1 Example FT HANDLE ftHandle valid handle returned from FT_OpenEx FT STATUS ftStatus LONG 1ComPortNumber Copyright 2011 Future Technology Devices International Limited 33 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 ftStatus FT GetComPortNumber ftHandle amp 1ComPortNumber if status FT OK if 1ComPortNumber 1 No COM port assigned else COM port assigned with number held in 1ComPortNumber else FT _GetComPortNumber FAILED
58. TS is on MS_DSR_ON Data Set Ready DSR is on MS_RING_ON Ring Indicator RI is on MS_RLSD_ON Receive Line Signal Detect RLSD is on Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Example FT HANDLE ftHandle setup by FT _W32 CreateFile DWORD dwStatus if FT _W32 GetCommModemStatus ftHandle amp dwStatus FT _W32 GetCommModemStatus ok if dwStatus amp MS CTS ON CTS is on if dwStatus amp MS DSR_ON DSR is on if dwStatus amp MS RI ON RI is on if dwStatus amp MS RLSD ON RLSD is on else FT_W32 GetCommModemStatus failed 6 8 FT_W32_SetupComm Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the read and write buffers Definition BOOL FT_W32_SetupComm FT_HANDLE ftHand le DWORD dwReadBufferSize DWORD dwwWriteBufferSize Copyright 2011 Future Technology Devices International Limited 82 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SS Chip Clearance No FTDI 170 Parameters ftHandle Handle of the device dwReadBufferSize Length in bytes of the read buffer dwWriteBufferSize Length in bytes of the write buffer Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is
59. TransferSize is supported Example FT HANDLE ftHandle FT STATUS ftStatus DWORD InTransferSize 16384 ftStatus FT Open 0 amp ftHandle if ftStatus FT_OK FT Open failed return ftStatus FT SetUSBParameters ftHandle InTransferSize 0 if ftStatus FT OK In transfer size set to 16 Kbytes else FT _SetUSBParameters FAILED FT Close ftHandle Copyright 2011 Future Technology Devices International Limited 72 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 6 FT Win32 API Functions The functions in this section are supplied to ease porting from a Win32 serial port application These functions are supported under non Windows platforms to assist with porting existing applications from Windows Note that classic D2XX functions and the Win32 D2XX functions should not be mixed unless stated 6 1 FT_W32_CreateFile Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Opens the specified device and return a handle which will be used for subsequent accesses The device can be specified by its serial number device description or location This function must be used if overlapped I O is required Definition FT_HANDLE FT_W32_CreateFile PVOID pvArgi1 DWORD dwAccess DWORD dwShareMode LPSECURITY_ATTRIBUTES pSecurityAttributes
60. UCHAR DriverType FT_EEPROM_232H PFT_EEPROM_232H FT X Series EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program typedef struct ft_eeprom_x_series Common header FT_EEPROM_HEADER common common elements for all device EEPROMs Drive options UCHAPR ACSlowSlow EAG iac Copyright 2011 Future Technology Devices International Limited 107 Document Reference No FT_000071 MET 4 E FTDI D2XX Programmer s Guide Version 1 3 Chip Clearance No FTDI 170 i UCHAR ACSchmittInput UCHAR ACDriveCurrent UCHAR ADSlowSlew UCHAR ADSchmittInput UCHAR ADDriveCurrent CBUS options UCHAR Cbus0 UCHAR Cbusi1 UCHAR Cbus2 UCHAR Cbus3 UCHAR Cbus4 UCHAR Cbus5 UCHAR Cbus6 UART signal options non zero if AC bus pins are Schmitt input valid values are 4mA 8mA 12mA 16mA non zero if AD bus pins have slow slew non zero if AD bus pins are Schmitt input valid values are 4mA 8mA 12mA 16mA Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control UCHAR InvertTXD non zero if invert TXD UCHAR InvertRXD non zero if invert RXD UCHAR InvertRTS non zero if invert RTS UCHAR InvertCTS non zero if invert CTS UCHAR InvertDTR non zero if invert DTR UCHAR InvertDSR non zero if invert DSR UCHAR InvertDCD non zero if invert DCD UCHAR InvertRI non zero if invert R
61. a 29 3 23 FT_GetDevicelnfo ccsiisisensndscectsntntnenselnanctentadnunvabnaneiaelndastentaaacnenbodnonsmintaenantndnuniabus 30 zar E a E EAA eisscsticssccstscittncesccsancstvcsinceancrancstncsaacsancsancsducsaiesancvescstucsenezens 31 3 25 FT_GetLibraryVersion scccviseisiessicseeccssinsetesaeeeeesicnnevesstnseenvenesevnnevaranndannwewsdennnauan 32 3 26 FT_GetComPortNumberf ccccccceessssssesssssseeeeeeseeeeesssseeeeeesseseneeeseseeeeeessaoaes 33 3 27 FT GetStat a rer ge re re ere Rr re Te Roe 34 3 28 FT_SetEventNotification nsssnennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnmnnn nnna 34 3 29 FT SUC ANS areas ae ca ctnith cnantnnecnenbpoauna naemen a aaaea ai aaaea a a aai daadaa 37 Copyright 2011 Future Technology Devices International Limited 1 z7 FTDI Document Reference No FT_000071 z D2XX Programmer s Guide Version 1 3 AN Chip Clearance No FTDI 170 3 30 FT SElBre aK iisicseieaecsssinicinnwacasianssandeiwanacanawanindnunannccuanincccinanenta seocadiuaisananenneeeen 39 3 31 FT_SetBreakOff isieeciiscawesavccenennemsnncsancnsuouensnameuau cueusucususnsudveaausndususugudueuansudianonsuduan 39 Bede OPT PUNGC ivicestisettnnntcsannstsntienandinnannnentaenentsenansdastassataicianaduniasusiditientiaksacsucsiaansianade 40 3 33 FT ROSCiDGvViCe isvscisicesscsitiiesecsisiesnesntincnecinsesnceteiecseskscexeentheceaskakessastsiecseckvaersestnet 41 3 34 PET PROS OUP OE sai acicctcticinte cara can uatotaspsinntcaduaiecte
62. acteristics FT_BITS_8 8 FT_BITS_7 7 Stop Bits see FT_SetDataCharacteristics FT_STOP_BITS_1 0 FT_STOP_BITS_2 2 Parity see FT_SetDataCharacteristics FT_PARITY_NONE 0 FT_PARITY_ODD 1 FT_PARITY_EVEN 2 FT_PARITY_MARK 3 FT_PARITY_SPACE 4 Flow Control see FT_SetFlowControl FT_FLOW_NONE 0x0000 FT_FLOW_RTS_CTS 0x0100 FT_FLOW_DTR_DSR 0x0200 FT_FLOW_XON_XOFF 0x0400 Purge RX and TX Buffers see FT_Purge FT_PURGE_RX 1 FT_PURGE_TX 2 Notification Events see FT_SetEventNotification FT_EVENT_RXCHAR 1 FT_EVENT_MODEM_STATUS 2 FT_EVENT_LINE_STATUS 4 Modem Status see FT GetModemStatus CTS 0x10 DSR 0x20 RI 0x40 DCD 0x80 Line Status see FT GetModemStatus OE 0x02 PE 0x04 FE 0x08 BI 0x10 Bit Modes see FT_SetBitMode FT_BITMODE_RESET 0x00 FT_BITMODE_ASYNC_BITBANG 0x01 FT_BITMODE_MPSSE 0x02 FT_BITMODE_SYNC_BITBANG 0x04 FT_BITMODE_MCU_HOST 0x08 EL BRITMODE_ FAST SERITAL S OX10 eaan Copyright 2011 Future Technology Devices International Limited 99 Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 FTDI Chip FT_BITMODE_CBUS_BITBANG 0x20 FT232R CBUS EEPROM OPTIONS Ignored for FT245R see FT_EE_Program and FT_EE_Read EN j N FT_BITMODE_SYNC_FIFO 0x40 FT_232R_CBUS_TXDEN 0x00 FT_232R_CBUS_PWRON 0x01 FT_232R_CBUS_RXLED 0x02 FT_232R_CBUS_TXLED 0x03 FT_232R_CBUS_TXRXLED 0x04 FT_232R_
63. aes 78 6 5 FT_W32_GetOverlappedResult sissiisisinesiiciesccersinnintennseesucanieemanceenisnwepeninsauns 80 6 6 FT_W32_EscapeCommFunction sssssnsnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nannaa 80 6 7 FT_W32_GetCommModemStatus cccccceeeeeeeeeeeeeeeeeeeeeeeeeeeeseeeeeeeeeseeeseeeeeees 81 6 8 FI W32 0c Oe ee 82 6 9 FT W32 SetCGommState eacisssoieccearssius nananana arinen nananana aaa ainaani iaaa naaien A ia 83 6 10 FT_W32_GetCommState nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnmnnn nnana 84 6 11 FT_W32_SetCommTimeouts nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn annnm nnna 84 6 12 FT_W32_GetCommMTimeouts ccccccceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeseeeseesseseeeeeeeeeeees 86 6 13 FT_W32_SetCommBreak nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnmnnn nnna 86 6 14 FT W32 ClearCommBreak viscsiccsisciiccsducsissninanscandiniaaeienndniaeianndanaanaienls 87 6 15 FT_W32_SetCommMaSk nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnaman 88 6 16 FT W32 Ge etG mMmMaSkK sisisicsiscscscstsctiscstncssncstuctincstncsencstacsencetncsencstacsencetncsenestne 89 6 17 FT_W32 WattCommeEvent iatiniiatintictiniiatintiatintitintiatintiiintiatiniians 90 6 18 FT _ W32 _P rgeCoMM icasitieiseipen oie reinenncatansieesddnhtmaieusianetnabineinuaiienieneanineaua 92 6 19 FIT_W32 Getlasib rr OF sicisscstscceccsisscencedsecencstsacancedsncencstaacenc
64. ary Write data into the EEPROM user area Definition FT_STATUS FT_EE_UAWrite FT_HANDLE ftHandle PUCHAR pucData DWORD dwDataLen Parameters ftHandle Handle of the device pucData Pointer to a buffer that contains the data to be written dwDataLen Size in bytes of buffer that contains storage for the data to be read Return Value FT_OK if successful otherwise the return value is an FT error code Remarks Copyright 2011 Future Technology Devices International Limited 61 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A A Chip Clearance No FTDI 170 This function interprets the parameter pucData as a pointer to an array of bytes of size dwDataLen that contains the data to be written to the EEPROM user area Itis a programming error for dwDataLen to be greater than the size of the EEPROM user area The available user area size can be determined by calling FT EE UASize Example FT_HANDLE ftHandle FT STATUS ftStatus FT_Open 0 amp ftHandle if ftStatus FT_OK FT_Open FAILED char buffer Hello World ftStatus FT EE UAWrite ftHandle unsigned char buffer 12 if ftStatus FT OK FT_EE UAWRITE failed else FT_EE UAWRITE failed FT Close ftHandle 4 11 FT_EEPROM_Read Supported Operating Systems Windows XP and later Summary Read data from the EEPROM this command will work
65. ber FT Close fthandle Copyright 2011 Future Technology Devices International Limited 66 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 5 Extended API Functions The extended API functions do not apply to FT8U232AM or FT8U245AM devices FTDI s other USB UART and USB FIFO ICs the FT2232H FT4232H FT232R FT245R FT2232 FT232B and FT245B do support these functions Note that there is device dependence in some of these functions 5 1 FT_SetLatencyTimer Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Set the latency timer value Definition FT_STATUS FT_SetLatencyTimer FT_HANDLE ftHandle UCHAR ucTimer Parameters ftHandle Handle of the device ucTimer Required value in milliseconds of latency timer Valid range is 2 255 Return Value FT_OK if successful otherwise the return value is an FT error code Remarks In the FT8U232AM and FT8U245AM devices the receive buffer timeout that is used to flush remaining data from the receive buffer was fixed at 16 ms In all other FTDI devices this timeout is programmable and can be set at 1 ms intervals between 2ms and 255 ms This allows the device to be better optimized for protocols requiring faster response times from short data packets Example FT_HANDLE ftHandle FT_STATUS ftStatus UCHAR LatencyTimer
66. bit is set in dwFlags the product description string will be returned if FT OPEN BY LOCATION bit is set in dwFlags the Location ID will be returned if none of these bits is set the serial number string will be returned by default It can be used to return device string information for a single device If FT LIST BY INDEX and FT OPEN BY SERIAL NUMBER or FT OPEN BY DESCRIPTION bits are set in dwFlags the parameter pvArgi is interpreted as the index of the device and the parameter pvArg2 is interpreted as a pointer to Copyright 2011 Future Technology Devices International Limited 11 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 JA Chip Clearance No FTDI 170 a buffer to contain the appropriate string Indexes are zero based and the error code FT DEVICE NOT FOUND is returned for an invalid index It can be used to return device string information for all connected devices If FT LIST ALL and FT OPEN BY SERIAL NUMBER or FT_OPEN BY DESCRIPTION bits are set in dwFlags the parameter pvArg1 is interpreted as a pointer to an array of pointers to buffers to contain the appropriate strings and the parameter pvArg2 is interpreted as a pointer to a DWORD location to store the number of devices currently connected Note that for pvArgi the last entry in the array of pointers to buffers should be a NULL pointer so the array will contain one more location than the number of devices connected
67. cture is being used This is done through the Signature1 Signature2 and Version elements of the structure Signature1 should always be 0x00000000 Signature2 should always be OxFFFFFFFF and Version can be set to use whichever version is required For compatibility with all current devices Version should be set to the latest version of the FT__PROGRAM_DATA structure which is defined in FTD2XX h If pData is NULL the structure version will default to 0 original BM series and the device will be programmed with the default data 4 8 FT_EE_UASize Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Get the available size of the EEPROM user area Definition FT_STATUS FT_EE_UASizeWrite FT_HANDLE ftHand e LPDWORD pdwSize Copyright 2011 Future Technology Devices International Limited 58 MET 4 7 FTDI SS Chip P Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 Parameters ftHandle Handle of the device IpdwSize Pointer to a DWORD that receives the available size in bytes of the EEPROM user area Return Value FT_OK if successful otherwise the return value is an FT error code Remarks The user area of an FTDI device EEPROM is the total area of the EEPROM that is unused by device configuration information and descriptors This area is available to the user to store information specific to their
68. d least significant byte of the pdwModemStatus value The modem status is bit mapped as follows Clear To Send CTS 0x10 Data Set Ready DSR 0x20 Ring Indicator RI 0x40 Data Carrier Detect DCD 0x80 The line status is bit mapped as follows Overrun Error OE 0x02 Parity Error PE 0x04 Framing Error FE 0x08 Break Interrupt BI 0x10 Example FT HANDLE ftHandle FT STATUS ftStatus DWORD dwModemStatus 0 DWORD dwLineStatus 0 ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return Copyright 2011 Future Technology Devices International Limited 28 sF FTDI Document Reference No FT_000071 z D2XX Programmer s Guide Version 1 3 A SSN Chip Clearance No FTDI 170 ftStatus FT GetModemStatus ftHandle amp dwModemStatus if ftStatus FT OK FT _GetModemStatus OK Line status is the second byte of the dwModemStatus value dwLineStatus dwModemStatus gt gt 8 amp 0x000000FF Now mask off the modem status byte dwModemStatus dwModemStatus amp 0x000000FF else FT _GetModemStatus failed FT Close ftHandle 3 22 FT_GetQueueStatus Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Gets the number of bytes in the receive queue Definition FT_STATUS FT_GetQueueStatus FT_HANDLE ftHand e LPDWORD pdwAmountInRxQueue Param
69. description ftStatus FT ListDevices 0 Buf FT LIST BY _INDEX FT_OPEN_BY DESCRIPTION ftHandle FT W32 CreateFile Buf GENERIC READ GENERIC WRITE 0 0 OPEN EXISTING FILE ATTRIBUTE NORMAL FT OPEN BY DESCRIPTION 0 if ftHandle INVALID HANDLE VALUE FT_W32 CreateDevice failed 3 Open a device for non overlapped I O using its location long locID ftStatus FT ListDevices 0 amp locID FT LIST BY INDEX FT OPEN BY LOCATION ftHandle FT W32 CreateFile PVOID locID GENERIC READ GENERIC WRITE 0 0 OPEN EXISTING FILE ATTRIBUTE NORMAL FT OPEN BY LOCATION 0 if ftHandle INVALID HANDLE VALUE Copyright 2011 Future Technology Devices International Limited 74 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 FT_W32 CreateDevice failed 6 2 FT_W32_CloseHandle Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Close the specified device handle Definition BOOL FT_W32_CloseHandle FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Example This examp
70. e DTR signal SETRTS 3 Set the RTS signal SETBREAK 8 Set the BREAK condition CLRBREAK 9 Clear the BREAK condition MS_CTS_ON 0x0010 Clear To Send CTS is on MS_DSR_ON 0x0020 Data Set Ready DSR is on MS_RING_ON 0x0040 Ring Indicator RI is on MS_RLSD_ON 0x0080 Receive Line Signal Detect RLSD is on FTDCB structure typedef struct _FTDCB DWORD DCBlength sizeof FTDCB DWORD BaudRate Baud rate at which running DWORD fBinary 1 Binary Mode skip EOF check DWORD fParity 1 Enable parity checking DWORD fOutxCtsFlow 1 CTS handshaking on output DWORD fOutxDsrFlow 1 DSR handshaking on output DWORD fDtrControl 2 DTR Flow control DWORD fDsrSensitivity 1 DSR Sensitivity DWORD fTXContinueOnxXoff 1 Continue TX when Xoff sent DWORD fOutxX 1 Enable output X ON X OFF DWORD fInxX 1 Enable input X ON X OFF DWORD fErrorChar 1 Enable Err Replacement DWORD fNull 1 Enable Null stripping DWORD fRtsControl 2 Rts Flow control DWORD fAbortOnError 1 Abort all reads and writes on Error DWORD fDummy2 17 Reserved WORD wReserved Not currently used WORD XonLim Transmit X ON threshold Copyright 2011 Future Technology Devices International Limited 109 a7 FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A SAS Chip Clearance No FTDI 170 BYTE ByteSize Number of bits byte 7 8 BYTE Parity 0 4 None Odd Even Mark Space
71. e FTTIMEOUTS structure For read requests the number of bytes to be read is multiplied by the total timeout multiplier and added to the total timeout constant So if TS is an FTTIMEOUTS structure and the number of bytes to read is dwToRead the read timeout rdTO is calculated as follows rdTO dwToRead TS ReadTotalTimeoutMultiplier TS ReadTotalTimeoutConstant For write requests the number of bytes to be written is multiplied by the total timeout multiplier and added to the total timeout constant So if TS is an FTTIMEOUTS structure and the number of bytes to write is dwToWrite the write timeout wrTO is calculated as follows wrTO dwToWrite TS WriteTotalTimeoutMultiplier TS WriteTotalTimeoutConstant Linux and Mac OS X currently ignore the ReadIntervalTimeout ReadTotalTimeoutMultiplier and WriteTotalTimeoutMultiplier Example FT HANDLE ftHandle setup by FT _W32 CreateFile FTTIMEOUTS f tTS ftTS ReadIntervalTimeout 0 ftTS ReadTotalTimeoutMultiplier 0 ftTS ReadTotalTimeoutConstant 100 f tTS WriteTotalTimeoutMultiplier 0 ftTS WriteTotalTimeoutConstant 200 if FT_W32 SetCommTimeouts ftHandle amp ftTS FT_W32 SetCommTimeouts OK Copyright 2011 Future Technology Devices International Limited 85 zS FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A A Chip Clearance No FTDI 170 else FT_W32 SetCommTimeouts failed
72. echnology Devices International Limited 102 T FTDI UCHAR CSlowSlew UCHAR CSchmittInput UCHAR CDriveCurrent UCHAR DSlowSlew UCHAR DSchmittInput UCHAR DDriveCurrent UCHAR ARIIsTXDEN UCHAR BRIIsTXDEN UCHAR CRIISTXDEN UCHAR DRIIsTXDEN UCHAR AIsVCP8 UCHAR BIsVCP8 UCHAR CIsVCP8 UCHAR DIsVCP8 Rev 9 FT232H Extensions UCHAR PullDownEnableH UCHAR SerNumEnableH UCHAR ACSlowSlewH UCHAR ACSchmittInputH UCHAR ACDriveCurrentH UCHAR ADSlowSlewH UCHAR ADSchmittInputH UCHAR ADDriveCurrentH UCHAR Cbus0H UCHAR CbusiH UCHAR Cbus2H UCHAR Cbus3H UCHAR Cbus4H UCHAR Cbus5H UCHAR Cbus6H UCHAR Cbus7H UCHAR Cbus8H UCHAR Cbus9H UCHAR IsFifoH UCHAR IsFifoTarH UCHAR IsFastSerH UCHAR IsFT1248H UCHAR FT1248CpolH UCHAR FT1248LsbH UCHAR FT1248FlowControlH UCHAR IsVCPH UCHAR PowerSaveEnableH designs Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 non zero if BL pins have slow slew non zero if BL pins are Schmitt input valid values are 4mA 8mA 12mA 16mA non zero if BH pins have slow slew non zero if BH pins are Schmitt input valid values are 4mA 8mA 12mA 16mA non zero if port A uses RI as RS485 TXDEN non zero if port B uses RI as RS485 TXDEN non zero if port C uses RI as RS485 TXDEN non zero if port D uses RI as RS485 TXDEN non zero if interface is to use VCP dr
73. edsacencianncencedsecenenaanenne 93 6 20 FI _W32 Clear Comm rr wissicsssessiisesecssecssncscnnsienssecsnectsesstensseresentienstensierssectienss 93 7 Contact Information sssssssessnnnnsssnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnmnnn nnmnnn 96 8 Appendix A Type Definitions cc ccceeeeeeeeeeeeeeeeeeeeeeeeeeeneeeeeeeeeeeeeee 98 9 Appendix B Revision History ccccceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeneeeeeeeeee 111 Copyright 2011 Future Technology Devices International Limited 3 Document Reference No FT_000071 A FTDI D2XX Programmer s Guide Version 1 3 SN Chip Clearance No FTDI 170 1 Preface The D2XX interface is a proprietary interface specifically for FTDI devices This document provides an explanation of the functions available to application developers via the FTD2XX library Any software code examples given in this document are for information only The examples are not guaranteed and are not supported by FTDI 1 1 Acronyms and Abbreviations Combined Driver Model Windows driver package which incorporates both D2XX CDM and VCP drivers D2XX FTDI s proprietary direct driver interface via FTD2XX DLL VCP Virtual COM Port Table 1 1 Acronyms and Abbreviations Copyright 2011 Future Technology Devices International Limited 7A FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 am y Chip Clearance No FTDI 170 2 Introduction FTDI provides two a
74. er s Guide Version 1 3 TA Chip Clearance No FTDI 170 18 MET 4 7 FTDI SS Chip P 3 11 FT_Write Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Write data to the device Definition Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 FT_STATUS FT_Write FT_HANDLE ftHandle LPVOID lpBuffer DWORD dwBytesToWrite LPDWORD IpdwBytesWritten Parameters ftHandle Handle of the device lpBuffer Pointer to the buffer that contains the data to be written to the device dwBytesToWrite Number of bytes to write to the device IpdwBytesWritten Pointer to a variable of type DWORD which receives the number of bytes written to the device Return Value FT_OK if successful otherwise the return value is an FT error code Example FT HANDLE ftHandle FT STATUS ftStatus DWORD BytesWritten char TxBuffer 256 Contains data to write to device ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return ftStatus FT Write ftHandle TxBuffer sizeof TxBuffer if ftStatus FT OK FT Write OK else FT Write Failed FT Close ftHandle amp BytesWritten Copyright 2011 Future Technology Devices International Limited 19 MET Y 4 7 FTDI Ss Chip P 3 12 FT_SetBaudRate Supported Operating Systems Lin
75. erial available on the Internet regarding serial communication The D2XX interface is a proprietary interface specifically for FTDI devices This document provides an explanation of the functions available to application developers via the FTD2XxX library Copyright 2011 Future Technology Devices International Limited 5 zS FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A SN Chip Clearance No FTDI 170 3 D2XX Classic Functions The functions listed in this section are compatible with all FTDI devices 3 1 FT_SetVIDPID Supported Operating Systems Linux Mac OS X 10 4 and later Summary A command to include a custom VID and PID combination within the internal device list table This will allow the driver to load for the specified VID and PID combination Definition FT_STATUS FT_SetVIDPID DWORD dwVID DWORD dwPID Parameters dwVID Device Vendor ID VID dwPID Device Product ID PID Return Value FT_OK if successful otherwise the return value is an FT error code Remarks By default the driver will support a limited set of VID and PID matched devices VID 0x0403 with PIDs 0x6001 0x6010 0x6006 only In order to use the driver with other VID and PID combinations the FT_SetVIDPID function must be used prior to calling FT ListDevices FT Open FT OpenEx or FT CreateDevicelInfoList 3 2 FT_GetVIDPID Supported Operating Systems Linux Mac OS X 10 4 and later Summary A co
76. etLastError ftHandle ERROR_IO PENDING wait is delayed so do some other stuff until if FT W32 GetOverlappedResult ftHandle amp osWait amp dwRes FALSE error else FT _W32 WaitCommEvent OK Events that occurred are stored in dwEvents else FT _W32 WaitCommEvent OK Events that occurred are stored in dwEvents Copyright 2011 Future Technology Devices International Limited 91 zS FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A SSN Chip Clearance No FTDI 170 6 18 FT_W32_PurgeComm Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function purges the device Definition BOOL FT_W32_PurgeComm FT_HANDLE ftHandle DWORD dwFlags Parameters ftHandle Handle of the device dwFlags Specifies the action to take The action can be a combination of the following PURGE_TXABORT Terminate outstanding overlapped writes PURGE_RXABORT Terminate outstanding overlapped reads PURGE_TXCLEAR Clear the transmit buffer PURGE_RXCLEAR Clear the receive buffer Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Example FT HANDLE ftHandle setup by FT _W32 CreateFile if FT W32 PurgeComm ftHandle PURGE TXCLEAR PURGE RXCLEAR FT_W3
77. eters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Example FT HANDLE ftHandle valid handle returned from FT _OpenEx FT STATUS ftStatus ftStatus FT SetBreakOn ftHandle if ftStatus FT _OK FT SetBreakOn OK else FT _SetBreakOn failed FT Close ftHandle 3 31 FT_SetBreakOff Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Copyright 2011 Future Technology Devices International Limited TA Chip Clearance No FTDI 170 E FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 39 zS FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A JA Chip Clearance No FTDI 170 Summary Resets the BREAK condition for the device Definition FT_STATUS FT_SetBreakOff FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Example FT HANDLE ftHandle valid handle returned from FT_OpenEx FT STATUS ftStatus ftStatus FT SetBreakOff ftHandle if ftStatus FT_OK FT SetBreakOff OK else FT SetBreakOff failed FT Close ftHandle 3 32 FT_Purge Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later S
78. eters ftHandle Handle of the device IpdwAmountInRxQueue Pointer to a variable of type DWORD which receives the number of bytes in the receive queue Return Value FT_OK if successful otherwise the return value is an FT error code Example FT HANDLE ftHandle FT STATUS ftStatus DWORD RxBytes DWORD BytesReceived char RxBuffer 256 ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return FT GetQueueStatus ftHandle amp RxBytes if RxBytes gt 0 Copyright 2011 Future Technology Devices International Limited 29 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 if ftStatus FT_OK FT Read OK else FT Read Failed FT Close ftHandle 3 23 FT_GetDeviceInfo Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Get device information for an open device Definition FT_STATUS FT_GetDeviceInfo FT_HANDLE ftHandle FT_DEVICE pftType LPDWORD pdwID PCHAR pcSerialNumber PCHAR pcDescription PVOID pyDummy Parameters ftHandle Handle of the device pftType Pointer to unsigned long to store device type IpdwID Pointer to unsigned long to store device ID pcSerialNumber Pointer to buffer to store device serial number as a null terminated string pcDescription Pointer to buffer to store d
79. eturn ftStatus FT SetBitMode ftHandle Mask Mode if ftStatus FT OK Oxff written to device else FT _SetBitMode FAILED FT Close ftHandle 5 4 FT_GetBitMode Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Gets the instantaneous value of the data bus Copyright 2011 Future Technology Devices International Limited 70 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 JA Chip Clearance No FTDI 170 Definition FT_STATUS FT_GetBitmode FT_HANDLE ftHandle PUCHAR pucMode Parameters ftHandle Handle of the device pucMode Pointer to unsigned char to store the instantaneous data bus value Return Value FT_OK if successful otherwise the return value is an FT error code Remarks For a description of available bit modes for the FT232R see the application note Bit Bang Modes for the FT232R and FT245R For a description of available bit modes for the FT2232 see the application note Bit Mode Functions for the FT2232 For a description of bit bang modes for the FT232B and FT245B see the application note FT232B FT245B Bit Bang Mode For a description of bit modes supported by the FT4232H and FT2232H devices please see the IC data sheets These application notes are available for download from the FTDI website Example FT HANDLE ftHandle UCHAR BitMode FT
80. evice description as a null terminated string pvDummy Reserved for future use should be set to NULL Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function is used to return the device type device ID device description and serial number The device ID is encoded in a DWORD the most significant word contains the vendor ID and the least significant word contains the product ID So the returned ID 0x04036001 corresponds to the device ID VID_0403 amp PID_6001 Example Copyright 2011 Future Technology Devices International Limited 30 FT HANDLE MT y Y FT DEVICE DWORD deviceID char SerialNumber 16 char Description 64 ftStatus if ftStatus FT Open 0 FT OK FTDI Chip ftHandle S ftDevice FT STATUS ftStatus FT Open failed return ftStatus FT GetDevicelInfo amp ftHandle Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 ftHandle amp ftDevice amp devicelD SerialNumber Description NULL if ftStatus FT K if ftDevice FT_ DEVICE 232H device is FT232H else if ftDevice FT DEVICE 4232H device is FT4232H else if ftDevice FT DEVICE 2232H device is FT2232H else if ftDevice FT DEVICE 232R device is FT232R else if ft
81. for FT_EEPROM_Read 23 Feb 12 and FT_EEPROM_Program Updated ftd2xx h attachemnet at the end of the doc Copyright 2011 Future Technology Devices International Limited 111
82. ge the device info list will not be updated until FT_CreateDevicelInfoList is called again Example FT STATUS ftStatus DWORD numDevs create the device information list ftStatus FT CreateDevicelInfoList amp numDevs if ftStatus FT OK printf Number of devices is d n numDevs else FT CreateDeviceInfoList failed Copyright 2011 Future Technology Devices International Limited 7 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 AS Chip Clearance No FTDI 170 3 4 FT_GetDevicelInfoList Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function returns a device information list and the number of D2XX devices in the list Definition FT_STATUS FT_GetDevicelInfoList FT_DEVICE_LIST_INFO_NODE pDest LPDWORD IpdwNumDevs Parameters pDest Pointer to an array of FT DEVICE LIST INFO NODE structures IpdwNumDevs Pointer to the number of elements in the array Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function should only be called after calling FT CreateDevicelnfoList If the devices connected to the system change the device info list will not be updated until FT CreateDevicelInfoList is called again Location ID information is not returned for devices that are open when FT_CreateDevicelnfoList is called
83. gnal Definition FT_STATUS FT_SetDtr FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function asserts the Data Terminal Ready DTR line of the device 0x13 Copyright 2011 Future Technology Devices International Limited 24 MET y 4 7 FTDI SS Chip P Example FT_HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return ftStatus FT SetDtr ftHandle if ftStatus FT OK FT SetDtr OK else FT SetDtr failed FT Close ftHandle 3 18 FT_ClirDtr Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function clears the Data Terminal Ready DTR control signal Definition FT_STATUS FT_ClIrDtr FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 This function de asserts the Data Terminal Ready DTR line of the device Example FT HANDLE ftHandle FT STATUS ftStatus Copyright 2011 Future Technology Devices International Limited 25 a7 FTDI Document Reference No FT_000071 T D2XX Programmer s
84. he application checks the result of the overlapped request by calling FT W32 GetOverlappedResult If successful the number of bytes written is returned in pdwBytesWritten Example 1 This example shows how to write 128 bytes to the device using non overlapped I O FT HANDLE ftHandle setup by FT _W32 CreateFile for overlapped i o char Buf 128 contains data to write to the devic DWORD dwToWrite 128 DWORD dwWritten if FT_W32 WriteFile ftHandle Buf dwToWrite amp dwWritten amp o0sWrite if dwToWrite dwWritten FT_W32 WriteFile OK else FT _W32 WriteFile timeout else FT _W32 WriteFile failed 2 This example shows how to write 128 bytes to the device using overlapped I O FT HANDLE ftHandle setup by FT W32 CreateFile for overlapped i o char Buf 128 contains data to write to the devic DWORD dwToWrite 128 DWORD dwWritten OVERLAPPED osWrite 0 if FT_W32 WriteFile ftHandle Buf dwToWrite amp dwWritten amp osWrite if FT W32 GetLastError ftHandle ERROR_IO PENDING write is delayed so do some other stuff until if FT_W32 GetOverlappedResult ftHandle amp o0sWrite amp dwWritten FALSE error else if dwToWrite dwWritten FT _W32 WriteFile OK else FT _W32 WriteFile timeout Copyright 2011 Future Technology Devices International Limited 79 zS FTD
85. hich are open in other processes In this case the pdwFlags parameter will indicate that the device is open but other fields will be unpopulated To return the whole device info list as an array of FT DEVICE LIST INFO NODE structures use FT CreateDevicelInfoList Please note that Linux Mac OS X and Windows CE do not support location IDs As such the Location ID parameter in the structure will be empty under these operating systems Example FT STATUS ftStatus FT HANDLE ftHandleTemp DWORD numDevs DWORD Flags DWORD ID DWORD Type DWORD LoclId char SerialNumber 16 char Description 64 create the device information list ftStatus FT CreateDevicelInfoList amp numDevs if ftStatus FT _OK printf Number of devices is d n numDevs if numDevs gt 0 get information for device 0 ftStatus FT GetDeviceInfoDetail 0 amp Flags amp Type amp ID amp LocId SerialNumber Description amp ftHandleTemp if ftStatus FT OK printf Dev 0 n printf Flags 0x x n Flags ce printf Type 0x x n Type Copyright 2011 Future Technology Devices International Limited 10 MET 4 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Chip Clearance No FTDI 170 i printf ID 0x x n ID printf LocId 0x x n LocId printf SerialNumber s n SerialNumber printf Description s n Description
86. ivers non zero if interface is to use VCP drivers non zero if interface is to use VCP drivers non zero if interface is to use VCP drivers non zero if pull down enabled non zero if serial number to be used non zero if AC pins have slow slew non zero if AC pins are Schmitt input valid values are 4mA 8mA 12mA 16mA non zero if AD pins have slow slew non zero if AD pins are Schmitt input valid values are 4mA 8mA 12mA 16mA Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control non zero if interface is 245 FIFO non zero if interface is 245 FIFO CPU target non zero if interface is Fast serial non zero if interface is FT1248 FT1248 clock polarity clock idle high 1 or clock idle low 0 FT1248 data is LSB 1 or MSB 0 FT1248 flow control enable non zero if interface is to use VCP drivers non zero if using ACBUS7 to save power for self powered FT_PROGRAM_DATA PFT_PROGRAM_DATA EEPROM_HEADER STRUCTURE See FT_EEPROM_Read and FT_EEPROM_Program typedef struct ft_eeprom_header FT_DEVICE deviceType Device descriptor opt WORD Vendorld WORD ProductId UCHAR SerNumEnable FTxxxx device type to be programmed ions 0x0403 0x6001 non zero if serial number to be used Config descri
87. k containing events that the device has to monitor This can be a combination of the following EV_BREAK BREAK condition detected EV_CTS Change in Clear To Send CTS EV_DSR Change in Data Set Ready DSR EV_ERR Error in line status EV_RING Change in Ring Indicator RI EV_RLSD Change in Receive Line Signal Detect RLSD EV_RXCHAR Character received EV_RXFLAG Event character received EV_TXEMPTY Transmitter empty Return Value If the function is successful the return value is nonzero Copyright 2011 Future Technology Devices International Limited 88 zg FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 a SAS Chip Clearance No FTDI 170 If the function is unsuccessful the return value is zero Remarks This function specifies the events that the device should monitor An application can call the function FT W32 WaitCommeEvent to wait for an event to occur Example FT_HANDLE ftHandle setup by FT_W32_CreateFile DWORD dwMask EV_CTS EV_DSR if FT_W32_SetCommMask ftHandle dwMask FT_W32 SetCommMask failed else FT_W32 SetCommMask OK 6 16 FT_W32_GetCommMask Supported Operating Systems Windows 2000 and later Summary Retrieves the events that are currently being monitored by a device Definition BOOL FT_W32_GetCommMask FT_HANDLE ftHandle LPDWORD pdwEventMask Parameters ftHandle Handle of the device IpdwEventMask Poin
88. l Limited 52 MET y N 7 FTDI SS Chip P Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 ftData Description DescriptionBuf ftData SerialNumber SerialNumberBuf ftStatus FT EE Read ftHandle amp ftData if ftStatus FT OK FT_EE Read OK data is available in ftData else FT_EE Read FAILED FT Close ftHandle 4 5 FT_EE_ReadEx Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Read the contents of the EEPROM and pass strings separately Definition FT_STATUS FT_EE_ReadEx FT_HANDLE ftHandle PFT_PROGRAM_DATA pData Parameters ftHandle pData Manufacturer Manufacturerld Description SerialNumber Return Value char Manufacturer char Manufacturerld char Description char SerialNumber Handle of the device Pointer to structure of type FT_PROGRAM_DATA Pointer to a null terminated string containing the manufacturer name Pointer to a null terminated string containing the manufacturer ID Pointer to a null terminated string containing the device description Pointer to a null terminated string containing the device serial number FT_OK if successful otherwise the return value is an FT error code Remarks This variation of the standard FT EE Read function was included to provide support for languages
89. l signal Definition FT_STATUS FT_ClIrRts FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function de asserts the Request To Send RTS line of the device Example FT HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return ftStatus FT ClrRts ftHandle if ftStatus FT OK FT_ClrRts OK else ET CICR failed Copyright 2011 Future Technology Devices International Limited 27 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 FT Close ftHandle 3 21 FT_GetModemStatus Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Gets the modem status and line status from the device Definition FT_STATUS FT_GetModemStatus FT_HANDLE ftHand e LPDWORD IpdwModemStatus Parameters ftHandle Handle of the device IpdwModemStatus Pointer to a variable of type DWORD which receives the modem status and line status from the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks The least significant byte of the pdwModemStatus value holds the modem status On Windows and Windows CE the line status is held in the secon
90. le FT HANDLE ftHandle FT STATUS ftStatus DWORD dwDriverVer Get driver version ftStatus FT Open 0 amp ftHandle if ftStatus FT OK ftStatus FT GetDriverVersion ftHandle amp dwDriverVer if ftStatus FT OK printf Driver version 0x x n dwDriverVer else printf error reading driver version n FT Close ftHandle 3 25 FT_GetLibraryVersion Supported Operating Systems Windows 2000 and later Windows CE 4 2 and later Summary This function returns D2XX DLL version number Definition FT_STATUS FT_GetLibraryVersion LPDWORD pdwDLLVersion Parameters IpdwDLLVersion Pointer to the DLL version number Return Value FT_OK if successful otherwise the return value is an FT error code Copyright 2011 Future Technology Devices International Limited 32 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 AS Chip Clearance No FTDI 170 Remarks A version number consists of major minor and build version numbers contained in a 4 byte field unsigned long ByteO least significant holds the build version Byte1 holds the minor version and Byte2 holds the major version Byte3 is currently set to zero For example D2XX DLL version 3 01 15 is represented as 0x00030115 Note that this function does not take a handle and so it can be called without opening a device Example FT STATUS ftStatus DWORD dwLibraryVer Get DLL version ft
91. le Handle of the device lpBuffer Pointer to the buffer that receives the data from the device dwBytesToRead Number of bytes to be read from the device IpdwBytesReturned Pointer to a variable of type DWORD which receives the number of bytes read from the device Return Value FT_OK if successful FT_IO_ERROR otherwise Remarks FT_Read always returns the number of bytes read in pdwBytesReturned This function does not return until dwBytesToRead bytes have been read into the buffer The number of bytes in the receive queue can be determined by calling FT GetStatus or FT_GetQueueStatus and passed to FT_Read as dwBytesToRead so that the function reads the device and returns immediately When a read timeout value has been specified in a previous call to FT SetTimeouts FT_Read returns when the timer expires or dwBytesToRead have been read whichever occurs first If the timeout occurred FT_Read reads available data into the buffer and returns FT_OK An application should use the function return value and pdwBytesReturned when processing the buffer If the return value is FT_OK and pdwBytesReturned is equal to dwBytesToRead then FT_Read has completed normally If the return value is FT_OK and pdwBytesReturned is less then dwBytesToRead then a timeout has occurred and the read has been partially completed Note that if a timeout occurred and no data was read the return value is still F7_OK A return value of FT_IO_ERROR suggests an err
92. le shows how to close a device after opening it for non overlapped I O using its description FT STATUS ftStatus FT HANDLE ftHandle char Buf 64 ftStatus FT ListDevices 0 Buf FT LIST BY_INDEX FT OPEN BY DESCRIPTION 0 ftHandle FT W32_CreateFile Buf GENERIC_READ GENERIC_ WRITE 0 0 OPEN_EXISTING FILE ATTRIBUTE NORMAL FT OPEN BY DESCRIPTION 0 if ftHandle INVALID HANDLE VALUE FT _W32 CreateDevice failed else FT _W32 CreateFile OK so do some work and eventually FT W32_ CloseHandle ftHandle 6 3 FT_W32_ReadFile Supported Operating Systems Linux MacOSX 10 4 and Late aareeeaaaamamammm X Copyright 2011 Future Technology Devices International Limited 75 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 Windows 2000 and later Windows CE 4 2 and later Summary Read data from the device Definition BOOL FT_W32_ReadFile FT_HANDLE ftHandle LPVOID pBuffer DWORD dwBytesToRead LPDWORD IpdwBytesReturned LPOVERLAPPED IpOverlapped Parameters ftHandle Handle of the device IpBuffer Pointer to a buffer that receives the data from the device dwBytesToRead Number of bytes to read from the device IpdwBytesReturned Pointer to a variable that receives the number of bytes read from the device IpOverlapped Pointer
93. lternative software interfaces for its range of USB UART and USB FIFO ICs One interface provides a Virtual COM Port VCP which appears to the system as a legacy COM port The second interface D2XX is provided via a proprietary DLL FTD2XX DLL The D2XxX interface provides special functions that are not available in standard operating system COM port APIs such as setting the device into a different mode or writing data into the device EEPROM In the case of the FTDI drivers for Windows the D2XX driver and VCP driver are distributed in the same driver package called the Combined Driver Model CDM package Figure 2 1 Windows CDM Driver Architecture illustrates the architecture of the Windows CDM driver D2XX Application COM Port Application FTD2XX DLL FTSER2K SYS FTDIBUS SYS Figure 2 1 Windows CDM Driver Architecture For Linux Mac OS X 10 4 and later and Windows CE 4 2 and later the D2XX driver and VCP driver are mutually exclusive options as only one driver type may be installed at a given time for a given device ID In the case of a Windows system running the CDM driver applications may use either the D2XX or VCP interface without installing a different driver but may not use both interfaces at the same time As the VCP driver interface is designed to emulate a legacy COM port FTDI does not provide documentation on how to communicate with the VCP driver from an application the developer is referred to the large amount of mat
94. mmand to retrieve the current VID and PID combination from within the internal device list table Definition FT_STATUS FT_GetVIDPID DWORD pdwVID DWORD pdwPID Parameters pdwVID Pointer to DWORD that will contain the internal VID DIE Poi DWORD tl i inthe i LPIL Copyright 2011 Future Technology Devices International Limited 6 F4 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 Return Value FT_OK if successful otherwise the return value is an FT error code Remarks See FT SetVIDPID 3 3 FT_CreateDevicelInfoList Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function builds a device information list and returns the number of D2XX devices connected to the system The list contains information about both unopen and open devices Definition FT_STATUS FT_CreateDeviceInfoList LPDWORD pdwNumDevs Parameters IpdwNumDevs Pointer to unsigned long to store the number of devices connected Return Value FT_OK if successful otherwise the return value is an FT error code Remarks An application can use this function to get the number of devices attached to the system It can then allocate space for the device information list and retrieve the list using FT GetDeviceInfoList or FT GetDeviceInfoDetailFT_GetDeviceInfoDetail If the devices connected to the system chan
95. n 0 amp ftHandle if ftStatus FT OK FT Open failed Copyright 2011 Future Technology Devices International Limited 68 a7 FTDI Document Reference No FT_000071 w D2XX Programmer s Guide Version 1 3 A A Chip Clearance No FTDI 170 return ftStatus FT GetLatencyTimer ftHandle amp LatencyTimer if ftStatus FT _OK LatencyTimer contains current value else FT _GetLatencyTimer FAILED FT Close ftHandle 5 3 FT_SetBitMode Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Enables different chip modes Definition FT_STATUS FT_SetBitmode FT_HANDLE ftHand le UCHAR ucMask UCHAR ucMode Parameters ftHandle Handle of the device ucMask Required value for bit mode mask This sets up which bits are inputs and outputs A bit value of O sets the corresponding pin to an input a bit value of 1 sets the corresponding pin to an output In the case of CBUS Bit Bang the upper nibble of this value controls which pins are inputs and outputs while the lower nibble controls which of the outputs are high and low ucMode Mode value Can be one of the following 0x0 Reset 0x1 Asynchronous Bit Bang 0x2 MPSSE FT2232 FT2232H FT4232H and FT232H devices only 0x4 Synchronous Bit Bang FT232R FT245R FT2232 FT2232H FT4232H and FT232H devices only 0x8 MCU Host Bus Emulation Mode FT2
96. n 1 3 a SN Chip Clearance No FTDI 170 4 EEPROM Programming Interface Functions FTDI device EEPROMs can be both read and programmed using the functions listed in this section 4 1 FT_ReadEE Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Read a value from an EEPROM location Definition FT_STATUS FT_ReadEE FT_HANDLE ftHandle DWORD dwWordOffset LPWORD pwValue Parameters ftHandle Handle of the device dwWordOffset EEPROM location to read from IpwValue Pointer to the WORD value read from the EEPROM Return Value FT_OK if successful otherwise the return value is an FT error code Remarks EEPROMs for FTDI devices are organised by WORD so each value returned is 16 bits wide 4 2 FT_WriteEE Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Write a value to an EEPROM location Definiti Copyright 2011 Future Technology Devices International Limited 50 zS FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SSN Chip Clearance No FTDI 170 FT_STATUS FT_WriteEE FT_HANDLE ftHandle DWORD dwWordOffset WORD wValue Parameters ftHandle Handle of the device dwWordOffset EEPROM location to read from wValue The WORD value write to the EEPROM Return Value FT_OK if successful otherwise the return value is an FT error
97. n zero if AH pins are Schmitt input Oy valid values are 4mA 8mA 12mA 16mA Os non zero if BL pins have slow slew 0 non zero if BL pins are Schmitt input 0 valid values are 4mA 8mA 12mA 16mA 0 non zero if BH pins have slow slew 0 non zero if BH pins are Schmitt input Oy valid values are 4mA 8mA 12mA 16mA 0 non zero if port A uses RI as RS485 TXDEN Oy non zero if port B uses RI as RS485 TXDEN 0 non zero if port C uses RI as RS485 TXDEN 0 non zero if port D uses RI as RS485 TXDE 0 non zero if interface is to use VCP drivers 0 non zero if interface is to use VCP drivers 0 non zero if interface is to use VCP drivers 0 non zero if interface is to use VCP drivers Rev 9 FT232H Extensions Enabled if Version 5 0 non zero if pull down enabled 0y non zero if serial number to be used Os non zero if AC pins have slow slew 0 non zero if AC pins are Schmitt input Copyright 2011 Future Technology Devices International Limited 56 N FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 ye Y Chip Clearance No FTDI 170 valid values are 4mA 8mA 12mA 16mA non zero if AD pins have slow slew non zero if AD pins are Schmitt input valid values are 4mA 8mA 12mA 16mA Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux control Cbus Mux co
98. nction does not perform any checks on buffer sizes so the buffers passed in the FT_PROGRAM_DATA structure must be big enough to accommodate their respective strings including null terminators The sizes shown in the following example are more than adequate and can be rounded down if necessary The restriction is that the Manufacturer string length plus the Description string length is less than or equal to 40 characters Note that the DLL must be informed which version of the FT_PROGRAM_DATA structure is being used This is done through the Signature1 Signature2 and Version elements of the structure Signature1 should always be 0x00000000 Signature2 should always be OxFFFFFFFF and Version can be set to use whichever version is required For compatibility with all current devices Version should be set to the latest version of the FT__PROGRAM_DATA structure which is defined in FTD2XX h Example FT HANDLE ftHandle FT STATUS ftStatus FT Open 0 amp ftHandle if ftStatus l FT OK FT Open FAILED FT PROGRAM DATA ftData char ManufacturerBuf 32 char ManufacturerldBuf 16 char DescriptionBuf 64 char SerialNumberBuf 16 ftData Signaturel 0x00000000 ftData Signature2 Oxffffffff ftData Version 0x00000005 EEPROM structure with FT232H extensions ftData Manufacturer ManufacturerBuf ftData ManufactureriId ManufacturerIdBuf Copyright 2011 Future Technology Devices Internationa
99. non zero if AL pins are Schmitt input UCHAR ALDriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR AHSlowSlew non zero if AH pins have slow slew UCHAR AHSchmittInput non zero if AH pins are Schmitt input UCHAR AHDriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR BLSlowSlew non zero if BL pins have slow slew UCHAR BLSchmittInput non zero if BL pins are Schmitt input UCHAR BLDriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR BHSlowSlew non zero if BH pins have slow slew UCHAR BHSchmittInput non zero if BH pins are Schmitt input UCHAR BHDriveCurrent valid values are 4mA 8mA 12mA 16mA Hardware options UCHAR AIsFifo non zero if interface is 245 FIFO UCHAR AlsFifoTar non zero if interface is 245 FIFO CPU target UCHAR AlsFastSer non zero if interface is Fast serial UCHAR BIsFifo non zero if interface is 245 FIFO UCHAR BIsFifoTar non zero if interface is 245 FIFO CPU target UCHAR BicEactSer F cE Copyright 2011 Future Technology Devices International Limited 105 MET 4 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Chip Clearance No FTDI 170 i UCHAR PowerSaveEnable non zero if using BCBUS7 to save power for self powered designs Driver option UCHAR ADriverType UCHAR BDriverType FT_EEPROM_2232H PFT_EEPROM_2232H FT4232H EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program t
100. ntrol Cbus Mux control Cbus Mux control non zero if interface is 245 FIFO non zero if interface is 245 FIFO CPU target non zero if interface is Fast serial non zero if interface is FT1248 FT1248 clock polarity clock idle high 1 or clock idle low 0 ys NN YSN SNS x oN Sa oN OOO OOOO Oe ee eee eRe ener oN xN oN 0 FT1248 data is LSB 1 or MSB 0 0 FT1248 flow control enable 0 non zero if interface is to use VCP drivers 0 non zero if using ACBUS7 to save power for self powered designs he FT HANDLE ftHandle FT STATUS ftStatus FT Open 0 amp ftHandle if ftStatus FT _OK ftStatus FT EE Program ftHandle amp ftData if ftStatus FT OK FT_EE Program OK else FT EE Program FAILED FT Close ftHandle 4 7 FT_EE_ProgramEx Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Program the EEPROM and pass strings separately Definition FT_STATUS FT_EE_ProgramEx FT_HANDLE ftHandle PFT_PROGRAM_DATA pData char Manufacturer char Manufacturerld char Description char SerialNumber Copyright 2011 Future Technology Devices International Limited 57 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No
101. o if out endpoint is isochronous UCHAR PullDownEnable non zero if pull down enabled UCHAR SerNumEnable non zero if serial number to be used UCHAR USBVersionEnable non zero if chip uses USBVersion WORD USBVersion BCD 0x0200 gt USB2 Rev 5 FT2232 extensions UCHAR Rev5 non zero if Rev5 chip zero otherwise UCHAR IsoInA non zero if in endpoint is isochronous UCHAR IsoInB non zero if in endpoint is isochronous UCHAR IsoOutA non zero if out endpoint is isochronous UCHAR IsoOutB non zero if out endpoint is isochronous UCHAR PullDownEnableS non zero if pull down enabled UCHAR SerNumEnable5 non zero if serial number to be used UCHAR USBVersionEnable5 non zero if chip uses USBVersion WORD USBVersion5 BCD 0x0200 gt USB2 UCHAR AlsHighCurrent non zero if interface is high current UCHAR BlIsHighCurrent non zero if interface is high current UCHAR IFAISsFifo non zero if interface is 245 FIFO UCHAR IFAIsFifoTar non zero if interface is 245 FIFO CPU target UCHAR IFAIsFastSer non zero if interface is Fast serial UCHAR AIsVCP non zero if interface is to use VCP drivers UCHAR IFBIsFifo non zero if interface is 245 FIFO Copyright 2011 Future Technology Devices International Limited 101 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 AN Chip Clearance No FTDI 170 UCHAR IFBIsFifoTar non zero if interface
102. occurred and no data was read the return value is still non zero A return value of FT_IO_ERROR suggests an error in the parameters of the function or a fatal error like USB disconnect has occurred Overlapped I O Copyright 2011 Future Technology Devices International Limited 76 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SSN Chip Clearance No FTDI 170 When the device has been opened for overlapped I O an application can issue a request and perform some additional work while the request is pending This contrasts with the case of non overlapped I O in which the application issues a request and receives control again only after the request has been completed The parameter pOverlapped must point to an initialized OVERLAPPED structure If there is enough data in the receive queue to satisfy the request the request completes immediately and the return code is non zero The number of bytes read is returned in pdwBytesReturned If there is not enough data in the receive queue to satisfy the request the request completes immediately and the return code is zero signifying an error An application should call FT W32 GetLastError to get the cause of the error If the error code is ERROR_IO_PENDING the overlapped operation is still in progress and the application can perform other processing Eventually the application checks the result of the overlapped request by calling FT W32 GetOverlappedRe
103. ointer to unsigned long to store device type Copyright 2011 Future Technology Devices International Limited 9 77 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 As Chip Clearance No FTDI 170 IpdwID Pointer to unsigned long to store device ID IpdwLocId Pointer to unsigned long to store the device location ID pcSerialNumber Pointer to buffer to store device serial number as a null terminated string pcDescription Pointer to buffer to store device description as a null terminated string ftHandle Pointer to a variable of type FT_HANDLE where the handle will be stored Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function should only be called after calling FT CreateDevicelInfoList If the devices connected to the system change the device info list will not be updated until FT CreateDevicelInfoList is called again The index value is zero based The flag value is a 4 byte bit map containing miscellaneous data as defined Appendix A Type Definitions Bit O least significant bit of this number indicates if the port is open 1 or closed 0 Bit 1 indicates if the device is enumerated as a high speed USB device 2 or a full speed USB device 0 The remaining bits 2 31 are reserved Location ID information is not returned for devices that are open when FT CreateDevicelnfoList is called Information is not available for devices w
104. onal Limited 45 MET 4 7 FTDI SS Chip ld DWORD dwRetryCount dwRetryCount 100 Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 ftStatus FT SetResetPipeRetryCount ftHandle dwRetryCount if ftStatus FT OK ResetPipeRetryCount set to 100 else FT SetResetPipeRetryCount FAILED 3 39 FT_StopInTask Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Stops the driver s IN task Definition FT_STATUS FT_StopInTask FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function is used to put the driver s IN task read into a wait state It can be used in situations where data is being received continuously so that the device can be purged without more data being received It is used together with FT RestartInTask which sets the IN task running again Example FT HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return do ftStatus FT StopInTask ftHandle while ftStatus FT OK Copyright 2011 Future Technology Devices International Limited 46 a7 FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A
105. or in the parameters of the function or a fatal error like a USB disconnect has occurred Copyright 2011 Future Technology Devices International Limited 17 uy pay p Examples 1 This sample shows how to read all the data currently available FT_HANDLE ftHandle FT STATUS ftStatus DWORD EventDWord DWORD TxBytes DWORD RxBytes DWORD BytesReceived char RxBuffer 256 ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return FT GetStatus ftHandle amp RxBytes amp TxBytes amp EventDWord if RxBytes gt 0 ftStatus FT Read ftHandle RxBuffer RxBytes amp BytesReceived if ftStatus FT OK FT Read OK else FT Read Failed FT Close ftHandle 2 This sample shows how to read with a timeout of 5 seconds FT HANDLE ftHandle FT STATUS ftStatus DWORD RxBytes 10 DWORD BytesReceived char RxBuffer 256 ftStatus FT Open 0 amp ftHandle if ftStatus FT_OK FT Open failed return FT SetTimeouts ftHandle 5000 0 ftStatus FT Read ftHandle RxBuffer RxBytes amp BytesReceived if ftStatus FT OK if BytesReceived RxBytes FT Read OK else FT Read Timeout else FT Read Failed FT Close ftHandle Copyright 2011 Future Technology Devices International Limited 7A FTDI Document Reference No FT_000071 D2XX Programm
106. orm an extended function Definition BOOL FT_W32_EscapeCommFunction FT_HANDLE ftHandle DWORD dwFunc Parameters ftHandle Handle of the device dwFunc The extended function to perform can be one of the following values CLRDTR Clear the DTR signal CLRRTS Clear the RTS signal SETDTR Set the DTR signal SETRTS Set the RTS signal SETBREAK Set the BREAK condition CLRBREAK Clear the BREAK condition Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Example FT_HANDLE ftHandle setup by FT_W32_CreateFile FT_W32_EscapeCommFunction ftHandle CLRDTS FT_W32_EscapeCommFunction ftHandle SETRTS Clear the DTR signal Set the RTS signal f r 6 7 FT_W32_GetCommModemStatus Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function gets the current modem control value Definition BOOL FT_W32_GetCommModemStatus FT_HANDLE ftHandle LPDWORD pdwStat Copyright 2011 Future Technology Devices International Limited 81 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SS Chip Clearance No FTDI 170 Parameters ftHandle Handle of the device IpdwStat Pointer to a variable to contain modem control value The modem control value can be a combination of the following MS_CTS_ON Clear To Send C
107. pen 0 amp fthandle if status FT OK Copyright 2011 Future Technology Devices International Limited 63 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A SS Chip Clearance No FTDI 170 printf open status not ok d n status status FT EEPROM Read fthandle amp ft_eeprom 2232h sizeof ft eeprom 2232h Manufacturer ManufacturerlId Description SerialNumber if status FT OK printf EEPROM Read status not ok d n status else printf VendorID 0x 04x n ft _eeprom_2232h common VendorId printf ProductID 0x 04x n ft _ eeprom _2232h common ProductId FT Close fthandle 4 12 FT_EEPROM_Program Supported Operating Systems Windows XP and later Summary Write data into the EEPROM this command will work for all existing FTDI chipset and must be used for the FT X series Definition FT_STATUS FT_EEPROM_Program FT_HANDLE ftHandle void eepromData DWORD eepromDataSize char Manufacturer char ManufacturerId char Description char SerialNumber Parameters ftHandle Handle of the device eepromData Pointer to a buffer that contains the data to be written Note This structure is different for each device type epromDataSize Size of the eepromData buffer that contains storage for the data to be written Manufacturer Pointer to a null terminated string containing the manufacturer name ManufacturerId Pointer
108. ptor options WORD MaxPower Copyright 2011 F 0 lt MaxPower lt 500 uture Technology Devices International Limited 103 MET y 4 E FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 AN Chip Clearance No FTDI 170 UCHAR SelfPowered 0 bus powered 1 self powered UCHAR RemoteWakeup 0 not capable 1 capable Hardware options UCHAR PullDownEnable non zero if pull down in suspend enabled FT_EEPROM_HEADER PFT_EEPROM_HEADER FT232B EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program typedef struct ft_eeprom_232b Common header FT_EEPROM_HEADER common common elements for all device EEPROMs FT_EEPROM_232B PFT_EEPROM_232B FT2232 EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program typedef struct ft_eeprom_2232 Common header FT_EEPROM_HEADER common common elements for all device EEPROMs Drive options UCHAR AlsHighCurrent non zero if interface is high current UCHAR BlIsHighCurrent non zero if interface is high current Hardware options UCHAR AIsFifo non zero if interface is 245 FIFO UCHAR AlsFifoTar non zero if interface is 245 FIFO CPU target UCHAR AlIsFastSer non zero if interface is Fast serial UCHAR BIsFifo non zero if interface is 245 FIFO UCHAR BIsFifoTar non zero if interface is 245 FIFO CPU target UCHAR BIsFastSer non zero if interface is Fast serial Driver option UCHAR
109. ram the EEPROM Definition FT_STATUS FT_EE_Program FT_HANDLE ftHandle PFT_PROGRAM_DATA pData Parameters ftHandle Handle of the device pData Pointer to structure of type FT_PROGRAM_DATA Return Value FT_OK if successful otherwise the return value is an FT error code Remarks This function interprets the parameter pData as a pointer to a structure of type FT_PROGRAM_DATA that contains the data to write to the EEPROM The data is written to EEPROM then read back and verified If the SerialNumber field in FT_PROGRAM_DATA is NULL or SerialNumber points to a NULL string a serial number based on the ManufacturerId and the current date and time will be generated The Manufacturer string length plus the Description string length must be less than or equal to 40 characters Note that the DLL must be informed which version of the FT_PROGRAM_DATA structure is being used This is done through the Signature1 Signature2 and Version elements of the structure Signature1 should always be 0x00000000 Signature2 should always be OxFFFFFFFF and Version can be set to use whichever version is required For compatibility with all current devices Version should be set to the latest version of the FT_PROGRAM_DATA structure which is defined in FTD2XX h If pData is NULL the structure version will default to O original BM series and the device will be programmed with the default data Copyright 2011 Future Technology Devices International Limited
110. ransmitter is waiting because XOFF was received Copyright 2011 Future Technology Devices International Limited 94 Document Reference No FT_000071 7 FTDI T D2XX Programmer s Guide Version 1 3 A SAS Chip Clearance No FTDI 170 if newCS fXoffSent z if newCS fEof End of file character has been received if newCS fTxim Tx immediate character queued for transmission newCS cbInQue contains number of bytes in receive queu newCS cbhOutQue contains number of bytes in transmit queue Copyright 2011 Future Technology Devices International Limited 95 TA FTDI a Chip p P 7 Contact Information Head Office Glasgow UK Future Technology Devices International Limited Unit 1 2 Seaward Place Centurion Business Park Glasgow G41 1HH United Kingdom Tel 44 0 141 429 2777 Fax 44 0 141 429 2758 E mail Sales sales1 ftdichip com E mail Support supporti ftdichip com E mail General Enquiries admini ftdichip com Web Site URL http www ftdichip com Web Shop URL http www ftdichip com Branch Office Taipei Taiwan Future Technology Devices International Limited Taiwan 2F No 516 Sec 1 NeiHu Road Taipei 114 Taiwan R O C Tel 886 0 2 8791 3570 Fax 886 0 2 8791 3576 E mail Sales tw sales1 ftdichip com E mail Support tw support1 ftdichip com E mail General Enquiries tw admini ftdichip com Web Site URL http
111. re 4mA 8mA 12mA 16mA UCHAR BLSlowSlew non zero if BL pins have slow slew UCHAR BLSchmittInput non zero if BL pins are Schmitt input UCHAR BLDriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR BHSlowSlew non zero if BH pins have slow slew UCHAR BHSchmittInput non zero if BH pins are Schmitt input UCHAR BHDriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR IFAISFifo7 non zero if interface is 245 FIFO UCHAR IFAIsFifoTar7 non zero if interface is 245 FIFO CPU target UCHAR IFAIsFastSer7 non zero if interface is Fast serial UCHAR AIsVCP7 non zero if interface is to use VCP drivers UCHAR IFBISsFifo7 non zero if interface is 245 FIFO UCHAR IFBIsFifoTar7 non zero if interface is 245 FIFO CPU target UCHAR IFBIsFastSer7 non zero if interface is Fast serial UCHAR BIsVCP7 non zero if interface is to use VCP drivers UCHAR PowerSaveEnable non zero if using BCBUS7 to save power for self powered designs Rev 8 FT4232H Extensions UCHAR PullDownEnable8 non zero if pull down enabled UCHAR SerNumEnable8g non zero if serial number to be used UCHAR ASlowSlew non zero if AL pins have slow slew UCHAR ASchmittInput non zero if AL pins are Schmitt input UCHAR ADriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR BSlowSlew non zero if AH pins have slow slew UCHAR BSchmittInput non zero if AH pins are Schmitt input RB HERE tH HSH A aaa Copyright 2011 Future T
112. rrent device state Definition BOOL FT_W32_GetCommState FT_HANDLE ftHandle LPFTDCB pftDcb Parameters ftHandle Handle of the device IpftDcb Pointer to an FTDCB structure Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Remarks The current state of the device is returned in a device control block Example FT HANDLE ftHandle setup by FT_W32_ CreateFile FTDCB f tDCB if FT _W32 GetCommState ftHandle amp ftDCB FT_W32 GetCommState ok device state is in ftDCB else FT_W32 GetCommState failed 6 11 FT_W32_SetCommTimeouts Supported Operating Systems Copyright 2011 Future Technology Devices International Limited 84 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 I A A Y Chip Clearance No FTDI 170 Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the timeout parameters for I O requests Definition BOOL FT_W32_SetCommTimeouts FT_HANDLE ftHandle LPFTTIMEOUTS pftTimeouts Parameters ftHandle Handle of the device IpftTimeouts Pointer to an FTTIMEOUTS structure to store timeout information Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Remarks Timeouts are calculated using the information in th
113. rror code Remarks This function interprets the parameter pucData as a pointer to an array of bytes of size dwDataLen that contains storage for the data to be read from the EEPROM user area The actual number of bytes read is stored in the DWORD referenced by pdwBytesRead If dwDataLen is less than the size of the EEPROM user area then dwDataLen bytes are read into the buffer Otherwise the whole of the EEPROM user area is read into the buffer The available user area size can be determined by calling FT EE UASize An application should check the function return value and pdwBytesRead when FT_EE_UARead returns Copyright 2011 Future Technology Devices International Limited 60 a7 FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A SAS Chip Clearance No FTDI 170 Example FT_HANDLE ftHandle FT STATUS ftStatus FT_Open 0 amp ftHandle if ftStatus FT_ K FT Open FAILED unsigned char Buffer 64 DWORD BytesRead ftStatus FT EE UARead ftHandle Buffer 64 amp BytesRead if ftStatus FT OK FT_EE UARead OK User Area data stored in Buffer Number of bytes read from EEUA stored in BytesRead else FT_EE UARead FAILED FT Close ftHandle 4 10 FT_EE_UAWrite Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summ
114. such as LabVIEW where problems can occur when string pointers are contained in a structure This function interprets the parameter pData as a pointer to a structure of type FT_PROGRAM_DATA that contains storage for the data to be read from the EEPROM Copyright 2011 Future Technology Devices International Limited 53 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI 170 The function does not perform any checks on buffer sizes so the buffers passed in the FT_PROGRAM_DATA structure must be big enough to accommodate their respective strings including null terminators Note that the DLL must be informed which version of the FT_PROGRAM_DATA structure is being used This is done through the Signature1 Signature2 and Version elements of the structure Signature1 should always be 0x00000000 Signature2 should always be OxFFFFFFFF and Version can be set to use whichever version is required For compatibility with all current devices Version should be set to the latest version of the FT_PROGRAM_DATA structure which is defined in FTD2XX h The string parameters in the FT_PROGRAM_DATA structure should be passed as DWORDs to avoid overlapping of parameters All string pointers are passed out separately from the FT_PROGRAM_DATA structure 4 6 FT_EE_Program Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Prog
115. sult If successful the number of bytes read is returned in pdwBytesReturned Example 1 This example shows how to read 256 bytes from the device using non overlapped I O FT HANDLE ftHandle setup by FT _W32 CreateFile for non overlapped i o char Buf 256 DWORD dwToRead 256 DWORD dwRead if FT _W32 ReadFile ftHandle Buf dwToRead amp dwRead amp osRead if dwToRead dwRead FT_W32 ReadFile OK else FT W32 ReadFile timeout else FT W32 ReadFile failed 2 This example shows how to read 256 bytes from the device using overlapped I O FT HANDLE ftHandle setup by FT _W32 CreateFile for overlapped i o char Buf 256 DWORD dwToRead 256 DWORD dwRead OVERLAPPED osRead 0 osRead hEvent CreateEvent NULL FALSE FALSE NULL if FT W32 ReadFile ftHandle Buf dwToRead amp dwRead amp osRead if FT _W32 GetLastError ftHandle ERROR_IO PENDING write is delayed so do some other stuff until if FT _W32 GetOverlappedResult ftHandle amp osRead amp dwRead FALSE error else if dwToRead dwRead FT W32_ ReadFile OK else FT W32 ReadFile timeout else FT_W32 ReadFile OK Copyright 2011 Future Technology Devices International Limited 77 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SAS Chip Clearance No FTDI
116. t all applicable safety regulatory and system level performance requirements All application related information in this document including application descriptions suggested FTDI devices and other materials is provided for reference only While FTDI has taken care to assure it is accurate this information is subject to customer confirmation and FTDI disclaims all liability for system designs and for any applications assistance provided by FTDI Use of FTDI devices in life support and or safety applications is entirely at the user s risk and the user agrees to defend indemnify and hold harmless FTDI from any and all damages claims suits or expense resulting from such use This document is subject to change without notice No freedom to use patents or other intellectual property rights is implied by the publication of this document Neither the whole nor any part of the information contained in or the product described in this document may be adapted or reproduced in any material or electronic form without the prior written consent of the copyright holder Future Technology Devices International Ltd Unit 1 2 Seaward Place Centurion Business Park Glasgow G41 1HH United Kingdom Scotland Registered Company Number SC136640 Copyright 2011 Future Technology Devices International Limited 97 pe T FTDI a Chip 8 Appendix A Type Definitions UCHAR Unsigned char 1 byte e PUCHAR Pointer to unsigned char 4 bytes PCHAR Pointer to
117. t and FT_GetDeviceInfoDetail typedef struct _ft_device_list_info_node DWORD Flags mmm Copyright 2011 Future Technology Devices International Limited 100 7777797979777777 797777 sF FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SN Chip Clearance No FTDI 170 DWORD Type DWORD ID DWORD Locld char SerialNumber 16 char Description 64 FT_HANDLE ftHandle FT_DEVICE_LIST_INFO_NODE FT_FLAGS see FT DEVICE LIST INFO NODE FT_FLAGS_OPENED 0x00000001 FT_PROGRAM_DATA_STRUCTURE typedef struct ft_program_data DWORD Signature1 Header must be 0x0000000 DWORD Signature2 Header must be Oxffffffff DWORD Version Header FT_PROGRAM_DATA version 0 original FT232B 1 FT2232 extensions 2 FT232R extensions 3 FT2232H extensions 4 FT4232H extensions 5 FT232H extensions WORD Vendorld 0x0403 WORD ProductId Ox6001 char Manufacturer FTDI char Manufacturerld FT char Description USB HS Serial Converter char SerialNumber FT000001 if fixed or NULL WORD MaxPower 0 lt MaxPower lt 500 WORD PnP 0 disabled 1 enabled WORD SelfPowered 0 bus powered 1 self powered WORD RemoteWakeup 0 not capable 1 capable Rev4 FT232B extensions UCHAR Rev4 non zero if Rev4 chip zero otherwise UCHAR IsoIn non zero if in endpoint is isochronous UCHAR IsoOut non zer
118. ter Summary This function sets the flow control for the device Definition Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 FT_STATUS FT_SetFlowControl FT_HANDLE ftHand e USHORT usFlowControl UCHAR uXon UCHAR uXoff Parameters ftHandle Handle of the device usFlowControl Must be one of FT FLOW NONE FT FLOW_RTS CTS FT FLOW _DTR_DSR or FT FLOW _XON_XOFF Copyright 2011 Future Technology Devices International Limited 23 Sg FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 AS Chip Clearance No FTDI 170 uXon Character used to signal Xon Only used if flow control is FT FLOW _XON_XOFF uXoff Character used to signal Xoff Only used if flow control is FT FLOW _XON_XOFF Return Value FT_OK if successful otherwise the return value is an FT error code FT HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return Set RTS CTS flow control ftStatus FT SetFlowControl ftHandle FT FLOW _RTS CTS 0x11 if ftStatus FT OK FT_SetFlowControl OK else FT _SetFlowControl Failed FT Close ftHandle 3 17 FT_SetDtr Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the Data Terminal Ready DTR control si
119. ter to a location that receives a mask that contains the events that are currently enabled This parameter can be one or more of the following values EV_BREAK BREAK condition detected EV_CTS Change in Clear To Send CTS EV_DSR Change in Data Set Ready DSR EV_ERR Error in line status EV_RING Change in Ring Indicator RI EV_RLSD Change in Receive Line Signal Detect RLSD EV_RXCHAR Character received EV_RXFLAG Event character received EV_TXEMPTY Transmitter empty Return Value Copyright 2011 Future Technology Devices International Limited 89 F4 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A SAS Chip Clearance No FTDI 170 If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Remarks This function returns events currently being monitored by the device Event monitoring for these events is enabled by the FT _ W32 SetCommMask function Example FT_HANDLE ftHandle setup by FT_W32_CreateFile DWORD dwMask if FT_W32_GetCommMask ftHandle amp dwMask FT_W32 GetCommMask failed else FT_W32 GetCommMask OK 6 17 FT_W32_WaitCommeEvent Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function waits for an event to occur Definition BOOL FT_W32_SetupComm FT_HANDLE ftHandle LPDWO
120. to an overlapped structure Return Value If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Remarks This function supports both non overlapped and overlapped I O except under Linux Mac OS X and Windows CE where only non overlapped IO is supported Non overlapped I O The parameter pOverlapped must be NULL for non overlapped I O This function always returns the number of bytes read in pdwBytesReturned This function does not return until dwBytesToRead have been read into the buffer The number of bytes in the receive queue can be determined by calling FT GetStatus or FT GetQueueStatus and passed as dwBytesToRead so that the function reads the device and returns immediately When a read timeout has been setup in a previous call to FT W32 SetCommTimeouts this function returns when the timer expires or dwBytesToRead have been read whichever occurs first If a timeout occurred any available data is read into oBuffer and the function returns a non zero value An application should use the function return value and pdwBytesReturned when processing the buffer If the return value is non zero and pdwBytesReturned is equal to dwBytesToRead then the function has completed normally If the return value is non zero and pdwBytesReturned is less then dwBytesToRead then a timeout has occurred and the read request has been partially completed Note that if a timeout
121. turn value is an FT error code Remarks This function is no longer required as FT SetBaudRate will now automatically calculate the required divisor for a requested baud rate The application note Setting baud rates for the FT8U232AM is available from the Application Notes section of the FTDI website describes how to calculate the divisor for a non standard baud rate 3 14 FT_SetDataCharacteristics Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the data characteristics for the device Definition FT_STATUS FT_SetDataCharacteristics FT_HANDLE ftHandle UCHAR uWordLength UCHAR UStopBits UCHAR uParity Copyright 2011 Future Technology Devices International Limited 21 a7 FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 SS Chip Clearance No FTDI 170 Parameters ftHandle Handle of the device uWordLength Number of bits per word must be FT BITS 8 or FT BITS 7 uStopBits Number of stop bits must be FT STOP BITS i or FT STOP BITS 2 uParity Parity must be FT PARITY NONE FT PARITY ODD Return Value FT PARITY EVEN FT PARITY MARK or FT PARITY SPACE FT_OK if successful otherwise the return value is an FT error code Example FT HANDLE ftHandle FT STATUS ftStatus ftStatus FT Open 0 amp ftHandle if ftStatus FT OK FT Open failed return
122. ul the return value is nonzero If the function is unsuccessful the return value is zero Example FT_HANDLE ftHandle setup by FT_W32_CreateFile if FT_W32_SetCommBreak ftHandle FT_W32 SetCommBreak failed else FT_W32 SetCommBreak OK 6 14 FT_W32_ClearCommBreak Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Puts the communications line in the non BREAK state Definition BOOL FT_W32_ClearCommBreak FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value Copyright 2011 Future Technology Devices International Limited 87 e FTDI Document Reference No FT_000071 7 T D2XX Programmer s Guide Version 1 3 A SAS Chip Clearance No FTDI 170 If the function is successful the return value is nonzero If the function is unsuccessful the return value is zero Example FT_HANDLE ftHandle setup by FT_W32_CreateFile if FT W32 ClearCommBreak ftHandle FT_W32_ ClearCommBreak failed else FT _W32 ClearCommBreak OK 6 15 FT_W32_SetCommMask Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function specifies events that the device has to monitor Definition BOOL FT_W32_SetCommMask FT_HANDLE ftHand e DWORD dwMask Parameters ftHandle Handle of the device dwMask Mas
123. ummary This function purges receive and transmit buffers in the device Definition FT_STATUS FT_Purge FT_HANDLE ftHandle DWORD dwMask Parameters ftHandle Handle of the device uEventCh Combination of FT PURGE RX and FT PURGE TX Return Value FT_OK if successful otherwise the return value is an FT error code Copyright 2011 Future Technology Devices International Limited 40 a7 FTDI Document Reference No FT_000071 T D2XX Programmer s Guide Version 1 3 A SSN Chip Clearance No FTDI 170 Example FT HANDLE ftHandle valid handle returned from FT _OpenEx FT STATUS ftStatus ftStatus FT Purge ftHandle FT PURGE RX FT PURGE TX Purge both Rx and Tx buffers if ftStatus FT OK FT Purge OK else FT Purge failed FT Close ftHandle 3 33 FT_ResetDevice Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sends a reset command to the device Definition FT_STATUS FT_ResetDevice FT_HANDLE ftHandle Parameters ftHandle Handle of the device Return Value FT_OK if successful otherwise the return value is an FT error code Example FT HANDLE ftHandle valid handle returned from FT _OpenEx FT STATUS ftStatus ftStatus FT ResetDevice ftHandle if ftStatus FT OK FT_ResetDevice OK else FT _ResetDevice failed FT Close
124. usasnatausanececucesestaudasucivususesducesasirudanectanse 42 3 395 FT CycleP ortsin ei a Ee e Ee ES a a E EEEE 42 OS gt a N a CE ee 43 Bil FI ROA scscsiisscctscctscenscesncscacedscuencutucsancudncanscetncsancatncsescetacsancetecsascatecssseetacssacets 44 3 38 FT_SetResetPipeRetryGounl iiiaciiscsccciiscaiastiuasersineianaiaiannivawasasdininaiaduiadanaanciul 45 3 39 od ees eo g Fee eee eee ner ea a EEEE eee ee ere ene sneer 46 3 40 FI Restartin ask seciescscsissccscccsincsscecancsasieancnacexanccanecancsececancsasacanevenetencvasacenevacneess 47 3 41 FT SetDeadMan Time ow lh veissssiessiiecssicssecssiscesecssevssensssessennsevesectssissecesevetertiavnnecnsenes 48 Se Tl a E A A A E A A 49 3 43 FT SetWatMaSkK racists cso ssaneciacectcincnnsisieen odteantuaanisananedacontnaptcininedtnaeounsicontnedanuwneadtn 49 344 FI WattOn MAS Kaaa aeaaeae aeaaea aa aaa a aaa aaa aa aaa aaRS E aaan E in 49 4 EEPROM Programming Interface Functions sssseeeeeeeeeeeeeee 50 Bl PRAGA EE A E 50 4 2 FT WriteBE ciiin a aa aa aaa 50 43 FT EraseBE inna eaa aA Ea iaa eaaa iaa 51 4 4 PU EE ROA isinira arana 51 4 5 FI EE R adEX snn rara a raaraa aaa aaa aai 53 ee od Me a cide e oe eee 54 47 FY EE Progra ly wiissitstsiitnatiiiiitatii is ees 57 48 FI al a ee eee ec eee eee 58 BO PIES WARM T o a E a 59 4 10 FT EE UAWritE iacecicats seieuateansacdiaaceuctin ach daabaacetlsateanehadesunbeanuaceiuadecasaakeacaleoumaguilinn 61 4 11 FE BE
125. uture Technology Devices International Limited 14 zg FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 iA EN Chip Clearance No FTDI 170 Remarks The parameter specified in pvArg1 depends on dwFlags if dwFlags is FT_ OPEN BY SERIAL NUMBER pvArg1 is interpreted as a pointer to a null terminated string that represents the serial number of the device if dwFlags is FT OPEN BY DESCRIPTION pvArg1 is interpreted as a pointer to a null terminated string that represents the device description if dwFlags is FT OPEN BY LOCATION pvArg1 is interpreted as a long value that contains the location ID of the device Please note that Windows CE and Linux do not support location IDs ftHandle is a pointer to a variable of type FT_HANDLE where the handle is to be stored This handle must be used to access the device Examples The examples that follow use these variables FT STATUS ftStatus FT STATUS ftStatus2 FT HANDLE ftHandlel FT HANDLE ftHandle2 long dwLoc 1 Open a device with serial number FTO00001 ftStatus FT _OpenEx FT000001 FT OPEN BY SERIAL NUMBER amp ftHandlel if ftStatus FT OK success device with serial number FTO000001 is open else failure 2 Open a device with device description USB Serial Converter ftStatus FT OpenEx USB Serial Converter FT OPEN BY DESCRIPTION amp ftHandlel if ftStatus
126. ux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the baud rate for the device Definition Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 Clearance No FTDI 170 FT_STATUS FT_SetBaudRate FT_HANDLE ftHandle DWORD dwBaudRate Parameters ftHandle Handle of the device dwBaudRate Baud rate Return Value FT_OK if successful otherwise the return value is an FT error code Example FT_HANDLE ftHandle FT_STATUS ftStatus ftStatus FT_Open 0 amp ftHandle if ftStatus FT_OK FT Open failed return ftStatus FT SetBaudRate ftHandle 115200 if ftStatus FT_OK FT SetBaudRate OK else FT _SetBaudRate Failed FT Close ftHandle Set baud rate to 115200 Copyright 2011 Future Technology Devices International Limited 20 S FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A SS Chip Clearance No FTDI 170 3 13 FT_SetDivisor Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the baud rate for the device It is used to set non standard baud rates Definition FT_STATUS FT_SetDivisor FT_HANDLE ftHandle USHORT usDivisor Parameters ftHandle Handle of the device usDivisor Divisor Return Value FT_OK if successful otherwise the re
127. vices OK serial number is in Buffer else FT ListDevices failed Note that indexes are zero based If more than one device is connected incrementing devIndex will get the serial number of each connected device in turn 3 Get device descriptions of all devices currently connected char BufPtrs 3 pointer to array of 3 pointers char Bufferl 64 buffer for description of first device char Buffer2 64 buffer for description of second device initialize the array of pointers BufPtrs 0 Bufferl BufPtrs 1 Buffer2 BufPtrs 2 NULL last entry should be NULL Copyright 2011 Future Technology Devices International Limited 12 sF FTDI Document Reference No FT_000071 z D2XX Programmer s Guide Version 1 3 A SSN Chip Clearance No FTDI 170 ftStatus FT ListDevices BufPtrs amp numDevs FT LIST ALL FT OPEN BY DESCRIPTION if ftStatus FT OK FT _ListDevices OK product descriptions are in Bufferl and Buffer2 and numDevs contains the number of devices connected else FT ListDevices failed Note that this example assumes that two devices are connected If more devices are connected then the size of the array of pointers must be increased and more description buffers allocated 4 Get locations of all devices currently connected long locIdBuf 16 ftStatus FT ListDevices locIdBuf amp numDevs FT LIST AL
128. x00000020 DSR is high else DSR is low if RxBytes gt 0 call FT _Read to get received data from device FT Close ftHandle 3 29 FT_SetChars Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary This function sets the special characters for the device Definition FT_STATUS FT_SetChars FT_HANDLE ftHandle UCHAR uEventCh UCHAR uEventChEn UCHAR uErrorCh UCHAR uErrorChEn Parameters ftHandle Handle of the device uEventCh Event character uEventChEn 0 if event character disabled non zero otherwise uErrorCh Error character uErrorChEn 0 if error character disabled non zero otherwise Return Value FT_OK if successful otherwise the return value is an FT error code Remarks Copyright 2011 Future Technology Devices International Limited 37 A FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A Ss Chip Clearance No FTDI 170 This function allows for inserting specified characters in the data stream to represent events firing or errors occurring Copyright 2011 Future Technology Devices International Limited 38 pe 3 30 FT_SetBreakOn Supported Operating Systems Linux Mac OS X 10 4 and later Windows 2000 and later Windows CE 4 2 and later Summary Sets the BREAK condition for the device Definition FT_STATUS FT_SetBreakOn FT_HANDLE ftHandle Param
129. ypedef struct ft_eeprom_4232h Common header FT_EEPROM_HEADER common common elements for all device EEPROMs Drive options UCHAR ASlowSlew non zero if A pins have slow slew UCHAR ASchmittInput non zero if A pins are Schmitt input UCHAR ADriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR BSlowSlew non zero if B pins have slow slew UCHAR BSchmittInput non zero if B pins are Schmitt input UCHAR BDriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR CSlowSlew non zero if C pins have slow slew UCHAR CSchmittInput non zero if C pins are Schmitt input UCHAR CDriveCurrent valid values are 4mA 8mA 12mA 16mA UCHAR DSlowSlew non zero if D pins have slow slew UCHAR DSchmittInput non zero if D pins are Schmitt input UCHAR DDriveCurrent valid values are 4mA 8mA 12mA 16mA Hardware options UCHAR ARIIsTXDEN non zero if port A uses RI as RS485 TXDEN UCHAR BRIIsTXDEN non zero if port B uses RI as RS485 TXDEN UCHAR CRIISTXDEN non zero if port C uses RI as RS485 TXDEN UCHAR DRIIsTXDEN non zero if port D uses RI as RS485 TXDEN Driver option UCHAR ADriverType UCHAR BDriverType UCHAR CDriverType UCHAR DDriverType FT_EEPROM_4232H PFT_EEPROM_4232H FT232H EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program typedef struct ft_eeprom_232h EE ee NO Copyright 2011 Future Technology Devices International Limited 106 MET
130. ytesWritten contains the number of bytes actually written and the function returns a non zero value Copyright 2011 Future Technology Devices International Limited 78 sS FTDI Document Reference No FT_000071 D2XX Programmer s Guide Version 1 3 A Chip Clearance No FTDI 170 An application should always use the function return value and pdwBytesWritten If the return value is non zero and pdwBytesWritten is equal to dwBytesToWrite then the function has completed normally If the return value is non zero and pdwBytesWritten is less then dwBytesToWrite then a timeout has occurred and the write request has been partially completed Note that if a timeout occurred and no data was written the return value is still non zero Overlapped I O When the device has been opened for overlapped I O an application can issue a request and perform some additional work while the request is pending This contrasts with the case of non overlapped I O in which the application issues a request and receives control again only after the request has been completed The parameter pOverlapped must point to an initialized OVERLAPPED structure This function completes immediately and the return code is zero signifying an error An application should call FT W32 GetLastError to get the cause of the error If the error code is ERROR_IO_PENDING the overlapped operation is still in progress and the application can perform other processing Eventually t
Download Pdf Manuals
Related Search
Related Contents
INSTALLATION AND OPERATING INSTRUCTIONS Bedienungsanleitung - HiFi ISTRUZIONI PER L`USO CONFIGURAZIONE STRADALE ご注文の勇者ですか? - タテ書き小説ネット GHG602BL Curtis IP202UK User's Manual Handbuch P110i Manual do utilizador 商標法における認証・証明マークの保護の 在り方に関する調査研究報告書 Russell Hobbs 18941-70 electrical kettle Copyright © All rights reserved.
Failed to retrieve file