1.35.17.8 TWIx_CallbackRegister Function
C
/* x = TWI instance number */
/* TWI master mode */
void TWIx_CallbackRegister(TWI_CALLBACK callback, uintptr_t contextHandle)
Summary
Sets the pointer to the function (and it's context) to be called when the given TWI's transfer events occur.
Description
This function sets the pointer to a client/application function to be called "back" when the given TWI'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
TWIx_Initialize must have been called for the associated TWI instance.
Parameters
Param | Description |
---|---|
callback | A pointer to a function with a calling signature definedby the TWI_CALLBACK data type. Setting this to NULL disables the callback feature. |
context | A value (usually a pointer) passed (unused) into the function identified by the callback parameter. |
Returns
None.
Example
void TWI1_Callback(uintptr_t context) { if(TWI1_ErrorGet() == TWI_ERROR_NONE) { //Transfer is completed successfully } else { //Error occurred during transfer. } } // Register Callback function which is defined above TWI1_CallbackRegister(TWI1_Callback, (uintptr_t)NULL);
Remarks
None