Skip to content

Commit 5488420

Browse files
cmagliemattairtech
authored andcommitted
Simplified "callbacksInt" structure in WInterrupts.c
1 parent efe4632 commit 5488420

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

cores/arduino/WInterrupts.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@
2525
extern "C" {
2626
#endif
2727

28-
static struct
29-
{
30-
uint32_t _ulPin ;
31-
voidFuncPtr _callback ;
32-
} callbacksInt[EXTERNAL_NUM_INTERRUPTS] ;
28+
static voidFuncPtr callbacksInt[EXTERNAL_NUM_INTERRUPTS];
3329

3430
/* Configure I/O interrupt sources */
3531
static void __initialize()
3632
{
37-
memset( callbacksInt, 0, sizeof( callbacksInt ) ) ;
33+
memset(callbacksInt, 0, sizeof(callbacksInt));
3834

3935
NVIC_DisableIRQ( EIC_IRQn ) ;
4036
NVIC_ClearPendingIRQ( EIC_IRQn ) ;
@@ -86,8 +82,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
8682
}
8783

8884
// Assign callback to interrupt
89-
callbacksInt[digitalPinToInterrupt(pin)]._ulPin = pin;
90-
callbacksInt[digitalPinToInterrupt(pin)]._callback = callback;
85+
callbacksInt[digitalPinToInterrupt(pin)] = callback;
9186

9287
// Look for right CONFIG register to be addressed
9388
if (digitalPinToInterrupt(pin) > EXTERNAL_INT_7) {
@@ -151,9 +146,8 @@ void EIC_Handler( void )
151146
if ( (EIC->INTFLAG.reg & ( 1 << ul ) ) != 0 )
152147
{
153148
// Call the callback function if assigned
154-
if ( callbacksInt[ul]._callback != NULL )
155-
{
156-
callbacksInt[ul]._callback() ;
149+
if (callbacksInt[ul]) {
150+
callbacksInt[ul]();
157151
}
158152

159153
// Clear the interrupt

0 commit comments

Comments
 (0)