Loading...
Searching...
No Matches
examples/libs/libirq/async_isr.c

libirq usage example using asynchronous ISR handler functionality.

libirq usage example using asynchronous ISR handler functionality.

/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* This file is part of TUD:OS and distributed under the terms of the
* GNU General Public License 2.
* Please see the COPYING-GPL-2 file for details.
*/
/*
* This example shall show how to use the libirq.
*/
#include <l4/irq/irq.h>
#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;
if (!(irqdesc = l4irq_request(IRQ_NO, isr_handler, 0, 0xff, 0)))
{
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);
l4_sleep(seconds * 1000);
if (l4irq_release(irqdesc))
{
printf("Failed to release IRQ\n");
return 1;
}
printf("Bye\n");
return 0;
}
l4irq_request
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.
l4irq_release
long l4irq_release(l4irq_t *irq)
Release asynchronous ISR handler and free resources.
l4_sleep
void l4_sleep(l4_uint32_t ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
irq.h
IRQ handling routines.