source: rtems/c/src/lib/libcpu/arm/lpc22xx/irq/irq.c @ 61e293b6

4.104.114.84.95
Last change on this file since 61e293b6 was 61e293b6, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/25/07 at 11:57:13

Use current OAR license file URL.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * Philps LPC22XX Interrupt handler
3 *
4 * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
5 * Modified by ray     
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13#include <bsp.h>
14#include <irq.h>
15#include <rtems/score/thread.h>
16#include <rtems/score/apiext.h>
17#include <lpc22xx.h>
18
19/*
20 * This function check that the value given for the irq line
21 * is valid.
22 */
23static int isValidInterrupt(int irq)
24{
25  if ( (irq < 0) || (irq >= BSP_MAX_INT))
26    return 0;
27  return 1;
28}
29
30/*
31 * Installs the interrupt handler.
32 *
33 * You should only have to add the code to unmask the interrupt.
34 *
35 */
36int BSP_install_rtems_irq_handler  (const rtems_irq_connect_data* irq)
37{
38    rtems_interrupt_level level;
39    rtems_irq_hdl *bsp_tbl;
40    int *vic_cntl;
41    static int     irq_counter=0;
42   
43    bsp_tbl = (rtems_irq_hdl *)VICVectAddrBase;
44
45    vic_cntl=(int *)VICVectCntlBase;
46   
47    if (!isValidInterrupt(irq->name)) {
48      return 0;
49    }
50
51    /*
52     * Check if default handler is actually connected. If not issue an error.
53     */
54
55    if (bsp_tbl[irq_counter] != default_int_handler) {
56      return 0;
57    }
58
59    _CPU_ISR_Disable(level);
60
61    /*
62     * store the new handler
63     */
64    bsp_tbl[irq_counter] = irq->hdl;
65    /* *(volatile unsigned long*)(VICVectAddr0+(irq->name * 4)&0x7c )= (uint32_t) irq->hdl;*/
66    /*
67     * Enable interrupt on device
68     */
69    vic_cntl[irq_counter] = 0x20 | irq->name;
70
71    VICIntEnable |= 1 << irq->name;
72   
73    if(irq->on)
74    {
75        irq->on(irq);
76    }
77
78    irq_counter++;   
79
80    _CPU_ISR_Enable(level);
81   
82    return 1;
83}
84
85/*
86 * Remove and interrupt handler
87 *
88 * You should only have to add the code to mask the interrupt.
89 *
90 */
91int BSP_remove_rtems_irq_handler  (const rtems_irq_connect_data* irq)
92{
93    rtems_interrupt_level level;
94    rtems_irq_hdl *bsp_tbl;
95
96    bsp_tbl = (rtems_irq_hdl *)&VICVectAddr0;
97 
98    if (!isValidInterrupt(irq->name)) {
99      return 0;
100    }
101    /*
102     * Check if the handler is actually connected. If not issue an error.
103     */
104    if (bsp_tbl[irq->name] != irq->hdl) {
105      return 0;
106    }
107
108    _CPU_ISR_Disable(level);
109
110    VICIntEnClr = 1 << irq->name;
111
112    /*
113     * Disable interrupt on device
114     */
115    if(irq->off) {
116        irq->off(irq);
117    }
118    /*
119     * restore the default irq value
120     */
121    bsp_tbl[irq->name] = default_int_handler;
122   
123
124    _CPU_ISR_Enable(level);
125
126    return 1;
127}
128
129
Note: See TracBrowser for help on using the repository browser.