# I2C

## Communication speed

* Normal
  * Fast
* High-speed

## Basic features

* Two-wire communication
* Half-duplex
  * Bidirectional communication (only one direction at a time)
* Multi-Master/Slave
* Clock stretching
  * Slave devices can hold the clock line (SCL) to allow more time for processing data
* Addressing
* Pull-up resistors
* Arbitration
  * Ensure data integrity when multiple masters attempting to use the bus simultaneously
    * Detect & resolve conflicts
    * Ensure data integrity
* ACK/NACK (acknowledge / not acknowledge)

## I2C implementation spec-sheet

### From TI (Texas Instruments)

{% file src="<https://238602542-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmSGvun1bZyDSuQgRsLbo%2Fuploads%2FuDx2ztePclHk5prv36CU%2Fslva689%20(I2C%20Bus%20Pullup%20Resistor%20Calculation).pdf?alt=media&token=3218082a-4d2c-4e35-bd92-c0bbeb6d512f>" %}

{% file src="<https://238602542-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmSGvun1bZyDSuQgRsLbo%2Fuploads%2FQYxU5ZYC816bVkaeoS5K%2Fslva704%20(Understanding%20the%20I2C%20Bus).pdf?alt=media&token=993720e8-febd-49cc-a460-65062d700014>" %}

### From NXP

{% file src="<https://238602542-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmSGvun1bZyDSuQgRsLbo%2Fuploads%2FEdzcNa98MwQ77RclGzs1%2FUM10204.pdf?alt=media&token=2d6f54b8-f0f3-421e-ac10-bba8497e7686>" %}
[I2C-bus specification and user manual](https://www.nxp.com/docs/en/user-guide/UM10204.pdf)
{% endfile %}

## I2C primers & use-full resources

### I2C Primer

A very nice primer that explains how the I2C protocol works and some special considerations that we should take work working with it. On the surface it seems like a very simple 2 wire protocol but some features such as multi-master/slave, clock stretching, etc. (& maybe error detection/correction?) makes implementation not as straightforward as it seems.

{% embed url="<https://www.i2c-bus.org/i2c-primer>" %}

## Debugging I2C

### Waveform analysis

<https://www.ti.com/lit/an/slyt770/slyt770.pdf>
