1.1.11.33 I2CSMBx_TargetCallbackRegister Function
C
/* x = I2C SMBUS peripheral instance number */
/* I2C SMBUS Target mode */
void I2CSMBx_TargetCallbackRegister(I2C_SMB_TARGET_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_TARGET_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
bool i2cSMB0TargetEventHandler (I2C_SMB_TARGET_TRANSFER_EVENT event, uintptr_t contextHandle)
{
// Handle callback
}
// Register Callback function which is defined above
I2CSMB0_TargetCallbackRegister(i2cSMB0TargetEventHandler, (uintptr_t)NULL);