Features Supported
- Controller and Target 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 parameters like bitrate, Own target address, Clock Source.
- I2C instances and pin Configurations.
- Interrupt Mode enable option. If disabled, gets configured to carry out transactions in 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
Usage Overview
API Sequence
To use the I2C HLD driver to transmit/receive data over the I2C bus, probe target and set bus frequency the application may call the following APIs:
Initializing the I2C HLD Driver
I2C_init() must be called before any other I2C Open is called.
I2C_open() must be called before calling any I2C APIs. This function takes index and params to initialize an instance and returns the handle to the I2C instance.
Calling I2C_close() closes the instance passed.
Please note that the initialization of I2C HLD instances is taken care by the SysConfig generated code.
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 HLD