com.ftdi.j2xx.interfaces

## Interface SpiMaster

- All Known Implementing Classes:
    FT_4222_Spi_Master

      public interface SpiMaster

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `init(int ioLine, int clock, int cpol, int cpha, byte ssoMap)` Initialize the device as an SPI master.
    `int` | `multiReadWrite(byte[] readBuffer, byte[] writeBuffer, int singleWriteBytes, int multiWriteBytes, int multiReadBytes, int[] sizeOfRead)` Under SPI dual or quad mode, write data to and read data from an SPI slave.
    `int` | `reset()` Reset the SPI master device.
    `int` | `setLines(int spiMode)` Switch the SPI master to single, dual, or quad lines.
    `int` | `singleRead(byte[] readBuffer, int sizeToTransfer, int[] sizeOfRead, boolean isEndTransaction)` Under SPI single mode, read data from an SPI slave.
    `int` | `singleReadWrite(byte[] readBuffer, byte[] writeBuffer, int sizeToTransfer, int[] sizeTransferred, boolean isEndTransaction)` Under SPI single mode, full-duplex write data to and read data from an SPI slave.
    `int` | `singleWrite(byte[] writeBuffer, int sizeToTransfer, int[] sizeTransferred, boolean isEndTransaction)` Under SPI single mode, write data to an SPI slave.

- - ### Method Detail

    - #### init

          int init(int ioLine,
                 int clock,
                 int cpol,
                 int cpha,
                 byte ssoMap)

      Initialize the device as an SPI master.
      Parameters:
        `ioLine` - SPI transmission lines
        `clock` - Clock divider
        `cpol` - Clock polarity
        `cpha` - Clock phase
        `ssoMap` - Slave selection output pins
      Returns:
        0 if successful, otherwise the return value is an FT error code.

    - #### reset

          int reset()

      Reset the SPI master device.
      Returns:
        0 if successful, otherwise the return value is an FT error code.

    - #### setLines

          int setLines(int spiMode)

      Switch the SPI master to single, dual, or quad lines.
      Parameters:
        `spiMode` - SPI mode could be: SPI_IO_SINGLE , SPI_IO_DUAL, SPI_IO_QUAD
      Returns:
        0 if successful, otherwise the return value is an FT error code.

    - #### singleWrite

          int singleWrite(byte[] writeBuffer,
                        int sizeToTransfer,
                        int[] sizeTransferred,
                        boolean isEndTransaction)

      Under SPI single mode, write data to an SPI slave.
      Parameters:
        `writeBuffer` - buffer that contains the data to be written to the device.
        `sizeToTransfer` - The size of read and write buffer. They must be the same.
        `sizeTransferred` - Pointer to a variable of type uint16 which receives the number of bytes read and written to the device.
        `isEndTransaction` - TRUE to raise the pin of SS at the end of the transaction
      Returns:
        0 if successful, otherwise the return value is an FT error code.

    - #### singleRead

          int singleRead(byte[] readBuffer,
                       int sizeToTransfer,
                       int[] sizeOfRead,
                       boolean isEndTransaction)

      Under SPI single mode, read data from an SPI slave.
      Parameters:
        `readBuffer` - buffer that receives the data from the device
        `sizeToTransfer` - The size of read and write buffer. They must be the same.
        `sizeTransferred` - Pointer to a variable of type uint16 which receives the number of bytes read and written to the device.
        `isEndTransaction` - TRUE to raise the pin of SS at the end of the transaction
      Returns:
        0 if successful, otherwise the return value is an FT error code.

    - #### singleReadWrite

          int singleReadWrite(byte[] readBuffer,
                            byte[] writeBuffer,
                            int sizeToTransfer,
                            int[] sizeTransferred,
                            boolean isEndTransaction)

      Under SPI single mode, full-duplex write data to and read data from an SPI slave.
      Parameters:
        `readBuffer` - buffer that receives the data from the device
        `writeBuffer` - buffer that contains the data to be written to the device.
        `sizeToTransfer` - The size of read and write buffer. They must be the same.
        `sizeTransferred` - Pointer to a variable of type uint16 which receives the number of bytes read and written to the device.
        `isEndTransaction` - TRUE to raise the pin of SS at the end of the transaction
      Returns:
        0 if successful, otherwise the return value is an FT error code.

    - #### multiReadWrite

          int multiReadWrite(byte[] readBuffer,
                           byte[] writeBuffer,
                           int singleWriteBytes,
                           int multiWriteBytes,
                           int multiReadBytes,
                           int[] sizeOfRead)

      Under SPI dual or quad mode, write data to and read data from an SPI slave.
      Parameters:
        `readBuffer` - buffer that receives the data from the device.
        `writeBuffer` - buffer that contains the data to be written to the device. .
        `singleWriteBytes` - number of bytes in writeBuffer will be written as single-line.
        `multiWriteBytes` - number of bytes in writeBuffer will be written as multi-line.
        `multiReadBytes` - number of bytes to read as multi-line.
        `sizeOfRead` - number of bytes read from the device.
      Returns:
        0 if successful, otherwise the return value is an FT error code.

About FTDI | FTDI Licence Terms