32
32
33
33
#include "wiring_private.h"
34
34
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 EXTERNAL_NUM_INTERRUPTS > 8
40
+ #warning There are more than 8 external interrupts. Some callbacks may not be initialized.
41
+ nothing ,
42
+ #endif
43
+ #if EXTERNAL_NUM_INTERRUPTS > 7
44
+ nothing ,
45
+ #endif
46
+ #if EXTERNAL_NUM_INTERRUPTS > 6
47
+ nothing ,
48
+ #endif
49
+ #if EXTERNAL_NUM_INTERRUPTS > 5
50
+ nothing ,
51
+ #endif
52
+ #if EXTERNAL_NUM_INTERRUPTS > 4
53
+ nothing ,
54
+ #endif
55
+ #if EXTERNAL_NUM_INTERRUPTS > 3
56
+ nothing ,
57
+ #endif
58
+ #if EXTERNAL_NUM_INTERRUPTS > 2
59
+ nothing ,
60
+ #endif
61
+ #if EXTERNAL_NUM_INTERRUPTS > 1
62
+ nothing ,
63
+ #endif
64
+ nothing
65
+ };
36
66
// volatile static voidFuncPtr twiIntFunc;
37
67
38
68
void attachInterrupt (uint8_t interruptNum , void (* userFunc )(void ), int mode ) {
@@ -238,7 +268,7 @@ void detachInterrupt(uint8_t interruptNum) {
238
268
#endif
239
269
}
240
270
241
- intFunc [interruptNum ] = 0 ;
271
+ intFunc [interruptNum ] = nothing ;
242
272
}
243
273
}
244
274
@@ -250,87 +280,71 @@ void attachInterruptTwi(void (*userFunc)(void) ) {
250
280
251
281
#if defined(__AVR_ATmega32U4__ )
252
282
ISR (INT0_vect ) {
253
- if (intFunc [EXTERNAL_INT_0 ])
254
- intFunc [EXTERNAL_INT_0 ]();
283
+ intFunc [EXTERNAL_INT_0 ]();
255
284
}
256
285
257
286
ISR (INT1_vect ) {
258
- if (intFunc [EXTERNAL_INT_1 ])
259
- intFunc [EXTERNAL_INT_1 ]();
287
+ intFunc [EXTERNAL_INT_1 ]();
260
288
}
261
289
262
290
ISR (INT2_vect ) {
263
- if (intFunc [EXTERNAL_INT_2 ])
264
- intFunc [EXTERNAL_INT_2 ]();
291
+ intFunc [EXTERNAL_INT_2 ]();
265
292
}
266
293
267
294
ISR (INT3_vect ) {
268
- if (intFunc [EXTERNAL_INT_3 ])
269
- intFunc [EXTERNAL_INT_3 ]();
295
+ intFunc [EXTERNAL_INT_3 ]();
270
296
}
271
297
272
298
ISR (INT6_vect ) {
273
- if (intFunc [EXTERNAL_INT_4 ])
274
- intFunc [EXTERNAL_INT_4 ]();
299
+ intFunc [EXTERNAL_INT_4 ]();
275
300
}
276
301
277
302
#elif defined(EICRA ) && defined(EICRB )
278
303
279
304
ISR (INT0_vect ) {
280
- if (intFunc [EXTERNAL_INT_2 ])
281
305
intFunc [EXTERNAL_INT_2 ]();
282
306
}
283
307
284
308
ISR (INT1_vect ) {
285
- if (intFunc [EXTERNAL_INT_3 ])
286
309
intFunc [EXTERNAL_INT_3 ]();
287
310
}
288
311
289
312
ISR (INT2_vect ) {
290
- if (intFunc [EXTERNAL_INT_4 ])
291
313
intFunc [EXTERNAL_INT_4 ]();
292
314
}
293
315
294
316
ISR (INT3_vect ) {
295
- if (intFunc [EXTERNAL_INT_5 ])
296
317
intFunc [EXTERNAL_INT_5 ]();
297
318
}
298
319
299
320
ISR (INT4_vect ) {
300
- if (intFunc [EXTERNAL_INT_0 ])
301
321
intFunc [EXTERNAL_INT_0 ]();
302
322
}
303
323
304
324
ISR (INT5_vect ) {
305
- if (intFunc [EXTERNAL_INT_1 ])
306
325
intFunc [EXTERNAL_INT_1 ]();
307
326
}
308
327
309
328
ISR (INT6_vect ) {
310
- if (intFunc [EXTERNAL_INT_6 ])
311
329
intFunc [EXTERNAL_INT_6 ]();
312
330
}
313
331
314
332
ISR (INT7_vect ) {
315
- if (intFunc [EXTERNAL_INT_7 ])
316
333
intFunc [EXTERNAL_INT_7 ]();
317
334
}
318
335
319
336
#else
320
337
321
338
ISR (INT0_vect ) {
322
- if (intFunc [EXTERNAL_INT_0 ])
323
339
intFunc [EXTERNAL_INT_0 ]();
324
340
}
325
341
326
342
ISR (INT1_vect ) {
327
- if (intFunc [EXTERNAL_INT_1 ])
328
343
intFunc [EXTERNAL_INT_1 ]();
329
344
}
330
345
331
346
#if defined(EICRA ) && defined(ISC20 )
332
347
ISR (INT2_vect ) {
333
- if (intFunc [EXTERNAL_INT_2 ])
334
348
intFunc [EXTERNAL_INT_2 ]();
335
349
}
336
350
#endif
0 commit comments