Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
3316205f
Commit
3316205f
authored
Sep 04, 2012
by
Henrik Nordstrom
Browse files
pio: Fix Pxx= and Pxx? commands
parent
f0cadac8
Changes
1
Show whitespace changes
Inline
Side-by-side
pio.c
View file @
3316205f
...
@@ -146,13 +146,14 @@ static const char *argv0;
...
@@ -146,13 +146,14 @@ static const char *argv0;
static
void
usage
(
int
rc
)
static
void
usage
(
int
rc
)
{
{
fprintf
(
stderr
,
"usage: %s -i input [-o output] pin..
\n
"
,
argv0
);
fprintf
(
stderr
,
"usage: %s -i input [-o output] pin..
\n
"
,
argv0
);
fprintf
(
stderr
,
"
print Show all pins
\n
"
);
fprintf
(
stderr
,
"
print
Show all pins
\n
"
);
fprintf
(
stderr
,
"
Pxx Show pin
\n
"
);
fprintf
(
stderr
,
"
Pxx
Show pin
\n
"
);
fprintf
(
stderr
,
"
Pxx<mode><pull><drive><data>
\n
Configure pin
\n
"
);
fprintf
(
stderr
,
"
Pxx<mode><pull><drive><data> Configure pin
\n
"
);
fprintf
(
stderr
,
"
Pxx=data,drive
,pull
\n
Configure GPIO output
\n
"
);
fprintf
(
stderr
,
"
Pxx=data,drive Configure GPIO output
\n
"
);
fprintf
(
stderr
,
"
Pxx?pull
\n
Configure GPIO input
\n
"
);
fprintf
(
stderr
,
"
Pxx?pull Configure GPIO input
\n
"
);
fprintf
(
stderr
,
"
clean Clean input pins
\n
"
);
fprintf
(
stderr
,
"
clean
Clean input pins
\n
"
);
fprintf
(
stderr
,
"
\n
mode 0-7, 0=input, 1=ouput, 2-7 I/O function
\n
"
);
fprintf
(
stderr
,
"
\n
mode 0-7, 0=input, 1=ouput, 2-7 I/O function
\n
"
);
fprintf
(
stderr
,
" pull 0=none, 1=up, 2=down
\n
"
);
fprintf
(
stderr
,
" pull 0=none, 1=up, 2=down
\n
"
);
fprintf
(
stderr
,
" drive 0-3, I/O drive level
\n
"
);
fprintf
(
stderr
,
" drive 0-3, I/O drive level
\n
"
);
...
@@ -210,12 +211,6 @@ static void cmd_set_pin(char *buf, const char *pin)
...
@@ -210,12 +211,6 @@ static void cmd_set_pin(char *buf, const char *pin)
t
++
;
t
++
;
parse_int
(
&
pio
.
drv_level
,
t
);
parse_int
(
&
pio
.
drv_level
,
t
);
}
}
if
(
t
)
t
=
strchr
(
t
,
','
);
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
pull
,
t
);
}
}
else
if
((
t
=
strchr
(
pin
,
'?'
)))
{
}
else
if
((
t
=
strchr
(
pin
,
'?'
)))
{
pio
.
mul_sel
=
0
;
pio
.
mul_sel
=
0
;
pio
.
data
=
0
;
pio
.
data
=
0
;
...
@@ -270,10 +265,16 @@ static void cmd_clean(char *buf)
...
@@ -270,10 +265,16 @@ static void cmd_clean(char *buf)
static
int
do_command
(
char
*
buf
,
const
char
**
args
,
int
argc
)
static
int
do_command
(
char
*
buf
,
const
char
**
args
,
int
argc
)
{
{
const
char
*
command
=
args
[
0
];
const
char
*
command
=
args
[
0
];
if
(
*
command
==
'P'
)
{
if
(
strchr
(
command
,
'<'
))
if
(
strchr
(
command
,
'<'
))
cmd_set_pin
(
buf
,
command
);
cmd_set_pin
(
buf
,
command
);
else
if
(
*
command
==
'P'
)
else
if
(
strchr
(
command
,
'='
))
cmd_set_pin
(
buf
,
command
);
else
if
(
strchr
(
command
,
'?'
))
cmd_set_pin
(
buf
,
command
);
else
cmd_show_pin
(
buf
,
command
);
cmd_show_pin
(
buf
,
command
);
}
else
if
(
strcmp
(
command
,
"print"
)
==
0
)
else
if
(
strcmp
(
command
,
"print"
)
==
0
)
print
(
buf
);
print
(
buf
);
else
if
(
strcmp
(
command
,
"clean"
)
==
0
)
else
if
(
strcmp
(
command
,
"clean"
)
==
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment