EasyManua.ls Logo

FTDI LibFT4222 - I 2 C Master Write

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
48
Product Page
Document Feedback Copyright © Future Technology Devices International Limited
Error code:
FT4222_DEVICE_NOT_OPENED: The initialization API is not called.
FT4222_IS_NOT_I2C_MODE: The device is not in i2c slave mode
FT4222_INVALID_POINTER: Parameter buffer is NULL
FT4222_INVALID_PARAMETER: bytesToRead is equal to zero
FT4222_FAILED_TO_READ_DEVICE: Failed to read 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 slave_data[4];
uint16 sizeTransferred = 0;
// read 4 bytes data from master
ft4222Status = FT4222_I2CMaster_Read(ftHandle, slaveAddr, slave_data, sizeof(slave_data),
&sizeTransferred);
if (FT4222_OK == ft4222Status)
{
// read data success
}
else
{
// read data failed
}
FT4222_UnInitialize(ftHandle);
FT_Close(ftHandle);
3.6.3 I
2
C Master Write
FT4222_STATUS FT4222_I2CMaster_Write(FT_HANDLE ftHandle, uint16 slaveAddress, uint8*
buffer, uint16 bytesToWrite, uint16* sizeTransferred)
Supported Chip:
FT4222 chip version
Supported
FT4222 Rev A
YES
FT4222 Rev B
YES

Table of Contents