Application Note
AN_329 User Guide For LibFT4222
Version 1.5
Document Reference No.: FT_001060 Clearance No.: FTDI#406
8
Product Page
Document Feedback Copyright © Future Technology Devices International Limited
2 Getting Started
A LibFT4222 application usually starts with FT_CreateDeviceInfoList and FT_GetDeviceInfoList as a
traditional D2XX application does. Under different chip modes, FT_CreateDeviceInfoList reports a
different number of interfaces as shown in the table below.
a. The first interface: it can be one of SPI master, SPI slave, I
2
C master,
or I
2
C slave device.
b. The second interface: GPIO device.
a. The first 3 interfaces: SPI master connects up to 3 SPI slaves.
b. The 4
th
interface: GPIO device.
a. SPI master connects up to 4 SPI slaves. Please refer figure 1.4.
FT4222H works as SPI master.
a. it can be one of SPI master, SPI slave, I
2
C master, or I
2
C slave device.
Table 2.1 Chip Mode and Device Functions
After opening the device with FT_Open, developers need to initialize the FT4222H device as either
SPI master, SPI slave, I
2
C master, or I
2
C slave. Different types of device require different
configurations. For more details, please refer the next chapter.
Following example code shows FT4222H works in SPI master mode.
Example#
include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include "ftd2xx.h"
#include "LibFT4222.h"
std::vector< FT_DEVICE_LIST_INFO_NODE > g_FT4222DevList;
inline std::string DeviceFlagToString(DWORD flags)
{
std::string msg;
msg += (flags & 0x1)? "DEVICE_OPEN" : "DEVICE_CLOSED";
msg += ", ";
msg += (flags & 0x2)? "High-speed USB" : "Full-speed USB";
return msg;
}
void ListFtUsbDevices()
{
DWORD numOfDevices = 0;
FT_STATUS status = FT_CreateDeviceInfoList(&numOfDevices);
for(DWORD iDev=0; iDev<numOfDevices; ++iDev)
{
FT_DEVICE_LIST_INFO_NODE devInfo;
memset(&devInfo, 0, sizeof(devInfo));
status = FT_GetDeviceInfoDetail(iDev,
&devInfo.Flags, &devInfo.Type, &devInfo.ID, &devInfo.LocId,
devInfo.SerialNumber, devInfo.Description, &devInfo.ftHandle);
if (FT_OK == status)