Show / Hide Table of Contents

    Class SpiDevice

    The communications channel to a device on a SPI bus.

    Inheritance
    Object
    SpiDevice
    Implements
    IDisposable
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: System.Device.Spi
    Assembly: System.Device.Spi.dll
    Syntax
    public class SpiDevice : IDisposable

    Constructors

    | Improve this Doc View Source

    SpiDevice(SpiConnectionSettings)

    Creates a communications channel to a device on a SPI bus running on the current hardware.

    Declaration
    public SpiDevice(SpiConnectionSettings settings)
    Parameters
    Type Name Description
    SpiConnectionSettings settings

    The connection settings of a device on a SPI bus.

    Exceptions
    Type Condition
    ArgumentException

    ChipSelectLine is not valid.

    - or -

    The specified BusId is not available.

    - or -

    One, or more of the GPIOs for the SPI bus are already used.

    - or -

    Some other invalid property in the specified SpiConnectionSettings.

    ArgumentOutOfRangeException

    Maximum number of SPI devices for the specified bus has been reached.

    SpiDeviceAlreadyInUseException

    If ChipSelectLine it's already in use.

    Properties

    | Improve this Doc View Source

    ConnectionSettings

    The connection settings of a device on a SPI bus. The connection settings are immutable after the device is created so the object returned will be a clone of the settings object.

    Declaration
    public SpiConnectionSettings ConnectionSettings { get; }
    Property Value
    Type Description
    SpiConnectionSettings

    Methods

    | Improve this Doc View Source

    Create(SpiConnectionSettings)

    Creates a communications channel to a device on a SPI bus running on the current hardware.

    Declaration
    public static SpiDevice Create(SpiConnectionSettings settings)
    Parameters
    Type Name Description
    SpiConnectionSettings settings

    The connection settings of a device on a SPI bus.

    Returns
    Type Description
    SpiDevice

    A communications channel to a device on a SPI bus.

    | Improve this Doc View Source

    Dispose()

    Disposes this instance

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    Dispose(Boolean)

    Disposes this instance

    Declaration
    protected void Dispose(bool disposing)
    Parameters
    Type Name Description
    Boolean disposing

    true if explicitly disposing, false if in finalizer

    | Improve this Doc View Source

    Finalize()

    Declaration
    protected void Finalize()
    | Improve this Doc View Source

    GetBusInfo(Int32)

    Retrieves the info about a certain bus.

    Declaration
    public static SpiBusInfo GetBusInfo(int busId)
    Parameters
    Type Name Description
    Int32 busId

    The id of the bus.

    Returns
    Type Description
    SpiBusInfo

    The bus info requested.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the busId is not available in the device.

    | Improve this Doc View Source

    Read(SpanByte)

    Reads data from the SPI device.

    Declaration
    public void Read(SpanByte buffer)
    Parameters
    Type Name Description
    SpanByte buffer

    The buffer to read the data from the SPI device. The length of the buffer determines how much data to read from the SPI device.

    | Improve this Doc View Source

    Read(UInt16[])

    Reads data from the SPI device.

    Declaration
    public void Read(ushort[] buffer)
    Parameters
    Type Name Description
    UInt16[] buffer

    The buffer to read the data from the SPI device. The length of the buffer determines how much data to read from the SPI device.

    | Improve this Doc View Source

    ReadByte()

    Reads a byte from the SPI device.

    Declaration
    public byte ReadByte()
    Returns
    Type Description
    Byte

    A byte read from the SPI device.

    | Improve this Doc View Source

    TransferFullDuplex(SpanByte, SpanByte)

    Writes and reads data from the SPI device.

    Declaration
    public void TransferFullDuplex(SpanByte writeBuffer, SpanByte readBuffer)
    Parameters
    Type Name Description
    SpanByte writeBuffer

    The buffer that contains the data to be written to the SPI device.

    SpanByte readBuffer

    The buffer to read the data from the SPI device.

    Exceptions
    Type Condition
    InvalidOperationException

    If the ConnectionSettings for this SpiDevice aren't configured for FullDuplex.

    | Improve this Doc View Source

    TransferFullDuplex(UInt16[], UInt16[])

    Writes and reads data from the SPI device.

    Declaration
    public void TransferFullDuplex(ushort[] writeBuffer, ushort[] readBuffer)
    Parameters
    Type Name Description
    UInt16[] writeBuffer

    The buffer that contains the data to be written to the SPI device.

    UInt16[] readBuffer

    The buffer to read the data from the SPI device.

    Exceptions
    Type Condition
    InvalidOperationException

    If the ConnectionSettings for this SpiDevice aren't configured for FullDuplex.

    | Improve this Doc View Source

    Write(SpanByte)

    Writes data to the SPI device.

    Declaration
    public void Write(SpanByte buffer)
    Parameters
    Type Name Description
    SpanByte buffer

    The buffer that contains the data to be written to the SPI device.

    | Improve this Doc View Source

    Write(UInt16[])

    Writes data to the SPI device.

    Declaration
    public void Write(ushort[] buffer)
    Parameters
    Type Name Description
    UInt16[] buffer

    The buffer that contains the data to be written to the SPI device.

    | Improve this Doc View Source

    WriteByte(Byte)

    Writes a byte to the SPI device.

    Declaration
    public void WriteByte(byte value)
    Parameters
    Type Name Description
    Byte value

    The byte to be written to the SPI device.

    Implements

    IDisposable

    Extension Methods

    LogDispatcher.GetCurrentClassLogger(Object)
    • Improve this Doc
    • View Source
    Back to top Copyright © 2018 nanoFramework Contributors
    Generated by DocFX