C# Class CyrusBuilt.MonoPi.IO.SPI.SimpleSPI

A simplified SPI data access mechanism. This wraps the wiringPiSPI module in wiringPi, thus relies on wiringPi.so lib.
ファイルを表示 Open project: cyrusbuilt/MonoPi

Public Methods

Method Description
FullDuplexTransfer ( AdcChannels channel, String data ) : String

Write and read a block of data over the SPI bus. This is a full duplex operation.

GetFileDescriptor ( AdcChannels channel ) : Int32

Gets the file descriptor for the given channel.

Init ( AdcChannels channel ) : System.Boolean

Open the SPI device and set it up, etc, at the default speed (1000000).

Init ( AdcChannels channel, Int32 speed ) : System.Boolean

Open the SPI device and set it up, etc.

Read ( AdcChannels channel, Byte register ) : Byte

Reads a packet from the specified register over the specified channel.

Write ( AdcChannels channel, Byte register, Byte data ) : void

Write the specified data to the specified register on the specified channel.

Method Details

FullDuplexTransfer() public static method

Write and read a block of data over the SPI bus. This is a full duplex operation.
/// You initialize the SPI by calling Init() first. /// /// This module only supports a 2-channel device. Valid channels are /// and . ///
public static FullDuplexTransfer ( AdcChannels channel, String data ) : String
channel AdcChannels /// The channel to transfer on. ///
data String /// The data to transfer. ///
return String

GetFileDescriptor() public static method

Gets the file descriptor for the given channel.
public static GetFileDescriptor ( AdcChannels channel ) : Int32
channel AdcChannels /// The channel to get the descriptor for. ///
return System.Int32

Init() public static method

Open the SPI device and set it up, etc, at the default speed (1000000).
public static Init ( AdcChannels channel ) : System.Boolean
channel AdcChannels /// The channel to open. ///
return System.Boolean

Init() public static method

Open the SPI device and set it up, etc.
public static Init ( AdcChannels channel, Int32 speed ) : System.Boolean
channel AdcChannels /// The channel to open. ///
speed System.Int32 /// The speed to negotiate the transfer rate at (ie. 38400). ///
return System.Boolean

Read() public static method

Reads a packet from the specified register over the specified channel.
/// Failed to read from register. ///
public static Read ( AdcChannels channel, Byte register ) : Byte
channel AdcChannels /// The channel to comunicate with the target on. ///
register Byte /// The register to read the packet from. ///
return Byte

Write() public static method

Write the specified data to the specified register on the specified channel.
public static Write ( AdcChannels channel, Byte register, Byte data ) : void
channel AdcChannels /// The channel to communicate with the target on. ///
register Byte /// The register to write the data to. ///
data Byte /// The data to write. ///
return void