public class Spi
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
HAS_CS |
static int |
MAX_FRAME_SIZE |
static int |
MAX_TIMEOUT |
static int |
NO_CS |
static int |
SPI_POL0_PHA0 |
static int |
SPI_POL0_PHA1 |
static int |
SPI_POL1_PHA0 |
static int |
SPI_POL1_PHA1 |
Constructor and Description |
---|
Spi(int spiFrequency,
int spiMode,
int spiUseCs)
Creates a Master Spi interface at the specified frequency.
|
Spi(int target,
int spiFrequency,
int spiMode,
int spiUseCs)
Creates a Master Spi interface at the specified frequency.
|
Modifier and Type | Method and Description |
---|---|
int |
fill(byte[] buffer,
int numberOfTimes)
Sends the provided buffer repeatedly.
|
int |
readBytes(byte[] buffer,
int length,
int timeout)
Read the requested bytes through the SPI port and store them in the given buffer.
|
int |
sendBitMap(byte[] bitmap,
int width,
int height,
int scaling,
short colorOn,
short colorOff)
Transforms the given bitmap, replacing every bit (MSB to LSB) by the corresponding colorOn / colorOff short value.
|
int |
writeBytes(byte[] buffer,
int length,
int timeout)
Write the given buffer through the SPI port
|
int |
writeReadBytes(byte[] bufferTx,
byte[] bufferRx,
int length,
int timeout)
Write and read the requested bytes through the SPI port and store them in the given buffer.
|
public static final int MAX_FRAME_SIZE
public static final int MAX_TIMEOUT
public static final int SPI_POL0_PHA0
public static final int SPI_POL0_PHA1
public static final int SPI_POL1_PHA0
public static final int SPI_POL1_PHA1
public static final int NO_CS
public static final int HAS_CS
public Spi(int spiFrequency, int spiMode, int spiUseCs)
spiFrequency
- the frequency of the SPI clockspiMode
- the polarity and the phase of the SPI (should 0,1,2 or 3.spiUseCs
- 1 when the /CS pin is used, 0 when it is not connectedpublic Spi(int target, int spiFrequency, int spiMode, int spiUseCs)
target
- spiFrequency
- the frequency of the SPI clockspiMode
- the polarity and the phase of the SPI (should 0,1,2 or 3.spiUseCs
- 1 when the /CS pin is used, 0 when it is not connectedpublic int writeReadBytes(byte[] bufferTx, byte[] bufferRx, int length, int timeout)
buffer
- the buffer that will receive the datalength
- the number of bytes to readtimeout
- (used when usecs==1)public int readBytes(byte[] buffer, int length, int timeout)
buffer
- the buffer that will receive the datalength
- the number of bytes to readtimeout
- (used when usecs==1)public int writeBytes(byte[] buffer, int length, int timeout)
buffer
- the buffer to writelength
- the number of bytes to write (should be less or equal to buffer.length)timeout
- (used when usecs==1)public int fill(byte[] buffer, int numberOfTimes)
buffer
- numberOfTimes
- public int sendBitMap(byte[] bitmap, int width, int height, int scaling, short colorOn, short colorOff)
bitmap
- Bitmap to send through SPI. Each bit of each byte, from most signifcant to least significant,
are interpreted as consecutive pixels (on or off) of the output, leftwidth
- height
- scaling
- colorOn
- colorOff
-