Class SpiExample
- java.lang.Object
-
- SpiExample
-
public class SpiExample extends Object
This example code demonstrates how to perform basic SPI communications using the Raspberry Pi. CS0 and CS1 (ship-select) are supported for SPI0.- Author:
- Robert Savage
-
-
Field Summary
Fields Modifier and Type Field Description static short
ADC_CHANNEL_COUNT
protected static Console
console
static SpiDevice
spi
-
Constructor Summary
Constructors Constructor Description SpiExample()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
getConversionValue(short channel)
Communicate to the ADC chip via SPI to get single-ended conversion value for a specified channel.static void
main(String[] args)
Sample SPI Programstatic void
read()
Read data via SPI bus from MCP3002 chip.
-
-
-
Method Detail
-
main
public static void main(String[] args) throws InterruptedException, IOException
Sample SPI Program- Parameters:
args
- (none)- Throws:
InterruptedException
IOException
-
read
public static void read() throws IOException, InterruptedException
Read data via SPI bus from MCP3002 chip.- Throws:
IOException
InterruptedException
-
getConversionValue
public static int getConversionValue(short channel) throws IOException
Communicate to the ADC chip via SPI to get single-ended conversion value for a specified channel.- Parameters:
channel
- analog input channel on ADC chip- Returns:
- conversion value for specified analog input channel
- Throws:
IOException
-
-