Skip to content

Commit 7165f31

Browse files
mmahadevan108adbridge
authored andcommitted
LPC546XX: Add check for GPIO IRQ
GPIO IRQ is available on pins for Ports 0 & 1. Add a check to return error for other ports. Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent 4ec0bc6 commit 7165f31

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/gpio_irq_api.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "fsl_pint.h"
2626
#include "mbed_error.h"
2727

28+
#define INTERRUPT_PORTS 2
29+
2830
static uint32_t channel_ids[NUMBER_OF_GPIO_INTS] = {0};
2931
static gpio_irq_handler irq_handler;
3032
/* Array of PORT IRQ number. */
@@ -83,6 +85,10 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
8385
obj->pin = pin & 0x1F;
8486
obj->port = pin / 32;
8587

88+
if (obj->port >= INTERRUPT_PORTS) {
89+
return -1;
90+
}
91+
8692
/* Connect trigger sources to PINT */
8793
INPUTMUX_Init(INPUTMUX);
8894

0 commit comments

Comments
 (0)