Zephyr Project API 3.7.0
A Scalable Open Source RTOS
|
Macros | |
#define | DT_PROP(node_id, prop) DT_CAT3(node_id, _P_, prop) |
Get a devicetree property value. | |
#define | DT_PROP_LEN(node_id, prop) DT_CAT4(node_id, _P_, prop, _LEN) |
Get a property's logical length. | |
#define | DT_PROP_LEN_OR(node_id, prop, default_value) |
Like DT_PROP_LEN(), but with a fallback to default_value . | |
#define | DT_PROP_HAS_IDX(node_id, prop, idx) IS_ENABLED(DT_CAT6(node_id, _P_, prop, _IDX_, idx, _EXISTS)) |
Is index idx valid for an array type property? | |
#define | DT_PROP_HAS_NAME(node_id, prop, name) IS_ENABLED(DT_CAT6(node_id, _P_, prop, _NAME_, name, _EXISTS)) |
Is name name available in a foo-names property? | |
#define | DT_PROP_BY_IDX(node_id, prop, idx) DT_CAT5(node_id, _P_, prop, _IDX_, idx) |
Get the value at index idx in an array type property. | |
#define | DT_PROP_OR(node_id, prop, default_value) |
Like DT_PROP(), but with a fallback to default_value . | |
#define | DT_ENUM_IDX(node_id, prop) DT_CAT4(node_id, _P_, prop, _ENUM_IDX) |
Get a property value's index into its enumeration values. | |
#define | DT_ENUM_IDX_OR(node_id, prop, default_idx_value) |
Like DT_ENUM_IDX(), but with a fallback to a default enum index. | |
#define | DT_ENUM_HAS_VALUE(node_id, prop, value) IS_ENABLED(DT_CAT6(node_id, _P_, prop, _ENUM_VAL_, value, _EXISTS)) |
Does a node enumeration property have a given value? | |
#define | DT_STRING_TOKEN(node_id, prop) DT_CAT4(node_id, _P_, prop, _STRING_TOKEN) |
Get a string property's value as a token. | |
#define | DT_STRING_TOKEN_OR(node_id, prop, default_value) |
Like DT_STRING_TOKEN(), but with a fallback to default_value . | |
#define | DT_STRING_UPPER_TOKEN(node_id, prop) DT_CAT4(node_id, _P_, prop, _STRING_UPPER_TOKEN) |
Like DT_STRING_TOKEN(), but uppercased. | |
#define | DT_STRING_UPPER_TOKEN_OR(node_id, prop, default_value) |
Like DT_STRING_UPPER_TOKEN(), but with a fallback to default_value . | |
#define | DT_STRING_UNQUOTED(node_id, prop) DT_CAT4(node_id, _P_, prop, _STRING_UNQUOTED) |
Get a string property's value as an unquoted sequence of tokens. | |
#define | DT_STRING_UNQUOTED_OR(node_id, prop, default_value) |
Like DT_STRING_UNQUOTED(), but with a fallback to default_value . | |
#define | DT_STRING_TOKEN_BY_IDX(node_id, prop, idx) DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_TOKEN) |
Get an element out of a string-array property as a token. | |
#define | DT_STRING_UPPER_TOKEN_BY_IDX(node_id, prop, idx) DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UPPER_TOKEN) |
Like DT_STRING_TOKEN_BY_IDX(), but uppercased. | |
#define | DT_STRING_UNQUOTED_BY_IDX(node_id, prop, idx) DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UNQUOTED) |
Get a string array item value as an unquoted sequence of tokens. | |
#define | DT_PROP_BY_PHANDLE_IDX(node_id, phs, idx, prop) DT_PROP(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop) |
Get a property value from a phandle in a property. | |
#define | DT_PROP_BY_PHANDLE_IDX_OR(node_id, phs, idx, prop, default_value) DT_PROP_OR(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop, default_value) |
Like DT_PROP_BY_PHANDLE_IDX(), but with a fallback to default_value . | |
#define | DT_PROP_BY_PHANDLE(node_id, ph, prop) DT_PROP_BY_PHANDLE_IDX(node_id, ph, 0, prop) |
Get a property value from a phandle's node. | |
#define | DT_PHA_BY_IDX(node_id, pha, idx, cell) DT_CAT7(node_id, _P_, pha, _IDX_, idx, _VAL_, cell) |
Get a phandle-array specifier cell value at an index. | |
#define | DT_PHA_BY_IDX_OR(node_id, pha, idx, cell, default_value) DT_PROP_OR(node_id, DT_CAT5(pha, _IDX_, idx, _VAL_, cell), default_value) |
Like DT_PHA_BY_IDX(), but with a fallback to default_value . | |
#define | DT_PHA(node_id, pha, cell) DT_PHA_BY_IDX(node_id, pha, 0, cell) |
Equivalent to DT_PHA_BY_IDX(node_id, pha, 0, cell) | |
#define | DT_PHA_OR(node_id, pha, cell, default_value) DT_PHA_BY_IDX_OR(node_id, pha, 0, cell, default_value) |
Like DT_PHA(), but with a fallback to default_value . | |
#define | DT_PHA_BY_NAME(node_id, pha, name, cell) DT_CAT7(node_id, _P_, pha, _NAME_, name, _VAL_, cell) |
Get a value within a phandle-array specifier by name. | |
#define | DT_PHA_BY_NAME_OR(node_id, pha, name, cell, default_value) DT_PROP_OR(node_id, DT_CAT5(pha, _NAME_, name, _VAL_, cell), default_value) |
Like DT_PHA_BY_NAME(), but with a fallback to default_value . | |
#define | DT_PHANDLE_BY_NAME(node_id, pha, name) DT_CAT6(node_id, _P_, pha, _NAME_, name, _PH) |
Get a phandle's node identifier from a phandle array by name . | |
#define | DT_PHANDLE_BY_IDX(node_id, prop, idx) DT_CAT6(node_id, _P_, prop, _IDX_, idx, _PH) |
Get a node identifier for a phandle in a property. | |
#define | DT_PHANDLE(node_id, prop) DT_PHANDLE_BY_IDX(node_id, prop, 0) |
Get a node identifier for a phandle property's value. | |
#define DT_ENUM_HAS_VALUE | ( | node_id, | |
prop, | |||
value | |||
) | IS_ENABLED(DT_CAT6(node_id, _P_, prop, _ENUM_VAL_, value, _EXISTS)) |
#include <include/zephyr/devicetree.h>
Does a node enumeration property have a given value?
node_id | node identifier |
prop | lowercase-and-underscores property name |
value | lowercase-and-underscores enumeration value |
#define DT_ENUM_IDX | ( | node_id, | |
prop | |||
) | DT_CAT4(node_id, _P_, prop, _ENUM_IDX) |
#include <include/zephyr/devicetree.h>
Get a property value's index into its enumeration values.
The return values start at zero.
Example devicetree fragment:
Example bindings fragment:
Example usage:
node_id | node identifier |
prop | lowercase-and-underscores property name |
#define DT_ENUM_IDX_OR | ( | node_id, | |
prop, | |||
default_idx_value | |||
) |
#include <include/zephyr/devicetree.h>
Like DT_ENUM_IDX(), but with a fallback to a default enum index.
If the value exists, this expands to its zero based index value thanks to DT_ENUM_IDX(node_id, prop).
Otherwise, this expands to provided default index enum value.
node_id | node identifier |
prop | lowercase-and-underscores property name |
default_idx_value | a fallback index value to expand to |
#define DT_PHA | ( | node_id, | |
pha, | |||
cell | |||
) | DT_PHA_BY_IDX(node_id, pha, 0, cell) |
#include <include/zephyr/devicetree.h>
Equivalent to DT_PHA_BY_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 |
#define DT_PHA_BY_IDX | ( | node_id, | |
pha, | |||
idx, | |||
cell | |||
) | DT_CAT7(node_id, _P_, pha, _IDX_, idx, _VAL_, cell) |
#include <include/zephyr/devicetree.h>
Get a phandle-array specifier cell value at an index.
It might help to read the argument order as being similar to node->phandle_array[index].cell
. That is, the cell value is in the pha
property of node_id
, inside the specifier at index idx
.
Example devicetree fragment:
Bindings fragment for the gpio0
and gpio1
nodes:
Above, gpios
has two elements:
pin
cell is 17, and its flags
cell is 0x1pin
is 5 and flags
is 0x3Example usage:
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
idx | logical index into pha |
cell | lowercase-and-underscores cell name within the specifier at pha index idx |
#define DT_PHA_BY_IDX_OR | ( | node_id, | |
pha, | |||
idx, | |||
cell, | |||
default_value | |||
) | DT_PROP_OR(node_id, DT_CAT5(pha, _IDX_, idx, _VAL_, cell), default_value) |
#include <include/zephyr/devicetree.h>
Like DT_PHA_BY_IDX(), but with a fallback to default_value
.
If the value exists, this expands to DT_PHA_BY_IDX(node_id, pha,
idx, cell). The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
idx | logical index into pha |
cell | lowercase-and-underscores cell name within the specifier at pha index idx |
default_value | a fallback value to expand to |
default_value
#define DT_PHA_BY_NAME | ( | node_id, | |
pha, | |||
name, | |||
cell | |||
) | DT_CAT7(node_id, _P_, pha, _NAME_, name, _VAL_, cell) |
#include <include/zephyr/devicetree.h>
Get a value within a phandle-array specifier by name.
This is like DT_PHA_BY_IDX(), except it treats pha
as a structure where each array element has a name.
It might help to read the argument order as being similar to node->phandle_struct.name.cell
. That is, the cell value is in the pha
property of node_id
, treated as a data structure where each array element has a name.
Example devicetree fragment:
Bindings fragment for the "adc1" and "adc2" nodes:
Example usage:
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
name | lowercase-and-underscores name of a specifier in pha |
cell | lowercase-and-underscores cell name in the named specifier |
#define DT_PHA_BY_NAME_OR | ( | node_id, | |
pha, | |||
name, | |||
cell, | |||
default_value | |||
) | DT_PROP_OR(node_id, DT_CAT5(pha, _NAME_, name, _VAL_, cell), default_value) |
#include <include/zephyr/devicetree.h>
Like DT_PHA_BY_NAME(), but with a fallback to default_value
.
If the value exists, this expands to DT_PHA_BY_NAME(node_id, pha,
name, cell). The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
name | lowercase-and-underscores name of a specifier in pha |
cell | lowercase-and-underscores cell name in the named specifier |
default_value | a fallback value to expand to |
default_value
#define DT_PHA_OR | ( | node_id, | |
pha, | |||
cell, | |||
default_value | |||
) | DT_PHA_BY_IDX_OR(node_id, pha, 0, cell, default_value) |
#include <include/zephyr/devicetree.h>
Like DT_PHA(), but with a fallback to default_value
.
If the value exists, this expands to DT_PHA(node_id, pha, cell). The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
cell | lowercase-and-underscores cell name |
default_value | a fallback value to expand to |
default_value
#define DT_PHANDLE | ( | node_id, | |
prop | |||
) | DT_PHANDLE_BY_IDX(node_id, prop, 0) |
#include <include/zephyr/devicetree.h>
Get a node identifier for a phandle property's value.
This is equivalent to DT_PHANDLE_BY_IDX(node_id, prop, 0). Its primary benefit is readability when prop
has type phandle
.
node_id | node identifier |
prop | lowercase-and-underscores property of node_id with type phandle |
#define DT_PHANDLE_BY_IDX | ( | node_id, | |
prop, | |||
idx | |||
) | DT_CAT6(node_id, _P_, prop, _IDX_, idx, _PH) |
#include <include/zephyr/devicetree.h>
Get a node identifier for a phandle in a property.
When a node's value at a logical index contains a phandle, this macro returns a node identifier for the node with that phandle.
Therefore, if prop
has type phandle
, idx
must be zero. (A phandle
type is treated as a phandles
with a fixed length of 1).
Example devicetree fragment:
Above, foo
has type phandles and has two elements:
&n2
, which is node-2
's phandle&n3
, which is node-3
's phandleExample usage:
Behavior is analogous for phandle-arrays.
node_id | node identifier |
prop | lowercase-and-underscores property name in node_id with type phandle , phandles or phandle-array |
idx | index into prop |
#define DT_PHANDLE_BY_NAME | ( | node_id, | |
pha, | |||
name | |||
) | DT_CAT6(node_id, _P_, pha, _NAME_, name, _PH) |
#include <include/zephyr/devicetree.h>
Get a phandle's node identifier from a phandle array by name
.
It might help to read the argument order as being similar to node->phandle_struct.name.phandle
. That is, the phandle array is treated as a structure with named elements. The return value is the node identifier for a phandle inside the structure.
Example devicetree fragment:
Above, "io-channels" has two elements:
"SENSOR"
has phandle &adc1
"BANDGAP"
has phandle &adc2
Example usage:
Notice how devicetree properties and names are lowercased, and non-alphanumeric characters are converted to underscores.
node_id | node identifier |
pha | lowercase-and-underscores property with type phandle-array |
name | lowercase-and-underscores name of an element in pha |
#define DT_PROP | ( | node_id, | |
prop | |||
) | DT_CAT3(node_id, _P_, prop) |
#include <include/zephyr/devicetree.h>
Get a devicetree property value.
For properties whose bindings have the following types, this macro expands to:
0
if the property is false, or 1
if it is true{0, 1, 2}
, {"hello", "world"}
, etc.)A property's type is usually defined by its binding. In some special cases, it has an assumed type defined by the devicetree specification even when no binding is available: compatible
has type string-array, status
has type string, and interrupt-controller
has type boolean.
For other properties or properties with unknown type due to a missing binding, behavior is undefined.
For usage examples, see DT_PATH(), DT_ALIAS(), DT_NODELABEL(), and DT_INST() above.
node_id | node identifier |
prop | lowercase-and-underscores property name |
#define DT_PROP_BY_IDX | ( | node_id, | |
prop, | |||
idx | |||
) | DT_CAT5(node_id, _P_, prop, _IDX_, idx) |
#include <include/zephyr/devicetree.h>
Get the value at index idx
in an array type property.
It might help to read the argument order as being similar to node->property[index]
.
The return value depends on the property's type:
These properties are handled as special cases:
reg
: use DT_REG_ADDR_BY_IDX() or DT_REG_SIZE_BY_IDX() insteadinterrupts
: use DT_IRQ_BY_IDX()ranges
: use DT_NUM_RANGES()dma-ranges
: it is an error to use this property with DT_PROP_BY_IDX()For properties of other types, behavior is undefined.
node_id | node identifier |
prop | lowercase-and-underscores property name |
idx | the index to get |
#define DT_PROP_BY_PHANDLE | ( | node_id, | |
ph, | |||
prop | |||
) | DT_PROP_BY_PHANDLE_IDX(node_id, ph, 0, prop) |
#include <include/zephyr/devicetree.h>
Get a property value from a phandle's node.
This is equivalent to DT_PROP_BY_PHANDLE_IDX(node_id, ph, 0, prop).
node_id | node identifier |
ph | lowercase-and-underscores property of node_id with type phandle |
prop | lowercase-and-underscores property of the phandle's node |
#define DT_PROP_BY_PHANDLE_IDX | ( | node_id, | |
phs, | |||
idx, | |||
prop | |||
) | DT_PROP(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop) |
#include <include/zephyr/devicetree.h>
Get a property value from a phandle in a property.
This is a shorthand for:
That is, prop
is a property of the phandle's node, not a property of node_id
.
Example devicetree fragment:
Example usage:
node_id | node identifier |
phs | lowercase-and-underscores property with type phandle , phandles , or phandle-array |
idx | logical index into phs , which must be zero if phs has type phandle |
prop | lowercase-and-underscores property of the phandle's node |
#define DT_PROP_BY_PHANDLE_IDX_OR | ( | node_id, | |
phs, | |||
idx, | |||
prop, | |||
default_value | |||
) | DT_PROP_OR(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop, default_value) |
#include <include/zephyr/devicetree.h>
Like DT_PROP_BY_PHANDLE_IDX(), but with a fallback to default_value
.
If the value exists, this expands to DT_PROP_BY_PHANDLE_IDX(node_id, phs,
idx, prop). The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | node identifier |
phs | lowercase-and-underscores property with type phandle , phandles , or phandle-array |
idx | logical index into phs , which must be zero if phs has type phandle |
prop | lowercase-and-underscores property of the phandle's node |
default_value | a fallback value to expand to |
#define DT_PROP_HAS_IDX | ( | node_id, | |
prop, | |||
idx | |||
) | IS_ENABLED(DT_CAT6(node_id, _P_, prop, _IDX_, idx, _EXISTS)) |
#include <include/zephyr/devicetree.h>
Is index idx
valid for an array type property?
If this returns 1, then DT_PROP_BY_IDX(node_id, prop, idx) or DT_PHA_BY_IDX(node_id, prop, idx, ...) are valid at index idx
. If it returns 0, it is an error to use those macros with that index.
These properties are handled as special cases:
reg
property: use DT_REG_HAS_IDX(node_id, idx) insteadinterrupts
property: use DT_IRQ_HAS_IDX(node_id, idx) insteadIt is an error to use this macro with the reg
or interrupts
properties.
node_id | node identifier |
prop | a lowercase-and-underscores property with a logical length |
idx | index to check |
idx
is a valid index into the given property, and 0 otherwise. #define DT_PROP_HAS_NAME | ( | node_id, | |
prop, | |||
name | |||
) | IS_ENABLED(DT_CAT6(node_id, _P_, prop, _NAME_, name, _EXISTS)) |
#include <include/zephyr/devicetree.h>
Is name name
available in a foo-names
property?
This property is handled as special case:
interrupts
property: use DT_IRQ_HAS_NAME(node_id, idx) insteadIt is an error to use this macro with the interrupts
property.
Example devicetree fragment:
Example usage:
node_id | node identifier |
prop | a lowercase-and-underscores prop-names type property |
name | a lowercase-and-underscores name to check |
#define DT_PROP_LEN | ( | node_id, | |
prop | |||
) | DT_CAT4(node_id, _P_, prop, _LEN) |
#include <include/zephyr/devicetree.h>
Get a property's logical length.
Here, "length" is a number of elements, which may differ from the property's size in bytes.
The return value depends on the property's type:
These properties are handled as special cases:
DT_NUM_REGS(node_id)
insteadDT_NUM_IRQS(node_id)
insteadIt is an error to use this macro with the ranges
, dma-ranges
, reg
or interrupts
properties.
For other properties, behavior is undefined.
node_id | node identifier |
prop | a lowercase-and-underscores property with a logical length |
#define DT_PROP_LEN_OR | ( | node_id, | |
prop, | |||
default_value | |||
) |
#include <include/zephyr/devicetree.h>
Like DT_PROP_LEN(), but with a fallback to default_value
.
If the property is defined (as determined by DT_NODE_HAS_PROP()), this expands to DT_PROP_LEN(node_id, prop). The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | node identifier |
prop | a lowercase-and-underscores property with a logical length |
default_value | a fallback value to expand to |
#define DT_PROP_OR | ( | node_id, | |
prop, | |||
default_value | |||
) |
#include <include/zephyr/devicetree.h>
Like DT_PROP(), but with a fallback to default_value
.
If the value exists, this expands to DT_PROP(node_id, prop). The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | node identifier |
prop | lowercase-and-underscores property name |
default_value | a fallback value to expand to |
default_value
#define DT_STRING_TOKEN | ( | node_id, | |
prop | |||
) | DT_CAT4(node_id, _P_, prop, _STRING_TOKEN) |
#include <include/zephyr/devicetree.h>
Get a string property's value as a token.
This removes "the quotes" from a string property's value, converting any non-alphanumeric characters to underscores. This can be useful, for example, when programmatically using the value to form a C variable or code.
DT_STRING_TOKEN() can only be used for properties with string type.
It is an error to use DT_STRING_TOKEN() in other circumstances.
Example devicetree fragment:
Example bindings fragment:
Example usage:
Notice how:
"FOO"
in the DTS remains FOO
as a token. It is not converted to foo
."123 foo"
string is converted to 123_foo
as a token.node_id | node identifier |
prop | lowercase-and-underscores property name |
prop
as a token, i.e. without any quotes and with special characters converted to underscores #define DT_STRING_TOKEN_BY_IDX | ( | node_id, | |
prop, | |||
idx | |||
) | DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_TOKEN) |
#include <include/zephyr/devicetree.h>
Get an element out of a string-array property as a token.
This removes "the quotes" from an element in the array, and converts non-alphanumeric characters to underscores. That can be useful, for example, when programmatically using the value to form a C variable or code.
DT_STRING_TOKEN_BY_IDX() can only be used for properties with string-array type.
It is an error to use DT_STRING_TOKEN_BY_IDX() in other circumstances.
Example devicetree fragment:
Example bindings fragment:
Example usage:
For more information, see DT_STRING_TOKEN.
node_id | node identifier |
prop | lowercase-and-underscores property name |
idx | the index to get |
prop
at index idx
as a token #define DT_STRING_TOKEN_OR | ( | node_id, | |
prop, | |||
default_value | |||
) |
#include <include/zephyr/devicetree.h>
Like DT_STRING_TOKEN(), but with a fallback to default_value
.
If the value exists, this expands to DT_STRING_TOKEN(node_id, prop). The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | node identifier |
prop | lowercase-and-underscores property name |
default_value | a fallback value to expand to |
default_value
#define DT_STRING_UNQUOTED | ( | node_id, | |
prop | |||
) | DT_CAT4(node_id, _P_, prop, _STRING_UNQUOTED) |
#include <include/zephyr/devicetree.h>
Get a string property's value as an unquoted sequence of tokens.
This removes "the quotes" from string-valued properties. That can be useful, for example, when defining floating point values as a string in devicetree that you would like to use to initialize a float or double variable in C.
DT_STRING_UNQUOTED() can only be used for properties with string type.
It is an error to use DT_STRING_UNQUOTED() in other circumstances.
Example devicetree fragment:
n1: node-1 { prop = "12.7"; }; n2: node-2 { prop = "0.5"; } n3: node-3 { prop = "A B C"; };
Example bindings fragment:
properties: prop: type: string
Example usage:
DT_STRING_UNQUOTED(DT_NODELABEL(n1), prop) // 12.7 DT_STRING_UNQUOTED(DT_NODELABEL(n2), prop) // 0.5 DT_STRING_UNQUOTED(DT_NODELABEL(n3), prop) // A B C
node_id | node identifier |
prop | lowercase-and-underscores property name |
#define DT_STRING_UNQUOTED_BY_IDX | ( | node_id, | |
prop, | |||
idx | |||
) | DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UNQUOTED) |
#include <include/zephyr/devicetree.h>
Get a string array item value as an unquoted sequence of tokens.
This removes "the quotes" from string-valued item. That can be useful, for example, when defining floating point values as a string in devicetree that you would like to use to initialize a float or double variable in C.
DT_STRING_UNQUOTED_BY_IDX() can only be used for properties with string-array type.
It is an error to use DT_STRING_UNQUOTED_BY_IDX() in other circumstances.
Example devicetree fragment:
n1: node-1 { prop = "12.7", "34.1"; }; n2: node-2 { prop = "A B", "C D"; }
Example bindings fragment:
properties: prop: type: string-array
Example usage:
DT_STRING_UNQUOTED_BY_IDX(DT_NODELABEL(n1), prop, 0) // 12.7 DT_STRING_UNQUOTED_BY_IDX(DT_NODELABEL(n1), prop, 1) // 34.1 DT_STRING_UNQUOTED_BY_IDX(DT_NODELABEL(n2), prop, 0) // A B DT_STRING_UNQUOTED_BY_IDX(DT_NODELABEL(n2), prop, 1) // C D
node_id | node identifier |
prop | lowercase-and-underscores property name |
idx | the index to get |
#define DT_STRING_UNQUOTED_OR | ( | node_id, | |
prop, | |||
default_value | |||
) |
#include <include/zephyr/devicetree.h>
Like DT_STRING_UNQUOTED(), but with a fallback to default_value
.
If the value exists, this expands to DT_STRING_UNQUOTED(node_id, prop). The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | node identifier |
prop | lowercase-and-underscores property name |
default_value | a fallback value to expand to |
default_value
#define DT_STRING_UPPER_TOKEN | ( | node_id, | |
prop | |||
) | DT_CAT4(node_id, _P_, prop, _STRING_UPPER_TOKEN) |
#include <include/zephyr/devicetree.h>
Like DT_STRING_TOKEN(), but uppercased.
This removes "the quotes" from a string property's value, converting any non-alphanumeric characters to underscores, and capitalizing the result. This can be useful, for example, when programmatically using the value to form a C variable or code.
DT_STRING_UPPER_TOKEN() can only be used for properties with string type.
It is an error to use DT_STRING_UPPER_TOKEN() in other circumstances.
Example devicetree fragment:
Example bindings fragment:
Example usage:
Notice how:
"foo"
in the DTS becomes FOO
as a token, i.e. it is uppercased."123 foo"
string is converted to 123_FOO
as a token, i.e. it is uppercased and whitespace becomes an underscore.node_id | node identifier |
prop | lowercase-and-underscores property name |
prop
as an uppercased token, i.e. without any quotes and with special characters converted to underscores #define DT_STRING_UPPER_TOKEN_BY_IDX | ( | node_id, | |
prop, | |||
idx | |||
) | DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UPPER_TOKEN) |
#include <include/zephyr/devicetree.h>
Like DT_STRING_TOKEN_BY_IDX(), but uppercased.
This removes "the quotes" and capitalizes an element in the array, and converts non-alphanumeric characters to underscores. That can be useful, for example, when programmatically using the value to form a C variable or code.
DT_STRING_UPPER_TOKEN_BY_IDX() can only be used for properties with string-array type.
It is an error to use DT_STRING_UPPER_TOKEN_BY_IDX() in other circumstances.
Example devicetree fragment:
Example bindings fragment:
Example usage:
For more information, see DT_STRING_UPPER_TOKEN.
node_id | node identifier |
prop | lowercase-and-underscores property name |
idx | the index to get |
prop
at index idx
as an uppercased token #define DT_STRING_UPPER_TOKEN_OR | ( | node_id, | |
prop, | |||
default_value | |||
) |
#include <include/zephyr/devicetree.h>
Like DT_STRING_UPPER_TOKEN(), but with a fallback to default_value
.
If the value exists, this expands to DT_STRING_UPPER_TOKEN(node_id, prop). The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | node identifier |
prop | lowercase-and-underscores property name |
default_value | a fallback value to expand to |
default_value