Class I2cPart
A part that is not there, answering from 256 registers a byte wide.
public sealed class I2cPart : SimulatedPart, IDisposable
- Inheritance
-
I2cPart
- Implements
- Inherited Members
Remarks
A write names a register and fills it and the ones after it; a read takes them back from wherever the last write left off. What a driver writes stays written, so Register(byte) reads a part's configuration back once a driver is done with it.
Constructors
I2cPart(NativeHandle)
Wraps a part a native call made, such as a simulated sensor from another package.
public I2cPart(NativeHandle handle)
Parameters
handleNativeHandleThe part's handle, released with
pamoja_i2c_part_free.
I2cPart(byte)
Creates a part answering at one address, with every register reading zero.
public I2cPart(byte address)
Parameters
addressbyteThe 7-bit address it answers to.
Methods
Holding(byte, ReadOnlySpan<byte>)
Puts bytes in the part from a register on, and returns the part.
public I2cPart Holding(byte first, ReadOnlySpan<byte> bytes)
Parameters
firstbyteThe register the bytes start at.
bytesReadOnlySpan<byte>What to put there. Past the last register it wraps to the first.
Returns
- I2cPart
This part, so calls chain.
Load(byte, ReadOnlySpan<byte>)
Puts bytes in the part from a register on.
public void Load(byte first, ReadOnlySpan<byte> bytes)
Parameters
firstbyteThe register the bytes start at.
bytesReadOnlySpan<byte>What to put there. Past the last register it wraps to the first.
Read(byte, int)
Reads consecutive registers from one register on.
public byte[] Read(byte first, int length)
Parameters
Returns
- byte[]
One byte per register.
Register(byte)
Reads what one register holds now.
public byte Register(byte register)
Parameters
registerbyteWhich register.
Returns
- byte
Its value, which is what a driver wrote if it wrote one.