sanguino/cores/arduino/WInterrupts.c

Thu, 07 Jul 2016 12:23:34 +0200

author
mbayer
date
Thu, 07 Jul 2016 12:23:34 +0200
changeset 2
b373b0288715
permissions
-rw-r--r--

added missing sanguino files

2
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
1 /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
2
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
3 /*
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
4 Part of the Wiring project - http://wiring.uniandes.edu.co
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
5
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
6 Copyright (c) 2004-05 Hernando Barragan
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
7
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
8 This library is free software; you can redistribute it and/or
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
9 modify it under the terms of the GNU Lesser General Public
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
10 License as published by the Free Software Foundation; either
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
11 version 2.1 of the License, or (at your option) any later version.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
12
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
13 This library is distributed in the hope that it will be useful,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
16 Lesser General Public License for more details.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
17
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
18 You should have received a copy of the GNU Lesser General
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
19 Public License along with this library; if not, write to the
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
20 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
21 Boston, MA 02111-1307 USA
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
22
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
23 Modified 24 November 2006 by David A. Mellis
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
24 Modified 1 August 2010 by Mark Sproul
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
25 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
26
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
27 #include <inttypes.h>
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
28 #include <avr/io.h>
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
29 #include <avr/interrupt.h>
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
30 #include <avr/pgmspace.h>
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
31 #include <stdio.h>
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
32
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
33 #include "wiring_private.h"
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
34
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
35 static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
36 // volatile static voidFuncPtr twiIntFunc;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
37
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
38 void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
39 if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
40 intFunc[interruptNum] = userFunc;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
41
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
42 // Configure the interrupt mode (trigger on low input, any change, rising
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
43 // edge, or falling edge). The mode constants were chosen to correspond
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
44 // to the configuration bits in the hardware register, so we simply shift
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
45 // the mode into place.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
46
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
47 // Enable the interrupt.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
48
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
49 switch (interruptNum) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
50 #if defined(__AVR_ATmega32U4__)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
51 // I hate doing this, but the register assignment differs between the 1280/2560
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
52 // and the 32U4. Since avrlib defines registers PCMSK1 and PCMSK2 that aren't
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
53 // even present on the 32U4 this is the only way to distinguish between them.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
54 case 0:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
55 EICRA = (EICRA & ~((1<<ISC00) | (1<<ISC01))) | (mode << ISC00);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
56 EIMSK |= (1<<INT0);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
57 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
58 case 1:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
59 EICRA = (EICRA & ~((1<<ISC10) | (1<<ISC11))) | (mode << ISC10);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
60 EIMSK |= (1<<INT1);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
61 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
62 #elif defined(EICRA) && defined(EICRB) && defined(EIMSK)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
63 case 2:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
64 EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
65 EIMSK |= (1 << INT0);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
66 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
67 case 3:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
68 EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
69 EIMSK |= (1 << INT1);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
70 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
71 case 4:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
72 EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
73 EIMSK |= (1 << INT2);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
74 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
75 case 5:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
76 EICRA = (EICRA & ~((1 << ISC30) | (1 << ISC31))) | (mode << ISC30);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
77 EIMSK |= (1 << INT3);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
78 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
79 case 0:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
80 EICRB = (EICRB & ~((1 << ISC40) | (1 << ISC41))) | (mode << ISC40);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
81 EIMSK |= (1 << INT4);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
82 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
83 case 1:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
84 EICRB = (EICRB & ~((1 << ISC50) | (1 << ISC51))) | (mode << ISC50);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
85 EIMSK |= (1 << INT5);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
86 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
87 case 6:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
88 EICRB = (EICRB & ~((1 << ISC60) | (1 << ISC61))) | (mode << ISC60);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
89 EIMSK |= (1 << INT6);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
90 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
91 case 7:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
92 EICRB = (EICRB & ~((1 << ISC70) | (1 << ISC71))) | (mode << ISC70);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
93 EIMSK |= (1 << INT7);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
94 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
95 #else
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
96 case 0:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
97 #if defined(EICRA) && defined(ISC00) && defined(EIMSK)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
98 EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
99 EIMSK |= (1 << INT0);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
100 #elif defined(MCUCR) && defined(ISC00) && defined(GICR)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
101 MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
102 GICR |= (1 << INT0);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
103 #elif defined(MCUCR) && defined(ISC00) && defined(GIMSK)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
104 MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
105 GIMSK |= (1 << INT0);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
106 #else
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
107 #error attachInterrupt not finished for this CPU (case 0)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
108 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
109 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
110
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
111 case 1:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
112 #if defined(EICRA) && defined(ISC10) && defined(ISC11) && defined(EIMSK)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
113 EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
114 EIMSK |= (1 << INT1);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
115 #elif defined(MCUCR) && defined(ISC10) && defined(ISC11) && defined(GICR)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
116 MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
117 GICR |= (1 << INT1);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
118 #elif defined(MCUCR) && defined(ISC10) && defined(GIMSK) && defined(GIMSK)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
119 MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
120 GIMSK |= (1 << INT1);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
121 #else
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
122 #warning attachInterrupt may need some more work for this cpu (case 1)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
123 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
124 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
125
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
126 case 2:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
127 #if defined(EICRA) && defined(ISC20) && defined(ISC21) && defined(EIMSK)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
128 EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
129 EIMSK |= (1 << INT2);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
130 #elif defined(MCUCR) && defined(ISC20) && defined(ISC21) && defined(GICR)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
131 MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
132 GICR |= (1 << INT2);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
133 #elif defined(MCUCR) && defined(ISC20) && defined(GIMSK) && defined(GIMSK)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
134 MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
135 GIMSK |= (1 << INT2);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
136 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
137 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
138 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
139 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
140 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
141 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
142
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
143 void detachInterrupt(uint8_t interruptNum) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
144 if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
145 // Disable the interrupt. (We can't assume that interruptNum is equal
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
146 // to the number of the EIMSK bit to clear, as this isn't true on the
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
147 // ATmega8. There, INT0 is 6 and INT1 is 7.)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
148 switch (interruptNum) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
149 #if defined(__AVR_ATmega32U4__)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
150 case 0:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
151 EIMSK &= ~(1<<INT0);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
152 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
153 case 1:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
154 EIMSK &= ~(1<<INT1);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
155 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
156 #elif defined(EICRA) && defined(EICRB) && defined(EIMSK)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
157 case 2:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
158 EIMSK &= ~(1 << INT0);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
159 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
160 case 3:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
161 EIMSK &= ~(1 << INT1);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
162 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
163 case 4:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
164 EIMSK &= ~(1 << INT2);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
165 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
166 case 5:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
167 EIMSK &= ~(1 << INT3);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
168 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
169 case 0:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
170 EIMSK &= ~(1 << INT4);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
171 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
172 case 1:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
173 EIMSK &= ~(1 << INT5);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
174 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
175 case 6:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
176 EIMSK &= ~(1 << INT6);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
177 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
178 case 7:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
179 EIMSK &= ~(1 << INT7);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
180 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
181 #else
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
182 case 0:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
183 #if defined(EIMSK) && defined(INT0)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
184 EIMSK &= ~(1 << INT0);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
185 #elif defined(GICR) && defined(ISC00)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
186 GICR &= ~(1 << INT0); // atmega32
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
187 #elif defined(GIMSK) && defined(INT0)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
188 GIMSK &= ~(1 << INT0);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
189 #else
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
190 #error detachInterrupt not finished for this cpu
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
191 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
192 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
193
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
194 case 1:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
195 #if defined(EIMSK) && defined(INT1)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
196 EIMSK &= ~(1 << INT1);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
197 #elif defined(GICR) && defined(INT1)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
198 GICR &= ~(1 << INT1); // atmega32
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
199 #elif defined(GIMSK) && defined(INT1)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
200 GIMSK &= ~(1 << INT1);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
201 #else
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
202 #warning detachInterrupt may need some more work for this cpu (case 1)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
203 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
204 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
205 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
206 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
207
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
208 intFunc[interruptNum] = 0;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
209 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
210 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
211
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
212 /*
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
213 void attachInterruptTwi(void (*userFunc)(void) ) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
214 twiIntFunc = userFunc;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
215 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
216 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
217
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
218 #if defined(__AVR_ATmega32U4__)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
219 SIGNAL(INT0_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
220 if(intFunc[EXTERNAL_INT_0])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
221 intFunc[EXTERNAL_INT_0]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
222 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
223
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
224 SIGNAL(INT1_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
225 if(intFunc[EXTERNAL_INT_1])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
226 intFunc[EXTERNAL_INT_1]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
227 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
228
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
229 #elif defined(EICRA) && defined(EICRB)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
230
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
231 SIGNAL(INT0_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
232 if(intFunc[EXTERNAL_INT_2])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
233 intFunc[EXTERNAL_INT_2]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
234 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
235
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
236 SIGNAL(INT1_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
237 if(intFunc[EXTERNAL_INT_3])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
238 intFunc[EXTERNAL_INT_3]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
239 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
240
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
241 SIGNAL(INT2_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
242 if(intFunc[EXTERNAL_INT_4])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
243 intFunc[EXTERNAL_INT_4]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
244 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
245
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
246 SIGNAL(INT3_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
247 if(intFunc[EXTERNAL_INT_5])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
248 intFunc[EXTERNAL_INT_5]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
249 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
250
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
251 SIGNAL(INT4_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
252 if(intFunc[EXTERNAL_INT_0])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
253 intFunc[EXTERNAL_INT_0]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
254 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
255
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
256 SIGNAL(INT5_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
257 if(intFunc[EXTERNAL_INT_1])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
258 intFunc[EXTERNAL_INT_1]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
259 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
260
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
261 SIGNAL(INT6_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
262 if(intFunc[EXTERNAL_INT_6])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
263 intFunc[EXTERNAL_INT_6]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
264 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
265
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
266 SIGNAL(INT7_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
267 if(intFunc[EXTERNAL_INT_7])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
268 intFunc[EXTERNAL_INT_7]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
269 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
270
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
271 #else
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
272
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
273 SIGNAL(INT0_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
274 if(intFunc[EXTERNAL_INT_0])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
275 intFunc[EXTERNAL_INT_0]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
276 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
277
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
278 SIGNAL(INT1_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
279 if(intFunc[EXTERNAL_INT_1])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
280 intFunc[EXTERNAL_INT_1]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
281 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
282
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
283 #if defined(EICRA) && defined(ISC20)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
284 SIGNAL(INT2_vect) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
285 if(intFunc[EXTERNAL_INT_2])
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
286 intFunc[EXTERNAL_INT_2]();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
287 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
288 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
289
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
290 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
291
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
292 /*
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
293 SIGNAL(SIG_2WIRE_SERIAL) {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
294 if(twiIntFunc)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
295 twiIntFunc();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
296 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
297 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
298

mercurial