|
Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
|
Macros | |
| #define | MUX_CONTROL_DT_GET_BY_IDX(node_id, idx) |
Get a pointer to the mux_control object defined by MUX_CONTROL_DT_SPEC_DEFINE_BY_IDX(). | |
| #define | MUX_CONTROL_DT_GET(node_id) |
| Equivalent to MUX_CONTROL_DT_GET_BY_IDX(node_id, 0). | |
| #define | MUX_CONTROL_DT_GET_BY_NAME(node_id, name) |
Get a pointer to the mux_control object defined by MUX_CONTROL_DT_SPEC_DEFINE_BY_NAME(). | |
| #define | MUX_STATE_DT_GET_BY_IDX(node_id, idx) |
Get a pointer to the mux_state object defined by MUX_STATE_DT_SPEC_DEFINE_BY_IDX(). | |
| #define | MUX_STATE_DT_GET(node_id) |
| Equivalent to MUX_STATE_DT_GET_BY_IDX(node_id, 0). | |
| #define | MUX_STATE_DT_GET_BY_NAME(node_id, name) |
Get a pointer to the mux_state object defined by MUX_STATE_DT_SPEC_DEFINE_BY_NAME(). | |
| #define | MUX_CONTROL_DT_DEV_GET_BY_IDX(node_id, idx) |
Get the MUX controller device pointer for a mux-controls entry. | |
| #define | MUX_CONTROL_DT_DEV_GET(node_id) |
| Equivalent to MUX_CONTROL_DT_DEV_GET_BY_IDX(node_id, 0). | |
| #define | MUX_STATE_DT_DEV_GET_BY_IDX(node_id, idx) |
Get the MUX controller device pointer for a mux-states entry. | |
| #define | MUX_STATE_DT_DEV_GET(node_id) |
| Equivalent to MUX_STATE_DT_DEV_GET_BY_IDX(node_id, 0). | |
| #define | MUX_STATE_DT_SPEC_DEFINE_ALL(node_id) |
Define a mux_state object for every entry in a node's mux-states property. | |
| #define | MUX_STATE_DT_INST_SPEC_DEFINE_ALL(inst) |
Equivalent to MUX_STATE_DT_SPEC_DEFINE_ALL() for DT_DRV_INST(inst). | |
| #define MUX_CONTROL_DT_DEV_GET | ( | node_id | ) |
#include <zephyr/devicetree/mux.h>
Equivalent to MUX_CONTROL_DT_DEV_GET_BY_IDX(node_id, 0).
| node_id | Devicetree node identifier of the consumer. |
struct device for the first MUX controller. | #define MUX_CONTROL_DT_DEV_GET_BY_IDX | ( | node_id, | |
| idx ) |
#include <zephyr/devicetree/mux.h>
Get the MUX controller device pointer for a mux-controls entry.
Equivalent to looking up the phandle of mux-controls at index idx and fetching its struct device pointer with DEVICE_DT_GET(). Use the returned device with mux_control_set() (and friends).
Example devicetree fragment:
mux0: mux-controller@... { compatible = "vendor,demux"; ... };
mux1: mux-controller@... { compatible = "vendor,demux"; ... };
n: node {
mux-controls = <&mux0 5>, <&mux1 9>;
};
Example usage:
const struct device *d0 = MUX_CONTROL_DT_DEV_GET_BY_IDX(DT_NODELABEL(n), 0); // &mux0 const struct device *d1 = MUX_CONTROL_DT_DEV_GET_BY_IDX(DT_NODELABEL(n), 1); // &mux1
| node_id | Devicetree node identifier of the consumer. |
| idx | Logical index into the mux-controls property. |
struct device for the MUX controller at index idx. | #define MUX_CONTROL_DT_GET | ( | node_id | ) |
#include <zephyr/devicetree/mux.h>
Equivalent to MUX_CONTROL_DT_GET_BY_IDX(node_id, 0).
Example devicetree fragment:
n: node {
mux-controls = <&mux0 5>;
};
Example usage:
MUX_CONTROL_DT_SPEC_DEFINE(DT_NODELABEL(n)); const struct mux_control *m = MUX_CONTROL_DT_GET(DT_NODELABEL(n));
| node_id | Devicetree node identifier of the consumer. |
struct mux_control for the first entry. | #define MUX_CONTROL_DT_GET_BY_IDX | ( | node_id, | |
| idx ) |
#include <zephyr/devicetree/mux.h>
Get a pointer to the mux_control object defined by MUX_CONTROL_DT_SPEC_DEFINE_BY_IDX().
The MUX_CONTROL_DT_SPEC_DEFINE_BY_IDX() macro that allocates the underlying storage lives in <zephyr/drivers/mux.h>; this macro just returns its address.
Example devicetree fragment:
mux0: mux-controller@... {
compatible = "vendor,demux";
#mux-control-cells = <1>;
...
};
n: node {
mux-controls = <&mux0 5>, <&mux0 7>;
};
Example usage:
MUX_CONTROL_DT_SPEC_DEFINE_BY_IDX(DT_NODELABEL(n), 0);
MUX_CONTROL_DT_SPEC_DEFINE_BY_IDX(DT_NODELABEL(n), 1);
const struct mux_control *m0 =
MUX_CONTROL_DT_GET_BY_IDX(DT_NODELABEL(n), 0); // channel 5
const struct mux_control *m1 =
MUX_CONTROL_DT_GET_BY_IDX(DT_NODELABEL(n), 1); // channel 7
| node_id | Devicetree node identifier of the consumer. |
| idx | Logical index into the mux-controls property. |
struct mux_control. | #define MUX_CONTROL_DT_GET_BY_NAME | ( | node_id, | |
| name ) |
#include <zephyr/devicetree/mux.h>
Get a pointer to the mux_control object defined by MUX_CONTROL_DT_SPEC_DEFINE_BY_NAME().
Example devicetree fragment:
n: node {
mux-controls = <&mux0 5>, <&mux0 7>;
mux-control-names = "phase_a", "phase_b";
};
Example usage:
MUX_CONTROL_DT_SPEC_DEFINE_BY_NAME(DT_NODELABEL(n), phase_a);
const struct mux_control *ma =
MUX_CONTROL_DT_GET_BY_NAME(DT_NODELABEL(n), phase_a); // channel 5
| node_id | Devicetree node identifier of the consumer. |
| name | Lowercase-and-underscores name from the mux-control-names property. |
struct mux_control for the named entry. | #define MUX_STATE_DT_DEV_GET | ( | node_id | ) |
#include <zephyr/devicetree/mux.h>
Equivalent to MUX_STATE_DT_DEV_GET_BY_IDX(node_id, 0).
| node_id | Devicetree node identifier of the consumer. |
struct device for the first MUX controller. | #define MUX_STATE_DT_DEV_GET_BY_IDX | ( | node_id, | |
| idx ) |
#include <zephyr/devicetree/mux.h>
Get the MUX controller device pointer for a mux-states entry.
Equivalent to looking up the phandle of mux-states at index idx and fetching its struct device pointer with DEVICE_DT_GET(). Pair with MUX_STATE_DT_GET_BY_IDX() to feed mux_state_apply():
mux_state_apply(MUX_STATE_DT_DEV_GET_BY_IDX(node, idx),
MUX_STATE_DT_GET_BY_IDX(node, idx));
Example devicetree fragment:
mux0: mux-controller@... { compatible = "vendor,demux"; ... };
n: node {
mux-states = <&mux0 5 2>;
};
Example usage:
const struct device *dev = MUX_STATE_DT_DEV_GET_BY_IDX(DT_NODELABEL(n), 0); // &mux0
| node_id | Devicetree node identifier of the consumer. |
| idx | Logical index into the mux-states property. |
struct device for the MUX controller at index idx. | #define MUX_STATE_DT_GET | ( | node_id | ) |
#include <zephyr/devicetree/mux.h>
Equivalent to MUX_STATE_DT_GET_BY_IDX(node_id, 0).
Example devicetree fragment:
n: node {
mux-states = <&mux0 5 2>;
};
Example usage:
MUX_STATE_DT_SPEC_DEFINE(DT_NODELABEL(n)); const struct mux_state *s = MUX_STATE_DT_GET(DT_NODELABEL(n));
| node_id | Devicetree node identifier of the consumer. |
struct mux_state for the first entry. | #define MUX_STATE_DT_GET_BY_IDX | ( | node_id, | |
| idx ) |
#include <zephyr/devicetree/mux.h>
Get a pointer to the mux_state object defined by MUX_STATE_DT_SPEC_DEFINE_BY_IDX().
Example devicetree fragment:
mux0: mux-controller@... {
compatible = "vendor,demux";
#mux-control-cells = <1>;
#mux-state-cells = <2>;
...
};
n: node {
mux-states = <&mux0 5 2>, <&mux0 7 3>;
// entry 0: channel=5, state=2
// entry 1: channel=7, state=3
};
Example usage:
MUX_STATE_DT_SPEC_DEFINE_BY_IDX(DT_NODELABEL(n), 0); const struct mux_state *s0 = MUX_STATE_DT_GET_BY_IDX(DT_NODELABEL(n), 0); // s0->control->cells[0] == 5, s0->state == 2
| node_id | Devicetree node identifier of the consumer. |
| idx | Logical index into the mux-states property. |
struct mux_state. | #define MUX_STATE_DT_GET_BY_NAME | ( | node_id, | |
| name ) |
#include <zephyr/devicetree/mux.h>
Get a pointer to the mux_state object defined by MUX_STATE_DT_SPEC_DEFINE_BY_NAME().
Example devicetree fragment:
n: node {
mux-states = <&mux0 5 2>, <&mux0 7 3>;
mux-state-names = "default", "alt";
};
Example usage:
MUX_STATE_DT_SPEC_DEFINE_BY_NAME(DT_NODELABEL(n), default); const struct mux_state *def = MUX_STATE_DT_GET_BY_NAME(DT_NODELABEL(n), default);
| node_id | Devicetree node identifier of the consumer. |
| name | Lowercase-and-underscores name from the mux-state-names property. |
struct mux_state for the named entry. | #define MUX_STATE_DT_INST_SPEC_DEFINE_ALL | ( | inst | ) |
#include <zephyr/devicetree/mux.h>
Equivalent to MUX_STATE_DT_SPEC_DEFINE_ALL() for DT_DRV_INST(inst).
| inst | DT_DRV_COMPAT instance number. |
| #define MUX_STATE_DT_SPEC_DEFINE_ALL | ( | node_id | ) |
#include <zephyr/devicetree/mux.h>
Define a mux_state object for every entry in a node's mux-states property.
Convenience over calling MUX_STATE_DT_SPEC_DEFINE_BY_IDX() in a loop. The emitted mux_state storage is then referenced from a consumer- defined entry array; the consumer chooses the entry struct shape.
Example devicetree fragment:
mux0: mux-controller@... { compatible = "vendor,demux"; ... };
mux1: mux-controller@... { compatible = "vendor,demux"; ... };
consumer: my-consumer {
mux-states = <&mux0 5 2>, <&mux1 9 3>;
};
Example usage:
struct my_mux_entry {
const struct device *dev;
const struct mux_state *state;
};
#define MY_ENTRY_INIT(node_id, prop, idx) \
{ .dev = MUX_STATE_DT_DEV_GET_BY_IDX(node_id, idx), \
.state = MUX_STATE_DT_GET_BY_IDX(node_id, idx), },
MUX_STATE_DT_SPEC_DEFINE_ALL(DT_NODELABEL(consumer));
static const struct my_mux_entry entries[] = {
DT_FOREACH_PROP_ELEM(DT_NODELABEL(consumer), mux_states,
MY_ENTRY_INIT)
};
| node_id | Devicetree node identifier of the consumer. |