Skip to main content

I2C

Availability

Device

Description

The I2C class represents an I²C two-wire serial port. Objects representing a given imp’s specific I²C ports are automatically instantiated at start-up and are accessed through the following object properties of the hardware object:

imp I²C 1 I²C 2 I²C 3 I²C 4
imp001 hardware.i2c12 hardware.i2c89
imp002 hardware.i2c12 hardware.i2c89
imp003 (Murata part number LBWA1ZV1CD) hardware.i2cAB hardware.i2cFG
imp004m (Murata part number LBEE5ZZ1MD) hardware.i2cNM hardware.i2cQP
imp005 (Murata part number LBWA1UZ1GC-901) hardware.i2cJK hardware.i2c0
imp006 hardware.i2cJK hardware.i2cLM hardware.i2cTU
impC001 hardware.i2cJH hardware.i2cKL hardware.i2cXBA hardware.i2cXDC

The imp005’s second I²C bus is accessed via dedicated pins rather than GPIO, hence the slightly different nomenclature.

  • For more information on each imp’s pin-out, please see the imp pin mux.

When implementing I²C using an imp, please note that external pull-ups are required. It is not possible to enable the internal pull-ups when pins are used for I²C.

Known Issues

imp005 i2cJK, i2c0

These peripherals do not support clock-stretching, so any I²C peripheral which must delay before replying to communications from the host will not work with the imp005.

Member Entities

The I2C object has the following member methods:

  • i2c.configure()Configures the I²C clock speed and enables the port
  • i2c.disable()Disables the I²C bus
  • i2c.read()Initiates an I²C read from a specific register within a specific device
  • i2c.readerror()Returns the error code generated by the last I²C read
  • i2c.write()Initiates an I²C write to the device at the specified address