Search Results for

    Show / Hide Table of Contents

    Class I2cDevice

    The communications channel to a device on an I2C bus.

    Inheritance
    object
    I2cDevice
    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.I2c
    Assembly: System.Device.I2c.dll
    Syntax
    public class I2cDevice : IDisposable

    Constructors

    I2cDevice(I2cConnectionSettings)

    Create an I2C Device

    Declaration
    public I2cDevice(I2cConnectionSettings settings)
    Parameters
    Type Name Description
    I2cConnectionSettings settings

    Connection settings

    Properties

    ConnectionSettings

    The connection settings of a device on an I2C 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 I2cConnectionSettings ConnectionSettings { get; }
    Property Value
    Type Description
    I2cConnectionSettings

    Methods

    Create(I2cConnectionSettings)

    Creates a communications channel to a device on an I2C bus running on the current platform

    Declaration
    public static I2cDevice Create(I2cConnectionSettings settings)
    Parameters
    Type Name Description
    I2cConnectionSettings settings

    The connection settings of a device on an I2C bus.

    Returns
    Type Description
    I2cDevice

    A communications channel to a device on an I2C bus

    Dispose()

    Declaration
    public void Dispose()

    Finalize()

    Declaration
    protected override void Finalize()

    Read(SpanByte)

    Reads data from the I2C device.

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

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

    Returns
    Type Description
    I2cTransferResult

    ReadByte()

    Reads a byte from the I2C device.

    Declaration
    public byte ReadByte()
    Returns
    Type Description
    byte

    A byte read from the I2C device.

    Write(SpanByte)

    Writes data to the I2C device.

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

    The buffer that contains the data to be written to the I2C device. The data should not include the I2C device address.

    Returns
    Type Description
    I2cTransferResult

    WriteByte(byte)

    Writes a byte to the I2C device.

    Declaration
    public I2cTransferResult WriteByte(byte value)
    Parameters
    Type Name Description
    byte value

    The byte to be written to the I2C device.

    Returns
    Type Description
    I2cTransferResult

    WriteRead(SpanByte, SpanByte)

    Performs an atomic operation to write data to and then read data from the I2C bus on which the device is connected, and sends a restart condition between the write and read operations.

    Declaration
    public I2cTransferResult WriteRead(SpanByte writeBuffer, SpanByte readBuffer)
    Parameters
    Type Name Description
    SpanByte writeBuffer

    The buffer that contains the data to be written to the I2C device. The data should not include the I2C device address.

    SpanByte readBuffer

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

    Returns
    Type Description
    I2cTransferResult

    Implements

    IDisposable

    Extension Methods

    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    In This Article
    Back to top Copyright © 2023 nanoFramework Contributors
    Generated by DocFX