Class I2cDevice
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
I2cConnectionSettingsConnection 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
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
I2cConnectionSettingsThe 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
SpanByteThe 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
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
SpanByteThe buffer that contains the data to be written to the I2C device. The data should not include the I2C device address.
Returns
WriteByte(byte)
Writes a byte to the I2C device.
public I2cTransferResult WriteByte(byte value)
Parameters
value
byteThe byte to be written to the I2C device.
Returns
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
SpanByteThe buffer that contains the data to be written to the I2C device. The data should not include the I2C device address.
readBuffer
SpanByteThe buffer to read the data from the I2C device. The length of the buffer determines how much data to read from the I2C device.