Jump to main content

##

# 3.2.11 Inter-Integrated Circuit - I2C

The Inter-Integrated Circuit (I2C) module is a serial interface useful for communicating with other peripheral or microcontroller (MCU) devices. The external peripheral devices may be serial EEPROMs, display drivers, Analog-to-Digital Converters (ADC) and so on. The I2C module can operate as any one of the following in the I2C system:

• Client Device

• Host Device in a Single Host System (Client May Be Active)

• Host or Client Device in a Multi-Host System (Bus Collision Detection and Arbitration are Available)

Key features of the I2C module include the following:

• Independent Host and Client Logic

• Supports 100 kHz, 400 kHz and 1MHz Bus Specifications

• 7-bit and 10-bit Device Addresses.

• Client Mode Can be Configured for:

– Two unique addresses

– Range of address

– General call address

– Address bit masking

• Automatic Clock Stretching Provides Delays for the Processor to Respond to a Client Data Request

• Multi-Host Support Which Prevents Message Losses in Arbitration

• Smart Mode for Minimal User Interaction and Simpler Application Code

• Supports Data Hold Time for SMBus (300 nS or 150 nS) in Client Mode

• Supports SMBus v2.0 and v3.0 Input Voltage Levels.

• Supports the Intelligent Platform Management Interface (IPMI) Standard

• System Management Bus (SMBus) and Power Management Bus (PMBus) Support:

– Packet Error Checking (PEC) using CRC-8 calculator

– Clock low timeout, Bus idle timeout and cumulative timeout

– Frame error detection

## Library Interface

Functions

Name | Description | Host mode | Client mode
--- | --- | --- | ---
I2Cx_Initialize | Initializes the instance of the I2C peripheral in either host or client mode | Yes | Yes
I2Cx_Deinitialize | De-initializes the instance of the I2C peripheral | Yes | Yes
I2Cx_TransferAbort | Force stops the I2C transfer | Yes | No
I2Cx_Read | Reads data from the client | Yes | No
I2Cx_Write | Writes data to the client | Yes | No
I2Cx_WriteRead | Write and Read data from client | Yes | No
I2Cx_WriteForced | Forced write data to the client | Yes | No
I2Cx_IsBusy | Returns the Peripheral busy status | Yes | Yes
I2Cx_ErrorGet | Returns the I2C error that occurred on the bus | Yes | Yes
I2Cx_TransferSetup | Dynamic setup of I2C Peripheral | Yes | No
I2Cx_CallbackRegister | Sets the pointer to the function (and it's context) to be called when the given I2C's transfer events occur | Yes | Yes
I2Cx_ReadByte | Read the received I2C byte | No | Yes
I2Cx_WriteByte | Write a data byte to I2C host | No | Yes
I2Cx_TransferDirGet | Returns the I2C transfer direction | No | Yes
I2Cx_LastByteAckStatusGet | Returns the ACK status of the last byte written to the I2C host | No | Yes
I2Cx_BusScan Function | Scans and reports the target devices found on the bus | Yes | No

Data types and constants

Name | Type | Description | Host mode | Client mode
--- | --- | --- | --- | ---
I2C_ERROR | Enum | Defines the possible errors that the I2C peripheral can generate in I2C host mode | Yes | No
I2C_TRANSFER_SETUP | Struct | I2C transfer setup data structure | Yes | No
I2C_CALLBACK | Typedef | Defines the data type and function signature for the I2C peripheral callback function in I2C host mode | Yes | No
I2C_CLIENT_TRANSFER_DIR | Enum | Defines the enum for I2C data transfer direction | No | Yes
I2C_CLIENT_ACK_STATUS | Enum | Defines the enum for the I2C acknowledgement | No | Yes
I2C_CLIENT_TRANSFER_EVENT | Enum | Defines the enum for the I2C client transfer event | No | Yes
I2C_CLIENT_ERROR | Enum | Defines errors associated with I2C in client mode | No | Yes
I2C_CLIENT_CALLBACK | Typedef | Defines the data type and function signature for the I2C client callback function | No | Yes
I2C_STATE | Enum | Defines the I2C PLib Task State | Yes | Yes
I2C_TRANSFER_TYPE | Enum | Defines the I2C Transfer Type | Yes | No

## Remarks

For paticular family devices the Master term is referred as Host and Slave term is referred as Client

Please refer respective device header files for specific API prototype.