cd5771b78e798d3e49d97ef73d73cd70cab6261a
[fw/sdcc] / device / include / pic16 / signal.h
1
2 /*
3  * Signal handler header
4  *
5  * written by Vangelis Rokas, 2005 <vrokas AT otenet.gr>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  *
21  *
22  * $Id$
23  */
24
25 #ifndef __SIGNAL_H__
26 #define __SIGNAL_H__
27
28 #define RBIF    0x0
29 #define INT0IF  0x1
30 #define TMR0IF  0x2
31
32 #define INT1IF  0x0
33 #define INT2IF  0x1
34
35 #define TMR1IF  0x0
36 #define TMR2IF  0x1
37 #define CCP1IF  0x2
38 #define SSPIF   0x3
39 #define TXIF    0x4
40 #define RCIF    0x5
41 #define ADIF    0x6
42 #define PSPIF   0x7
43
44 #define CCP2IF  0x0
45 #define TMR3IF  0x1
46 #define LVDIF   0x2
47 #define BCLIF   0x3
48 #define EEIF    0x4
49 #define USBIF   0x5
50
51 /* interrupt testing arguments */
52 #define SIG_RB          _INTCON, RBIF
53 #define SIG_INT0        _INTCON, INT0IF
54 #define SIG_INT1        _INTCON3, INT1IF
55 #define SIG_INT2        _INTCON3, INT2IF
56 #define SIG_CCP1        _PIR1, CCP1IF
57 #define SIG_CCP2        _PIR2, CCP2IF
58 #define SIG_TMR0        _INTCON, TMR0IF
59 #define SIG_TMR1        _PIR1, TMR1IF
60 #define SIG_TMR2        _PIR1, TMR2IF
61 #define SIG_TMR3        _PIR2, TMR3IF
62 #define SIG_EE          _PIR2, EEIF
63 #define SIG_BCOL        _PIR2, BCLIF
64 #define SIG_LVD         _PIR2, LVDIF
65 #define SIG_PSP         _PIR1, PSPIF
66 #define SIG_AD          _PIR1, ADIF
67 #define SIG_RC          _PIR1, RCIF
68 #define SIG_TX          _PIR1, TXIF
69 #define SIG_MSSP        _PIR1, SSPIF
70 #define SIG_USB         _PIR2, USBIF
71
72
73 #define DEF_ABSVECTOR(vecno, name)      \
74 void __ivt_ ## name(void) __interrupt vecno __naked \
75 {\
76   __asm                          \n\
77     goto        _ ## name           \n\
78   __endasm;                      \
79 }
80
81 #define DEF_INTHIGH(name)       \
82 DEF_ABSVECTOR(1, name)                   \
83 void name(void) __naked __interrupt        \
84 {\
85   __asm                                  \n
86   
87
88 #define DEF_INTLOW(name)        \
89 DEF_ABSVECTOR(2, name)                   \
90 void name(void) __naked __interrupt        \
91 {\
92   __asm                          \n
93
94
95 #define END_DEF                 \
96     retfie                        \n\
97   __endasm;\
98 }
99
100
101 #define DEF_HANDLER(sig, handler)       \
102     btfsc       sig                 \n\
103     goto        _ ## handler
104
105
106 #define SIGHANDLER(handler)             void handler (void) __interrupt
107 #define SIGHANDLERNAKED(handler)        void handler (void) __naked __interrupt
108
109 #endif  /* __SIGNAL_H__ */