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
82e0c517
Commit
82e0c517
authored
9 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Patches
Plain Diff
cpu/lpc11u34: adapted GPIO driver
parent
e4e23a00
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/lpc11u34/periph/gpio.c
+22
-16
22 additions, 16 deletions
cpu/lpc11u34/periph/gpio.c
with
22 additions
and
16 deletions
cpu/lpc11u34/periph/gpio.c
+
22
−
16
View file @
82e0c517
...
@@ -261,7 +261,7 @@ static const uint8_t gpio_pin_map[GPIO_NUMOF] = {
...
@@ -261,7 +261,7 @@ static const uint8_t gpio_pin_map[GPIO_NUMOF] = {
#endif
#endif
};
};
int
gpio_init
(
gpio_t
dev
,
gpio_
dir_t
dir
,
gpio_pp_t
pullup
)
int
gpio_init
(
gpio_t
dev
,
gpio_
mode_t
mode
)
{
{
uint8_t
port
;
uint8_t
port
;
uint8_t
pin
;
uint8_t
pin
;
...
@@ -279,26 +279,32 @@ int gpio_init(gpio_t dev, gpio_dir_t dir, gpio_pp_t pullup)
...
@@ -279,26 +279,32 @@ int gpio_init(gpio_t dev, gpio_dir_t dir, gpio_pp_t pullup)
/* Disable resistors */
/* Disable resistors */
*
lpc_pin_registers
[
pin
+
(
port
*
24
)]
&=
~
(
3
<<
3
);
*
lpc_pin_registers
[
pin
+
(
port
*
24
)]
&=
~
(
3
<<
3
);
/* Set resistors */
if
(
pullup
==
GPIO_PULLUP
)
{
*
lpc_pin_registers
[
pin
+
(
port
*
24
)]
|=
(
2
<<
3
);
}
else
if
(
pullup
==
GPIO_PULLDOWN
)
{
*
lpc_pin_registers
[
pin
+
(
port
*
24
)]
|=
(
1
<<
3
);
}
/* Set direction */
/* Set mode */
if
(
dir
==
GPIO_DIR_OUT
)
{
switch
(
mode
)
{
LPC_GPIO
->
DIR
[
port
]
|=
(
1
<<
pin
);
/* set pin to output mode */
case
GPIO_IN
:
}
LPC_GPIO
->
DIR
[
port
]
&=
~
(
1
<<
pin
);
else
{
break
;
LPC_GPIO
->
DIR
[
port
]
&=
~
(
1
<<
pin
);
/* set pin to output mode */
case
GPIO_IN_PD
:
LPC_GPIO
->
DIR
[
port
]
&=
~
(
1
<<
pin
);
*
lpc_pin_registers
[
pin
+
(
port
*
24
)]
|=
(
1
<<
3
);
break
;
case
GPIO_IN_PU
:
LPC_GPIO
->
DIR
[
port
]
&=
~
(
1
<<
pin
);
*
lpc_pin_registers
[
pin
+
(
port
*
24
)]
|=
(
2
<<
3
);
break
;
case
GPIO_OUT
:
LPC_GPIO
->
DIR
[
port
]
|=
(
1
<<
pin
);
break
;
default:
return
-
1
;
}
}
return
0
;
/* all OK */
return
0
;
/* all OK */
}
}
int
gpio_init_int
(
gpio_t
dev
,
gpio_pp_t
pullup
,
gpio_flank_t
flank
,
gpio_cb_t
cb
,
void
*
arg
)
int
gpio_init_int
(
gpio_t
dev
,
gpio_mode_t
mode
,
gpio_flank_t
flank
,
gpio_cb_t
cb
,
void
*
arg
)
{
{
int
res
;
int
res
;
uint8_t
pin
;
uint8_t
pin
;
...
@@ -318,7 +324,7 @@ int gpio_init_int(gpio_t dev, gpio_pp_t pullup, gpio_flank_t flank, gpio_cb_t cb
...
@@ -318,7 +324,7 @@ int gpio_init_int(gpio_t dev, gpio_pp_t pullup, gpio_flank_t flank, gpio_cb_t cb
pin
=
gpio_pin_map
[
dev
];
pin
=
gpio_pin_map
[
dev
];
/* configure pin as input */
/* configure pin as input */
res
=
gpio_init
(
dev
,
GPIO_DIR_IN
,
pullup
);
res
=
gpio_init
(
dev
,
mode
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
return
res
;
return
res
;
}
}
...
...
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