|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.comm.SPI
This class is a thin wrapper over a bit-bang SPI native library.
The bit-bang SPI port is implemented using pins ... (PCE0\-PCE3\) of
the DS80C390. This is a master only implementation.
P5.4 (PCE0\) = SSCK (Serial clock)
P5.5 (PCE1\) = MOSI (Master Out/Slave In)
P5.6 (PCE2\) = MISO (Master In/Slave Out)
P5.7 (PCE3\) = SS (Slave select)
setClockDelay
method.
Field Summary | |
static int |
DEFAULT_CLOCK_DELAY
|
static int |
MAX_CLOCK_DELAY
|
Constructor Summary | |
SPI()
Construct an SPI object with default configuration state which includes: DEFAULT_CLOCK_DELAY Allow skew i.e. |
|
SPI(int delay,
boolean noskew,
boolean use_ss,
boolean CPOL,
boolean CPHA,
boolean bitOrder,
boolean slaveSelectInvert,
boolean enableWordMode)
Construct an SPI object with all configuration state specified. |
Method Summary | |
void |
enableMinimumClockSkew(boolean noskew)
Disable interrupts during byte transfers to ensure a stable clock frequency. |
void |
enableSlaveSelect(boolean use_ss)
Enable the use of the SS (slave select) line during communication. |
void |
setBitOrder(boolean bitOrder)
Set the bit order that the SPI library will use during communication. |
void |
setClockDelay(int delay)
Specify the number of microseconds to delay between clock edges. |
void |
setPhase(boolean CPHA)
Select the Phase of the SCLK line. |
void |
setPolarity(boolean CPOL)
Select the Polarity of the SCLK line. |
void |
setSlaveSelectInvert(boolean slaveSelectInvert)
Sets the Invert option for Slave Select |
void |
setTransferSize(boolean enableWordMode)
Sets the transfer size |
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 |
Field Detail |
public static final int DEFAULT_CLOCK_DELAY
public static final int MAX_CLOCK_DELAY
Constructor Detail |
public SPI()
public SPI(int delay, boolean noskew, boolean use_ss, boolean CPOL, boolean CPHA, boolean bitOrder, boolean slaveSelectInvert, boolean enableWordMode)
delay
- # of microseconds of delay between clock edgesnoskew
- set to true to disable interrupts for strict clock ratesuse_ss
- set to true to enable use of the SS line
Note on noskew option: Do not attempt to use the noskew option of this
SPI library with a *Large* Data Array. Using noskew turns off interrupts
on TINI and will cause UNPREDICTABLE system behavior and watch dog reboots
if sending of a *Large* data array is attempted.CPOL
- set to true
forces SCLK to idle highCPHA
- set to true
sample on second SCLK edge
i.e. CPOL = 0 -> sample on falling edge; CPOL = 1 -> sample on rising edgebitOrder
- set to true
to use Least Significant Bit first transmissionslaveSelectInvert
- set to true
changes the SS line to be active highenableWordMode
- set to true
does 16 bit transfersMethod Detail |
public int xmit(byte[] ba, int off, int len)
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.ba
- source byte array, contains data to be written to the SPI slaveoff
- starting offset into ba
len
- number of bytes to write, if in word mode, this remains the number
of bytes, NOT the number of 16 bit words. Also when using word mode,
len of transfer must be an even number.public void setClockDelay(int delay) throws java.lang.IllegalArgumentException
delay
- The number of microseconds between clock edgesdelay
is negative
or greater than MAX_CLOCK_DELAY
.public void enableMinimumClockSkew(boolean noskew)
noskew
- set to true
to disable interruptspublic void enableSlaveSelect(boolean use_ss)
use_ss
- set to true
to force use of SS pinpublic void setPolarity(boolean CPOL)
CPOL
- set to true
forces SCLK to idle highpublic void setPhase(boolean CPHA)
CPHA
- set to true
sample on second SCLK edge
i.e. CPOL = 0 -> sample on falling edge; CPOL = 1 -> sample on rising edgepublic void setBitOrder(boolean bitOrder)
bitOrder
- set to true
to use Least Significant Bit first transmissionpublic void setSlaveSelectInvert(boolean slaveSelectInvert)
slaveSelectInvert
- set to true
, the SS line will be active high,
otherwise the SS line will be active low.public void setTransferSize(boolean enableWordMode)
enableWordMode
- set to true
, transfers 16 bits at a time,
otherwise 8 bits at a time
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |