PeterChan

i.MX28: GPIO interrupt on both rising and falling edges

Discussion created by PeterChan Employee on Mar 13, 2013

i.MX28 GPIO pins only support the following IRQ types: IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, IRQ_TYPE_LEVEL_HIGH and IRQ_TYPE_LEVEL_LOW. IRQ_TYPE_EDGE_BOTH is not supported.

 

It application requires interrupt on both rising and falling edges, software can set the IRQ type to level trigger and set the polarity in reverse to the current GPIO input level. Below is the example.

 

value = gpio_get_value(pdata->id_gpio) ? 1 : 0;

if (value)

    set_irq_type(gpio_to_irq(pdata->id_gpio), IRQ_TYPE_LEVEL_LOW); else

    set_irq_type(gpio_to_irq(pdata->id_gpio), IRQ_TYPE_LEVEL_HIGH); ...

 

When GPIO input value is low, set the IRQ type to IRQ_TYPE_LEVEL_HIGH. When the GPIO input value is high, set the IRQ type to IRQ_TYPE_LEVEL_LOW. Do the same checking in the GPIO IRQ handler. In this way, interrupts on both edges can be captured.

 

Outcomes