Characteristic Locus
Namespace Meadow.Hardware
Assembly Meadow.dll

Syntax

public interface II2cBus

Properties

Frequency

Bus Clock speed in Hz

Declaration
int Frequency { get; set; }

Property Value

Type Description
System.Int32

Methods

ReadData(Byte, Int32)

Read the specified number of bytes from the I2C device.

Declaration
byte[] ReadData(byte peripheralAddress, int numberOfBytes)

Parameters

Type Name Description
System.Byte peripheralAddress

Address of the I2C peripheral.

System.Int32 numberOfBytes

Number of bytes.

Returns

Type Description
System.Byte[]

The bytes.

WriteData(Byte, Span<Byte>)

Writes a number of bytes to the bus.

Declaration
void WriteData(byte peripheralAddress, Span<byte> data)

Parameters

Type Name Description
System.Byte peripheralAddress

Address of the I2C peripheral.

Span<System.Byte> data

Data to be written.

Remarks

The number of bytes to be written will be determined by the length of the byte array.

WriteData(Byte, Byte[])

Writes a number of bytes to the bus.

Declaration
void WriteData(byte peripheralAddress, params byte[] data)

Parameters

Type Name Description
System.Byte peripheralAddress

Address of the I2C peripheral.

System.Byte[] data

Data to be written.

Remarks

The number of bytes to be written will be determined by the length of the byte array.

WriteData(Byte, IEnumerable<Byte>)

Writes a number of bytes to the bus.

Declaration
void WriteData(byte peripheralAddress, IEnumerable<byte> data)

Parameters

Type Name Description
System.Byte peripheralAddress

Address of the I2C peripheral.

System.Collections.Generic.IEnumerable<System.Byte> data

Data to be written.

Remarks

The number of bytes to be written will be determined by the length of the byte array.

WriteReadData(Byte, Int32, Byte[])

Writes data to the bus, followed by a restart and then reads a specified number of bytes

Declaration
byte[] WriteReadData(byte peripheralAddress, int byteCountToRead, params byte[] dataToWrite)

Parameters

Type Name Description
System.Byte peripheralAddress

Address of the I2C peripheral.

System.Int32 byteCountToRead

Number of bytes to read

System.Byte[] dataToWrite

Data to be written.

Returns

Type Description
System.Byte[]

The data read from the bus