Class SPI400EM

java.lang.Object
  |
  +--SPI400EM

public class SPI400EM
extends java.lang.Object

This class is a thin wrapper over a SPI native library for the DS400em's SPI device This is a master only implementation. Data rate is either 1 or 2 MHz, depending on whether "divide" is set to one or not respectively


Constructor Summary
SPI400EM()
          Construct an SPI object with default configuration state which includes: No clock divider Use SS line 0 CPOL = 0 CPOL = 1
SPI400EM(boolean divide, int ss_channel, boolean CPOL, boolean CPHA)
          Construct an SPI object with all configuration state specified.
 
Method Summary
 void setPhase(boolean CPHA)
          Select the Phase of the SCLK line.
 void setPolarity(boolean CPOL)
          Select the Polarity of the SCLK line.
 void SlaveSelectChannel(int ss_channel)
          Change the SS line used for communication.
 int xmit(byte[] ba, int off, int len)
          Write len bytes of data to MOSI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SPI400EM

public SPI400EM()
Construct an SPI object with default configuration state which includes: No clock divider Use SS line 0 CPOL = 0 CPOL = 1


SPI400EM

public SPI400EM(boolean divide,
                int ss_channel,
                boolean CPOL,
                boolean CPHA)
Construct an SPI object with all configuration state specified.

Parameters:
divide - Use internal clock divider of 2 - true/false
ss_channel - SS channel to use, 0 through 2, 3 is the "off" state setting ss_channel to 3 will result in SS 3 being always on.
CPOL - set to true or false selects the polarity of the clock
CPHA - set to true or false selects the phase of the clock
Method Detail

xmit

public int xmit(byte[] ba,
                int off,
                int len)
Write len bytes of data to MOSI. Return data simultaneously read from MISO. Source data is contained in ba starting at off. Read data is returned in the same positions within the array.

Parameters:
ba - source byte array, contains data to be written to the SPI slave
off - starting offset into ba
len - number of bytes to write

SlaveSelectChannel

public void SlaveSelectChannel(int ss_channel)
Change the SS line used for communication. If The SS line is asserted before each read or write operation and deasserted immediately following the operation.

Parameters:
ss_channel - The SS channel to use 0-2

setPolarity

public void setPolarity(boolean CPOL)
Select the Polarity of the SCLK line. If set to true, the SCLK will idle high, otherwise the SCLK will idle low

Parameters:
CPOL - set to true forces SCLK to idle high

setPhase

public void setPhase(boolean CPHA)
Select the Phase of the SCLK line. If set to true, the SCLK will transition at the start of bit timing

Parameters:
CPHA - set to true forces SCLK to transition at start of bit timing