2.2.6 ACC_CallbackRegister Function

C

void ACC_CallbackRegister (ACC_CALLBACK callback, uintptr_t context);

Summary

Allows application to register callback with PLIB

Description

This function allows application to register a callback function for the PLIB to call back when interrupt occurred. At any point if application wants to stop the callback, it can call this function with "callback" value as NULL.

Precondition

The ACC_Initialize function must have been called.

Parameters

ParamDescription
callbackPointer to the callback function implemented by the user.
contextThe value of parameter will be passed back to the application unchanged, when the callback function is called. It can be used to identify any application specific value that identifies the instance of the client module (for example, it may be a pointer to the client module's state structure)

Returns

None.

Example

MY_APP_OBJ myAppObj;

void APP_ACC_CallbackFunction (uintptr_t context)
{
    // The context was set to an application specific object.
    // It is now retrievable easily in Callback function.
    MY_APP_OBJ myAppObj = (MY_APP_OBJ *) context;
    //Application related tasks
}

ACC_CallbackRegister (APP_ACC_CallbackFunction, (uintptr_t)&myAppObj);

Remarks

None.