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
02d8bf82
Commit
02d8bf82
authored
7 years ago
by
Cristian Maglie
Browse files
Options
Downloads
Patches
Plain Diff
Fixed allocation/deallocation of interrupts subroutines
parent
d2b71787
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
-16
14 additions, 16 deletions
cores/arduino/WInterrupts.c
with
14 additions
and
16 deletions
cores/arduino/WInterrupts.c
+
14
−
16
View file @
02d8bf82
...
...
@@ -91,18 +91,14 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
uint32_t
current
=
0
;
// Check if we already have this interrupt
int
id
=
-
1
;
for
(
uint32_t
i
=
0
;
i
<
nints
;
i
++
)
{
if
(
ISRlist
[
i
]
==
in
)
id
=
in
;
for
(
current
=
0
;
current
<
nints
;
current
++
)
{
if
(
ISRlist
[
current
]
==
in
)
{
break
;
}
}
if
(
id
==
-
1
)
{
if
(
current
==
nints
)
{
// Need to make a new entry
current
=
nints
;
nints
++
;
}
else
{
// We already have an entry for this pin
current
=
id
;
}
ISRlist
[
current
]
=
in
;
// List with nr of interrupt in order of when they were attached
ISRcallback
[
current
]
=
callback
;
// List of callback adresses
...
...
@@ -163,16 +159,18 @@ void detachInterrupt(uint32_t pin)
EIC
->
WAKEUP
.
reg
&=
~
(
1
<<
in
);
// Remove callback from the ISR list
int
id
=
-
1
;
for
(
uint32_t
i
=
0
;
i
<
nints
;
i
++
)
{
if
(
ISRlist
[
i
]
==
in
)
id
=
in
;
uint32_t
current
;
for
(
current
=
0
;
current
<
nints
;
current
++
)
{
if
(
ISRlist
[
current
]
==
in
)
{
break
;
}
}
if
(
id
==
-
1
)
return
;
// We didn't have it
if
(
current
==
nints
)
return
;
// We didn't have it
// Shift the reminder down
for
(
uint32_t
i
=
id
;
i
<
nints
-
1
;
i
++
)
{
ISRlist
[
i
]
=
ISRlist
[
i
+
1
];
ISRcallback
[
i
]
=
ISRcallback
[
i
+
1
];
for
(
;
current
<
nints
-
1
;
current
++
)
{
ISRlist
[
current
]
=
ISRlist
[
current
+
1
];
ISRcallback
[
current
]
=
ISRcallback
[
current
+
1
];
}
nints
--
;
}
...
...
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