.state R/O Property

Function:

Returns the state of the currently selected I²C channel (selection is made through i2c.channel).

Type:

Enum (i2c_state, byte)

Value Range:

  • 0 — I2C_IDLE (default): There are no active I²C transactions.
  • 1 — I2C_STARTED: The START condition has been set.
  • 2 — I2C_STRETCHING_ERROR: A clock stretching error has been encountered.
  • 3 — I2C_ARBITRATION_ERROR: An arbitration error has been encountered.

See Also:

---


Details

How your application handles clock stretching and arbitration errors will depend on your connected I²C peripherals.

At a minimum, Tibbo recommends setting i2c.enabled to 0 — NO and resetting the peripherals connected to your I²C bus. Once your devices have returned to a working state, you can set i2c.enabled back to 1 — YES to continue working on the bus.

A tip note icon.Setting i2c.enabled automatically configures the selected I²C channel's SCL and SDA lines as inputs (and by extension, pulls them HIGH).


.state R/O Property

Details