16FXlib
interrupts.c
Go to the documentation of this file.
1 
2 //*****************************************************************************
3 // Author : Christian Illy
4 // Created : 12.09.2012
5 // Version : 0.1
6 // Target MCU : Fujitsu MB96300 series
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
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.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //*****************************************************************************
22 #include "mb96348hs.h"
23 #include "interrupts.h"
24 
25 extern void InitIrqLevels(void);
26 
27 #pragma segment DATA=ivt,locate=0x7270
28 #pragma segment FAR_DATA=ivt,locate=0x7270
29 static IRQHandler ivt[100];
30 
31 static uint8_t initialized = 0;
32 
33 void interrupts_init(void) {
34  uint16_t i;
35 
36  if (initialized == 0) {
38  InitIrqLevels();
39 
40  for (i = 0; i < 100; i++) {
41  ivt[i] = *((IRQHandler*) (0xFFFC00ul + 0x270ul + i * 4ul));
42  }
43 
44  TBR = ((long) (&ivt[0]) & 0xfffc00l) >> 8;
45 
46  initialized = 1;
47 
49  }
50 }
51 
52 void interrupts_setHandler(uint8_t interruptNr, uint8_t interruptLevel, IRQHandler handler) {
53  if ((interruptNr < 12) || (interruptNr > 96))
54  return;
55  if (interruptLevel > 7)
56  return;
57 
58  if (initialized == 0)
60 
61  ICR = (interruptNr << 8) | interruptLevel;
62 
63  ivt[99 - interruptNr] = handler;
64 }
65 
67  if ((interruptNr < 12) || (interruptNr > 96))
68  return;
69 
70  if (initialized == 0)
72 
73  ICR = (interruptNr << 8) | 7;
74 }
#define interrupts_enable()
Definition: interrupts.h:63
void interrupts_init(void)
Definition: interrupts.c:33
void interrupts_disableInterrupt(uint8_t interruptNr)
Definition: interrupts.c:66
unsigned int uint16_t
Definition: inttypes.h:50
unsigned char uint8_t
Definition: inttypes.h:35
#define interrupts_disable()
Definition: interrupts.h:68
void interrupts_setHandler(uint8_t interruptNr, uint8_t interruptLevel, IRQHandler handler)
Definition: interrupts.c:52