3

I'm a newbie trying to get level triggered interrupts on an embedded linux board. I'm using poll() to wait for the interrupt event. I was successful in getting edge triggered interrupts.

How can I get level-triggered interrupts? What do I set the edge to?

Zaxter
  • 2,939
  • 3
  • 31
  • 48
  • I'm not sure if I understood correctly what you want. You would like interrupts both for rising and falling events? – Michele d'Amico Nov 03 '14 at 12:40
  • 2
    @MicheleD'Amico: He wants level triggered interrupts. If you don't know what "level triggered" means, use Google – its a well defined programming term. Essentially he wants to get interrupt events continuously if the level on a certain line is either low or high (depending on the configuration). – datenwolf Nov 03 '14 at 12:52
  • 1
    I know what is it but I was not sure because is not really applicable for gpio sysfs. If he want it he must write it at higher level because gpio sysfs don't give (and IMHO maybe will never give) something like that to userspace. – Michele d'Amico Nov 03 '14 at 13:08

1 Answers1

2

The falling or rising transition triggers edge-triggered interrupt. Though polling is an option to handle such interrupts, to save CPU cycles, create a thread that can be scheduled by kernel to sleep until interrupt happens, and wake it up when the interrupt happens. In this way, the main program does not get locked in polling.

The interrupt line is at a high or low level for level-triggered interrupt. Concept of edge does not apply for level-triggered interrupt. Here the CPU shall scan the devices to find the one who triggered the interrupt. Once the device is serviced, it will continue to recheck the interrupt line status for other devices that may need the service(interrupt sharing). If this is not immediately Acked(cleared/handled), the system can go into a hanging state due to repeated/continuous calling of interrupt handler attention. That is, the external device shall assert the IRQ signal until the pending interrupt is cleared by software in-terms of writing to the device register. If many devices have triggered IRQ signal, the high or low level will be present until all the device drivers have serviced their respective devices. So, this should be handled immediately.

Karthik Balaguru
  • 7,424
  • 7
  • 48
  • 65