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
b0e8ff06
Commit
b0e8ff06
authored
9 years ago
by
Cristian Maglie
Browse files
Options
Downloads
Patches
Plain Diff
WInterrupts: optimized use of digitalPinToInterrupt()
parent
e53a7a7a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cores/arduino/WInterrupts.c
+9
-11
9 additions, 11 deletions
cores/arduino/WInterrupts.c
with
9 additions
and
11 deletions
cores/arduino/WInterrupts.c
+
9
−
11
View file @
b0e8ff06
...
...
@@ -57,9 +57,8 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
uint32_t
config
;
uint32_t
pos
;
if
(
digitalPinToInterrupt
(
pin
)
==
NOT_AN_INTERRUPT
)
return
;
if
(
digitalPinToInterrupt
(
pin
)
==
EXTERNAL_INT_NMI
)
EExt_Interrupts
in
=
digitalPinToInterrupt
(
pin
);
if
(
in
==
NOT_AN_INTERRUPT
||
in
==
EXTERNAL_INT_NMI
)
return
;
if
(
!
enabled
)
{
...
...
@@ -71,17 +70,17 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
pinPeripheral
(
pin
,
PIO_EXTINT
);
// Assign callback to interrupt
callbacksInt
[
digitalPinToInterrupt
(
pin
)
]
=
callback
;
callbacksInt
[
in
]
=
callback
;
// Look for right CONFIG register to be addressed
if
(
digitalPinToInterrupt
(
pin
)
>
EXTERNAL_INT_7
)
{
if
(
in
>
EXTERNAL_INT_7
)
{
config
=
1
;
}
else
{
config
=
0
;
}
// Configure the interrupt mode
pos
=
(
(
digitalPinToInterrupt
(
pin
)
-
(
8
*
config
))
<<
2
)
;
pos
=
(
in
-
(
8
*
config
))
<<
2
;
switch
(
mode
)
{
case
LOW
:
...
...
@@ -106,7 +105,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
}
// Enable the interrupt
EIC
->
INTENSET
.
reg
=
EIC_INTENSET_EXTINT
(
1
<<
digitalPinToInterrupt
(
pin
)
);
EIC
->
INTENSET
.
reg
=
EIC_INTENSET_EXTINT
(
1
<<
in
);
}
/*
...
...
@@ -114,12 +113,11 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
*/
void
detachInterrupt
(
uint32_t
pin
)
{
if
(
digitalPinToInterrupt
(
pin
)
==
NOT_AN_INTERRUPT
)
return
;
if
(
digitalPinToInterrupt
(
pin
)
==
EXTERNAL_INT_NMI
)
EExt_Interrupts
in
=
digitalPinToInterrupt
(
pin
);
if
(
in
==
NOT_AN_INTERRUPT
||
in
==
EXTERNAL_INT_NMI
)
return
;
EIC
->
INTENCLR
.
reg
=
EIC_INTENCLR_EXTINT
(
1
<<
digitalPinToInterrupt
(
pin
)
);
EIC
->
INTENCLR
.
reg
=
EIC_INTENCLR_EXTINT
(
1
<<
in
);
}
/*
...
...
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