1.36.15.3 RTT_CallbackRegister Function
C
void RTT_CallbackRegister( RTT_CALLBACK callback, uintptr_t context );
Summary
Sets the pointer to the function (and it's context) to be called.
Description
This function sets the pointer to a client function to be called "back" when the interrupt occurs. It also passes a context value that is passed into the function when it is called. This function is available only in interrupt mode of operation.
Precondition
None.
Parameters
Param | Description |
---|---|
callback | A pointer to a function with a calling signature defined by the RTT_CALLBACK data type |
context | A value (usually a pointer) passed (unused) into the function identified by the callback parameter |
Returns
None.
Example
void My_callback(uintptr_t context) { //Interrupt recieved stop RTT RTT_Disable(); } int main(void) { RTT_Initialize(); //Enable callback for the periodic interrupt RTT_CallbackRegister(My_callback, NULL); //start RTT RTT_Enable(); }
Remarks
The context value may be set to NULL if it is not required. In this case the value NULL will be passed to the callback function. To disable the callback function, pass a NULL for the callback parameter. See the RTT_CALLBACK type definition for additional information.