Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class SpiDevice

  1. Object
  2. SpiDevice
A device on an SPI bus, opened through Hardware.openSpi(int, int, int, int, int).

Methods

public int getBus()The SPI controller number.
public int getChipSelect()The chip-select line.
public byte[] transfer(byte[] tx) throws HardwareExceptionClocks tx out and returns the bytes clocked in at the same time.
public void transfer(byte[] tx, byte[] rx) throws HardwareExceptionClocks tx out while filling rx; both must be the same length, and may be the same array.
public void close()Releases the device.

Inherited methods

Method details

getBus

public int getBus()
The SPI controller number.

getChipSelect

public int getChipSelect()
The chip-select line.

transfer

public byte[] transfer(byte[] tx) throws HardwareException
Clocks tx out and returns the bytes clocked in at the same time.

Throws

HardwareException
when the transfer fails or the device is closed

transfer

public void transfer(byte[] tx, byte[] rx) throws HardwareException
Clocks tx out while filling rx; both must be the same length, and may be the same array.

Throws

HardwareException
when the transfer fails or the device is closed

close

public void close()
Releases the device. Closing twice is harmless.