Class I2cBus
Represents an I2C communication channel that conforms to the ICommunicationBus contract.
Assembly: Meadow.F7.dll
View Source
Declaration
public class I2cBus : II2cBus, IDisposable
Implements:
Meadow.Hardware.II2cBus, System.IDisposable
Properties
BusSpeed
Bus Clock speed
View Source
Declaration
public I2cBusSpeed BusSpeed { get; set; }
Methods
From(IMeadowIOController, IPin, IPin, I2cBusSpeed, ushort)
Creates an I2C bus for a set of given pins and parameters
View Source
Declaration
public static I2cBus From(IMeadowIOController ioController, IPin clock, IPin data, I2cBusSpeed busSpeed, ushort transactionTimeout = 100)
Returns
Meadow.Hardware.I2cBus: An I2CBus instance
Parameters
| Type | Name | Description |
|---|---|---|
| Meadow.Hardware.IMeadowIOController | ioController | The Meadow IO Controller |
| Meadow.Hardware.IPin | clock | Clock (SCL) pin |
| Meadow.Hardware.IPin | data | Data (SDA) pin |
| Meadow.Hardware.I2cBusSpeed | busSpeed | I2C bus speed |
System.UInt16 | transactionTimeout | Bus transaction timeout |
Read(byte, Span<byte>)
Reads bytes from a peripheral
View Source
Declaration
public void Read(byte peripheralAddress, Span<byte> readBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
System.Byte | peripheralAddress | The I2C Address to read |
System.Span<System.Byte> | readBuffer |
Write(byte, Span<byte>)
Writes a number of bytes to the bus.
View Source
Declaration
public void Write(byte peripheralAddress, Span<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
System.Byte | peripheralAddress | Address of the I2C peripheral. |
System.Span<System.Byte> | data | Data to be written. |
Exchange(byte, Span<byte>, Span<byte>)
Writes data from the write buffer to a peripheral on the bus, then resets the bus and reads the return data into the read buffer.
View Source
Declaration
public void Exchange(byte peripheralAddress, Span<byte> writeBuffer, Span<byte> readBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
System.Byte | peripheralAddress | Address of the I2C peripheral. |
System.Span<System.Byte> | writeBuffer | Buffer to read data from. |
System.Span<System.Byte> | readBuffer | Buffer to read returning data into. |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
View Source
Declaration
public void Dispose()
Implements
- Meadow.Hardware.II2cBus
System.IDisposable