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
cc5948b2
Commit
cc5948b2
authored
9 years ago
by
Cristian Maglie
Browse files
Options
Downloads
Patches
Plain Diff
WInterrupts.c cosmetic fix
parent
0368e10e
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
+41
-53
41 additions, 53 deletions
cores/arduino/WInterrupts.c
with
41 additions
and
53 deletions
cores/arduino/WInterrupts.c
+
41
−
53
View file @
cc5948b2
...
...
@@ -68,101 +68,89 @@ static void __initialize()
* \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs.
* Replaces any previous function that was attached to the interrupt.
*/
//void attachInterrupt( uint32_t ulPin, void (*callback)(void), EExt_IntMode mode )
//void attachInterrupt( uint32_t ulPin, voidFuncPtr callback, EExt_IntMode mode )
void
attachInterrupt
(
uint32_t
ulPin
,
voidFuncPtr
callback
,
uint32_t
ulMode
)
void
attachInterrupt
(
uint32_t
pin
,
voidFuncPtr
callback
,
uint32_t
mode
)
{
static
int
enabled
=
0
;
uint32_t
ulC
onfig
;
uint32_t
ulP
os
;
static
int
enabled
=
0
;
uint32_t
c
onfig
;
uint32_t
p
os
;
if
(
digitalPinToInterrupt
(
ulPin
)
==
NOT_AN_INTERRUPT
)
{
return
;
}
if
(
digitalPinToInterrupt
(
pin
)
==
NOT_AN_INTERRUPT
)
return
;
if
(
!
enabled
)
{
__initialize
()
;
enabled
=
1
;
if
(
!
enabled
)
{
__initialize
();
enabled
=
1
;
}
// Assign pin to EIC
pinPeripheral
(
ulP
in
,
PIO_EXTINT
)
;
pinPeripheral
(
p
in
,
PIO_EXTINT
)
;
// Assign callback to interrupt
callbacksInt
[
digitalPinToInterrupt
(
ulP
in
)].
_ulPin
=
ulP
in
;
callbacksInt
[
digitalPinToInterrupt
(
ulP
in
)].
_callback
=
callback
;
callbacksInt
[
digitalPinToInterrupt
(
p
in
)].
_ulPin
=
p
in
;
callbacksInt
[
digitalPinToInterrupt
(
p
in
)].
_callback
=
callback
;
// Check if normal interrupt or NMI
if
(
ulP
in
!=
2
)
if
(
p
in
!=
2
)
{
// Look for right CONFIG register to be addressed
if
(
digitalPinToInterrupt
(
ulPin
)
>
EXTERNAL_INT_7
)
{
ulConfig
=
1
;
}
else
{
ulConfig
=
0
;
if
(
digitalPinToInterrupt
(
pin
)
>
EXTERNAL_INT_7
)
{
config
=
1
;
}
else
{
config
=
0
;
}
// Configure the interrupt mode
ulP
os
=
((
digitalPinToInterrupt
(
ulP
in
)
-
(
8
*
ulC
onfig
)
)
<<
2
)
;
switch
(
ulM
ode
)
p
os
=
((
digitalPinToInterrupt
(
p
in
)
-
(
8
*
c
onfig
))
<<
2
);
switch
(
m
ode
)
{
case
LOW
:
EIC
->
CONFIG
[
ulC
onfig
].
reg
|=
EIC_CONFIG_SENSE0_LOW_Val
<<
ulP
os
;
break
;
EIC
->
CONFIG
[
c
onfig
].
reg
|=
EIC_CONFIG_SENSE0_LOW_Val
<<
p
os
;
break
;
case
HIGH
:
// EIC->CONFIG[ulConfig].reg = EIC_CONFIG_SENSE0_HIGH_Val << ((digitalPinToInterrupt( ulPin ) >> ulConfig ) << ulPos) ;
EIC
->
CONFIG
[
ulConfig
].
reg
|=
EIC_CONFIG_SENSE0_HIGH_Val
<<
ulPos
;
break
;
EIC
->
CONFIG
[
config
].
reg
|=
EIC_CONFIG_SENSE0_HIGH_Val
<<
pos
;
break
;
case
CHANGE
:
// EIC->CONFIG[ulConfig].reg = EIC_CONFIG_SENSE0_BOTH_Val << ((digitalPinToInterrupt( ulPin ) >> ulConfig ) << ulPos) ;
EIC
->
CONFIG
[
ulConfig
].
reg
|=
EIC_CONFIG_SENSE0_BOTH_Val
<<
ulPos
;
break
;
EIC
->
CONFIG
[
config
].
reg
|=
EIC_CONFIG_SENSE0_BOTH_Val
<<
pos
;
break
;
case
FALLING
:
// EIC->CONFIG[ulConfig].reg = EIC_CONFIG_SENSE0_FALL_Val << ((digitalPinToInterrupt( ulPin ) >> ulConfig ) << ulPos) ;
EIC
->
CONFIG
[
ulConfig
].
reg
|=
EIC_CONFIG_SENSE0_FALL_Val
<<
ulPos
;
break
;
EIC
->
CONFIG
[
config
].
reg
|=
EIC_CONFIG_SENSE0_FALL_Val
<<
pos
;
break
;
case
RISING
:
// EIC->CONFIG[ulConfig].reg = EIC_CONFIG_SENSE0_RISE_Val << ((digitalPinToInterrupt( ulPin ) >> ulConfig ) << ulPos) ;
EIC
->
CONFIG
[
ulConfig
].
reg
|=
EIC_CONFIG_SENSE0_RISE_Val
<<
ulPos
;
break
;
EIC
->
CONFIG
[
config
].
reg
|=
EIC_CONFIG_SENSE0_RISE_Val
<<
pos
;
break
;
}
// Enable the interrupt
EIC
->
INTENSET
.
reg
=
EIC_INTENSET_EXTINT
(
1
<<
digitalPinToInterrupt
(
ulPin
)
)
;
EIC
->
INTENSET
.
reg
=
EIC_INTENSET_EXTINT
(
1
<<
digitalPinToInterrupt
(
pin
))
;
}
else
// Handles NMI on pin 2
{
// Configure the interrupt mode
switch
(
ulM
ode
)
switch
(
m
ode
)
{
case
LOW
:
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_LOW
;
break
;
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_LOW
;
break
;
case
HIGH
:
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_HIGH
;
break
;
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_HIGH
;
break
;
case
CHANGE
:
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_BOTH
;
break
;
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_BOTH
;
break
;
case
FALLING
:
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_FALL
;
break
;
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_FALL
;
break
;
case
RISING
:
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_RISE
;
break
;
EIC
->
NMICTRL
.
reg
=
EIC_NMICTRL_NMISENSE_RISE
;
break
;
}
}
}
...
...
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