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
1690132c
Commit
1690132c
authored
Aug 01, 2012
by
Henrik Nordstrom
Browse files
pio: Correct parsing of pin values
parent
e9f338bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
pio.c
View file @
1690132c
...
...
@@ -7,6 +7,7 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <endian.h>
...
...
@@ -174,6 +175,19 @@ static void cmd_show_pin(char *buf, const char *pin)
pio_print
(
port
,
port_nr
,
&
pio
);
}
static
int
parse_int
(
int
*
dst
,
const
char
*
in
)
{
int
value
;
char
*
next
;
errno
=
0
;
value
=
strtol
(
in
,
&
next
,
0
);
if
(
!
errno
&&
next
!=
in
)
{
*
dst
=
value
;
return
0
;
}
return
-
1
;
}
static
void
cmd_set_pin
(
char
*
buf
,
const
char
*
pin
)
{
int
port
,
port_nr
;
...
...
@@ -182,29 +196,29 @@ 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
);
t
=
strchr
(
t
,
'<'
);
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
if
(
*
t
&&
*
t
!=
'>'
)
pio
.
mul_sel
=
atoi
(
t
);
parse_int
(
&
pio
.
mul_sel
,
t
);
}
t
=
strchr
(
t
,
'<'
);
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
if
(
*
t
&&
*
t
!=
'>'
)
pio
.
pull
=
atoi
(
t
);
parse_int
(
&
pio
.
pull
,
t
);
}
t
=
strchr
(
t
,
'<'
);
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
if
(
*
t
&&
*
t
!=
'>'
)
pio
.
drv_level
=
atoi
(
t
);
parse_int
(
&
pio
.
drv_level
,
t
);
}
t
=
strchr
(
t
,
'<'
);
if
(
t
)
t
=
strchr
(
t
,
'<'
);
if
(
t
)
{
t
++
;
if
(
*
t
&&
*
t
!=
'>'
)
pio
.
data
=
atoi
(
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