EasyManua.ls Logo

FTDI LibFT4222 - I 2 C Master Read Extension

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
51
Product Page
Document Feedback Copyright © Future Technology Devices International Limited
FT4222_INVALID_POINTER: Parameter buffer is NULL
FT4222_INVALID_PARAMETER: bytesToWrite is equal to zero
FT4222_FAILED_TO_WRITE_DEVICE: Failed to write data.
Prerequisite:
FT4222_I2CMaster_Init
Example:
FT_HANDLE ftHandle = NULL;
FT_STATUS ftStatus;
FT4222_STATUS ft4222Status;
ftStatus = FT_Open(0, &ftHandle);
if (FT_OK != ftStatus)
{
// open failed
return;
}
// initial i2c master with 1000K bps
ft4222Status = FT4222_I2CMaster_Init(ftHandle, 1000);
if (FT4222_OK != ft4222Status)
{
// i2c master init failed
return;
}
const uint16 slaveAddr = 0x22;
uint8 write_req[1];
uint8 recvBuf[16];
uint16 sizeTransferred = 0;
write_req[0] = 0x00; // addr
ft4222Status = FT4222_I2CMaster_WriteEx(ftHandle, slaveAddr, START, &write_req[0], 1,
&sizeTransferred);
if (FT4222_OK == ft4222Status)
{
// write data success
}
else
{
// write data failed
}
ft4222Status = FT4222_I2CMaster_ReadEx(ftHandle,slaveAddr, Repeated_START | STOP,
&recvBuf[0], 16, &sizeTransferred);
if (FT4222_OK == ft4222Status)
{
// read data success
}
else
{
// read data failed
}
FT4222_UnInitialize(ftHandle);
FT_Close(ftHandle);
3.6.5 I
2
C Master Read Extension
FT4222_STATUS FT4222_I2CMaster_ReadEx(FT_HANDLE ftHandle, uint16 deviceAddress, uint8
flag, uint8* buffer, uint16 bytesToRead, uint16* sizeTransferred).

Table of Contents