EasyManua.ls Logo

FTDI LibFT4222 - SPI Slave Functions

Default Icon
78 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Application Note
AN_329 User Guide For LibFT4222
Version 1.5
Document Reference No.: FT_001060 Clearance No.: FTDI#406
33
Product Page
Document Feedback Copyright © Future Technology Devices International Limited
if (FT_OK != ftStatus)
{
// open failed
return;
}
ft4222Status = FT4222_SPIMaster_Init(ftHandle, SPI_IO_QUAD, CLK_DIV_4, CLK_IDLE_LOW,
CLK_LEADING, 0x01);
if (FT4222_OK != ft4222Status)
{
// spi master init failed
return;
}
uint8 writeData[7];
uint8 readData[16];
uint32 sizeOfRead;
// for mxic flash,
writeData[0] = 0xEB; // 4 x I/O Read Mode (4READ)
writeData[1] = (unsigned char)((_addr & 0xFF0000) >> 16); // for addr
writeData[2] = (unsigned char)((_addr & 0x00FF00) >> 8); // for addr
writeData[3] = (unsigned char)((_addr & 0x0000FF)); // for addr
writeData[4] = 0xFF; // dummy byte
writeData[5] = 0xFF; // dummy byte
writeData[6] = 0xFF; // dummy byte
ft4222Status = FT4222_SPIMaster_MultiReadWrite(ftHandle, readData, &writeData[0], 1, 6, 16,
&sizeOfRead);
if((ft4222Status!=FT4222_OK) || (sizeOfRead != 16))
{
// can not get correct data
return;
}
FT4222_UnInitialize(ftHandle);
FT_Close(ftHandle);
3.4 SPI Slave Functions
The FT4222H can be initialized as an SPI slave under mode 0 to mode 3. As an SPI slave, the
FT4222H only supports the standard single SPI transfer. Please refer to DS_FT4222H for more
details. SPI Slave function is not suitable on Android system. Garbage collection is a form of
automatic memory management. When garbage collection happens, it does not emit bulk-in
packet and RX data may be lost during this period of time
A USB-SPI bridge usually faces the challenge that USB cannot guarantee the throughput for each
endpoint, but SPI requires data transmission at a steady rate. It is highly possible when an SPI
master starts to request data from a USB-SPI slave bridge device, the data has not arrived from
the USB host side yet. In addition, SPI does not have a standard protocol to allow the master side
to check the status of the slave side. The protocol is usually provided by an SPI slave device on its
own, which makes the SPI master device communicate with the slave device by its specified
commands.
There are there methods to access FT4222 SPI Slave function.
SPI_SLAVE_WITH_PROTOCOL
SPI_SLAVE_NO_ACK
SPI_SLAVE_NO_PROTOCOL
With all the SPI Slave operational modes listed, the support library will always add a dummy byte

Table of Contents