Class FrcSpiDevice


public class FrcSpiDevice extends TrcSerialBusDevice
This class implements a platform dependent SPI device. It extends TrcSerialBusDevice to provide asynchronous request queue support and creates the SPI device using WPILib.
  • Constructor Details

    • FrcSpiDevice

      public FrcSpiDevice(String instanceName, edu.wpi.first.wpilibj.SPI spi, boolean useRequestQueue)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      spi - specifies the SPI port the device is connected to.
      useRequestQueue - specifies true to use a request queue, false otherwise.
  • Method Details

    • readData

      public byte[] readData(int address, int length)
      This method is called to read data from the device with the specified length.
      Specified by:
      readData in class TrcSerialBusDevice
      Parameters:
      address - specifies the data address if any (not applicable for SPI).
      length - specifies the number of bytes to read.
      Returns:
      a byte array containing the data read.
    • writeData

      public int writeData(int address, byte[] buffer, int length)
      This method is called to write data to the device with the specified data buffer and length.
      Specified by:
      writeData in class TrcSerialBusDevice
      Parameters:
      address - specifies the data address if any (not applicable for SPI).
      buffer - specifies the buffer containing the data to be written to the device.
      length - specifies the number of bytes to write.
      Returns:
      number of bytes written.