1.3.2.4.9 I2C_BB_CallbackRegister Function

C

void I2C_BB_CallbackRegister(I2CBB_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 function to be called "back" when the given I2C 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 timer peripheral interrupt context.

Precondition

I2C_BB_Initialize must have been called for the associated I2C instance.

Parameters

ParamDescription
callbackA pointer to a function with a calling signature defined by the I2CBB_CALLBACK data type. Setting this to NULL disables the callback feature.
contextHandleA value (usually a pointer) passed (unused) into the function identified by the callback parameter.

Returns

None.

Example

void MyI2CCallback(uintptr_t context)
{
    // This function will be called when the transfer completes. Note
    // that this function executes in the context of the I2C interrupt.
}

I2C_BB_Initialize();

I2C_BB_CallbackRegister(MyI2CCallback, NULL);

Remarks

None.