Class DefaultNativeSpiDevice
java.lang.Object
com.diozero.internal.spi.AbstractDevice
com.diozero.internal.provider.builtin.DefaultNativeSpiDevice
- All Implemented Interfaces:
DeviceInterface
,SpiDeviceInterface
,Closeable
,AutoCloseable
public class DefaultNativeSpiDevice extends AbstractDevice implements SpiDeviceInterface
-
Constructor Summary
Constructors Constructor Description DefaultNativeSpiDevice(DeviceFactoryInterface deviceFactory, String key, int controller, int chipSelect, int frequency, SpiClockMode spiClockMode, boolean lsbFirst)
-
Method Summary
Modifier and Type Method Description protected void
closeDevice()
int
getChipSelect()
Get the SPI Chip Selectint
getController()
Get the SPI controllervoid
write(byte... txBuffer)
Write the entire contents ofdata
to the devicevoid
write(byte[] txBuffer, int txOffset, int length)
Writelength
bytes fromdata
starting atoffset
byte[]
writeAndRead(byte... txBuffer)
Write thedata
to the device then readdata.length
bytes from the deviceMethods inherited from class com.diozero.internal.spi.AbstractDevice
close, getDeviceFactory, getKey, isOpen
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.diozero.api.DeviceInterface
close, getKey, isOpen
-
Constructor Details
-
DefaultNativeSpiDevice
public DefaultNativeSpiDevice(DeviceFactoryInterface deviceFactory, String key, int controller, int chipSelect, int frequency, SpiClockMode spiClockMode, boolean lsbFirst)
-
-
Method Details
-
closeDevice
- Specified by:
closeDevice
in classAbstractDevice
- Throws:
RuntimeIOException
-
getController
public int getController()Description copied from interface:SpiDeviceInterface
Get the SPI controller- Specified by:
getController
in interfaceSpiDeviceInterface
- Returns:
- the SPI controller
-
getChipSelect
public int getChipSelect()Description copied from interface:SpiDeviceInterface
Get the SPI Chip Select- Specified by:
getChipSelect
in interfaceSpiDeviceInterface
- Returns:
- the SPI chip select
-
write
public void write(byte... txBuffer)Description copied from interface:SpiDeviceInterface
Write the entire contents ofdata
to the device- Specified by:
write
in interfaceSpiDeviceInterface
- Parameters:
txBuffer
- the data to write
-
write
public void write(byte[] txBuffer, int txOffset, int length)Description copied from interface:SpiDeviceInterface
Writelength
bytes fromdata
starting atoffset
- Specified by:
write
in interfaceSpiDeviceInterface
- Parameters:
txBuffer
- the data to write.txOffset
- the start offset in the data.length
- the number of bytes to write.
-
writeAndRead
Description copied from interface:SpiDeviceInterface
Write thedata
to the device then readdata.length
bytes from the device- Specified by:
writeAndRead
in interfaceSpiDeviceInterface
- Parameters:
txBuffer
- the data to write.- Returns:
- the data read from the device, same length as the data written.
- Throws:
RuntimeIOException
- if an I/O error occurs
-