Skip to main content

Interface IByteCommunications

Define a contract for general peripheral communications classes.

Assembly: Meadow.Contracts.dll
View Source
Declaration
public interface IByteCommunications

Methods

Read(Span<byte>)

Reads data from the peripheral.

View Source
Declaration
void Read(Span<byte> readBuffer)
Parameters
TypeNameDescription
System.Span<System.Byte>readBufferThe buffer to read from the peripheral into.

ReadRegister(byte, Span<byte>)

Reads data from the peripheral starting at the specified address.

View Source
Declaration
void ReadRegister(byte address, Span<byte> readBuffer)
Parameters
TypeName
System.Byteaddress
System.Span<System.Byte>readBuffer

ReadRegister(byte)

Read a register from the peripheral.

View Source
Declaration
byte ReadRegister(byte address)
Returns

System.Byte

Parameters
TypeNameDescription
System.ByteaddressAddress of the register to read.

ReadRegisterAsUShort(byte, ByteOrder)

Read an unsigned short from a register.

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

System.UInt16: Value read from the register.

Parameters
TypeNameDescription
System.ByteaddressRegister address of the low byte (the high byte will follow).
Meadow.ByteOrderorderOrder of the bytes in the register (little endian is the default).

Write(byte)

Write a single byte to the peripheral.

View Source
Declaration
void Write(byte value)
Parameters
TypeNameDescription
System.BytevalueValue to be written (8-bits).

Write(Span<byte>)

Write an array of bytes to the peripheral.

View Source
Declaration
void Write(Span<byte> writeBuffer)
Parameters
TypeNameDescription
System.Span<System.Byte>writeBufferA buffer of byte values to be written.

WriteRegister(byte, byte)

Write data to a register in the peripheral.

View Source
Declaration
void WriteRegister(byte address, byte value)
Parameters
TypeNameDescription
System.ByteaddressAddress of the register to write to.
System.BytevalueData to write into the register.

WriteRegister(byte, Span<byte>, ByteOrder)

Write data to a register in the peripheral.

View Source
Declaration
void WriteRegister(byte address, Span<byte> writeBuffer, ByteOrder order = ByteOrder.LittleEndian)
Parameters
TypeNameDescription
System.ByteaddressAddress of the register to write to.
System.Span<System.Byte>writeBufferA buffer of byte values to be written.
Meadow.ByteOrderorderIndicate if the data should be written as big or little endian.

WriteRegister(byte, ushort, ByteOrder)

Write an unsigned short to the peripheral.

View Source
Declaration
void WriteRegister(byte address, ushort value, ByteOrder order = ByteOrder.LittleEndian)
Parameters
TypeNameDescription
System.ByteaddressAddress to write the first byte to.
System.UInt16valueValue to be written (16-bits).
Meadow.ByteOrderorderIndicate if the data should be written as big or little endian.

WriteRegister(byte, uint, ByteOrder)

Write an unsigned integer to the peripheral.

View Source
Declaration
void WriteRegister(byte address, uint value, ByteOrder order = ByteOrder.LittleEndian)
Parameters
TypeNameDescription
System.ByteaddressAddress to write the first byte to.
System.UInt32valueValue to be written.
Meadow.ByteOrderorderIndicate if the data should be written as big or little endian.

WriteRegister(byte, ulong, ByteOrder)

Write an unsigned long to the peripheral.

View Source
Declaration
void WriteRegister(byte address, ulong value, ByteOrder order = ByteOrder.LittleEndian)
Parameters
TypeNameDescription
System.ByteaddressAddress to write the first byte to.
System.UInt64valueValue to be written.
Meadow.ByteOrderorderIndicate if the data should be written as big or little endian.

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

Write data to followed by read data from the peripheral.

View Source
Declaration
void Exchange(Span<byte> writeBuffer, Span<byte> readBuffer, DuplexType duplex = DuplexType.Half)
Parameters
TypeNameDescription
System.Span<System.Byte>writeBufferData to write
System.Span<System.Byte>readBufferBuffer where read data will be written. Number of bytes read is determined by buffer size.
Meadow.Hardware.DuplexTypeduplexWhether the communication will happen in a half-duplex or full-duplex fashion.