scripts: dts: generate array values as initializer lists
Simplify use of property values that have multiple elements by providing all of them in an initializer list, in addition to each one as an enumerated value. For example if a driver requires a sequence of operations with instance-specific delays between stages the durations can be specified with: delays = <30000 20 45000>; and the driver can use: static u32_t delays[] = DT_INST_0_COMPAT_DELAYS; rather than enumerating the instances. This is particularly useful when the number of entries in the array varies per instance, in which case such an initialization is not easily expressed in code. Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit is contained in:
parent
aefe941396
commit
c1c82b7570
1 changed files with 2 additions and 0 deletions
|
@ -190,6 +190,8 @@ def write_props(node):
|
||||||
elif prop.type == "array":
|
elif prop.type == "array":
|
||||||
for i, val in enumerate(prop.val):
|
for i, val in enumerate(prop.val):
|
||||||
out_dev(node, "{}_{}".format(ident, i), val)
|
out_dev(node, "{}_{}".format(ident, i), val)
|
||||||
|
out_dev(node, ident,
|
||||||
|
"{" + ", ".join(map(str, prop.val)) + "}")
|
||||||
elif prop.type == "string-array":
|
elif prop.type == "string-array":
|
||||||
for i, val in enumerate(prop.val):
|
for i, val in enumerate(prop.val):
|
||||||
out_dev_s(node, "{}_{}".format(ident, i), val)
|
out_dev_s(node, "{}_{}".format(ident, i), val)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue