com.LabJack
Class GenericSPI

java.lang.Object
  extended bycom.LabJack.GenericSPI
All Implemented Interfaces:
SPI

public class GenericSPI
extends java.lang.Object
implements SPI

This class represents a generic SPI device consisting of a single block of contiguous bits.

This class can be used to drive any SPI device. For devices containing more than one set of internal control or data bits, you can control the device via bit-twiddling. An alternative is to define multiple Generic() objects corresponding to individual control or data bit fields. Lastly, you could define your own class implementing the SPI interface and provide custom methods to manipulate bits behind the scenes.


Constructor Summary
GenericSPI(int numberOfBits)
          Constructor.
 
Method Summary
 int getBits()
          Returns the read-back bits for this device, if any.
 int getNumberOfBits()
          This is an 'internal' method.
 int getOutBits()
          This is an 'internal' method.
 void setBits(int bits)
          Sets the out-going bits for this device, if any.
 void setInBits(int inBits)
          This is an 'internal' method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericSPI

public GenericSPI(int numberOfBits)
Constructor.

Parameters:
numberOfBits - Length of this SPI device.
Method Detail

getBits

public int getBits()
Returns the read-back bits for this device, if any.

Specified by:
getBits in interface SPI
Returns:
Read-back bits.

setBits

public void setBits(int bits)
Sets the out-going bits for this device, if any.

Specified by:
setBits in interface SPI
Parameters:
bits - Outgoing bits.

getNumberOfBits

public int getNumberOfBits()
This is an 'internal' method. It is used by the LabJackWrapper class to obtain the number of bits for this SPI device (ex. # of bits in shift-register).

Specified by:
getNumberOfBits in interface SPI
Returns:
Length of this SPI device.

getOutBits

public int getOutBits()
This is an 'internal' method. It is used by the LabJackWrapper class to obtain the out-going bits.

Specified by:
getOutBits in interface SPI
Returns:
The out-going bits to be sent to the SPI device.

setInBits

public void setInBits(int inBits)
This is an 'internal' method. It is used by the LabJackWrapper class to set the incomming bits.

Specified by:
setInBits in interface SPI
Parameters:
inBits - Bits read from SPI device.