-
Notifications
You must be signed in to change notification settings - Fork 0
/
interrupts.c
74 lines (58 loc) · 1.95 KB
/
interrupts.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*! \file interrupts.c */
//*****************************************************************************
// Author : Christian Illy
// Created : 12.09.2012
// Version : 0.1
// Target MCU : Fujitsu MB96300 series
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//*****************************************************************************
#include "mb96348hs.h"
#include "interrupts.h"
extern void InitIrqLevels(void);
#pragma segment DATA=ivt,locate=0x7270
#pragma segment FAR_DATA=ivt,locate=0x7270
static IRQHandler ivt[100];
static uint8_t initialized = 0;
void interrupts_init(void) {
uint16_t i;
if (initialized == 0) {
interrupts_disable();
InitIrqLevels();
for (i = 0; i < 100; i++) {
ivt[i] = *((IRQHandler*) (0xFFFC00ul + 0x270ul + i * 4ul));
}
TBR = ((long) (&ivt[0]) & 0xfffc00l) >> 8;
initialized = 1;
interrupts_enable();
}
}
void interrupts_setHandler(uint8_t interruptNr, uint8_t interruptLevel, IRQHandler handler) {
if ((interruptNr < 12) || (interruptNr > 96))
return;
if (interruptLevel > 7)
return;
if (initialized == 0)
interrupts_init();
ICR = (interruptNr << 8) | interruptLevel;
ivt[99 - interruptNr] = handler;
}
void interrupts_disableInterrupt(uint8_t interruptNr) {
if ((interruptNr < 12) || (interruptNr > 96))
return;
if (initialized == 0)
interrupts_init();
ICR = (interruptNr << 8) | 7;
}