Skip to content

Commit 9b48f39

Browse files
committed
MIMXRT1050_EVK: Fix the GPIO IRQ number assignements
Use the GPIO_Combined IRQ array Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent f12afde commit 9b48f39

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_IMX/gpio_irq_api.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static gpio_irq_handler irq_handler;
3838
static GPIO_Type * const gpio_addrs[] = GPIO_BASE_PTRS;
3939

4040
/* Array of PORT IRQ number. */
41-
static const IRQn_Type gpio_irqs[] = GPIO_IRQS;
41+
static const IRQn_Type gpio_irqs[] = GPIO_COMBINED_IRQS;
4242

4343
static void handle_interrupt_in(PortName port, int ch_base)
4444
{
@@ -117,6 +117,8 @@ void gpio5_irq(void)
117117

118118
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id)
119119
{
120+
uint32_t int_index;
121+
120122
if (pin == NC) {
121123
return -1;
122124
}
@@ -153,8 +155,14 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
153155
error("gpio_irq only supported on port A-E.");
154156
break;
155157
}
156-
NVIC_SetVector(gpio_irqs[obj->port], vector);
157-
NVIC_EnableIRQ(gpio_irqs[obj->port]);
158+
159+
int_index = 2 * obj->port;;
160+
if (obj->pin > 15) {
161+
int_index -= 1;
162+
}
163+
164+
NVIC_SetVector(gpio_irqs[int_index], vector);
165+
NVIC_EnableIRQ(gpio_irqs[int_index]);
158166

159167
obj->ch = ch_base + obj->pin;
160168
channel_ids[obj->ch] = id;

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/device/MIMXRT1052.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12095,7 +12095,7 @@ typedef struct {
1209512095
#define GPIO_BASE_PTRS { (GPIO_Type *)0u, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5 }
1209612096
/** Interrupt vectors for the GPIO peripheral type */
1209712097
#define GPIO_IRQS { NotAvail_IRQn, GPIO1_INT0_IRQn, GPIO1_INT1_IRQn, GPIO1_INT2_IRQn, GPIO1_INT3_IRQn, GPIO1_INT4_IRQn, GPIO1_INT5_IRQn, GPIO1_INT6_IRQn, GPIO1_INT7_IRQn, NotAvail_IRQn, NotAvail_IRQn, NotAvail_IRQn, NotAvail_IRQn }
12098-
#define GPIO_COMBINED_IRQS { NotAvail_IRQn, GPIO1_Combined_16_31_IRQn, GPIO2_Combined_16_31_IRQn, GPIO2_Combined_0_15_IRQn, GPIO3_Combined_16_31_IRQn, GPIO3_Combined_0_15_IRQn, GPIO4_Combined_16_31_IRQn, GPIO4_Combined_0_15_IRQn, GPIO5_Combined_16_31_IRQn, GPIO5_Combined_0_15_IRQn }
12098+
#define GPIO_COMBINED_IRQS { NotAvail_IRQn, GPIO1_Combined_16_31_IRQn, GPIO1_Combined_0_15_IRQn, GPIO2_Combined_16_31_IRQn, GPIO2_Combined_0_15_IRQn, GPIO3_Combined_16_31_IRQn, GPIO3_Combined_0_15_IRQn, GPIO4_Combined_16_31_IRQn, GPIO4_Combined_0_15_IRQn, GPIO5_Combined_16_31_IRQn, GPIO5_Combined_0_15_IRQn }
1209912099

1210012100
/*!
1210112101
* @}

0 commit comments

Comments
 (0)