I2C

    This module allows a driver to perform operations on an I2C controller for accessing devices on the I2C bus, including creating and destroying I2C controller handles as well as reading and writing data.

    Since:

    1.0

    Summary

    Files

    Data Structures

    Data Structure Name

    Description

    Defines the I2C transfer message used during custom transfers.

    Functions

    Function Name

    Description

    (int16_t number)

    Obtains the handle of an I2C controller.

    I2cClose (struct handle)

    void 

    Releases the handle of an I2C controller.

    I2cTransfer (struct handle, struct I2cMsg msgs, int16_t count)

    int32_t 

    Launches a custom transfer to an I2C device.

    Details

    Enumeration Type Documentation

    Description:

    Enumerates flags used for transferring I2C messages.

    Multiple flags can be used to jointly control a single I2C message transfer. If a bit is set to 1, the corresponding feature is enabled. If a bit is set to 0, the corresponding feature is disabled.

    Function Documentation

    I2cClose()

    Description:

    Releases the handle of an I2C controller.

    If you no longer need to access the I2C controller, you should call this function to close its handle so as to release unused memory resources.

    Name

    Description

    handle Indicates the pointer to the device handle of the I2C controller.

    I2cOpen()

    Description:

    Obtains the handle of an I2C controller.

    You must call this function before accessing the I2C bus.

    Parameters:

    Returns:

    Returns the pointer to the of the I2C controller if the operation is successful; returns NULL otherwise.

    Description:

    Launches a custom transfer to an I2C device.

    Parameters:

    Name

    Description

    handle Indicates the pointer to the device handle of the I2C controller obtained via .
    msgs Indicates the pointer to the I2C transfer message structure array.
    count Indicates the length of the message structure array.

    Returns:

    Returns the number of transferred message structures if the operation is successful; returns a negative value otherwise.

    See also:

    I2cMsg

    This function does not limit the number of message structures specified by count or the data length of each message structure. The specific I2C controller determines the maximum number and data length allowed.