Menu

SPISample

Stephen Davies

SPI Quickstart

int clockRate = 1000000;
Device[] devices = FTDIInterface.getDevices();

if (devices.length == 0) {
    // Error handling
}

Device dev = devices[0];
Spi spi = new Spi(dev, clockRate, SpiMode.M0, false);
spi.open();

// Write a single byte to the SPI bus
byte[] result = spi.transactReadWrite(new byte[] { (byte) 0xA5 });

spi.close();