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]);
}
}
Constructor and Description |
---|
FT_4222_Spi_Slave(FT_4222_Device pDevice) |
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 |
setMode(int cpol,
int cpha)
Set SPI slave mode.
|
int |
setRxQuickResponse(boolean enable)
Adjust SPI Slave RX response method.
|
int |
write(byte[] buffer,
int bufferSize,
int[] sizeTransferred)
Write data to the transmit queue of the SPI slave device.
|
public FT_4222_Spi_Slave(FT_4222_Device pDevice)
public int init()
public int getRxStatus(int[] pRxSize)
getRxStatus
in interface SpiSlave
iSpiIdx
- number of bytes in the receive queue.public int read(byte[] buffer, int bufferSize, int[] sizeOfRead)
public int write(byte[] buffer, int bufferSize, int[] sizeTransferred)
write
in interface SpiSlave
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.public int reset()
public int setDrivingStrength(int clkStrength, int ioStrength, int ssoStregth)
clkStrength
- The driving strength of the clk pinioStrength
- The driving strength of the io pinssoStregth
- The driving strength of the sso pinpublic int setMode(int cpol, int cpha)
SpiSlave
public int setRxQuickResponse(boolean enable)
enable
- enable quick response mode