Skip to content

Commit ebad10a

Browse files
cmagliemattairtech
authored andcommitted
Cosmetic changes in WInterrupt.*
1 parent 5488420 commit ebad10a

File tree

3 files changed

+20
-56
lines changed

3 files changed

+20
-56
lines changed

cores/arduino/WInterrupts.c

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,23 @@ static void __initialize()
3232
{
3333
memset(callbacksInt, 0, sizeof(callbacksInt));
3434

35-
NVIC_DisableIRQ( EIC_IRQn ) ;
36-
NVIC_ClearPendingIRQ( EIC_IRQn ) ;
37-
NVIC_SetPriority( EIC_IRQn, 0 ) ;
38-
NVIC_EnableIRQ( EIC_IRQn ) ;
35+
NVIC_DisableIRQ(EIC_IRQn);
36+
NVIC_ClearPendingIRQ(EIC_IRQn);
37+
NVIC_SetPriority(EIC_IRQn, 0);
38+
NVIC_EnableIRQ(EIC_IRQn);
3939

4040
// Enable GCLK for IEC (External Interrupt Controller)
41-
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID( GCM_EIC )) ;
41+
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_EIC));
4242

4343
/* Shall we do that?
4444
// Do a software reset on EIC
4545
EIC->CTRL.SWRST.bit = 1 ;
46-
47-
while ( (EIC->CTRL.SWRST.bit == 1) && (EIC->STATUS.SYNCBUSY.bit == 1) )
48-
{
49-
// Waiting for synchronisation
50-
}
46+
while ((EIC->CTRL.SWRST.bit == 1) && (EIC->STATUS.SYNCBUSY.bit == 1)) { }
5147
*/
5248

5349
// Enable EIC
54-
EIC->CTRL.bit.ENABLE = 1 ;
55-
56-
while ( EIC->STATUS.bit.SYNCBUSY == 1 )
57-
{
58-
// Waiting for synchronisation
59-
}
60-
50+
EIC->CTRL.bit.ENABLE = 1;
51+
while (EIC->STATUS.bit.SYNCBUSY == 1) { }
6152
}
6253

6354
/*
@@ -136,22 +127,20 @@ void detachInterrupt(uint32_t pin)
136127
/*
137128
* External Interrupt Controller NVIC Interrupt Handler
138129
*/
139-
void EIC_Handler( void )
130+
void EIC_Handler(void)
140131
{
141-
uint32_t ul ;
142-
143132
// Test the normal interrupts
144-
for ( ul = EXTERNAL_INT_0 ; ul < (EXTERNAL_NUM_INTERRUPTS - 1) ; ul++ )
133+
for (uint32_t i=EXTERNAL_INT_0; i<=EXTERNAL_NUM_INTERRUPTS; i++)
145134
{
146-
if ( (EIC->INTFLAG.reg & ( 1 << ul ) ) != 0 )
135+
if ((EIC->INTFLAG.reg & (1 << i)) != 0)
147136
{
148137
// Call the callback function if assigned
149-
if (callbacksInt[ul]) {
150-
callbacksInt[ul]();
138+
if (callbacksInt[i]) {
139+
callbacksInt[i]();
151140
}
152141

153142
// Clear the interrupt
154-
EIC->INTFLAG.reg = 1 << ul ;
143+
EIC->INTFLAG.reg = 1 << i;
155144
}
156145
}
157146
}

cores/arduino/WInterrupts.h

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2014 Arduino. All right reserved.
2+
Copyright (c) 2015 Arduino LLC. All right reserved.
33
44
This library is free software; you can redistribute it and/or
55
modify it under the terms of the GNU Lesser General Public
@@ -31,49 +31,24 @@ extern "C" {
3131
#define FALLING 3
3232
#define RISING 4
3333

34-
///*
35-
//* Interrupt modes
36-
//* The two first values are conflicting with the ones used by Digital API, so we use another name for each.
37-
//*/
38-
//typedef enum _EExt_IntMode
39-
//{
40-
//IM_LOW = 0,
41-
//IM_HIGH = 1,
42-
//CHANGE = 2,
43-
//FALLING = 3,
44-
//RISING = 4,
45-
//IM_CHANGE = 2,
46-
//IM_FALLING = 3,
47-
//IM_RISING = 4,
48-
//} EExt_IntMode ;
49-
5034
#define DEFAULT 1
5135
#define EXTERNAL 0
5236

53-
typedef void (*voidFuncPtr)( void ) ;
37+
typedef void (*voidFuncPtr)(void);
5438

5539
/*
5640
* \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs.
5741
* Replaces any previous function that was attached to the interrupt.
5842
*/
59-
//void attachInterrupt( uint32_t ulPin, void (*callback)(void), EExt_IntMode mode ) ;
60-
//void attachInterrupt( uint32_t ulPin, voidFuncPtr callback, EExt_IntMode mode ) ;
61-
void attachInterrupt( uint32_t ulPin, voidFuncPtr callback, uint32_t mode ) ;
43+
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
6244

6345
/*
6446
* \brief Turns off the given interrupt.
6547
*/
66-
void detachInterrupt( uint32_t ulPin ) ;
48+
void detachInterrupt(uint32_t pin);
6749

6850
#ifdef __cplusplus
6951
}
7052
#endif
7153

72-
//#ifdef __cplusplus
73-
//inline operator ::EExt_IntMode( uint32_t ul )
74-
//{
75-
//return (EExt_IntMode)ul ;
76-
//}
77-
//#endif
78-
79-
#endif /* _WIRING_INTERRUPTS_ */
54+
#endif

cores/arduino/WVariant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ typedef enum _EPortType
106106
} EPortType ;
107107

108108
/* The D11 has only INT 0 though 7 (the SAMD11C14A lacks INT 0 as well */
109-
typedef enum _EExt_Interrupts
109+
typedef enum
110110
{
111111
EXTERNAL_INT_0 = 0,
112112
EXTERNAL_INT_1,

0 commit comments

Comments
 (0)