gen_defines: add _CHILD_IDX macros for nodes with parents
These expose every node's index in its parent's list of children to C. The root node has no parent, so no _CHILD_IDX macro is generated for it. Keep macros.bnf up to date with the new generated macros. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
355cc01a36
commit
50f9b3c2ca
2 changed files with 6 additions and 0 deletions
|
@ -67,6 +67,8 @@ node-macro =/ %s"DT_N" path-id %s"_FOREACH_CHILD_VARGS"
|
|||
; over each child node with status "okay".
|
||||
node-macro =/ %s"DT_N" path-id %s"_FOREACH_CHILD_STATUS_OKAY"
|
||||
node-macro =/ %s"DT_N" path-id %s"_FOREACH_CHILD_STATUS_OKAY_VARGS"
|
||||
; The node's zero-based index in the list of it's parent's child nodes.
|
||||
node-macro =/ %s"DT_N" path-id %s"_CHILD_IDX"
|
||||
; The node's status macro; dt-name in this case is something like "okay"
|
||||
; or "disabled".
|
||||
node-macro =/ %s"DT_N" path-id %s"_STATUS_" dt-name
|
||||
|
|
|
@ -132,6 +132,10 @@ def main():
|
|||
out_dt_define(f"{node.z_path_id}_PARENT",
|
||||
f"DT_{node.parent.z_path_id}")
|
||||
|
||||
out_comment(f"Node's index in its parent's list of children:")
|
||||
out_dt_define(f"{node.z_path_id}_CHILD_IDX",
|
||||
node.parent.child_index(node))
|
||||
|
||||
write_children(node)
|
||||
write_dep_info(node)
|
||||
write_idents_and_existence(node)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue