Application Note
AN_329 User Guide For LibFT4222
Version 1.5
Document Reference No.: FT_001060 Clearance No.: FTDI#406
28
Product Page
Document Feedback Copyright © Future Technology Devices International Limited
If TRUE the Slave Select pin will be raised at the end of the write.
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_INVALID_POINTER: Pointer is a NULL pointer.
FT4222_IS_NOT_SPI_SINGLE_MODE: Device is not in SPI Master Single mode
FT4222_FAILED_TO_WRITE_DEVICE: Write data timeout or failed. FT_SetTimeouts can be called
to extend timeout.
FT4222_FAILED_TO_READ_DEVICE: Failed to read data.
Prerequisite:
FT4222_SPIMaster_init
Example:
FT_HANDLE ftHandle = NULL;
FT_STATUS ftStatus;
FT4222_STATUS ft4222Status;
ftStatus = FT_Open(0, &ftHandle);
if (FT_OK != ftStatus)
{
// open failed
return;
}
ft4222Status = FT4222_SPIMaster_Init(ftHandle, SPI_IO_SINGLE, CLK_DIV_4, CLK_IDLE_LOW,
CLK_LEADING, 0x01);
if (FT4222_OK != ft4222Status)
{
// spi master init failed
return;
}
uint8 sendData[10];
uint16 sizeTransferred;
for(int idx=0;idx<10;idx++)
sendData[idx] = idx;
ft4222Status = FT4222_SPIMaster_SingleWrite(ftHandle, &sendData[0], 10, &sizeTransferred,
true);
if (FT4222_OK != ft4222Status)
{
// spi master write failed
return;
}
FT4222_UnInitialize(ftHandle);
FT_Close(ftHandle);
3.3.5 SPI Master Single Read and Write
FT4222_STATUS FT4222_SPIMaster_SingleReadWrite(FT_HANDLE ftHandle, uint8* readBuffer,
uint8* writeBuffer, uint16 sizeToTransfer, uint16* sizeTransferred, BOOL isEndTransaction)