I2C module provides an interface to any I2C bus compatible device accessible via I2C serial bus. External components attached to I2C bus can serially transmit/receive data to/from the CPU through two wire interface. I2C driver provides API to perform transmit/receive to any of the I2C peripherals on the board, with the multiple modes of operation.
Features Supported
- Master and Slave mode of operation
- Interrupt, Polled Mode
- Blocking and Non-blocking (callback) transfers
- Queueing of I2C transactions
- I2C Bus Recovery
SysConfig Features
- Note
- It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
SysConfig can be used to configure below parameters apart from common configuration like Clock,MPU,RAT and others.
- I2C module configuration parmaters like bitrate, slave addresses to probe.
- I2C instances and pin configurations.
- Interrupt mode enable option.If you disable it, configures to polling mode.
- Based on above parameters, the SysConfig generated code does below as part of Drivers_open and Drivers_close functions
- Set I2C instance parameter configuration.
- Driver ISR registration if Interrupt Mode is enabled.
Features NOT Supported
- Slave mode is not supported in polling mode.
Failure Prevention Guidelines for Applications
Application developer must take care of the following guidelines to avoid failures:
- The application developer should verify the bit rate supported by the end connected device while configuring the bit rate in the application.
- The application developer should verify the pinmux settings in the syscfg and make sure that the correct pins are configured.
- The application developer should verify that the correct addressing mode as supported by the end device is configured.
- The application developer should make sure that suffecient buffers are allocated before starting the transaction.
- The application developer should have bus recovery mechanisms for different operation modes of I2C like interrupt callback mode.
- The application developer should make sure that there is no resource/memory conflict when using i2c in a multi-core use case
Important Usage Guidelines
NA
Example Usage
Include the below file to access the APIs
Instance Open Example
gI2cHandle =
I2C_open(CONFIG_I2C0, ¶ms);
if (!gI2cHandle) {
}
Instance Close Example
I2c Transfer Example
API
APIs for I2C