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
8368bee1
Commit
8368bee1
authored
May 04, 2012
by
Alejandro Mery
Browse files
script: implement script_gpio_entry_append()
parent
c62b4603
Changes
2
Hide whitespace changes
Inline
Side-by-side
script.c
View file @
8368bee1
...
...
@@ -126,6 +126,7 @@ void script_entry_delete(struct script_entry *entry)
assert
(
entry
);
assert
(
entry
->
type
==
SCRIPT_VALUE_TYPE_SINGLE_WORD
||
entry
->
type
==
SCRIPT_VALUE_TYPE_STRING
||
entry
->
type
==
SCRIPT_VALUE_TYPE_GPIO
||
entry
->
type
==
SCRIPT_VALUE_TYPE_NULL
);
if
(
!
list_empty
(
&
entry
->
entries
))
...
...
@@ -138,6 +139,9 @@ void script_entry_delete(struct script_entry *entry)
case
SCRIPT_VALUE_TYPE_STRING
:
container
=
container_of
(
entry
,
struct
script_string_entry
,
entry
);
break
;
case
SCRIPT_VALUE_TYPE_GPIO
:
container
=
container_of
(
entry
,
struct
script_gpio_entry
,
entry
);
break
;
case
SCRIPT_VALUE_TYPE_NULL
:
container
=
container_of
(
entry
,
struct
script_null_entry
,
entry
);
break
;
...
...
@@ -207,3 +211,27 @@ struct script_string_entry *script_string_entry_append(struct script *script,
return
entry
;
}
struct
script_gpio_entry
*
script_gpio_entry_append
(
struct
script
*
script
,
const
char
*
name
,
unsigned
port
,
unsigned
num
,
unsigned
data
[
4
])
{
struct
script_gpio_entry
*
entry
;
assert
(
script
);
assert
(
!
list_empty
(
&
script
->
sections
));
assert
(
name
&&
*
name
);
if
((
entry
=
malloc
(
sizeof
(
*
entry
))))
{
entry
->
port
=
port
;
entry
->
port_num
=
num
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
entry
->
data
[
i
]
=
data
[
i
];
script_entry_append
(
script
,
&
entry
->
entry
,
SCRIPT_VALUE_TYPE_GPIO
,
name
);
}
return
entry
;
}
script.h
View file @
8368bee1
...
...
@@ -67,6 +67,14 @@ struct script_string_entry {
char
string
[];
};
/** entry describing a GPIO */
struct
script_gpio_entry
{
struct
script_entry
entry
;
unsigned
port
,
port_num
;
unsigned
data
[
4
];
};
/** create a new script tree */
struct
script
*
script_new
(
void
);
/** deletes a tree recursively */
...
...
@@ -92,5 +100,10 @@ struct script_single_entry *script_single_entry_append(struct script *script,
struct
script_string_entry
*
script_string_entry_append
(
struct
script
*
script
,
const
char
*
name
,
size_t
l
,
const
char
*
s
);
/** create a new GPIO entry appended to the last section of a tree */
struct
script_gpio_entry
*
script_gpio_entry_append
(
struct
script
*
script
,
const
char
*
name
,
unsigned
port
,
unsigned
num
,
unsigned
data
[
4
]);
#endif
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