com.ftdi.j2xx.ft4222

## Class FT_4222_I2c_Master

- java.lang.Object
- - com.ftdi.j2xx.ft4222.FT_4222_I2c_Master

- All Implemented Interfaces:
    I2cMaster

      public class FT_4222_I2c_Master
      extends java.lang.Object
      implements I2cMaster

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FT_4222_I2c_Master(FT_4222_Device ft4222Device)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getStatus(int deviceAddress, byte[] controllerStatus)` Read the status of the I2C master controller.
    `int` | `init(int kbps)` Initialize the FT4222H as an I2C master with the requested I2C speed.
    `int` | `read(int deviceAddress, byte[] buffer, int sizeToTransfer, int[] sizeTransferred)` Read data from the specified I2C slave device with START and STOP conditions.
    `int` | `readEx(int deviceAddress, int flag, byte[] buffer, int sizeToTransfer, int[] sizeTransferred)` Read data from the specified I2C slave device with the specified I2C condition.
    `int` | `reset()` Reset the I2C master device.
    `int` | `write(int deviceAddress, byte[] buffer, int sizeToTransfer, int[] sizeTransferred)` Write data to the specified I2C slave device with START and STOP conditions
    `int` | `writeEx(int deviceAddress, int flag, byte[] buffer, int sizeToTransfer, int[] sizeTransferred)` Write data to the specified I2C slave device with the specified I2C condition.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FT_4222_I2c_Master

          public FT_4222_I2c_Master(FT_4222_Device ft4222Device)

  - ### Method Detail

    - #### init

          public int init(int kbps)

      Initialize the FT4222H as an I2C master with the requested I2C speed.
      Specified by:
        `init` in interface `I2cMaster`
      Parameters:
        `kbps` - The speed of I2C transmission. It ranges from 60K bps to 3400K bps. By specified speed, the initial function helps to setup bus speed with the corresponding mode.
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

    - #### reset

          public int reset()

      Reset the I2C master device.
      Specified by:
        `reset` in interface `I2cMaster`
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

    - #### read

          public int read(int deviceAddress,
                 byte[] buffer,
                 int sizeToTransfer,
                 int[] sizeTransferred)

      Read data from the specified I2C slave device with START and STOP conditions.
      Specified by:
        `read` in interface `I2cMaster`
      Parameters:
        `deviceAddress` - Address of the target I2C slave.
        `buffer` - Buffer array that receives the data from the device.
        `sizeToTransfer` - Number of bytes to read from the device.
        `sizeTransferred` - The actual number of bytes read from the device.
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

    - #### readEx

          public int readEx(int deviceAddress,
                   int flag,
                   byte[] buffer,
                   int sizeToTransfer,
                   int[] sizeTransferred)

      Read data from the specified I2C slave device with the specified I2C condition. This function is supported by the rev B FT4222H or later.
      Specified by:
        `readEx` in interface `I2cMaster`
      Parameters:
        `deviceAddress` - Address of the target I2C slave.
        `flag` - The I2C condition will be sent with this I2C transaction. flags is a bit-mask of `FT_4222_Defines.I2C_MasterFlag.NONE`, `FT_4222_Defines.I2C_MasterFlag.START`, `FT_4222_Defines.I2C_MasterFlag.Repeated_START`, `FT_4222_Defines.I2C_MasterFlag.STOP` and `FT_4222_Defines.I2C_MasterFlag.START_AND_STOP`.
        `buffer` - Buffer array that receives the data from the device.
        `sizeToTransfer` - Number of bytes to read from the device.
        `sizeTransferred` - The actual number of bytes read from the device.
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

    - #### write

          public int write(int deviceAddress,
                  byte[] buffer,
                  int sizeToTransfer,
                  int[] sizeTransferred)

      Write data to the specified I2C slave device with START and STOP conditions
      Specified by:
        `write` in interface `I2cMaster`
      Parameters:
        `deviceAddress` - Address of the target I2C slave.
        `buffer` - Buffer array that contains the data to be written to the device.
        `sizeToTransfer` - Number of bytes to write to the device.
        `sizeTransferred` - The actual number of bytes written to the device.
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

    - #### writeEx

          public int writeEx(int deviceAddress,
                    int flag,
                    byte[] buffer,
                    int sizeToTransfer,
                    int[] sizeTransferred)

      Write data to the specified I2C slave device with the specified I2C condition. This function is supported by the rev B FT4222H or later.
      Specified by:
        `writeEx` in interface `I2cMaster`
      Parameters:
        `deviceAddress` - Address of the target I2C slave.
        `flag` - The I2C condition will be sent with this I2C transaction. flags is a bit-mask of `FT_4222_Defines.I2C_MasterFlag.NONE`, `FT_4222_Defines.I2C_MasterFlag.START`, `FT_4222_Defines.I2C_MasterFlag.Repeated_START`, `FT_4222_Defines.I2C_MasterFlag.STOP` and `FT_4222_Defines.I2C_MasterFlag.START_AND_STOP`.
        `buffer` - Buffer array that contains the data to be written to the device.
        `sizeToTransfer` - Number of bytes to write to the device.
        `sizeTransferred` - The actual number of bytes written to the device.
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

    - #### getStatus

          public int getStatus(int deviceAddress,
                      byte[] controllerStatus)

      Read the status of the I2C master controller. This can be used to poll a slave until its write-cycle is complete.
      Specified by:
        `getStatus` in interface `I2cMaster`
      Parameters:
        `deviceAddress` - Address of the target I2C slave.
        `controllerStatus` - Buffer array that contains the to be return status data.
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

About FTDI | FTDI Licence Terms