Application Note
AN_329 User Guide For LibFT4222
Version 1.5
Document Reference No.: FT_001060 Clearance No.: FTDI#406
34
Product Page
Document Feedback Copyright © Future Technology Devices International Limited
of “0x00” as the first byte for every transmission. This is an internal sync byte that is needs to be
removed by the SPI Master.
SPI_SLAVE_WITH_PROTOCOL
The FT4222H and LibFT4222 design have implemented an SPI slave protocol which must be used
to handle the integrity of data transmission. The API “FT4222_SPISlave_Init” is used to initialize
the slave with this mode.
In this protocol, a master starts an SPI transaction by sending a packet in the format illustrated
below. The Sync Word “0x5A” is fixed with this slave mode and user applications do not need to do
any operations to add or remove the Sync Word. It is done by the support library.
Figure 3.4 SPI Slave Protocol Format
The packet starts with Sync word: 0x5A, and followed by a Command field:
Short master transfer (without checksum)
Short slave transfer (without checksum)
SN stands for serial number. It is monotonically increased, and helps to identify packets. Size is a
two-byte field, which is the size of the data field in big-endian order. The Checksum is the
summation of all data fields’ lower two bytes starting from the first byte, the sync word, to the
latest data byte.
The checksum is in big-endian order as well. When the slave, FT4222H, receives the transfer
request from the master, it will respond with an ACK. The master can confirm the transaction
succeeded when it receives the ACK from the slave.
When SPI Slave receives the Master transfer request, it will check if the format and checksum are
correct. If the answer is yes, the support-lib will send the response ACK automatically, grab the
data from the packet and send it to application.