# GPIO - interrupt

Source: [https://docs.qualcomm.com/doc/80-58740-4/topic/gpio-interrupt.html](https://docs.qualcomm.com/doc/80-58740-4/topic/gpio-interrupt.html)

This demo mainly introduces the synchronous low-level interrupt type of GPIO 0.

## Hardware connection

Connect GPIO 0 to GND.

## Software implementation

For more detailed code, please refer to
                    examples/peripherals/gpio/gpio\_interrupt.

    board_init();Copy to clipboard

- Turn on the clock in `board_init`

    gpio = qcc74x_device_get_by_name("gpio");
    
    qcc74x_gpio_int_init(gpio, GPIO_PIN_0, GPIO_INT_TRIG_MODE_SYNC_LOW_LEVEL);Copy to clipboard

- Set the interrupt type of GPIO 0

    qcc74x_gpio_int_mask(gpio, GPIO_PIN_0, false);
    
    qcc74x_irq_attach(gpio->irq_num, gpio_isr, gpio);
    qcc74x_irq_enable(gpio->irq_num);Copy to clipboard

- `qcc74x_gpio_int_mask(gpio, GPIO_PIN_0, false)` turns on GPIO
                        0 interrupt
- `qcc74x_irq_attach(gpio->irq_num, gpio_isr, gpio)` register
                        GPIO interrupt function
- `qcc74x_irq_enable(gpio->irq_num)` enables GPIO interrupt

## Experimental phenomena

Pull the GPIO 0 pin level low to enter the interrupt and print the number of
                interrupts.

**Parent Topic:** [GPIO](https://docs.qualcomm.com/doc/80-58740-4/topic/gpio.html)

Last Published: Feb 10, 2025

[Previous Topic
GPIO - input/output](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/gpio-input-output.md) [Next Topic
I2C](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/i2c.md)