Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arduino Core for SAMD21 CPU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
josc941e
Arduino Core for SAMD21 CPU
Commits
812d3e90
Commit
812d3e90
authored
7 years ago
by
Cristian Maglie
Browse files
Options
Downloads
Patches
Plain Diff
Put interrupt mask instead of interrupt num in ISR callbacks list
This should save some cycles inside ISR Handler.
parent
9d9fe5c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cores/arduino/WInterrupts.c
+14
-12
14 additions, 12 deletions
cores/arduino/WInterrupts.c
with
14 additions
and
12 deletions
cores/arduino/WInterrupts.c
+
14
−
12
View file @
812d3e90
...
@@ -21,9 +21,9 @@
...
@@ -21,9 +21,9 @@
#include
<string.h>
#include
<string.h>
static
voidFuncPtr
ISRcallback
[
EXTERNAL_NUM_INTERRUPTS
];
static
voidFuncPtr
ISRcallback
[
EXTERNAL_NUM_INTERRUPTS
];
static
EExt_Interrupts
ISRlist
[
EXTERNAL_NUM_INTERRUPTS
];
static
uint32_t
ISRlist
[
EXTERNAL_NUM_INTERRUPTS
];
static
uint32_t
nints
;
// Stores total number of attached interrupts
static
uint32_t
nints
;
// Stores total number of attached interrupts
/* Configure I/O interrupt sources */
/* Configure I/O interrupt sources */
...
@@ -76,7 +76,8 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
...
@@ -76,7 +76,8 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
}
}
// Enable wakeup capability on pin in case being used during sleep
// Enable wakeup capability on pin in case being used during sleep
EIC
->
WAKEUP
.
reg
|=
(
1
<<
in
);
uint32_t
inMask
=
1
<<
in
;
EIC
->
WAKEUP
.
reg
|=
inMask
;
// Assign pin to EIC
// Assign pin to EIC
pinPeripheral
(
pin
,
PIO_EXTINT
);
pinPeripheral
(
pin
,
PIO_EXTINT
);
...
@@ -92,7 +93,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
...
@@ -92,7 +93,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
// Check if we already have this interrupt
// Check if we already have this interrupt
for
(
current
=
0
;
current
<
nints
;
current
++
)
{
for
(
current
=
0
;
current
<
nints
;
current
++
)
{
if
(
ISRlist
[
current
]
==
in
)
{
if
(
ISRlist
[
current
]
==
in
Mask
)
{
break
;
break
;
}
}
}
}
...
@@ -100,7 +101,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
...
@@ -100,7 +101,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
// Need to make a new entry
// Need to make a new entry
nints
++
;
nints
++
;
}
}
ISRlist
[
current
]
=
in
;
// List of interrupt in order of when they were attached
ISRlist
[
current
]
=
in
Mask
;
// List of interrupt in order of when they were attached
ISRcallback
[
current
]
=
callback
;
// List of callback adresses
ISRcallback
[
current
]
=
callback
;
// List of callback adresses
// Look for right CONFIG register to be addressed
// Look for right CONFIG register to be addressed
...
@@ -138,7 +139,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
...
@@ -138,7 +139,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
}
}
}
}
// Enable the interrupt
// Enable the interrupt
EIC
->
INTENSET
.
reg
=
EIC_INTENSET_EXTINT
(
1
<<
in
);
EIC
->
INTENSET
.
reg
=
EIC_INTENSET_EXTINT
(
inMask
);
}
}
/*
/*
...
@@ -154,15 +155,16 @@ void detachInterrupt(uint32_t pin)
...
@@ -154,15 +155,16 @@ void detachInterrupt(uint32_t pin)
if
(
in
==
NOT_AN_INTERRUPT
||
in
==
EXTERNAL_INT_NMI
)
if
(
in
==
NOT_AN_INTERRUPT
||
in
==
EXTERNAL_INT_NMI
)
return
;
return
;
EIC
->
INTENCLR
.
reg
=
EIC_INTENCLR_EXTINT
(
1
<<
in
);
uint32_t
inMask
=
1
<<
in
;
EIC
->
INTENCLR
.
reg
=
EIC_INTENCLR_EXTINT
(
inMask
);
// Disable wakeup capability on pin during sleep
// Disable wakeup capability on pin during sleep
EIC
->
WAKEUP
.
reg
&=
~
(
1
<<
in
)
;
EIC
->
WAKEUP
.
reg
&=
~
inMask
;
// Remove callback from the ISR list
// Remove callback from the ISR list
uint32_t
current
;
uint32_t
current
;
for
(
current
=
0
;
current
<
nints
;
current
++
)
{
for
(
current
=
0
;
current
<
nints
;
current
++
)
{
if
(
ISRlist
[
current
]
==
in
)
{
if
(
ISRlist
[
current
]
==
in
Mask
)
{
break
;
break
;
}
}
}
}
...
@@ -187,12 +189,12 @@ void EIC_Handler(void)
...
@@ -187,12 +189,12 @@ void EIC_Handler(void)
// Loop over all enabled interrupts in the list
// Loop over all enabled interrupts in the list
for
(
uint32_t
i
=
0
;
i
<
nints
;
i
++
)
for
(
uint32_t
i
=
0
;
i
<
nints
;
i
++
)
{
{
if
((
EIC
->
INTFLAG
.
reg
&
1
<<
ISRlist
[
i
])
!=
0
)
if
((
EIC
->
INTFLAG
.
reg
&
ISRlist
[
i
])
!=
0
)
{
{
// Call the callback function
// Call the callback function
ISRcallback
[
i
]();
ISRcallback
[
i
]();
// Clear the interrupt
// Clear the interrupt
EIC
->
INTFLAG
.
reg
=
1
<<
ISRlist
[
i
];
EIC
->
INTFLAG
.
reg
=
ISRlist
[
i
];
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment