public class SpiDeviceImpl extends Object implements SpiDevice
Modifier and Type | Field and Description |
---|---|
protected SpiChannel |
channel |
protected SpiMode |
mode |
DEFAULT_SPI_MODE, DEFAULT_SPI_SPEED, MAX_SUPPORTED_BYTES
Constructor and Description |
---|
SpiDeviceImpl(SpiChannel channel)
Creates the SPI Device at the given SPI and input channel
(A default speed of 1 MHz will be used)
|
SpiDeviceImpl(SpiChannel channel,
int speed)
Creates the SPI Device at the given spi and input channel
|
SpiDeviceImpl(SpiChannel channel,
int speed,
SpiMode mode)
Creates the SPI Device at the given spi and input channel
|
SpiDeviceImpl(SpiChannel channel,
SpiMode mode)
Creates the SPI Device at the given SPI and input channel
(A default speed of 1 MHz will be used)
|
Modifier and Type | Method and Description |
---|---|
byte[] |
write(byte... data)
Attempts to read/write data through this SPI device
|
byte[] |
write(byte[] data,
int start,
int length)
Attempts to read/write data through this SPI device
|
ByteBuffer |
write(ByteBuffer data)
Attempts to read/write data through this SPI device
|
byte[] |
write(InputStream input)
Attempts to read/write data through this SPI device
|
int |
write(InputStream input,
OutputStream output)
Attempts to read/write data through this SPI device
|
short[] |
write(short... data)
Attempts to read/write data through this SPI device
|
short[] |
write(short[] data,
int start,
int length)
Attempts to read/write data through this SPI device
|
String |
write(String data,
Charset charset)
Attempts to read/write data through this SPI device
|
String |
write(String data,
String charset)
Attempts to read/write data through this SPI device
|
protected final SpiChannel channel
public SpiDeviceImpl(SpiChannel channel, int speed, SpiMode mode) throws IOException
channel
- spi channel to usespeed
- spi speed/rate (in Hertz) for channel to communicate at
(range is 500kHz - 32MHz)mode
- spi mode (see http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Mode_numbers)IOException
public SpiDeviceImpl(SpiChannel channel, int speed) throws IOException
channel
- spi channel to usespeed
- spi speed/rate (in Hertz) for channel to communicate at
(range is 500kHz - 32MHz)IOException
public SpiDeviceImpl(SpiChannel channel, SpiMode mode) throws IOException
channel
- spi channel to usemode
- spi mode (see http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Mode_numbers)IOException
public SpiDeviceImpl(SpiChannel channel) throws IOException
channel
- spi channel to useIOException
public String write(String data, String charset) throws IOException
SpiDevice
write
in interface SpiDevice
data
- bytes (encoded in string) to write to the SPI devicecharset
- character encoding for bytes in stringIOException
public String write(String data, Charset charset) throws IOException
SpiDevice
write
in interface SpiDevice
data
- bytes (encoded in string) to write to the SPI devicecharset
- character encoding for bytes in stringIOException
public ByteBuffer write(ByteBuffer data) throws IOException
SpiDevice
write
in interface SpiDevice
data
- bytes to write to the SPI deviceIOException
public byte[] write(InputStream input) throws IOException
SpiDevice
write
in interface SpiDevice
input
- input stream to read from to get
bytes to write to the SPI deviceIOException
public int write(InputStream input, OutputStream output) throws IOException
SpiDevice
write
in interface SpiDevice
input
- input stream to read from to get
bytes to write to the SPI deviceoutput
- output stream to write bytes
read from the SPI deviceIOException
public byte[] write(byte... data) throws IOException
SpiDevice
write
in interface SpiDevice
data
- bytes to write to the SPI deviceIOException
public short[] write(short... data) throws IOException
SpiDevice
write
in interface SpiDevice
data
- bytes to write to the SPI device (Note: short value should not exceed 255.)IOException
public byte[] write(byte[] data, int start, int length) throws IOException
SpiDevice
write
in interface SpiDevice
data
- bytes to write to the SPI devicestart
- start index position in the data buffer to start writing fromlength
- length of bytes to write from the data bufferIOException
public short[] write(short[] data, int start, int length) throws IOException
SpiDevice
write
in interface SpiDevice
data
- bytes to write to the SPI devicestart
- start index position in the data buffer to start writing fromlength
- length of bytes to write from the data bufferIOException
Copyright © 2012–2019 Pi4J. All rights reserved.