Skip to main content

I2cConnectionSettings Class

NuGet: GHIElectronics.TinyCLR.Devices.I2c
Assembly: GHIElectronics.TinyCLR.Devices.I2c
Namespace: GHIElectronics.TinyCLR.Devices.I2c

Per-device I²C connection settings: address, bus speed, and master/slave role.

public sealed class I2cConnectionSettings

Constructors

I2cConnectionSettings(int slaveAddress)

public I2cConnectionSettings(int slaveAddress) : this(slaveAddress, I2cAddressFormat.SevenBit)

Builds a 7-bit master-mode settings object at standard speed.

I2cConnectionSettings(int slaveAddress, uint busSpeed)

public I2cConnectionSettings(int slaveAddress, uint busSpeed) : this(slaveAddress, I2cAddressFormat.SevenBit, busSpeed)

Builds a 7-bit master-mode settings object at the given bus speed.

I2cConnectionSettings(int slaveAddress, I2cAddressFormat addressFormat, uint busSpeed)

public I2cConnectionSettings(int slaveAddress, I2cAddressFormat addressFormat, uint busSpeed = 100000) : this(slaveAddress, I2cMode.Master, addressFormat, busSpeed)

Builds a master-mode settings object with explicit address format.

I2cConnectionSettings(int slaveAddress, I2cMode mode)

public I2cConnectionSettings(int slaveAddress, I2cMode mode) : this(slaveAddress, mode, I2cAddressFormat.SevenBit)

Builds a 7-bit settings object with the given role (master/slave).

I2cConnectionSettings(int slaveAddress, I2cMode mode, I2cAddressFormat addressFormat, uint busSpeed)

public I2cConnectionSettings(int slaveAddress, I2cMode mode, I2cAddressFormat addressFormat, uint busSpeed = 100000) : this(slaveAddress, mode, addressFormat, busSpeed, false)

Builds a settings object with explicit role and address format.

I2cConnectionSettings(int slaveAddress, I2cMode mode, I2cAddressFormat addressFormat, uint busSpeed, bool enableClockStretching)

public I2cConnectionSettings(int slaveAddress, I2cMode mode, I2cAddressFormat addressFormat, uint busSpeed, bool enableClockStretching = false)

Builds a settings object with full control over every field.

Properties

SlaveAddress

public int SlaveAddress { get; set; }

The peer's slave address.

AddressFormat

public I2cAddressFormat AddressFormat { get; set; }

7-bit or 10-bit address format.

BusSpeed

public uint BusSpeed { get; set; }

Bus speed in Hz (e.g. 100_000 for standard, 400_000 for fast mode).

Mode

public I2cMode Mode { get; set; }

Whether this device acts as master or slave.

EnableClockStretching

public bool EnableClockStretching { get; set; }

Slave-mode only: allow the controller to stretch the clock while it's not ready.