source: rtems/c/src/lib/libbsp/arm/nds/libnds/source/common/interrupts.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*---------------------------------------------------------------------------------
2        Copyright (C) 2005
3                Dave Murphy (WinterMute)
4
5        This software is provided 'as-is', without any express or implied
6        warranty.  In no event will the authors be held liable for any
7        damages arising from the use of this software.
8
9        Permission is granted to anyone to use this software for any
10        purpose, including commercial applications, and to alter it and
11        redistribute it freely, subject to the following restrictions:
12
13        1.      The origin of this software must not be misrepresented; you
14                must not claim that you wrote the original software. If you use
15                this software in a product, an acknowledgment in the product
16                documentation would be appreciated but is not required.
17        2.      Altered source versions must be plainly marked as such, and
18                must not be misrepresented as being the original software.
19        3.      This notice may not be removed or altered from any source
20                distribution.
21
22---------------------------------------------------------------------------------*/
23
24#include <nds/interrupts.h>
25#include <nds/system.h>
26
27void IntrMain(void);    // Prototype for assembly interrupt dispatcher
28
29//---------------------------------------------------------------------------------
30void irqDummy(void) {}
31//---------------------------------------------------------------------------------
32
33
34#ifdef ARM9
35#define INT_TABLE_SECTION __attribute__((section(".bsp_fast_text")))
36#else
37#define INT_TABLE_SECTION
38#endif
39
40struct IntTable irqTable[MAX_INTERRUPTS] INT_TABLE_SECTION;
41
42//---------------------------------------------------------------------------------
43void irqSet(int mask, IntFn handler) {
44//---------------------------------------------------------------------------------
45        if (!mask) return;
46
47        int i;
48
49        for     (i=0;i<MAX_INTERRUPTS;i++)
50                if      (!irqTable[i].mask || irqTable[i].mask == mask) break;
51
52        if ( i == MAX_INTERRUPTS ) return;
53
54        irqTable[i].handler     = handler;
55        irqTable[i].mask        = mask;
56
57        if(mask & IRQ_VBLANK)
58                REG_DISPSTAT |= DISP_VBLANK_IRQ ;
59        if(mask & IRQ_HBLANK)
60                REG_DISPSTAT |= DISP_HBLANK_IRQ ;
61
62        REG_IE |= mask;
63}
64
65//---------------------------------------------------------------------------------
66void irqInit() {
67//---------------------------------------------------------------------------------
68        int i;
69
70        // Set all interrupts to dummy functions.
71        for(i = 0; i < MAX_INTERRUPTS; i ++)
72        {
73                irqTable[i].handler = irqDummy;
74                irqTable[i].mask = 0;
75        }
76
77        IRQ_HANDLER = IntrMain;
78
79        REG_IE  = 0;                    // disable all interrupts
80        REG_IF  = IRQ_ALL;              // clear all pending interrupts
81        REG_IME = 1;                    // enable global interrupt
82
83}
84
85
86//---------------------------------------------------------------------------------
87void irqClear(int mask) {
88//---------------------------------------------------------------------------------
89        int i = 0;
90
91        for     (i=0;i<MAX_INTERRUPTS;i++)
92                if      (irqTable[i].mask == mask) break;
93
94        if ( i == MAX_INTERRUPTS ) return;
95
96        irqTable[i].handler     = irqDummy;
97
98        if (mask & IRQ_VBLANK)
99                REG_DISPSTAT &= ~DISP_VBLANK_IRQ ;
100        if (mask & IRQ_HBLANK)
101                REG_DISPSTAT &= ~DISP_HBLANK_IRQ ;
102        if (mask & IRQ_VCOUNT)
103                REG_DISPSTAT &= ~DISP_YTRIGGER_IRQ;
104
105        REG_IE &= ~mask;
106}
107
108
109//---------------------------------------------------------------------------------
110void irqInitHandler(IntFn handler) {
111//---------------------------------------------------------------------------------
112        REG_IME = 0;
113        REG_IF = ~0;
114        REG_IE = 0;
115
116        IRQ_HANDLER = handler;
117
118        REG_IME = 1;
119}
120
121//---------------------------------------------------------------------------------
122void irqEnable(uint32 irq) {
123//---------------------------------------------------------------------------------
124        if (irq & IRQ_VBLANK)
125                REG_DISPSTAT |= DISP_VBLANK_IRQ ;
126        if (irq & IRQ_HBLANK)
127                REG_DISPSTAT |= DISP_HBLANK_IRQ ;
128        if (irq & IRQ_VCOUNT)
129                REG_DISPSTAT |= DISP_YTRIGGER_IRQ;
130
131        REG_IE |= irq;
132        REG_IME = 1;
133}
134
135//---------------------------------------------------------------------------------
136void irqDisable(uint32 irq) {
137//---------------------------------------------------------------------------------
138        if (irq & IRQ_VBLANK)
139                REG_DISPSTAT &= ~DISP_VBLANK_IRQ ;
140        if (irq & IRQ_HBLANK)
141                REG_DISPSTAT &= ~DISP_HBLANK_IRQ ;
142        if (irq & IRQ_VCOUNT)
143                REG_DISPSTAT &= ~DISP_YTRIGGER_IRQ;
144
145        REG_IE &= ~irq;
146}
147
Note: See TracBrowser for help on using the repository browser.