ioio.lib.impl
Class SpiMasterImpl
java.lang.Object
ioio.lib.impl.AbstractResource
ioio.lib.impl.SpiMasterImpl
- All Implemented Interfaces:
- Closeable, SpiMaster
public class SpiMasterImpl
- extends AbstractResource
- implements SpiMaster
Method Summary |
void |
close()
|
void |
dataReceived(byte[] data,
int size)
|
void |
disconnected()
|
void |
reportAdditionalBuffer(int bytesRemaining)
|
void |
send(ioio.lib.impl.FlowControlledPacketSender.Packet packet)
|
void |
writeRead(byte[] writeData,
int writeSize,
int totalSize,
byte[] readData,
int readSize)
Shorthand for SpiMaster.writeRead(int, byte[], int, int, byte[], int) for
the single-slave case. |
void |
writeRead(int slave,
byte[] writeData,
int writeSize,
int totalSize,
byte[] readData,
int readSize)
Perform a single SPI transaction which includes optional transmission and
optional reception of data to a single slave. |
SpiMasterImpl.SpiResult |
writeReadAsync(int slave,
byte[] writeData,
int writeSize,
int totalSize,
byte[] readData,
int readSize)
The same as SpiMaster.writeRead(int, byte[], int, int, byte[], int) , but
returns immediately and returns a SpiMaster.Result object that can be
waited on. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
disconnected
public void disconnected()
- Overrides:
disconnected
in class AbstractResource
writeRead
public void writeRead(int slave,
byte[] writeData,
int writeSize,
int totalSize,
byte[] readData,
int readSize)
throws ConnectionLostException,
java.lang.InterruptedException
- Description copied from interface:
SpiMaster
- Perform a single SPI transaction which includes optional transmission and
optional reception of data to a single slave. This is a blocking
operation that can take a few milliseconds to a few tens of milliseconds.
To abort this operation, client can interrupt the blocked thread. If
readSize is 0, the call returns immediately.
- Specified by:
writeRead
in interface SpiMaster
- Parameters:
slave
- The slave index. It is determined by the index of its
slave-select pin, as per the array passed to
IOIO#openSpiMaster(Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec[], Config)
.writeData
- A byte array of data to write. May be null if writeSize is 0.writeSize
- Number of bytes to write. Valid values are 0 to totalSize.totalSize
- Total transaction length, in bytes. Valid values are 1 to 64.readData
- An array where the response is to be stored. May be null if
readSize is 0.readSize
- The number of expected response bytes. Valid values are 0 to
totalSize.
- Throws:
ConnectionLostException
- Connection to the IOIO has been lost.
java.lang.InterruptedException
- Calling thread has been interrupted.
writeReadAsync
public SpiMasterImpl.SpiResult writeReadAsync(int slave,
byte[] writeData,
int writeSize,
int totalSize,
byte[] readData,
int readSize)
throws ConnectionLostException
- Description copied from interface:
SpiMaster
- The same as
SpiMaster.writeRead(int, byte[], int, int, byte[], int)
, but
returns immediately and returns a SpiMaster.Result
object that can be
waited on. If readSize is 0, the result object is ready immediately.
- Specified by:
writeReadAsync
in interface SpiMaster
- Throws:
ConnectionLostException
- See Also:
SpiMaster.writeRead(int, byte[], int, int, byte[], int)
writeRead
public void writeRead(byte[] writeData,
int writeSize,
int totalSize,
byte[] readData,
int readSize)
throws ConnectionLostException,
java.lang.InterruptedException
- Description copied from interface:
SpiMaster
- Shorthand for
SpiMaster.writeRead(int, byte[], int, int, byte[], int)
for
the single-slave case.
- Specified by:
writeRead
in interface SpiMaster
- Throws:
ConnectionLostException
java.lang.InterruptedException
- See Also:
SpiMaster.writeRead(int, byte[], int, int, byte[], int)
dataReceived
public void dataReceived(byte[] data,
int size)
reportAdditionalBuffer
public void reportAdditionalBuffer(int bytesRemaining)
close
public void close()
- Specified by:
close
in interface Closeable
- Overrides:
close
in class AbstractResource
send
public void send(ioio.lib.impl.FlowControlledPacketSender.Packet packet)