I2C (Inter-Integrated Circuit) Framework

Updated: October 26, 2022

I2C (Inter-Integrated Circuit) is a simple serial protocol that connects multiple devices in a master-slave relationship. Multiple master devices may share a single bus. The same device may function as both a master and a slave in different transactions. The I2C specification defines these transfer speed ranges:

The I2C framework is intended to facilitate consistent implementation of I2C interfaces. The framework consists of the following parts:

hardware/i2c/*
The hardware interface.
lib/i2c
The resource manager layer.
<hw/i2c.h>
A public header file that defines the hardware and application interfaces.

The most common application of the I2C bus is low-bandwidth access to a slave device's registers, such as:

Typically, only a few bytes are exchanged on the bus.

You can implement the I2C master as a single-threaded resource manager, or as a dedicated application. The primary advantages of a resource manager interface are:

For a dedicated I2C-bus application, a hardware access library is more efficient. The hardware interface, which defines the interface to this library, is useful as a starting point for developers and facilitates maintenance and code portability.