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

cancel
Showing results for 
Search instead for 
Did you mean: 

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

2,185 Views
PeterChan
NXP Employee
NXP Employee

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.

Labels (1)
0 Replies