|
Zephyr Project API
3.1.0
A Scalable Open Source RTOS
|
Macros | |
| #define | DT_BUS(node_id) DT_CAT(node_id, _BUS) |
| Node's bus controller. More... | |
| #define | DT_BUS_LABEL(node_id) DT_PROP(DT_BUS(node_id), label) |
| Node's bus controller's label property. More... | |
| #define | DT_ON_BUS(node_id, bus) IS_ENABLED(DT_CAT(node_id, _BUS_##bus)) |
| Is a node on a bus of a given type? More... | |
| #define DT_BUS | ( | node_id | ) | DT_CAT(node_id, _BUS) |
#include <include/zephyr/devicetree.h>
Node's bus controller.
Get the node identifier of the node's bus controller. This can be used with DT_PROP() to get properties of the bus controller.
It is an error to use this with nodes which do not have bus controllers.
Example devicetree fragment:
i2c@deadbeef {
label = "I2C_CTLR";
status = "okay";
clock-frequency = < 100000 >;
i2c_device: accelerometer@12 {
...
};
};
Example usage:
DT_PROP(DT_BUS(DT_NODELABEL(i2c_device)), clock_frequency) // 100000
| node_id | node identifier |
#include <include/zephyr/devicetree.h>
Node's bus controller's label property.
| node_id | node identifier |
| #define DT_ON_BUS | ( | node_id, | |
| bus | |||
| ) | IS_ENABLED(DT_CAT(node_id, _BUS_##bus)) |
#include <include/zephyr/devicetree.h>
Is a node on a bus of a given type?
Example devicetree overlay:
&i2c0 {
temp: temperature-sensor@76 {
compatible = "vnd,some-sensor";
reg = <0x76>;
};
};
Example usage, assuming "i2c0" is an I2C bus controller node, and therefore "temp" is on an I2C bus:
DT_ON_BUS(DT_NODELABEL(temp), i2c) // 1 DT_ON_BUS(DT_NODELABEL(temp), spi) // 0
| node_id | node identifier |
| bus | lowercase-and-underscores bus type as a C token (i.e. without quotes) |