All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sources.Spi Maven / Gradle / Ivy

/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 3.0.6
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package mraa;

public class Spi {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected Spi(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Spi obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        mraaJNI.delete_Spi(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public Spi(int bus) {
    this(mraaJNI.new_Spi__SWIG_0(bus), true);
  }

  public Spi(int bus, int cs) {
    this(mraaJNI.new_Spi__SWIG_1(bus, cs), true);
  }

  public Result mode(Spi_Mode mode) {
    return Result.swigToEnum(mraaJNI.Spi_mode(swigCPtr, this, mode.swigValue()));
  }

  public Result frequency(int hz) {
    return Result.swigToEnum(mraaJNI.Spi_frequency(swigCPtr, this, hz));
  }

  public int writeByte(short data) {
    return mraaJNI.Spi_writeByte(swigCPtr, this, data);
  }

  public int writeWord(int data) {
    return mraaJNI.Spi_writeWord(swigCPtr, this, data);
  }

  public byte[] write(byte[] txBuf) {
    return mraaJNI.Spi_write(swigCPtr, this, txBuf);
}

  public Result lsbmode(boolean lsb) {
    return Result.swigToEnum(mraaJNI.Spi_lsbmode(swigCPtr, this, lsb));
  }

  public Result bitPerWord(long bits) {
    return Result.swigToEnum(mraaJNI.Spi_bitPerWord(swigCPtr, this, bits));
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy