Table of Contents

Class I2cDevice

Namespace
System.Device.I2c
Assembly
System.Device.I2c.dll

The communications channel to a device on an I2C bus.

public class I2cDevice : IDisposable
Inheritance
I2cDevice
Implements
Inherited Members
Extension Methods

Constructors

I2cDevice(I2cConnectionSettings)

Create an I2C Device

public I2cDevice(I2cConnectionSettings settings)

Parameters

settings I2cConnectionSettings

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.

public I2cConnectionSettings ConnectionSettings { get; }

Property Value

I2cConnectionSettings

Methods

Create(I2cConnectionSettings)

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

public static I2cDevice Create(I2cConnectionSettings settings)

Parameters

settings I2cConnectionSettings

The connection settings of a device on an I2C bus.

Returns

I2cDevice

A communications channel to a device on an I2C bus

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Finalize()

protected override void Finalize()

Read(SpanByte)

Reads data from the I2C device.

public I2cTransferResult Read(SpanByte buffer)

Parameters

buffer SpanByte

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

I2cTransferResult

ReadByte()

Reads a byte from the I2C device.

public byte ReadByte()

Returns

byte

A byte read from the I2C device.

Write(SpanByte)

Writes data to the I2C device.

public I2cTransferResult Write(SpanByte buffer)

Parameters

buffer SpanByte

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

Returns

I2cTransferResult

WriteByte(byte)

Writes a byte to the I2C device.

public I2cTransferResult WriteByte(byte value)

Parameters

value byte

The byte to be written to the I2C device.

Returns

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.

public I2cTransferResult WriteRead(SpanByte writeBuffer, SpanByte readBuffer)

Parameters

writeBuffer SpanByte

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

readBuffer SpanByte

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

I2cTransferResult