public class SPI
extends Object
Modifier and Type | Field and Description |
---|---|
static int |
LSBFIRST
least significant bit first
|
static int |
MODE0
CPOL=0, CPHA=0, most common
|
static int |
MODE1
CPOL=0, CPHA=1
|
static int |
MODE2
CPOL=1, CPHA=0
|
static int |
MODE3
CPOL=1, CPHA=1
|
static int |
MSBFIRST
most significant bit first, most common
|
Constructor and Description |
---|
SPI(String dev)
Opens an SPI interface as master
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the SPI interface
|
static String[] |
list()
Lists all available SPI interfaces
|
void |
settings(int maxSpeed,
int dataOrder,
int mode)
Configures the SPI interface
|
byte[] |
transfer(byte out)
Transfers data over the SPI bus
|
byte[] |
transfer(byte[] out)
Transfers data over the SPI bus
|
byte[] |
transfer(int out)
Transfers data over the SPI bus
|
byte[] |
transfer(String out)
Transfers data over the SPI bus
|
public static final int MODE0
public static final int MODE1
public static final int MODE2
public static final int MODE3
public static final int MSBFIRST
public static final int LSBFIRST
public SPI(String dev)
dev
- device namelist
public void close()
public static String[] list()
public void settings(int maxSpeed, int dataOrder, int mode)
maxSpeed
- maximum transmission rate in Hz, 500000 (500 kHz) is a resonable defaultdataOrder
- whether data is send with the first- or least-significant bit first (SPI.MSBFIRST or SPI.LSBFIRST, the former is more common)mode
- SPI.MODE0 to SPI.MODE3public byte[] transfer(byte[] out)
out
- bytes to sendpublic byte[] transfer(String out)
out
- string to sendpublic byte[] transfer(int out)
out
- single byte to send, e.g. numeric literal (0 to 255, or -128 to 127)public byte[] transfer(byte out)
out
- single byte to send