public interface 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]);
}
}
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 master or slave device.
|
int |
write(byte[] buffer,
int bufferSize,
int[] sizeTransferred)
Write data to the transmit queue of the SPI slave device.
|
int init()
int getRxStatus(int[] pRxSize)
iSpiIdx
- number of bytes in the receive queue.int read(byte[] buffer, int bufferSize, int[] sizeOfRead)
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.int write(byte[] buffer, int bufferSize, int[] sizeTransferred)
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.int reset()