Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
efc5f2a9
You need to sign in or sign up before continuing.
Commit
efc5f2a9
authored
6 years ago
by
Joakim Nohlgård
Browse files
Options
Downloads
Patches
Plain Diff
msp430fxyz: Disable GPIO ISRs when periph_gpio_irq is not selected
parent
ace717ee
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
cpu/msp430fxyz/periph/gpio.c
+62
-61
62 additions, 61 deletions
cpu/msp430fxyz/periph/gpio.c
with
62 additions
and
61 deletions
cpu/msp430fxyz/periph/gpio.c
+
62
−
61
View file @
efc5f2a9
...
...
@@ -33,12 +33,6 @@
*/
#define PINS_PER_PORT (8U)
/**
* @brief Interrupt context for each interrupt line
*/
static
gpio_isr_ctx_t
isr_ctx
[
ISR_NUMOF
];
static
msp_port_t
*
_port
(
gpio_t
pin
)
{
switch
(
pin
>>
8
)
{
...
...
@@ -59,6 +53,11 @@ static msp_port_t *_port(gpio_t pin)
}
}
static
inline
uint8_t
_pin
(
gpio_t
pin
)
{
return
(
uint8_t
)(
pin
&
0xff
);
}
static
inline
msp_port_isr_t
*
_isr_port
(
gpio_t
pin
)
{
msp_port_t
*
p
=
_port
(
pin
);
...
...
@@ -68,17 +67,6 @@ static inline msp_port_isr_t *_isr_port(gpio_t pin)
return
NULL
;
}
static
inline
uint8_t
_pin
(
gpio_t
pin
)
{
return
(
uint8_t
)(
pin
&
0xff
);
}
static
int
_ctx
(
gpio_t
pin
)
{
int
i
=
bitarithm_lsb
(
_pin
(
pin
));
return
(
_port
(
pin
)
==
PORT_1
)
?
i
:
(
i
+
8
);
}
int
gpio_init
(
gpio_t
pin
,
gpio_mode_t
mode
)
{
msp_port_t
*
port
=
_port
(
pin
);
...
...
@@ -99,34 +87,6 @@ int gpio_init(gpio_t pin, gpio_mode_t mode)
return
0
;
}
int
gpio_init_int
(
gpio_t
pin
,
gpio_mode_t
mode
,
gpio_flank_t
flank
,
gpio_cb_t
cb
,
void
*
arg
)
{
msp_port_isr_t
*
port
=
_isr_port
(
pin
);
/* check if port, pull resistor and flank configuration are valid */
if
((
port
==
NULL
)
||
(
flank
==
GPIO_BOTH
))
{
return
-
1
;
}
/* disable any activated interrupt */
port
->
IE
&=
~
(
_pin
(
pin
));
/* configure as input */
if
(
gpio_init
(
pin
,
mode
)
<
0
)
{
return
-
1
;
}
/* save ISR context */
isr_ctx
[
_ctx
(
pin
)].
cb
=
cb
;
isr_ctx
[
_ctx
(
pin
)].
arg
=
arg
;
/* configure flank */
port
->
IES
&=
~
(
_pin
(
pin
));
port
->
IES
|=
(
flank
&
_pin
(
pin
));
/* clear pending interrupts and enable the IRQ */
port
->
IFG
&=
~
(
_pin
(
pin
));
gpio_irq_enable
(
pin
);
return
0
;
}
void
gpio_periph_mode
(
gpio_t
pin
,
bool
enable
)
{
REG8
*
sel
;
...
...
@@ -151,22 +111,6 @@ void gpio_periph_mode(gpio_t pin, bool enable)
}
}
void
gpio_irq_enable
(
gpio_t
pin
)
{
msp_port_isr_t
*
port
=
_isr_port
(
pin
);
if
(
port
)
{
port
->
IE
|=
_pin
(
pin
);
}
}
void
gpio_irq_disable
(
gpio_t
pin
)
{
msp_port_isr_t
*
port
=
_isr_port
(
pin
);
if
(
port
)
{
port
->
IE
&=
~
(
_pin
(
pin
));
}
}
int
gpio_read
(
gpio_t
pin
)
{
msp_port_t
*
port
=
_port
(
pin
);
...
...
@@ -203,6 +147,62 @@ void gpio_write(gpio_t pin, int value)
}
}
#ifdef MODULE_PERIPH_GPIO_IRQ
/**
* @brief Interrupt context for each interrupt line
*/
static
gpio_isr_ctx_t
isr_ctx
[
ISR_NUMOF
];
static
int
_ctx
(
gpio_t
pin
)
{
int
i
=
bitarithm_lsb
(
_pin
(
pin
));
return
(
_port
(
pin
)
==
PORT_1
)
?
i
:
(
i
+
8
);
}
int
gpio_init_int
(
gpio_t
pin
,
gpio_mode_t
mode
,
gpio_flank_t
flank
,
gpio_cb_t
cb
,
void
*
arg
)
{
msp_port_isr_t
*
port
=
_isr_port
(
pin
);
/* check if port, pull resistor and flank configuration are valid */
if
((
port
==
NULL
)
||
(
flank
==
GPIO_BOTH
))
{
return
-
1
;
}
/* disable any activated interrupt */
port
->
IE
&=
~
(
_pin
(
pin
));
/* configure as input */
if
(
gpio_init
(
pin
,
mode
)
<
0
)
{
return
-
1
;
}
/* save ISR context */
isr_ctx
[
_ctx
(
pin
)].
cb
=
cb
;
isr_ctx
[
_ctx
(
pin
)].
arg
=
arg
;
/* configure flank */
port
->
IES
&=
~
(
_pin
(
pin
));
port
->
IES
|=
(
flank
&
_pin
(
pin
));
/* clear pending interrupts and enable the IRQ */
port
->
IFG
&=
~
(
_pin
(
pin
));
gpio_irq_enable
(
pin
);
return
0
;
}
void
gpio_irq_enable
(
gpio_t
pin
)
{
msp_port_isr_t
*
port
=
_isr_port
(
pin
);
if
(
port
)
{
port
->
IE
|=
_pin
(
pin
);
}
}
void
gpio_irq_disable
(
gpio_t
pin
)
{
msp_port_isr_t
*
port
=
_isr_port
(
pin
);
if
(
port
)
{
port
->
IE
&=
~
(
_pin
(
pin
));
}
}
static
inline
void
isr_handler
(
msp_port_isr_t
*
port
,
int
ctx
)
{
for
(
unsigned
i
=
0
;
i
<
PINS_PER_PORT
;
i
++
)
{
...
...
@@ -226,3 +226,4 @@ ISR(PORT2_VECTOR, isr_port2)
isr_handler
((
msp_port_isr_t
*
)
PORT_2
,
8
);
__exit_isr
();
}
#endif
/* MODULE_PERIPH_GPIO_IRQ */
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