# DAL GPIO interrupt APIs

Source: [https://docs.qualcomm.com/doc/80-88500-4/topic/33_DAL_GPIO_interrupt_APIs.html](https://docs.qualcomm.com/doc/80-88500-4/topic/33_DAL_GPIO_interrupt_APIs.html)

The DAL GPIO interrupt APIs register a GPIO interrupt service routine (ISR), deregister
    and disable a GPIO interrupt, and set the trigger type for a GPIO interrupt without providing an
    ISR.

## GPIO interrupt register and deregister

The following API allows you to register a GPIO interrupt ISR by specifying its triggering type.
        As a result of calling this API, the GPIO interrupt is enabled:

    DALResult GPIOInt_RegisterIsr(DalDeviceHandle * _h, 
           uint32 gpio, GPIOIntTriggerType trigger, 
           GPIOINTISR isr,GPIOINTISRCtx param)Copy to clipboard

The following API is provided for deregistering and disabling a GPIO interrupt:

    DALResult GPIOInt_DeregisterIsr(DalDeviceHandle * _h, 
           uint32 gpio, GPIOINTISR isr)Copy to clipboard

## GPIO interrupt trigger

The following API sets the trigger type for a GPIO interrupt without providing an ISR:

    DALResult GPIOInt_SetTrigger(DalDeviceHandle * _h, 
           uint32 gpio, GPIOIntTriggerType trigger)Copy to clipboard

## IsInterruptEnabled

The state returns irrespective of whether the GPIO interrupt is enabled:

    DALResult GPIOInt_IsInterruptEnabled(DalDeviceHandle * _h, 
           uint32 gpio, uint32* state)Copy to clipboard

## IsInterruptPending

This state returns irrespective of  whether the GPIO interrupt is pending (that is, enabled and
        triggered).

    DALResult GPIOInt_IsInterruptPending(DalDeviceHandle * _h, 
           uint32 gpio, uint32 * state)Copy to clipboard

## Example code

The following is an example of registering an ISR and changing the interrupt trigger:

    DalDeviceHandle * hGPIOInt;
    // Attach to DAL
    if((DAL_DeviceAttach(DALDEVICEID_GPIOINT, &hGPIOInt) 
    != DAL_SUCCESS) || (hGPIOInt == NULL) )
    {
    // Clients need to handle a failure here.
    }
    // Register the ISR to GPIO 5 IRQ.
    GPIOInt_RegisterIsr(hGPIOInt, 5, GPIOINT_TRIGGER_HIGH, 
    gpio5_isr, gpio5_param);
    // Change the trigger to RISING
    GPIOInt_SetTrigger(hGPIOInt, 5, GPIOINT_TRIGGER_RISING);
    Copy to clipboard

**Parent Topic:** [GPIO interrupt driver](https://docs.qualcomm.com/doc/80-88500-4/topic/31_GPIO_interrupt_driver.html)

Last Published: Aug 18, 2023

[Previous Topic
Data definitions](https://docs.qualcomm.com/bundle/publicresource/80-88500-4/topics/32_Data_definitions.md) [Next Topic
Wake-up interrupts](https://docs.qualcomm.com/bundle/publicresource/80-88500-4/topics/34_Wake_up_interrupts.md)