| java.lang.Object | |
| ↳ | com.digi.android.spi.SPI |
This class allows the user to manage SPI devices. This interaction is performed via the corresponding native library that interfaces directly with the kernel.
Each object of this class is created for a determined SPI interface and SPI slave device.
To obtain an instance of the SPI interface you have to use the
SPIManager.createSPI(int, int) method.
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Attempts to close the SPI interface.
| |||||||||||
Gets the SPI configuration.
| |||||||||||
Gets the SPI interface number.
| |||||||||||
Gets the SPI slave device number.
| |||||||||||
Gets the status of the SPI interface.
| |||||||||||
Opens the SPI interface with the given configuration.
| |||||||||||
Reads the specified number of bytes from the SPI slave device.
| |||||||||||
Changes the configuration of the SPI.
| |||||||||||
Simultaneous write (of the given bytes) and read (of the same number of
bytes) using the default clock frequency and word length parameters.
| |||||||||||
Simultaneous write (of the given bytes) and read (of the same number of
bytes) using the given clock frequency and word length parameters (these
parameters are only used for this transfer, but their default values
remain the same).
| |||||||||||
Writes the given bytes in the SPI slave device.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||||
Attempts to close the SPI interface.
| Throws | |
|---|---|
IOException |
If there is an error closing the SPI interface. |
See also:
Gets the SPI interface number.
| Returns | |
|---|---|
int |
The SPI interface in use. |
Gets the SPI slave device number.
| Returns | |
|---|---|
int |
The SPI slave device. |
Gets the status of the SPI interface.
| Returns | |
|---|---|
boolean |
true if interface is open, false if not. |
See also:
Opens the SPI interface with the given configuration.
| Parameters | |
|---|---|
config |
SPIConfig: SPI configuration. |
| Throws | |
|---|---|
IOException |
If there is an error opening the SPI interface. |
NoSuchInterfaceException |
If the configured SPI interface does not exist. |
NullPointerException |
If config == null. |
See also:
Reads the specified number of bytes from the SPI slave device.
| Parameters | |
|---|---|
numBytes |
int: Amount of bytes to read. |
| Returns | |
|---|---|
byte[] |
The read bytes, null if error. |
| Throws | |
|---|---|
IllegalArgumentException |
If numBytes < 0. |
IOException |
If the interface is closed or there is an error reading from the SPI slave device. |
See also:
Changes the configuration of the SPI.
| Parameters | |
|---|---|
config |
SPIConfig: New SPI configuration. |
| Throws | |
|---|---|
IOException |
If the interface is closed or there is an error changing the configuration. |
NullPointerException |
If config == null. |
Simultaneous write (of the given bytes) and read (of the same number of bytes) using the default clock frequency and word length parameters.
| Parameters | |
|---|---|
txData |
byte: Bytes to write. |
| Returns | |
|---|---|
byte[] |
The read bytes, null if error. |
| Throws | |
|---|---|
IOException |
If the interface is closed or there is an error transferring data. |
NullPointerException |
If txData == null. |
Simultaneous write (of the given bytes) and read (of the same number of bytes) using the given clock frequency and word length parameters (these parameters are only used for this transfer, but their default values remain the same).
| Parameters | |
|---|---|
txData |
byte: Bytes to write. |
clockFrequency |
int: The clock frequency in Hz. |
wordLength |
int: Number of bits per word. |
| Returns | |
|---|---|
byte[] |
The read bytes, null if error. |
| Throws | |
|---|---|
IllegalArgumentException |
If clockFrequency < 1 o
if wordLength < 1. |
IOException |
If the interface is closed or there is an error transferring data. |
NullPointerException |
If txData == null. |
Writes the given bytes in the SPI slave device.
| Parameters | |
|---|---|
txData |
byte: Bytes to write. |
| Throws | |
|---|---|
IOException |
If the interface is closed or there is an error writing in the SPI slave device. |
NullPointerException |
If txData == null. |
See also:
| Throws | |
|---|---|
Throwable |
|