MINI2440: Removed old, non working NOR support
[u-boot-openmoko/mini2440.git] / examples / interrupt.c
blobf3061d1ec038ada1764e9c3bead01dbd4ae1d3c4
1 /*
2 * (C) Copyright 2006
3 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
5 * See file CREDITS for list of people who contributed to this
6 * project.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
23 * This is a very simple standalone application demonstrating
24 * catching IRQs on the MPC52xx architecture.
26 * The interrupt to be intercepted can be specified as an argument
27 * to the application. Specifying nothing will intercept IRQ1 on the
28 * MPC5200 platform. On the CR825 carrier board from MicroSys this
29 * maps to the ABORT switch :)
31 * Note that the specified vector is only a logical number specified
32 * by the respective header file.
35 #include <common.h>
36 #include <exports.h>
37 #include <config.h>
39 #if defined(CONFIG_MPC5xxx)
40 #define DFL_IRQ MPC5XXX_IRQ1
41 #else
42 #define DFL_IRQ 0
43 #endif
45 static void irq_handler (void *arg);
47 int interrupt (int argc, char *argv[])
49 int c, irq = -1;
51 app_startup (argv);
53 if (argc > 1)
54 irq = simple_strtoul (argv[1], NULL, 0);
55 if ((irq < 0) || (irq > NR_IRQS))
56 irq = DFL_IRQ;
58 printf ("Installing handler for irq vector %d and doing busy wait\n",
59 irq);
60 printf ("Press 'q' to quit\n");
62 /* Install interrupt handler */
63 install_hdlr (irq, irq_handler, NULL);
64 while ((c = getc ()) != 'q') {
65 printf ("Ok, ok, I am still alive!\n");
68 free_hdlr (irq);
69 printf ("\nInterrupt handler has been uninstalled\n");
71 return (0);
75 * Handler for interrupt
77 static void irq_handler (void *arg)
79 /* just for demonstration */
80 printf ("+");