Zephyr Project API 4.2.99
A Scalable Open Source RTOS
|
Macros | |
#define | DT_NODE_EXISTS(node_id) IS_ENABLED(DT_CAT(node_id, _EXISTS)) |
Does a node identifier refer to a node? | |
#define | DT_NODE_HAS_STATUS(node_id, status) DT_NODE_HAS_STATUS_INTERNAL(node_id, status) |
Does a node identifier refer to a node with a status? | |
#define | DT_NODE_HAS_STATUS_OKAY(node_id) DT_NODE_HAS_STATUS(node_id, okay) |
Does a node identifier refer to a node with a status okay ? | |
#define | DT_HAS_COMPAT_STATUS_OKAY(compat) IS_ENABLED(DT_CAT(DT_COMPAT_HAS_OKAY_, compat)) |
Does the devicetree have a status okay node with a compatible? | |
#define | DT_NUM_INST_STATUS_OKAY(compat) |
Get the number of instances of a given compatible with status okay | |
#define | DT_NODE_HAS_COMPAT(node_id, compat) IS_ENABLED(DT_CAT3(node_id, _COMPAT_MATCHES_, compat)) |
Does a devicetree node match a compatible? | |
#define | DT_NODE_HAS_COMPAT_STATUS(node_id, compat, status) UTIL_AND(DT_NODE_HAS_COMPAT(node_id, compat), DT_NODE_HAS_STATUS(node_id, status)) |
Does a devicetree node have a compatible and status? | |
#define | DT_NODE_HAS_PROP(node_id, prop) IS_ENABLED(DT_CAT4(node_id, _P_, prop, _EXISTS)) |
Does a devicetree node have a property? | |
#define | DT_PHA_HAS_CELL_AT_IDX(node_id, pha, idx, cell) |
Does a phandle array have a named cell specifier at an index? | |
#define | DT_PHA_HAS_CELL(node_id, pha, cell) DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell) |
Equivalent to DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell) | |
#define | DT_FOREACH_PHA_CELL_BY_IDX(node_id, pha, idx, fn) DT_CAT6(node_id, _P_, pha, _IDX_, idx, _FOREACH_CELL)(fn) |
Iterate over all cells in a phandle array element by index. | |
#define | DT_FOREACH_PHA_CELL_BY_IDX_SEP(node_id, pha, idx, fn, sep) DT_CAT6(node_id, _P_, pha, _IDX_, idx, _FOREACH_CELL_SEP)(fn, sep) |
Iterate over all cells in a phandle array element by index with separator. | |
#define | DT_PHA_NUM_CELLS_BY_IDX(node_id, pha, idx) DT_CAT6(node_id, _P_, pha, _IDX_, idx, _NUM_CELLS) |
Get the number of cells in a phandle array element by index. | |
#define | DT_PHA_ELEM_NAME_BY_IDX(node_id, pha, idx) DT_CAT6(node_id, _P_, pha, _IDX_, idx, _NAME) |
Get the name of a phandle array element by index. | |
#define | DT_FOREACH_PHA_CELL_BY_NAME(node_id, pha, name, fn) DT_CAT6(node_id, _P_, pha, _NAME_, name, _FOREACH_CELL)(fn) |
Iterate over all cells in a phandle array element by name. | |
#define | DT_FOREACH_PHA_CELL_BY_NAME_SEP(node_id, pha, name, fn, sep) DT_CAT6(node_id, _P_, pha, _NAME_, name, _FOREACH_CELL_SEP)(fn, sep) |
Iterate over all cells in a phandle array element by name with separator. | |
#define | DT_PHA_NUM_CELLS_BY_NAME(node_id, pha, name) DT_CAT6(node_id, _P_, pha, _NAME_, name, _NUM_CELLS) |
Get the number of cells in a phandle array element by name. | |
#define | DT_PHA_ELEM_IDX_BY_NAME(node_id, pha, name) DT_CAT6(node_id, _P_, pha, _NAME_, name, _IDX) |
Get the index of a phandle array element by name. | |
#define DT_FOREACH_PHA_CELL_BY_IDX | ( | node_id, | |
pha, | |||
idx, | |||
fn | |||
) | DT_CAT6(node_id, _P_, pha, _IDX_, idx, _FOREACH_CELL)(fn) |
#include <include/zephyr/devicetree.h>
Iterate over all cells in a phandle array element by index.
This macro calls fn(cell_value)
for each cell value in the phandle array element at index idx
.
In general, this macro expands to:
fn(node_id, pha, idx, cell[0]) fn(node_id, pha, idx, cell[1]) [...] fn(node_id, pha, idx, cell[n-1])
where n
is the number of cells in pha
, as it would be returned by DT_PHA_NUM_CELLS_BY_IDX(node_id, pha, idx)
, and cell[x] is the NAME of the cell in the specifier.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
idx | index of the phandle array element |
fn | macro to call for each cell value |
#define DT_FOREACH_PHA_CELL_BY_IDX_SEP | ( | node_id, | |
pha, | |||
idx, | |||
fn, | |||
sep | |||
) | DT_CAT6(node_id, _P_, pha, _IDX_, idx, _FOREACH_CELL_SEP)(fn, sep) |
#include <include/zephyr/devicetree.h>
Iterate over all cells in a phandle array element by index with separator.
This is like DT_FOREACH_PHA_CELL_BY_IDX(), but sep
is placed between each invocation of fn
.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
idx | index of the phandle array element |
fn | macro to call for each cell value |
sep | separator (e.g. comma or semicolon) |
#define DT_FOREACH_PHA_CELL_BY_NAME | ( | node_id, | |
pha, | |||
name, | |||
fn | |||
) | DT_CAT6(node_id, _P_, pha, _NAME_, name, _FOREACH_CELL)(fn) |
#include <include/zephyr/devicetree.h>
Iterate over all cells in a phandle array element by name.
This macro calls fn(cell_value)
for each cell value in the phandle array pha
element with the given name
in the *-names property.
In general, this macro expands to:
fn(node_id, pha, name, cell[0]) fn(node_id, pha, idx, cell[1]) [...] fn(node_id, pha, idx, cell[n-1])
where n
is the number of cells in pha
, as it would be returned by DT_PHA_NUM_CELLS_BY_NAME(node_id, pha, name)
, and cell[x] is the NAME of the cell in the specifier.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
name | lowercase-and-underscores name of the phandle array element |
fn | macro to call for each cell value |
#define DT_FOREACH_PHA_CELL_BY_NAME_SEP | ( | node_id, | |
pha, | |||
name, | |||
fn, | |||
sep | |||
) | DT_CAT6(node_id, _P_, pha, _NAME_, name, _FOREACH_CELL_SEP)(fn, sep) |
#include <include/zephyr/devicetree.h>
Iterate over all cells in a phandle array element by name with separator.
This is like DT_FOREACH_PHA_CELL_BY_NAME(), but sep
is placed between each invocation of fn
.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
name | lowercase-and-underscores name of the phandle array element |
fn | macro to call for each cell value |
sep | separator (e.g. comma or semicolon) |
#define DT_HAS_COMPAT_STATUS_OKAY | ( | compat | ) | IS_ENABLED(DT_CAT(DT_COMPAT_HAS_OKAY_, compat)) |
#include <include/zephyr/devicetree.h>
Does the devicetree have a status okay
node with a compatible?
Test for whether the devicetree has any nodes with status okay
and the given compatible. That is, this returns 1 if and only if there is at least one node_id
for which both of these expressions return 1:
As usual, both a missing status and an ok
status are treated as okay
.
compat | lowercase-and-underscores compatible, without quotes |
#define DT_NODE_EXISTS | ( | node_id | ) | IS_ENABLED(DT_CAT(node_id, _EXISTS)) |
#include <include/zephyr/devicetree.h>
Does a node identifier refer to a node?
Tests whether a node identifier refers to a node which exists, i.e. is defined in the devicetree.
It doesn't matter whether or not the node has a matching binding, or what the node's status value is. This is purely a check of whether the node exists at all.
node_id | a node identifier |
#define DT_NODE_HAS_COMPAT | ( | node_id, | |
compat | |||
) | IS_ENABLED(DT_CAT3(node_id, _COMPAT_MATCHES_, compat)) |
#include <include/zephyr/devicetree.h>
Does a devicetree node match a compatible?
Example devicetree fragment:
Example usages which evaluate to 1:
This macro only uses the value of the compatible property. Whether or not a particular compatible has a matching binding has no effect on its value, nor does the node's status.
node_id | node identifier |
compat | lowercase-and-underscores compatible, without quotes |
compat
, 0 otherwise. #define DT_NODE_HAS_COMPAT_STATUS | ( | node_id, | |
compat, | |||
status | |||
) | UTIL_AND(DT_NODE_HAS_COMPAT(node_id, compat), DT_NODE_HAS_STATUS(node_id, status)) |
#include <include/zephyr/devicetree.h>
Does a devicetree node have a compatible and status?
This is equivalent to:
node_id | node identifier |
compat | lowercase-and-underscores compatible, without quotes |
status | okay or disabled as a token, not a string |
#define DT_NODE_HAS_PROP | ( | node_id, | |
prop | |||
) | IS_ENABLED(DT_CAT4(node_id, _P_, prop, _EXISTS)) |
#include <include/zephyr/devicetree.h>
Does a devicetree node have a property?
Tests whether a devicetree node has a property defined.
This tests whether the property is defined at all, not whether a boolean property is true or false. To get a boolean property's truth value, use DT_PROP(node_id, prop) instead.
node_id | node identifier |
prop | lowercase-and-underscores property name |
#define DT_NODE_HAS_STATUS | ( | node_id, | |
status | |||
) | DT_NODE_HAS_STATUS_INTERNAL(node_id, status) |
#include <include/zephyr/devicetree.h>
Does a node identifier refer to a node with a status?
Example uses:
Tests whether a node identifier refers to a node which:
ok
status in the devicetree is treated as if it were okay
instead)node_id | a node identifier |
status | a status as one of the tokens okay or disabled, not a string |
#define DT_NODE_HAS_STATUS_OKAY | ( | node_id | ) | DT_NODE_HAS_STATUS(node_id, okay) |
#include <include/zephyr/devicetree.h>
Does a node identifier refer to a node with a status okay
?
Example uses:
Tests whether a node identifier refers to a node which:
okay
As usual, both a missing status and an ok
status are treated as okay
.
node_id | a node identifier |
okay
, 0 otherwise. #define DT_NUM_INST_STATUS_OKAY | ( | compat | ) |
#include <include/zephyr/devicetree.h>
Get the number of instances of a given compatible with status okay
compat | lowercase-and-underscores compatible, without quotes |
okay
#define DT_PHA_ELEM_IDX_BY_NAME | ( | node_id, | |
pha, | |||
name | |||
) | DT_CAT6(node_id, _P_, pha, _NAME_, name, _IDX) |
#include <include/zephyr/devicetree.h>
Get the index of a phandle array element by name.
This returns the index of the pha
which has the name name
in the corresponding *-names property.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
name | lowercase-and-underscores name of the phandle array element |
name
#define DT_PHA_ELEM_NAME_BY_IDX | ( | node_id, | |
pha, | |||
idx | |||
) | DT_CAT6(node_id, _P_, pha, _IDX_, idx, _NAME) |
#include <include/zephyr/devicetree.h>
Get the name of a phandle array element by index.
This returns the name in the *-names property of the node corresponding to the index idx
of pha
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
idx | index of the phandle array element |
idx
#define DT_PHA_HAS_CELL | ( | node_id, | |
pha, | |||
cell | |||
) | DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell) |
#include <include/zephyr/devicetree.h>
Equivalent to DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell)
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
cell | lowercase-and-underscores cell name whose existence to check at index idx |
#define DT_PHA_HAS_CELL_AT_IDX | ( | node_id, | |
pha, | |||
idx, | |||
cell | |||
) |
#include <include/zephyr/devicetree.h>
Does a phandle array have a named cell specifier at an index?
If this returns 1, then the phandle-array property pha
has a cell named cell
at index idx
, and therefore DT_PHA_BY_IDX(node_id,
pha, idx, cell) is valid. If it returns 0, it's an error to use DT_PHA_BY_IDX() with the same arguments.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
idx | index to check within pha |
cell | lowercase-and-underscores cell name whose existence to check at index idx |
#define DT_PHA_NUM_CELLS_BY_IDX | ( | node_id, | |
pha, | |||
idx | |||
) | DT_CAT6(node_id, _P_, pha, _IDX_, idx, _NUM_CELLS) |
#include <include/zephyr/devicetree.h>
Get the number of cells in a phandle array element by index.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
idx | index of the phandle array element |
idx
#define DT_PHA_NUM_CELLS_BY_NAME | ( | node_id, | |
pha, | |||
name | |||
) | DT_CAT6(node_id, _P_, pha, _NAME_, name, _NUM_CELLS) |
#include <include/zephyr/devicetree.h>
Get the number of cells in a phandle array element by name.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
name | lowercase-and-underscores name of the phandle array element |
name