Skip to content

Commit d654db2

Browse files
committed
Cosmetic changes in WInterrupt.*
1 parent e258489 commit d654db2

File tree

3 files changed

+37
-73
lines changed

3 files changed

+37
-73
lines changed

cores/arduino/WInterrupts.c

+14-25
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
/*
@@ -138,22 +129,20 @@ void detachInterrupt(uint32_t pin)
138129
/*
139130
* External Interrupt Controller NVIC Interrupt Handler
140131
*/
141-
void EIC_Handler( void )
132+
void EIC_Handler(void)
142133
{
143-
uint32_t ul ;
144-
145134
// Test the 16 normal interrupts
146-
for ( ul = EXTERNAL_INT_0 ; ul <= EXTERNAL_INT_15 ; ul++ )
135+
for (uint32_t i=EXTERNAL_INT_0; i<=EXTERNAL_INT_15; i++)
147136
{
148-
if ( (EIC->INTFLAG.reg & ( 1 << ul ) ) != 0 )
137+
if ((EIC->INTFLAG.reg & (1 << i)) != 0)
149138
{
150139
// Call the callback function if assigned
151-
if (callbacksInt[ul]) {
152-
callbacksInt[ul]();
140+
if (callbacksInt[i]) {
141+
callbacksInt[i]();
153142
}
154143

155144
// Clear the interrupt
156-
EIC->INTFLAG.reg = 1 << ul ;
145+
EIC->INTFLAG.reg = 1 << i;
157146
}
158147
}
159148
}

cores/arduino/WInterrupts.h

+5-30
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

+18-18
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,25 @@ typedef enum _EPortType
111111
PORTC=2,
112112
} EPortType ;
113113

114-
typedef enum _EExt_Interrupts
114+
typedef enum
115115
{
116-
EXTERNAL_INT_0 = 0, // Available on pin 11
117-
EXTERNAL_INT_1, // Available on pin 13
118-
EXTERNAL_INT_2, // Available on pins 10, A0, A5
119-
EXTERNAL_INT_3, // Available on pin 12
120-
EXTERNAL_INT_4, // Available on pin 6, 8, A3
121-
EXTERNAL_INT_5, // Available on pin 7, 9, A4
122-
EXTERNAL_INT_6, // Available on pin 16
123-
EXTERNAL_INT_7, // Available on pin 17
124-
EXTERNAL_INT_8, // Available on pin A1
125-
EXTERNAL_INT_9, // Available on pin 3, A2
126-
EXTERNAL_INT_10, // Available on pin 0, 21
127-
EXTERNAL_INT_11, // Available on pin 1, 20
128-
EXTERNAL_INT_12, // Available on pin 18
129-
EXTERNAL_INT_13, // Available on pin EDBG_GPIO0 (43)
130-
EXTERNAL_INT_14, // Available on pin 4
131-
EXTERNAL_INT_15, // Available on pin 5
132-
EXTERNAL_INT_NMI, // Available on pin 2
116+
EXTERNAL_INT_0 = 0,
117+
EXTERNAL_INT_1,
118+
EXTERNAL_INT_2,
119+
EXTERNAL_INT_3,
120+
EXTERNAL_INT_4,
121+
EXTERNAL_INT_5,
122+
EXTERNAL_INT_6,
123+
EXTERNAL_INT_7,
124+
EXTERNAL_INT_8,
125+
EXTERNAL_INT_9,
126+
EXTERNAL_INT_10,
127+
EXTERNAL_INT_11,
128+
EXTERNAL_INT_12,
129+
EXTERNAL_INT_13,
130+
EXTERNAL_INT_14,
131+
EXTERNAL_INT_15,
132+
EXTERNAL_INT_NMI,
133133
EXTERNAL_NUM_INTERRUPTS,
134134
NOT_AN_INTERRUPT = -1,
135135
EXTERNAL_INT_NONE = NOT_AN_INTERRUPT,

0 commit comments

Comments
 (0)