1.7.14.24 GPIO_PinInterruptCallbackRegister Function
C
The prototype of this function varies based on device family. Refer to the generated header file for the actual prototype to be used.
bool GPIO_PinInterruptCallbackRegister(
CN_PIN cnPin,
const GPIO_PIN_CALLBACK callBack,
uintptr_t context
);
bool GPIO_PinInterruptCallbackRegister(
GPIO_PIN pin,
const GPIO_PIN_CALLBACK callBack,
uintptr_t context
);
Summary
Allows application to register callback for every pin.
Description
This function allows application to register an event handling function for the PLIB to call back when I/O interrupt occurs on the selected pin.
At any point if application wants to stop the callback, it can call this function with "callback" value as NULL.
If a pin is not configured for interrupt in Pin Manager and yet its callback registration is attempted using this API, then registration doesn't happen and API returns false indicating the same.
Precondition
Corresponding pin must be configured in interrupt mode in MHC Pin Manager.
Parameters
Param | Description |
---|---|
pin | One of the Change Notice pins from the enum CN_PIN |
pin | One of the IO pins from the enum GPIO_PIN |
eventHandler | Pointer to the event handler function implemented by the user |
context | The value of parameter will be passed back to the application unchanged, when the eventHandler function is called. It can be used to identify any application specific value. |
Returns
Callback registration status: - true: Callback was successfully registered - false: Callback was not registered
Example
Example of this function varies based on device family. Refer to the one which is applicable for the device being used.
if(GPIO_PinInterruptCallbackRegister(CN8_PIN, &APP_PinHandler, NULL)) { // callback got registered }
if(GPIO_PinInterruptCallbackRegister(GPIO_PIN_RB3, &APP_PinHandler, NULL)) { // callback got registered }
Remarks
None.