ioio.lib.impl
Class TwiMasterImpl

java.lang.Object
  extended by ioio.lib.impl.AbstractResource
      extended by ioio.lib.impl.TwiMasterImpl
All Implemented Interfaces:
Closeable, TwiMaster

public class TwiMasterImpl
extends AbstractResource
implements TwiMaster


Nested Class Summary
 
Nested classes/interfaces inherited from interface ioio.lib.api.TwiMaster
TwiMaster.Rate, TwiMaster.Result
 
Method Summary
 void close()
           
 void dataReceived(byte[] data, int size)
           
 void disconnected()
           
 void reportAdditionalBuffer(int bytesRemaining)
           
 void send(ioio.lib.impl.FlowControlledPacketSender.Packet packet)
           
 boolean writeRead(int address, boolean tenBitAddr, byte[] writeData, int writeSize, byte[] readData, int readSize)
          Perform a single TWI transaction which includes optional transmission and optional reception of data to a single slave.
 TwiMaster.Result writeReadAsync(int address, boolean tenBitAddr, byte[] writeData, int writeSize, byte[] readData, int readSize)
          Asynchronous version of TwiMaster.writeRead(int, boolean, byte[], int, byte[], int).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

disconnected

public void disconnected()
Overrides:
disconnected in class AbstractResource

writeRead

public boolean writeRead(int address,
                         boolean tenBitAddr,
                         byte[] writeData,
                         int writeSize,
                         byte[] readData,
                         int readSize)
                  throws ConnectionLostException,
                         java.lang.InterruptedException
Description copied from interface: TwiMaster
Perform a single TWI 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.

Specified by:
writeRead in interface TwiMaster
Parameters:
address - The slave address, either 7-bit or 10-bit. Note that in some TWI device documentation the documented addresses are actually 2x the address values used here, as they regard the trailing 0-bit as part of the address.
tenBitAddr - Whether this is a 10-bit addressing mode.
writeData - The request data.
writeSize - The number of bytes to write. Valid value are 0-255.
readData - The array where the response should be stored.
readSize - The expected number of response bytes. Valid value are 0-255.
Returns:
Whether operation succeeded.
Throws:
ConnectionLostException - Connection to the IOIO has been lost.
java.lang.InterruptedException - Calling thread has been interrupted.

writeReadAsync

public TwiMaster.Result writeReadAsync(int address,
                                       boolean tenBitAddr,
                                       byte[] writeData,
                                       int writeSize,
                                       byte[] readData,
                                       int readSize)
                                throws ConnectionLostException
Description copied from interface: TwiMaster
Asynchronous version of TwiMaster.writeRead(int, boolean, byte[], int, byte[], int). Returns immediately and provides a TwiMaster.Result object on which the client can wait for the result.

Specified by:
writeReadAsync in interface TwiMaster
Throws:
ConnectionLostException
See Also:
TwiMaster.writeRead(int, boolean, byte[], 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)