Characteristic Locus
Namespace Meadow.Hardware
Assembly Meadow.Contracts.dll

Syntax

public interface IByteCommunications

Methods

Exchange(Span<byte>, Span<byte>, DuplexType)

Write data to followed by read data from the peripheral.

Declaration
void Exchange(Span<byte> writeBuffer, Span<byte> readBuffer, DuplexType duplex = DuplexType.Half)

Parameters

Type Name Description
Span<byte> writeBuffer

Data to write

Span<byte> readBuffer

Buffer where read data will be written. Number of bytes read is determined by buffer size.

DuplexType duplex

Whether the communication will happen in a half-duplex or full-duplex fashion.

Read(Span<byte>)

Reads data from the peripheral.

Declaration
void Read(Span<byte> readBuffer)

Parameters

Type Name Description
Span<byte> readBuffer

The buffer to read from the peripheral into.

Remarks

The number of bytes to be read is determined by the length of the readBuffer.

ReadRegister(byte)

Read a register from the peripheral.

Declaration
byte ReadRegister(byte address)

Parameters

Type Name Description
byte address

Address of the register to read.

Returns

Type Description
byte

ReadRegister(byte, Span<byte>)

Reads data from the peripheral starting at the specified address.

Declaration
void ReadRegister(byte address, Span<byte> readBuffer)

Parameters

Type Name Description
byte address
Span<byte> readBuffer

ReadRegisterAsUShort(byte, ByteOrder)

Read an unsigned short from a register.

Declaration
ushort ReadRegisterAsUShort(byte address, ByteOrder order = ByteOrder.LittleEndian)

Parameters

Type Name Description
byte address

Register address of the low byte (the high byte will follow).

ByteOrder order

Order of the bytes in the register (little endian is the default).

Returns

Type Description
ushort

Value read from the register.

Write(byte)

Write a single byte to the peripheral.

Declaration
void Write(byte value)

Parameters

Type Name Description
byte value

Value to be written (8-bits).

Write(Span<byte>)

Write an array of bytes to the peripheral.

Declaration
void Write(Span<byte> writeBuffer)

Parameters

Type Name Description
Span<byte> writeBuffer

A buffer of byte values to be written.

WriteRegister(byte, byte)

Write data to a register in the peripheral.

Declaration
void WriteRegister(byte address, byte value)

Parameters

Type Name Description
byte address

Address of the register to write to.

byte value

Data to write into the register.

WriteRegister(byte, Span<byte>, ByteOrder)

Write data to a register in the peripheral.

Declaration
void WriteRegister(byte address, Span<byte> writeBuffer, ByteOrder order = ByteOrder.LittleEndian)

Parameters

Type Name Description
byte address

Address of the register to write to.

Span<byte> writeBuffer

A buffer of byte values to be written.

ByteOrder order

Indicate if the data should be written as big or little endian.

WriteRegister(byte, ushort, ByteOrder)

Write an unsigned short to the peripheral.

Declaration
void WriteRegister(byte address, ushort value, ByteOrder order = ByteOrder.LittleEndian)

Parameters

Type Name Description
byte address

Address to write the first byte to.

ushort value

Value to be written (16-bits).

ByteOrder order

Indicate if the data should be written as big or little endian.

WriteRegister(byte, uint, ByteOrder)

Write an unsigned integer to the peripheral.

Declaration
void WriteRegister(byte address, uint value, ByteOrder order = ByteOrder.LittleEndian)

Parameters

Type Name Description
byte address

Address to write the first byte to.

uint value

Value to be written.

ByteOrder order

Indicate if the data should be written as big or little endian.

WriteRegister(byte, ulong, ByteOrder)

Write an unsigned long to the peripheral.

Declaration
void WriteRegister(byte address, ulong value, ByteOrder order = ByteOrder.LittleEndian)

Parameters

Type Name Description
byte address

Address to write the first byte to.

ulong value

Value to be written.

ByteOrder order

Indicate if the data should be written as big or little endian.