I2C is a widely used 2-wire synchronous serial communication protocol. It is commonly used to interface a microcontroller to all sorts of sensors and ICs, including other microcontrollers. Since it uses 2-wire, the I2C protocol is also known as the Two-Wire Interface (TWI).
As the name suggests, it is aimed for interconnection over short distances and generally within a device’s PCB. All Nordic SoC’s come with at least one I2C controller that can operate in two roles: as a “controller” that initiates transactions and controls the clock, or as a “target” that responds to transaction commands.
Most I2C controllers on Nordic’s chips support multiple speeds: 100 (I2C_BITRATE_STANDARD
), 400 (I2C_BITRATE_FAST
) and 1000 (I2C_BITRATE_FAST_PLUS
) kbps. The default speed is 100 kbps.
The two I2C wires are called serial clock (SCL) and serial data (SDA). All devices on the bus are connected to these two lines, as shown in the figure below.
The SCL is generated by the I2C controller sync all devices on the bus to one clock, while the SDA line is bidirectional, so data can travel in either direction (from controller to target or target to controller).
Each I2C target device has a unique address that distinguishes it from the other I2C target devices on the same bus. The address is usually a 7-bit value, however, some I2C target devices also use a 10-bit value.