public class SPI extends Interface
| Modifier and Type | Class and Description |
|---|---|
static class |
SPI.Port
Valid SPI ports on the RIO
|
Interface.InterfaceType| Modifier and Type | Field and Description |
|---|---|
private static boolean[] |
ALLOCATED_PORTS |
private int |
m_bitOrder |
private int |
m_clockPolarity |
private int |
m_dataOnTrailing |
private byte |
m_port |
m_ifaceType, MAX_ANALOG_IN_CHANNELS, MAX_ANALOG_OUT_CHANNELS, MAX_DIGITAL_CHANNELS, MAX_PWM_CHANNELS, MAX_RELAY_CHANNELS| Modifier and Type | Method and Description |
|---|---|
void |
free()
Free the resources used by this object
|
int |
read(java.lang.Boolean initiate,
byte[] data,
int size)
Read a word from the receive FIFO.
|
void |
setChipSelectActiveHigh()
Configure the chip select line to be active high.
|
void |
setChipSelectActiveLow()
Configure the chip select line to be active low.
|
void |
setClockActiveHight()
Configure the clock output line to be active high.
|
void |
setClockActiveLow()
Configure the clock output line to be active low.
|
void |
setClockRate(int hz)
Configure the rate of the generated clock signal.
|
void |
setLSBFirst()
Configure the order that bits are sent and received on the wire
to be least significant bit first.
|
void |
setMSBFirst()
Configure the order that bits are sent and received on the wire
to be most significant bit first.
|
void |
setSampleDataOnFalling()
Configure that the data is stable on the falling edge and the data
changes on the rising edge.
|
void |
setSampleDataOnRising()
Configure that the data is stable on the rising edge and the data
changes on the falling edge.
|
int |
transaction(byte[] dataSend,
byte[] dataGet,
int size)
Perform a simultaneous read/write transaction with the device
|
int |
write(byte[] data,
int size)
Write data to the slave device.
|
allocateMXPPin, checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPWMChannel, checkRelayChannel, freeMXPPin, getInterfaceTypeprivate int m_bitOrder
private final byte m_port
private int m_clockPolarity
private int m_dataOnTrailing
private static final boolean[] ALLOCATED_PORTS
public SPI(SPI.Port port)
port - the physical SPI portpublic final void free()
public final void setClockRate(int hz)
hz - The clock rate in Hertz.public final void setMSBFirst()
public final void setLSBFirst()
public final void setClockActiveLow()
public final void setClockActiveHight()
public final void setSampleDataOnFalling()
public final void setSampleDataOnRising()
public final void setChipSelectActiveHigh()
public final void setChipSelectActiveLow()
public final int write(byte[] data,
int size)
data - the data to writesize - the number of bytes to sendpublic final int read(java.lang.Boolean initiate,
byte[] data,
int size)
initiate - If true, this function pushes "0" into the
transmit buffer and initiates a transfer.
If false, this function assumes that data is
already in the receive FIFO from a previous write.data - the buffer to read intosize - the number of bytes to readpublic final int transaction(byte[] dataSend,
byte[] dataGet,
int size)
dataSend - The data to be written out to the devicedataGet - Buffer to receive data from the devicesize - The length of the transaction, in bytes