EasyManua.ls Logo

FTDI LibFT4222 - Page 41

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
40
Product Page
Document Feedback Copyright © Future Technology Devices International Limited
Supported Chip:
FT4222 chip version
Supported
FT4222 Rev A
YES
FT4222 Rev B
YES
FT4222 Rev C
YES
FT4222 Rev D
YES
Summary:
Read data from the receive queue of the SPI slave device.
Parameters:
ftHandle
Handle of the device.
buffer
Pointer to the buffer that receives the data from the device.
bytesToRead
Number of bytes to read from the device.
sizeOfRead
Pointer to a variable of type uint16 which receives the number of bytes read from
the device.
Return Value:
FT4222_OK if successful, otherwise the return value is an FT error code.
Error code:
FT4222_DEVICE_NOT_OPENED: The initialization API is not called
FT4222_DEVICE_NOT_SUPPORTED: This device is not a FT4222 chip.
FT4222_IS_NOT_SPI_MODE: The device is not in spi slave mode.
FT4222_INVALID_POINTER: The parameter buffer or sizeOfRead is NULL.
FT4222_INVALID_PARAMETER: Parameter bytesToRead is equal to zero.
Prerequisite:
FT4222_SPISlave_InitEx or FT4222_SPISlave_Init
Example:
FT_HANDLE ftHandle = NULL;
FT_STATUS ftStatus;
FT4222_STATUS ft4222Status;
ftStatus = FT_OpenEx("FT4222 A",FT_OPEN_BY_DESCRIPTION, &ftHandle);
if (FT_OK != ftStatus)
{
// open failed
return;
}
if (FT4222_OK != FT4222_SPISlave_InitEx(ftHandle, SPI_SLAVE_NO_PROTOCOL))
{
// init spi slave failed
return;
}
uint16 sizeTransferred = 0;
uint16 rxSize;
std::vector<unsigned char> recvBuf;
while(1)
{
if(FT4222_SPISlave_GetRxStatus(ftHandle, &rxSize) == FT4222_OK)
{

Table of Contents