Overview

Abstract I2C bus interface.

The types and functions in <ctl_i2c.h> provide a high-level set of services for a bus master to read and write data over one or more I2C buses. Additional features, such as sensor drivers and so on, build upon the services that the I2C interface offers. In addition, all I2C-interfaced devices in the CrossWorks Micro-Graphics Library use the I2C functions here for I/O to LCD and OLED displays.

The I2C interface in this library is abstract in the sense that there is no concrete implementation within the library. Rather, implementations of the I2C interface are offered by the many driver packages that you can install as a CrossWorks package.

To see examples of this API in use, please install the CrossWorks demonstration package for your particular board and open up its contents in the Project Explorer and take a look around.

API Summary

Bus
CTL_I2C_BUS_t Abstract I2C bus interface
ctl_i2c_lock_bus Acquire exclusive bus lock
ctl_i2c_lock_bus_ex Acquire exclusive bus lock (extended)
ctl_i2c_set_speed Set I2C bus speed
ctl_i2c_unlock_bus Release exclusive bus lock
I/O
ctl_i2c_read Read data from I2C bus
ctl_i2c_write Write data to I2C bus
ctl_i2c_write_read Write to then read from I2C bus
Implementation
CTL_I2C_REQUEST_t I/O request block
Constants
CTL_I2C_FAST_MODE_PLUS_SPEED I2C fast-mode+ bus speed
CTL_I2C_FAST_MODE_SPEED I2C fast-mode bus speed
CTL_I2C_STANDARD_SPEED I2C standard bus speed