|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SPISlave
The SPISlave
interface provides methods for transmitting and receiving
data to/from an SPI slave device.
SPISlave
instance can be retrieved by a call to SPIManager.getSlave(int)
or SPIManager.getSlave(java.lang.String)
.
On an SPI bus, data is transferred between the SPI master device and an SPI slave device
in full duplex. That is, data is transmitted by the SPI master to the SPI slave
at the same time data is received from the SPI slave by the SPI master.
To perform such an exchange of data with an SPI slave, an application may use
one of the exchange
methods.
write
or the read
method, respectively. When writing only, the data received from the SPI slave will be ignored/discarded.
When reading only, dummy data will be sent to the slave.
A data exchange consists of words of a certain length which may vary from SPI slave to SPI slave.
InvalidWordLengthException
will be thrown. For example, if the word length is 16bits and the designated portion of buffer
is only 1-byte long or is 3-byte long an InvalidWordLengthException
will be thrown.
SPISlave.close()
method
to release the SPI slave. Any further attempt to transmit/write or receive/read to/from an SPI slave which has been
released will result in a PeripheralNotAvailableException
been thrown.
Note that the appropriate SPI clock frequency, polarity and phase as well as finer slave select line handling
(whether it remains asserted during a series of word exchanges), the endianness, the word length and the dummy writing data
for exchanging data with a particular SPI slave device are set by
the platform.
SPIManager
,
SPIPermission
,
InvalidWordLengthException
,
PeripheralNotAvailableException
Method Summary | |
int |
getWordLength()
Gets the transfer word length in bits supported by this slave device. |
int |
read()
Reads one data word of up to 32 bits from this slave device. |
int |
read(byte[] rxBuf,
int rxOff,
int rxLen)
|
int |
read(int rxSkip,
byte[] rxBuf,
int rxOff,
int rxLen)
|
void |
write(byte[] txBuf,
int txOff,
int txLen)
Transmits/writes data to this slave device. |
void |
write(int txData)
Writes one data word of up to 32 bits to this slave device. |
int |
writeAndRead(byte[] txBuf,
int txOff,
int txLen,
byte[] rxBuf,
int rxOff,
int rxLen)
|
int |
writeAndRead(byte[] txBuf,
int txOff,
int txLen,
int rxSkip,
byte[] rxBuf,
int rxOff,
int rxLen)
Send and Receive data. |
int |
writeAndRead(int txData)
Exchanges (transmits and receives) one data word of up to 32 bits with this slave device. |
Methods inherited from interface com.oracle.deviceaccess.Peripheral |
close, getID, getName |
Method Detail |
int writeAndRead(byte[] txBuf, int txOff, int txLen, byte[] rxBuf, int rxOff, int rxLen) throws java.io.IOException, PeripheralNotAvailableException
txBuf
- - the buffer containing the bytes to send.txOff
- - the offset in txBuf of the first byte to send.txLen
- - the number of bytes from txBuf to send.rxBuf
- - the buffer for the received bytes.rxOff
- - the offset in rxBuf where to start copying the bytes received.rxLen
- - the number of bytes to receive.
java.io.IOException
- - if an IO error occurred.
InvalidWordLengthException
- - if the numbers of bytes to send or to receive bely word length.
java.lang.NullPointerException
- - If txBuf or rxBuf is null.
java.lang.IndexOutOfBoundsException
- - txOff, txLen, rxOff or rxLen points or results in pointing outside txBuf or rxBuf.
PeripheralNotAvailableException
- - if the peripheral is not currently available (has been released).int writeAndRead(byte[] txBuf, int txOff, int txLen, int rxSkip, byte[] rxBuf, int rxOff, int rxLen) throws java.io.IOException, PeripheralNotAvailableException
txBuf
- - the buffer containing the bytes to send.txOff
- - the offset in txBuf of the first byte to send.txLen
- - the number of bytes from txBuf to send.rxSkip
- - the number of received bytes that must be ignored/skipped before filling in the rxBuf buffer.rxBuf
- - buffer for the received bytes.rxOff
- - the offset in rxBuf where to start copying the bytes received.rxLen
- - the number of bytes to receive.
java.io.IOException
- - if an IO error occurred.
InvalidWordLengthException
- - if the numbers of bytes to send or to receive bely word length.
java.lang.NullPointerException
- - If txBuf or rxBuf is null.
java.lang.IndexOutOfBoundsException
- - txOff, txLen, rxOff or rxLen points or results in pointing outside txBuf or rxBuf.
PeripheralNotAvailableException
- - if the peripheral is not currently available (has been released).int writeAndRead(int txData) throws java.io.IOException, PeripheralNotAvailableException
txData
- - the word to send.
java.io.IOException
- - if an IO error occurred.
InvalidWordLengthException
- - if the numbers of bytes to send or to receive bely word length; that is this slave's word length is bigger than 32 bits.
PeripheralNotAvailableException
- - if the peripheral is not currently available (has been released).void write(byte[] txBuf, int txOff, int txLen) throws java.io.IOException, PeripheralNotAvailableException
txBuf
- - the buffer containing the bytes to send.txOff
- - the offset in txBuf of the first byte to send.txLen
- - the number of bytes from txBuf to send.
java.io.IOException
- - if an IO error occurred.
InvalidWordLengthException
- - if the number of bytes to send belies word length.
java.lang.NullPointerException
- - If txBuf is null.
java.lang.IndexOutOfBoundsException
- - txOff or txLen points or results in pointing outside txBuf.
PeripheralNotAvailableException
- - if the peripheral is not currently available (has been released).void write(int txData) throws java.io.IOException, PeripheralNotAvailableException
txData
- - the data word to be written
java.io.IOException
- - if an I/O error occurred
InvalidWordLengthException
- - if the numbers of bytes to send bely word length; that is this slave's word length is bigger than 32 bits.
PeripheralNotAvailableException
- - if the peripheral is not currently available (has been released).int read(byte[] rxBuf, int rxOff, int rxLen) throws java.io.IOException, PeripheralNotAvailableException
rxBuf
- - buffer for the received bytes.rxOff
- - the offset in rxBuf where to start copying the bytes received.rxLen
- - the number of bytes to receive.
java.io.IOException
- - if an IO error occurred.
InvalidWordLengthException
- - if the numbers of bytes to send or to receive bely word length.
java.lang.NullPointerException
- - If rxBuf is null.
java.lang.IndexOutOfBoundsException
- - rxOff or rxLen points or results in pointing outside rxBuf.
PeripheralNotAvailableException
- - if the peripheral is not currently available (has been released).int read(int rxSkip, byte[] rxBuf, int rxOff, int rxLen) throws java.io.IOException, PeripheralNotAvailableException
rxSkip
- - the number of received bytes that must be ignored/skipped before filling in the rxBuf buffer.rxBuf
- - buffer for the received bytes.rxOff
- - the offset in rxBuf where to start copying the bytes received.rxLen
- - the number of bytes to receive.
java.io.IOException
- - if an I/O error occurred
PeripheralNotAvailableException
- - if the peripheral is not currently available (has been released).int read() throws java.io.IOException, PeripheralNotAvailableException
java.io.IOException
- - if an I/O error occurs.
InvalidWordLengthException
- - if the numbers of bytes to receive bely word length; that is this slave's word length is bigger than 32 bits.
PeripheralNotAvailableException
- - if the peripheral is not currently available (has been released).int getWordLength()
|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |