summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libcpu/arm/lpc22xx/irq/irq.c
diff options
context:
space:
mode:
authorRalf Corsepius <ralf.corsepius@rtems.org>2007-04-25 11:51:44 +0000
committerRalf Corsepius <ralf.corsepius@rtems.org>2007-04-25 11:51:44 +0000
commita44e045bbfb1e8e1a41f246e5f36c7831ee92c3d (patch)
treea49f3680622b16d6755c2612bbb572cc7276a5a2 /c/src/lib/libcpu/arm/lpc22xx/irq/irq.c
parentConvert to Unix. (diff)
downloadrtems-a44e045bbfb1e8e1a41f246e5f36c7831ee92c3d.tar.bz2
2007-04-25 Ray Xu <xr@trasin.net>
* lpc22xx/irq/bsp_irq_init.c lpc22xx/irq/irq.c, lpc22xx/irq/irq.h: New (Initial submission).
Diffstat (limited to 'c/src/lib/libcpu/arm/lpc22xx/irq/irq.c')
-rw-r--r--c/src/lib/libcpu/arm/lpc22xx/irq/irq.c129
1 files changed, 129 insertions, 0 deletions
diff --git a/c/src/lib/libcpu/arm/lpc22xx/irq/irq.c b/c/src/lib/libcpu/arm/lpc22xx/irq/irq.c
new file mode 100644
index 0000000000..9738042b43
--- /dev/null
+++ b/c/src/lib/libcpu/arm/lpc22xx/irq/irq.c
@@ -0,0 +1,129 @@
+/*
+ * Philps LPC22XX Interrupt handler
+ *
+ * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
+ * Modified by ray
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ *
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+#include <bsp.h>
+#include <irq.h>
+#include <rtems/score/thread.h>
+#include <rtems/score/apiext.h>
+#include <lpc22xx.h>
+
+/*
+ * This function check that the value given for the irq line
+ * is valid.
+ */
+static int isValidInterrupt(int irq)
+{
+ if ( (irq < 0) || (irq >= BSP_MAX_INT))
+ return 0;
+ return 1;
+}
+
+/*
+ * Installs the interrupt handler.
+ *
+ * You should only have to add the code to unmask the interrupt.
+ *
+ */
+int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq)
+{
+ rtems_interrupt_level level;
+ rtems_irq_hdl *bsp_tbl;
+ int *vic_cntl;
+ static int irq_counter=0;
+
+ bsp_tbl = (rtems_irq_hdl *)VICVectAddrBase;
+
+ vic_cntl=(int *)VICVectCntlBase;
+
+ if (!isValidInterrupt(irq->name)) {
+ return 0;
+ }
+
+ /*
+ * Check if default handler is actually connected. If not issue an error.
+ */
+
+ if (bsp_tbl[irq_counter] != default_int_handler) {
+ return 0;
+ }
+
+ _CPU_ISR_Disable(level);
+
+ /*
+ * store the new handler
+ */
+ bsp_tbl[irq_counter] = irq->hdl;
+ /* *(volatile unsigned long*)(VICVectAddr0+(irq->name * 4)&0x7c )= (uint32_t) irq->hdl;*/
+ /*
+ * Enable interrupt on device
+ */
+ vic_cntl[irq_counter] = 0x20 | irq->name;
+
+ VICIntEnable |= 1 << irq->name;
+
+ if(irq->on)
+ {
+ irq->on(irq);
+ }
+
+ irq_counter++;
+
+ _CPU_ISR_Enable(level);
+
+ return 1;
+}
+
+/*
+ * Remove and interrupt handler
+ *
+ * You should only have to add the code to mask the interrupt.
+ *
+ */
+int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data* irq)
+{
+ rtems_interrupt_level level;
+ rtems_irq_hdl *bsp_tbl;
+
+ bsp_tbl = (rtems_irq_hdl *)&VICVectAddr0;
+
+ if (!isValidInterrupt(irq->name)) {
+ return 0;
+ }
+ /*
+ * Check if the handler is actually connected. If not issue an error.
+ */
+ if (bsp_tbl[irq->name] != irq->hdl) {
+ return 0;
+ }
+
+ _CPU_ISR_Disable(level);
+
+ VICIntEnClr = 1 << irq->name;
+
+ /*
+ * Disable interrupt on device
+ */
+ if(irq->off) {
+ irq->off(irq);
+ }
+ /*
+ * restore the default irq value
+ */
+ bsp_tbl[irq->name] = default_int_handler;
+
+
+ _CPU_ISR_Enable(level);
+
+ return 1;
+}
+
+