Skip to main content
Explorer
December 16, 2025
Solved

zephyr GPIO irq config

  • December 16, 2025
  • 1 reply
  • 50 views

Hi,
In the GPIO interrupt configuration, the port information is ignored and only the pin number is used for identification. As a result, pins with the same pin number on different ports cannot be enabled as interrupt sources at the same time.

 
stm32_gpio_irq_line_t stm32_gpio_intc_get_pin_irq_line(uint32_t port, gpio_pin_t pin)
{
    ARG_UNUSED(port);
    return linenum_to_ll_exti_line(pin);
}
 
int stm32_gpio_intc_set_irq_callback(stm32_gpio_irq_line_t line, stm32_gpio_irq_cb_t cb, void *user)
{
    const struct device *const dev = DEVICE_DT_GET(EXTI_NODE);
    struct stm32_exti_data *data = dev->data;
    uint32_t line_num = ll_exti_line_to_linenum(line);

    if ((data->cb[line_num].cb == cb) && (data->cb[line_num].data == user)) {
        return 0;
    }

    /* if callback already exists/maybe-running return busy */
    if (data->cb[line_num].cb != NULL) {
        return -EBUSY;
    }
    ...
    return 0;
}
 
static int gpio_stm32_pin_interrupt_configure(const struct device *dev,
                          gpio_pin_t pin,
                          enum gpio_int_mode mode,
                          enum gpio_int_trig trig)
{
   ...
    const stm32_gpio_irq_line_t irq_line = stm32_gpio_intc_get_pin_irq_line(cfg->port, pin);
  ...
    if (stm32_gpio_intc_set_irq_callback(irq_line, gpio_stm32_isr, data) != 0) {
        err = -EBUSY;
        goto exit;
    }
   ...
exit:
    return err;
}

 

    This topic has been closed for replies.
    Best answer by TDK

    > pins with the same pin number on different ports cannot be enabled as interrupt sources at the same time

    This is a hardware limitation of the chip, not a Zephyr implementation limitation. There is no bug here.

    PA7 and PB7 cannot both be interrupts at the same time. Only one of them can. See the EXTI_EXTICRm registers for the underlying hardware limitation.

    You can configure up to 16 pins to be interrupts, but they all need to have unique pin numbers. Ports can be the same or different.

    1 reply

    TDKAnswer
    Super User
    December 16, 2025

    > pins with the same pin number on different ports cannot be enabled as interrupt sources at the same time

    This is a hardware limitation of the chip, not a Zephyr implementation limitation. There is no bug here.

    PA7 and PB7 cannot both be interrupts at the same time. Only one of them can. See the EXTI_EXTICRm registers for the underlying hardware limitation.

    You can configure up to 16 pins to be interrupts, but they all need to have unique pin numbers. Ports can be the same or different.