Skip to content

Commit 5d03b57

Browse files
committed
Faster Interrupts, no size change.
1 parent b4f2af4 commit 5d03b57

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

Diff for: hardware/arduino/avr/cores/arduino/WInterrupts.c

+24-23
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,24 @@
3232

3333
#include "wiring_private.h"
3434

35-
static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
35+
static void nothing(void) {
36+
}
37+
38+
static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS] = {
39+
#if defined(__AVR_ATmega32U4__)
40+
nothing, // 3
41+
nothing, // 4
42+
#elif (defined(EICRA) && defined(EICRB) && defined(EIMSK))
43+
nothing, // 3
44+
nothing, // 4
45+
nothing, // 5
46+
nothing, // 6
47+
nothing, // 7
48+
#endif
49+
nothing, // 0
50+
nothing, // 1
51+
nothing // 2
52+
};
3653
// volatile static voidFuncPtr twiIntFunc;
3754

3855
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
@@ -226,7 +243,7 @@ void detachInterrupt(uint8_t interruptNum) {
226243
#endif
227244
}
228245

229-
intFunc[interruptNum] = 0;
246+
intFunc[interruptNum] = nothing;
230247
}
231248
}
232249

@@ -238,87 +255,71 @@ void attachInterruptTwi(void (*userFunc)(void) ) {
238255

239256
#if defined(__AVR_ATmega32U4__)
240257
ISR(INT0_vect) {
241-
if(intFunc[EXTERNAL_INT_0])
242-
intFunc[EXTERNAL_INT_0]();
258+
intFunc[EXTERNAL_INT_0]();
243259
}
244260

245261
ISR(INT1_vect) {
246-
if(intFunc[EXTERNAL_INT_1])
247-
intFunc[EXTERNAL_INT_1]();
262+
intFunc[EXTERNAL_INT_1]();
248263
}
249264

250265
ISR(INT2_vect) {
251-
if(intFunc[EXTERNAL_INT_2])
252-
intFunc[EXTERNAL_INT_2]();
266+
intFunc[EXTERNAL_INT_2]();
253267
}
254268

255269
ISR(INT3_vect) {
256-
if(intFunc[EXTERNAL_INT_3])
257-
intFunc[EXTERNAL_INT_3]();
270+
intFunc[EXTERNAL_INT_3]();
258271
}
259272

260273
ISR(INT6_vect) {
261-
if(intFunc[EXTERNAL_INT_4])
262-
intFunc[EXTERNAL_INT_4]();
274+
intFunc[EXTERNAL_INT_4]();
263275
}
264276

265277
#elif defined(EICRA) && defined(EICRB)
266278

267279
ISR(INT0_vect) {
268-
if(intFunc[EXTERNAL_INT_2])
269280
intFunc[EXTERNAL_INT_2]();
270281
}
271282

272283
ISR(INT1_vect) {
273-
if(intFunc[EXTERNAL_INT_3])
274284
intFunc[EXTERNAL_INT_3]();
275285
}
276286

277287
ISR(INT2_vect) {
278-
if(intFunc[EXTERNAL_INT_4])
279288
intFunc[EXTERNAL_INT_4]();
280289
}
281290

282291
ISR(INT3_vect) {
283-
if(intFunc[EXTERNAL_INT_5])
284292
intFunc[EXTERNAL_INT_5]();
285293
}
286294

287295
ISR(INT4_vect) {
288-
if(intFunc[EXTERNAL_INT_0])
289296
intFunc[EXTERNAL_INT_0]();
290297
}
291298

292299
ISR(INT5_vect) {
293-
if(intFunc[EXTERNAL_INT_1])
294300
intFunc[EXTERNAL_INT_1]();
295301
}
296302

297303
ISR(INT6_vect) {
298-
if(intFunc[EXTERNAL_INT_6])
299304
intFunc[EXTERNAL_INT_6]();
300305
}
301306

302307
ISR(INT7_vect) {
303-
if(intFunc[EXTERNAL_INT_7])
304308
intFunc[EXTERNAL_INT_7]();
305309
}
306310

307311
#else
308312

309313
ISR(INT0_vect) {
310-
if(intFunc[EXTERNAL_INT_0])
311314
intFunc[EXTERNAL_INT_0]();
312315
}
313316

314317
ISR(INT1_vect) {
315-
if(intFunc[EXTERNAL_INT_1])
316318
intFunc[EXTERNAL_INT_1]();
317319
}
318320

319321
#if defined(EICRA) && defined(ISC20)
320322
ISR(INT2_vect) {
321-
if(intFunc[EXTERNAL_INT_2])
322323
intFunc[EXTERNAL_INT_2]();
323324
}
324325
#endif

0 commit comments

Comments
 (0)