Application Note
AN_329 User Guide For LibFT4222
Version 1.5
Document Reference No.: FT_001060 Clearance No.: FTDI#406
30
Product Page
Document Feedback Copyright © Future Technology Devices International Limited
FT4222_SPIMaster_init
Example:
// This example is for mxic flash to read out RDSR(read status register)
// bit0 (WIP: write in progress bit). When WIP bit sets to 1, which means the device is
//busy in program/erase/write status register progress
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[2];
uint8 readData[2];
uint16 sizeTransferred;
// for mxic flash,
//byte 0: read status command
//byte 1: status
sendData[0] = 0x05; // read status command
sendData[1] = 0xFF; // a dummy byte,
ft4222Status = FT4222_SPIMaster_SingleReadWrite(ftHandle, &readData[0], &sendData[0], 2,
&sizeTransferred, true);
if((ft4222Status!=FT4222_OK) || (sizeTransferred!=2))
{
// single read write failed
return ;
}
if ((readData[1] & 0x01) == 0x00)
{
// not in writing operation
}
else
{
// still in writing process
}
FT4222_UnInitialize(ftHandle);
FT_Close(ftHandle);