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
1b62f7cd
Commit
1b62f7cd
authored
6 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Patches
Plain Diff
cpu/efm32/gpio: use gpio_irq feature
parent
ed24d362
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpu/efm32/periph/gpio.c
+39
-35
39 additions, 35 deletions
cpu/efm32/periph/gpio.c
with
39 additions
and
35 deletions
cpu/efm32/periph/gpio.c
+
39
−
35
View file @
1b62f7cd
...
...
@@ -27,6 +27,7 @@
#include
"em_gpio.h"
#ifdef MODULE_PERIPH_GPIO_IRQ
/**
* @brief Number of external interrupt lines.
*/
...
...
@@ -36,6 +37,7 @@
* @brief Hold one interrupt context per interrupt line
*/
static
gpio_isr_ctx_t
isr_ctx
[
NUMOF_IRQS
];
#endif
static
inline
GPIO_Port_TypeDef
_port_num
(
gpio_t
pin
)
{
...
...
@@ -47,11 +49,6 @@ static inline uint32_t _pin_num(gpio_t pin)
return
(
pin
&
0x0f
);
}
static
inline
uint32_t
_pin_mask
(
gpio_t
pin
)
{
return
(
1
<<
_pin_num
(
pin
));
}
int
gpio_init
(
gpio_t
pin
,
gpio_mode_t
mode
)
{
/* check for valid pin */
...
...
@@ -72,6 +69,42 @@ int gpio_init(gpio_t pin, gpio_mode_t mode)
return
0
;
}
int
gpio_read
(
gpio_t
pin
)
{
return
GPIO_PinInGet
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
void
gpio_set
(
gpio_t
pin
)
{
GPIO_PinOutSet
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
void
gpio_clear
(
gpio_t
pin
)
{
GPIO_PinOutClear
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
void
gpio_toggle
(
gpio_t
pin
)
{
GPIO_PinOutToggle
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
void
gpio_write
(
gpio_t
pin
,
int
value
)
{
if
(
value
)
{
GPIO_PinOutSet
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
else
{
GPIO_PinOutClear
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
}
#ifdef MODULE_PERIPH_GPIO_IRQ
static
inline
uint32_t
_pin_mask
(
gpio_t
pin
)
{
return
(
1
<<
_pin_num
(
pin
));
}
int
gpio_init_int
(
gpio_t
pin
,
gpio_mode_t
mode
,
gpio_flank_t
flank
,
gpio_cb_t
cb
,
void
*
arg
)
{
...
...
@@ -111,36 +144,6 @@ void gpio_irq_disable(gpio_t pin)
GPIO_IntDisable
(
_pin_mask
(
pin
));
}
int
gpio_read
(
gpio_t
pin
)
{
return
GPIO_PinInGet
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
void
gpio_set
(
gpio_t
pin
)
{
GPIO_PinOutSet
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
void
gpio_clear
(
gpio_t
pin
)
{
GPIO_PinOutClear
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
void
gpio_toggle
(
gpio_t
pin
)
{
GPIO_PinOutToggle
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
void
gpio_write
(
gpio_t
pin
,
int
value
)
{
if
(
value
)
{
GPIO_PinOutSet
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
else
{
GPIO_PinOutClear
(
_port_num
(
pin
),
_pin_num
(
pin
));
}
}
/**
* @brief Actual interrupt handler for both even and odd pin index numbers.
*/
...
...
@@ -170,3 +173,4 @@ void isr_gpio_odd(void)
{
gpio_irq
();
}
#endif
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