Skip to content

Commit e32f402

Browse files
Claudio Indellicatibitron
authored andcommitted
Fixed NMI handling.
1 parent 889332c commit e32f402

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

cores/arduino/WInterrupts.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ void attachInterrupt( uint32_t ulPin, voidFuncPtr callback, uint32_t ulMode )
176176
EIC->NMICTRL.reg= EIC_NMICTRL_NMISENSE_RISE ;
177177
break ;
178178
}
179-
180-
// Enable the interrupt
181-
EIC->INTENSET.reg = EIC_INTENSET_EXTINT( 1 << digitalPinToInterrupt( ulPin ) ) ;
182179
}
183180
}
184181

@@ -210,21 +207,8 @@ void EIC_Handler( void )
210207
{
211208
uint32_t ul ;
212209

213-
// Test NMI first
214-
if ( (EIC->NMIFLAG.reg & EIC_NMIFLAG_NMI) == EIC_NMIFLAG_NMI )
215-
{
216-
// Call the callback function if assigned
217-
if ( callbacksInt[EXTERNAL_INT_NMI]._callback != NULL )
218-
{
219-
callbacksInt[EXTERNAL_INT_NMI]._callback() ;
220-
}
221-
222-
// Clear the interrupt
223-
EIC->NMIFLAG.reg = EIC_NMIFLAG_NMI ;
224-
}
225-
226210
// Test the 16 normal interrupts
227-
for ( ul = EXTERNAL_INT_0 ; ul < EXTERNAL_INT_NMI ; ul++ )
211+
for ( ul = EXTERNAL_INT_0 ; ul <= EXTERNAL_INT_15 ; ul++ )
228212
{
229213
if ( (EIC->INTFLAG.reg & ( 1 << ul ) ) != 0 )
230214
{
@@ -240,6 +224,21 @@ void EIC_Handler( void )
240224
}
241225
}
242226

227+
/*
228+
* External Non-Maskable Interrupt Controller NVIC Interrupt Handler
229+
*/
230+
void NMI_Handler( void )
231+
{
232+
// Call the callback function if assigned
233+
if ( callbacksInt[EXTERNAL_INT_NMI]._callback != NULL )
234+
{
235+
callbacksInt[EXTERNAL_INT_NMI]._callback() ;
236+
}
237+
238+
// Clear the interrupt
239+
EIC->NMIFLAG.reg = EIC_NMIFLAG_NMI ;
240+
}
241+
243242
#ifdef __cplusplus
244243
}
245244
#endif

0 commit comments

Comments
 (0)