Step 4: Add Application Code to the Project
This example application on the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit demonstrates General Purpose Input/Output (GPIO) input handling. In this demo, application code is added to the created project to implement switch input handling with an LED as the output. Add the following code to perform the GPIO input handling operation.
Application Code for the Project
Open the main.c file and add the EIC_CallbackRegister function call after SYS_Initialize(NULL); inside the int main(void) function. This callback registration enables the application to automatically execute a specified function when an external interrupt occurs, such as a button press.
Code:

EIC_CallbackRegister is the callback registration function, EIC_PIN_2 specifies the pin used to generate the interrupt, and EIC_User_Handler is the user-defined callback function. When an interrupt (switch press) is detected on EIC_PIN_2, the EIC peripheral automatically invokes the registered callback function to handle the event.
Add the EIC_User_Handler function to the main.c file after the header files inclusions.
Code:
{
LED_Toggle();
}

EIC_User_Handler is the callback function registered using EIC_CallbackRegister. When a switch press is detected, the external interrupt triggers this function, which toggles the LED state using the LED_Toggle() function. If the LED is OFF, it is turned ON, and if it is ON, it is turned OFF.