libirq usage example using asynchronous ISR handler functionality.
libirq usage example using asynchronous ISR handler functionality.
 
#include <l4/util/util.h>
 
#include <stdio.h>
 
enum { IRQ_NO = 17 };
 
static void isr_handler(void *data)
{
  (void)data;
  printf("Got IRQ %d\n", IRQ_NO);
}
 
int main(void)
{
  const int seconds = 5;
  l4irq_t *irqdesc;
 
    {
      printf("Requesting IRQ %d failed\n", IRQ_NO);
      return 1;
    }
 
  printf("Attached to key IRQ %d\nPress keys now, will terminate in %d seconds\n",
         IRQ_NO, seconds);
 
 
    {
      printf("Failed to release IRQ\n");
      return 1;
    }
 
  printf("Bye\n");
  return 0;
}
l4irq_t * l4irq_request(int irqnum, void(*isr_handler)(void *), void *isr_data, int irq_thread_prio, unsigned mode)
Attach asychronous ISR handler to IRQ.
 
long l4irq_release(l4irq_t *irq)
Release asynchronous ISR handler and free resources.
 
void l4_sleep(l4_uint32_t ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.