Austin and Igor answers are detailed enough. However, I want to answer it in another way, maybe you find it helpful.
The LPC11xx (Cortex-M0) has 4 levels for GPIO pins, all the pins from GPIO0.0 to GPIO0.n share the same interrupt number, and all the pins from GPIO3.0 to GPIO3.m share the same interrupt number.
There are six steps to initialize GPIO interrupt in LPC11xx
- Set up the pin function by modifying Pin Connection Block Registers.
- Set up the pin direction by modifying GPIO data direction register (default value is input).
- Setup the interrupt for each individual pin, you have to go to the GPIO interrupt mask register GPIOnIE and set the bit (that corresponds to the pin) logic 1.
- Set up the interrupt for rising edge or falling edge or both by modifying the GPIO interrupt sense registers GPIOnIBE and GPIOnIS.
- Enable the interrupt source either PIO_0/PIO_1/PIO_2/PIO_3 in Nested Vectored Interrupt Control using CMSIS functions.
- Set interrupt priority by using CMSIS functions.
Code implementations. You need two functions: one initialize 6 above steps, and the second is the interrupt handler, which is required to be the same name as the handler defined in the start-up codes,
startup_LPC11xx.s file. The names are from
PIOINT3_IRQHandler. If you use different name, you have to change the names in start-up file.
/*Init the GPIO pin for interrupt control */
LPC_IOCON-> =.. //Pin configuration register
LPC_GPIO1->FIODIR = ... //GPIO Data direction register
LPC_GPIO1->FIOMASK = .. //GPIO Data mask register - choose the right pin
LPC_GPIO1->GPIOnIE = .. //Set up falling or rising edge
NVIC_EnableIRQ(PIO_1); //Call API to enable interrupt in NVIC
NVIC_SetPriority(PriorityN); //Set priority if needed
/*Must have the same name as listed in start-up file startup_LPC11xx.s */
//Do something here