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
8a2c09f5
Commit
8a2c09f5
authored
Sep 04, 2012
by
Henrik Nordstrom
Browse files
pio: Add = and ? pin commands for easier GPIO operation
parent
bcdc4cd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
pio.c
View file @
8a2c09f5
...
...
@@ -149,9 +149,11 @@ static void usage(int rc )
fprintf
(
stderr
,
"usage: %s -i input [-o output] pin..
\n
"
,
argv0
);
fprintf
(
stderr
,
" print Show all pins
\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>
\n
Configure pin
\n
"
);
fprintf
(
stderr
,
" Pxx=data,drive,pull
\n
Configure GPIO output
\n
"
);
fprintf
(
stderr
,
" Pxx?pull
\n
Configure GPIO input
\n
"
);
fprintf
(
stderr
,
" clean Clean input pins
\n
"
);
fprintf
(
stderr
,
"
\n
mode 0-7, 0=input, 1=ouput, 2-7 I/O
\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
,
" drive 0-3, I/O drive level
\n
"
);
...
...
@@ -196,29 +198,55 @@ static void cmd_set_pin(char *buf, const char *pin)
parse_pin
(
&
port
,
&
port_nr
,
pin
);
if
(
!
pio_get
(
buf
,
port
,
port_nr
,
&
pio
))
usage
(
1
);
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
mul_sel
,
t
);
}
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
pull
,
t
);
}
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
drv_level
,
t
);
}
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
data
,
t
);
if
((
t
=
strchr
(
pin
,
'='
)))
{
pio
.
mul_sel
=
1
;
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
data
,
t
);
}
if
(
t
)
t
=
strchr
(
t
,
','
);
if
(
t
)
{
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
,
'?'
)))
{
pio
.
mul_sel
=
0
;
pio
.
data
=
0
;
pio
.
drv_level
=
0
;
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
pull
,
t
);
}
}
else
if
((
t
=
strchr
(
pin
,
'<'
)))
{
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
mul_sel
,
t
);
}
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
pull
,
t
);
}
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
drv_level
,
t
);
}
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
parse_int
(
&
pio
.
data
,
t
);
}
}
pio_set
(
buf
,
port
,
port_nr
,
&
pio
);
}
...
...
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