Alex Hoppus
Alex Hoppus

Reputation: 3935

GPIO irq: Falling and Rising edge detection

I try to create bare metal application for TI am335x soc based board. One thing I need to do is to invoke callback1 on rising edge and callback2 on falling edge. From the datasheet I figured out, that simultaneous detection for rising and falling edge could be enabled by writing 1 << pin to RISINGDETECT and FALLINGDETECT GPIO registers. However, I can't understand (see no signs of it in datasheet), how could I determine if the currently appeared interrupt was caused by RISING edge on GPIO or by FALLING edge?

Upvotes: 3

Views: 2674

Answers (1)

sawdust
sawdust

Reputation: 17047

how could I determine if the currently appeared interrupt was caused by RISING edge on GPIO or by FALLING edge?

Try checking the state of the pin.
A rising edge results in a on state, whereas a falling edge results in a off state.
So the current state of the pin implies the direction of the most-recent interrupt.


ADDENDUM

This answer does not apply to Allwinner SoCs such as the A10 and H3. Those devices do not permit a pin multiplexed as an external interrupt source to be read. Only a pin multiplexed as a (general purpose) input can be read. For more details, see Wait for interrupt for specific level

Upvotes: 5

Related Questions