Jump to main content

##

# 2.112.27 I2CSMBx_HostCallbackRegister Function

## C

    /* x = I2C SMBUS peripheral instance number */

    /* I2C SMBUS Host mode */
    void I2CSMBx_HostCallbackRegister(I2C_SMB_HOST_CALLBACK callback, uintptr_t contextHandle)

## Summary

Sets the pointer to the function (and it's context) to be called when the given I2C's transfer events occur.

## Description

This function sets the pointer to a client/application function to be called "back" when the given I2C's transfer events occur. It also passes a context value (usually a pointer to a context structure) that is passed into the function when it is called. The specified callback function will be called from the peripheral interrupt context.

## Precondition

I2CSMBx_Initialize must have been called for the associated I2C instance.

## Parameters

Param | Description
--- | ---
callback | A pointer to a function with a calling signature defined by the I2C_SMB_HOST_CALLBACK data type. Setting this to NULL disables the callback feature.
contextHandle | A value (usually a pointer) which is passed (unused) into the function identified by the callback parameter

## Returns

None

## Example

    void I2CSMB0_Callback(I2C_SMB_HOST_TRANSFER_EVENT event, uintptr_t context)
    {
        // Handle callback
    }

    // Register Callback function which is defined above
    I2CSMB0_HostCallbackRegister(I2CSMB0_Callback, (uintptr_t)NULL);

## Remarks