1.1.4.44 1.6.13.28 1.7.14.28 1.10.11.28 1.11.11.28 1.12.11.28 1.13.10.28 1.14.10.28 1.15.10.28 1.16.8.25 1.17.8.25 1.18.9.25 1.19.8.25 1.20.8.24 1.21.9.24 1.22.13.28 1.23.12.28 1.24.9.28 GPIO_PIN_CALLBACK Typedef

C

The prototype varies based on device family. Refer to the generated header file for the actual prototype to be used.

typedef void (*GPIO_PIN_CALLBACK) ( CN_PIN cnPin, uintptr_t context);
typedef void (*GPIO_PIN_CALLBACK) ( GPIO_PIN pin, uintptr_t context);

Summary

Pointer to a GPIO Pin-Event handler function.

Description

This data type defines the required function signature for the GPIO pin-event handling callback function. The client must register a pointer to an event handling function whose function signature (parameter and return value types) match the types specified by this function pointer in order to receive calls back from the PLIB when a configured pin event occurs.

The parameters and return values are described here and a partial example implementation is provided.

Parameters

Param Description
cnPin One of the CN pins from the enum CN_PIN
pin One of the IO pins from the enum GPIO_PIN
context Value identifying the context of the client that registered the event handling function

Returns

None.

Example

Example of this function varies based on device family. Refer to the one which is applicable for the device being used.

//A function matching this signature:
void APP_PinEventHandler(CN_PIN pin, uintptr_t context)
{
    // Do Something
}

//Is registered as follows:
GPIO_PinInterruptCallbackRegister(CN8_PIN, &APP_PinEventHandler, NULL);
//A function matching this signature:
void APP_PinEventHandler(GPIO_PIN pin, uintptr_t context)
{
    // Do Something
}

//Is registered as follows:
GPIO_PinInterruptCallbackRegister(GPIO_PIN_RA5, &APP_PinEventHandler, NULL);

Remarks

The context parameter contains the a handle to the client context, provided at the time the event handling function was registered using the GPIO_PinInterruptCallbackRegister function. This context handle value is passed back to the client as the "context" parameter. It can be any value (such as a pointer to the client's data) necessary to identify the client context. The event handler function executes in the PLIB's interrupt context. It is recommended of the application to not perform process intensive or blocking operations with in this function.