FT_4222_Spi_Slave

com.ftdi.j2xx.ft4222

## Class FT_4222_Spi_Slave

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

- All Implemented Interfaces:
    SpiSlave

      public class FT_4222_Spi_Slave
      extends java.lang.Object
      implements SpiSlave

  FTDI SPI Slave Interface

  Example:

  init

  ----------------------------------------------------

  mSPISlave = mFT4222Device0.getSpiSlaveDevice();

  mSPISlave.init();

  FT_4222_Spi_Slave ft4222_spi_ext = (FT_4222_Spi_Slave) mSPISlave;

  if(ft4222_spi_ext != null)

  ft4222_spi_ext.setDrivingStrength(SPI_DrivingStrength.DS_12MA, SPI_DrivingStrength.DS_16MA, SPI_DrivingStrength.DS_16MA);

  polling

  -----------------------------------------------------

  public void Slave_Poll()

  {

  String output = "";

  //byte [] rdBuf = mSPISlave.read();

  int [] rxStatus = new int[1];

  mSPISlave.getRxStatus(rxStatus);

  if(rxStatus[0] > 0)

  {

  byte [] rdBuf = new byte[rxStatus[0]];

  int [] rdSize = new int[1];

  mSPISlave.read(rdBuf, rdBuf.length, rdSize);

  String outputText = "";

  byte [] wrBuf = new byte[rdSize[0]];

  for(int i=0; i < wrBuf.length ; i++)

  {

  //wrBuf[i] = (byte)(i & 0xff);

  int val = (byte)(rdBuf[i] & 0xff);

  wrBuf[i] = rdBuf[i];

  }

  int ret = mSPISlave.write(wrBuf, wrBuf.length, rdSize);

  if(wrBuf.length != rdSize[0])

  Log.d("FTDI", "send ="+wrBuf.length+" tx="+rdSize[0]);

  }

  }

  Version:
    1.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FT_4222_Spi_Slave(FT_4222_Device pDevice)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getRxStatus(int[] pRxSize)` Get number of bytes in the receive queue.
    `int` | `init()` Initialize FT4222H as SPI slave.
    `int` | `read(byte[] buffer, int bufferSize, int[] sizeOfRead)` Get number of bytes in the receive queue.
    `int` | `reset()` Reset the SPI slave device.
    `int` | `setDrivingStrength(int clkStrength, int ioStrength, int ssoStregth)` For the FT4222H SPI Slave, set the driving strength of clk, io, and sso pins.
    `int` | `write(byte[] buffer, int bufferSize, int[] sizeTransferred)` Write data to the transmit queue of the SPI slave device.

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

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

- - ### Constructor Detail

    - #### FT_4222_Spi_Slave

          public FT_4222_Spi_Slave(FT_4222_Device pDevice)

  - ### Method Detail

    - #### init

          public int init()

      Initialize FT4222H as SPI slave.
      Specified by:
        `init` in interface `SpiSlave`
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

    - #### getRxStatus

          public int getRxStatus(int[] pRxSize)

      Get number of bytes in the receive queue.
      Specified by:
        `getRxStatus` in interface `SpiSlave`
      Parameters:
        `iSpiIdx` - number of bytes in the receive queue.
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

    - #### read

          public int read(byte[] buffer,
                 int bufferSize,
                 int[] sizeOfRead)

      Get number of bytes in the receive queue.
      Specified by:
        `read` in interface `SpiSlave`
      Parameters:
        `buffer` - buffer that receives the data from the device.
        `bufferSize` - number of bytes to read from the device.
        `sizeOfRead` - 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(byte[] buffer,
                  int bufferSize,
                  int[] sizeTransferred)

      Write data to the transmit queue of the SPI slave device.
      Specified by:
        `write` in interface `SpiSlave`
      Parameters:
        `buffer` - buffer that contains the data to be written to the device.
        `bufferSize` - number of bytes to read from the device.
        `sizeTransferred` - number of bytes written to the device.
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

    - #### reset

          public int reset()

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

    - #### setDrivingStrength

          public int setDrivingStrength(int clkStrength,
                               int ioStrength,
                               int ssoStregth)

      For the FT4222H SPI Slave, set the driving strength of clk, io, and sso pins.
      Parameters:
        `clkStrength` - The driving strength of the clk pin
        `ioStrength` - The driving strength of the io pin
        `ssoStregth` - The driving strength of the sso pin
      Returns:
        FT4222_OK if successful, otherwise the return value is an FT error code.

About FTDI | FTDI Licence Terms