Zephyr API 3.6.99
Loading...
Searching...
No Matches
Pin control

Macros

#define DT_PINCTRL_BY_IDX(node_id, pc_idx, idx)
 Get a node identifier for a phandle in a pinctrl property by index.
 
#define DT_PINCTRL_0(node_id, idx)
 Get a node identifier from a pinctrl-0 property.
 
#define DT_PINCTRL_BY_NAME(node_id, name, idx)
 Get a node identifier for a phandle inside a pinctrl node by name.
 
#define DT_PINCTRL_NAME_TO_IDX(node_id, name)
 Convert a pinctrl name to its corresponding index.
 
#define DT_PINCTRL_IDX_TO_NAME_TOKEN(node_id, pc_idx)
 Convert a pinctrl property index to its name as a token.
 
#define DT_PINCTRL_IDX_TO_NAME_UPPER_TOKEN(node_id, pc_idx)
 Like DT_PINCTRL_IDX_TO_NAME_TOKEN(), but with an uppercased result.
 
#define DT_NUM_PINCTRLS_BY_IDX(node_id, pc_idx)
 Get the number of phandles in a pinctrl property.
 
#define DT_NUM_PINCTRLS_BY_NAME(node_id, name)
 Like DT_NUM_PINCTRLS_BY_IDX(), but by name instead.
 
#define DT_NUM_PINCTRL_STATES(node_id)
 Get the number of pinctrl properties in a node.
 
#define DT_PINCTRL_HAS_IDX(node_id, pc_idx)
 Test if a node has a pinctrl property with an index.
 
#define DT_PINCTRL_HAS_NAME(node_id, name)
 Test if a node has a pinctrl property with a name.
 
#define DT_INST_PINCTRL_BY_IDX(inst, pc_idx, idx)
 Get a node identifier for a phandle in a pinctrl property by index for a DT_DRV_COMPAT instance.
 
#define DT_INST_PINCTRL_0(inst, idx)
 Get a node identifier from a pinctrl-0 property for a DT_DRV_COMPAT instance.
 
#define DT_INST_PINCTRL_BY_NAME(inst, name, idx)
 Get a node identifier for a phandle inside a pinctrl node for a DT_DRV_COMPAT instance.
 
#define DT_INST_PINCTRL_NAME_TO_IDX(inst, name)
 Convert a pinctrl name to its corresponding index for a DT_DRV_COMPAT instance.
 
#define DT_INST_PINCTRL_IDX_TO_NAME_TOKEN(inst, pc_idx)
 Convert a pinctrl index to its name as an uppercased token.
 
#define DT_INST_PINCTRL_IDX_TO_NAME_UPPER_TOKEN(inst, pc_idx)
 Convert a pinctrl index to its name as an uppercased token.
 
#define DT_INST_NUM_PINCTRLS_BY_IDX(inst, pc_idx)
 Get the number of phandles in a pinctrl property for a DT_DRV_COMPAT instance.
 
#define DT_INST_NUM_PINCTRLS_BY_NAME(inst, name)
 Like DT_INST_NUM_PINCTRLS_BY_IDX(), but by name instead.
 
#define DT_INST_NUM_PINCTRL_STATES(inst)
 Get the number of pinctrl properties in a DT_DRV_COMPAT instance.
 
#define DT_INST_PINCTRL_HAS_IDX(inst, pc_idx)
 Test if a DT_DRV_COMPAT instance has a pinctrl property with an index.
 
#define DT_INST_PINCTRL_HAS_NAME(inst, name)
 Test if a DT_DRV_COMPAT instance has a pinctrl property with a name.
 

Detailed Description

Macro Definition Documentation

◆ DT_INST_NUM_PINCTRL_STATES

#define DT_INST_NUM_PINCTRL_STATES ( inst)

#include <zephyr/devicetree/pinctrl.h>

Value:
#define DT_DRV_INST(inst)
Node identifier for an instance of a DT_DRV_COMPAT compatible.
Definition devicetree.h:3623
#define DT_NUM_PINCTRL_STATES(node_id)
Get the number of pinctrl properties in a node.
Definition pinctrl.h:239

Get the number of pinctrl properties in a DT_DRV_COMPAT instance.

This is equivalent to DT_NUM_PINCTRL_STATES(DT_DRV_INST(inst)).

Parameters
instinstance number
Returns
number of pinctrl properties in the instance

◆ DT_INST_NUM_PINCTRLS_BY_IDX

#define DT_INST_NUM_PINCTRLS_BY_IDX ( inst,
pc_idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
#define DT_NUM_PINCTRLS_BY_IDX(node_id, pc_idx)
Get the number of phandles in a pinctrl property.
Definition pinctrl.h:189

Get the number of phandles in a pinctrl property for a DT_DRV_COMPAT instance.

This is equivalent to DT_NUM_PINCTRLS_BY_IDX(DT_DRV_INST(inst), pc_idx).

Parameters
instinstance number
pc_idxindex of the pinctrl property itself
Returns
number of phandles in the property with that index

◆ DT_INST_NUM_PINCTRLS_BY_NAME

#define DT_INST_NUM_PINCTRLS_BY_NAME ( inst,
name )

#include <zephyr/devicetree/pinctrl.h>

Value:
#define DT_NUM_PINCTRLS_BY_NAME(node_id, name)
Like DT_NUM_PINCTRLS_BY_IDX(), but by name instead.
Definition pinctrl.h:212

Like DT_INST_NUM_PINCTRLS_BY_IDX(), but by name instead.

This is equivalent to DT_NUM_PINCTRLS_BY_NAME(DT_DRV_INST(inst), name).

Parameters
instinstance number
namelowercase-and-underscores name of the pinctrl property
Returns
number of phandles in the property with that name

◆ DT_INST_PINCTRL_0

#define DT_INST_PINCTRL_0 ( inst,
idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
#define DT_PINCTRL_BY_IDX(node_id, pc_idx, idx)
Get a node identifier for a phandle in a pinctrl property by index.
Definition pinctrl.h:40

Get a node identifier from a pinctrl-0 property for a DT_DRV_COMPAT instance.

This is equivalent to:

DT_PINCTRL_BY_IDX(DT_DRV_INST(inst), 0, idx)

It is provided for convenience since pinctrl-0 is commonly used.

Parameters
instinstance number
idxindex into the pinctrl-0 property
Returns
node identifier for the phandle at index idx in the pinctrl-0 property of that instance

◆ DT_INST_PINCTRL_BY_IDX

#define DT_INST_PINCTRL_BY_IDX ( inst,
pc_idx,
idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_PINCTRL_BY_IDX(DT_DRV_INST(inst), pc_idx, idx)

Get a node identifier for a phandle in a pinctrl property by index for a DT_DRV_COMPAT instance.

This is equivalent to DT_PINCTRL_BY_IDX(DT_DRV_INST(inst), pc_idx, idx).

Parameters
instinstance number
pc_idxindex of the pinctrl property itself
idxindex into the value of the pinctrl property
Returns
node identifier for the phandle at index 'idx' in 'pinctrl-'pc_idx''

◆ DT_INST_PINCTRL_BY_NAME

#define DT_INST_PINCTRL_BY_NAME ( inst,
name,
idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_PINCTRL_BY_NAME(DT_DRV_INST(inst), name, idx)
#define DT_PINCTRL_BY_NAME(node_id, name, idx)
Get a node identifier for a phandle inside a pinctrl node by name.
Definition pinctrl.h:81

Get a node identifier for a phandle inside a pinctrl node for a DT_DRV_COMPAT instance.

This is equivalent to DT_PINCTRL_BY_NAME(DT_DRV_INST(inst), name, idx).

Parameters
instinstance number
namelowercase-and-underscores pinctrl property name
idxindex into the value of the named pinctrl property
Returns
node identifier for the phandle at that index in the pinctrl property

◆ DT_INST_PINCTRL_HAS_IDX

#define DT_INST_PINCTRL_HAS_IDX ( inst,
pc_idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
#define DT_PINCTRL_HAS_IDX(node_id, pc_idx)
Test if a node has a pinctrl property with an index.
Definition pinctrl.h:268

Test if a DT_DRV_COMPAT instance has a pinctrl property with an index.

This is equivalent to DT_PINCTRL_HAS_IDX(DT_DRV_INST(inst), pc_idx).

Parameters
instinstance number
pc_idxindex of a pinctrl property whose existence to check
Returns
1 if the property exists, 0 otherwise

◆ DT_INST_PINCTRL_HAS_NAME

#define DT_INST_PINCTRL_HAS_NAME ( inst,
name )

#include <zephyr/devicetree/pinctrl.h>

Value:
#define DT_PINCTRL_HAS_NAME(node_id, name)
Test if a node has a pinctrl property with a name.
Definition pinctrl.h:297

Test if a DT_DRV_COMPAT instance has a pinctrl property with a name.

This is equivalent to DT_PINCTRL_HAS_NAME(DT_DRV_INST(inst), name).

Parameters
instinstance number
namelowercase-and-underscores pinctrl property name to check
Returns
1 if the property exists, 0 otherwise

◆ DT_INST_PINCTRL_IDX_TO_NAME_TOKEN

#define DT_INST_PINCTRL_IDX_TO_NAME_TOKEN ( inst,
pc_idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
#define DT_PINCTRL_IDX_TO_NAME_TOKEN(node_id, pc_idx)
Convert a pinctrl property index to its name as a token.
Definition pinctrl.h:138

Convert a pinctrl index to its name as an uppercased token.

This is equivalent to DT_PINCTRL_IDX_TO_NAME_TOKEN(DT_DRV_INST(inst), pc_idx).

Parameters
instinstance number
pc_idxindex of the pinctrl property itself
Returns
name of the pin control property as a token

◆ DT_INST_PINCTRL_IDX_TO_NAME_UPPER_TOKEN

#define DT_INST_PINCTRL_IDX_TO_NAME_UPPER_TOKEN ( inst,
pc_idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
#define DT_PINCTRL_IDX_TO_NAME_UPPER_TOKEN(node_id, pc_idx)
Like DT_PINCTRL_IDX_TO_NAME_TOKEN(), but with an uppercased result.
Definition pinctrl.h:164

Convert a pinctrl index to its name as an uppercased token.

This is equivalent to DT_PINCTRL_IDX_TO_NAME_UPPER_TOKEN(DT_DRV_INST(inst), idx).

Parameters
instinstance number
pc_idxindex of the pinctrl property itself
Returns
name of the pin control property as an uppercase token

◆ DT_INST_PINCTRL_NAME_TO_IDX

#define DT_INST_PINCTRL_NAME_TO_IDX ( inst,
name )

#include <zephyr/devicetree/pinctrl.h>

Value:
#define DT_PINCTRL_NAME_TO_IDX(node_id, name)
Convert a pinctrl name to its corresponding index.
Definition pinctrl.h:104

Convert a pinctrl name to its corresponding index for a DT_DRV_COMPAT instance.

This is equivalent to DT_PINCTRL_NAME_TO_IDX(DT_DRV_INST(inst), name).

Parameters
instinstance number
namelowercase-and-underscores name of the pinctrl whose index to get
Returns
integer literal for the index of the pinctrl property with that name

◆ DT_NUM_PINCTRL_STATES

#define DT_NUM_PINCTRL_STATES ( node_id)

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_CAT(node_id, _PINCTRL_NUM)

Get the number of pinctrl properties in a node.

This expands to 0 if there are no pinctrl-i properties. Otherwise, it expands to the number of such properties.

Example devicetree fragment:

n1: node-1 {
        pinctrl-0 = <...>;
        pinctrl-1 = <...>;
};

n2: node-2 {
};

Example usage:

DT_NUM_PINCTRL_STATES(DT_NODELABEL(n1)) // 2
DT_NUM_PINCTRL_STATES(DT_NODELABEL(n2)) // 0
Parameters
node_idnode identifier; may or may not have any pinctrl properties
Returns
number of pinctrl properties in the node

◆ DT_NUM_PINCTRLS_BY_IDX

#define DT_NUM_PINCTRLS_BY_IDX ( node_id,
pc_idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_CAT4(node_id, _P_pinctrl_, pc_idx, _LEN)

Get the number of phandles in a pinctrl property.

Example devicetree fragment:

n1: node-1 {
        pinctrl-0 = <&foo &bar>;
};

n2: node-2 {
        pinctrl-0 = <&baz>;
};

Example usage:

DT_NUM_PINCTRLS_BY_IDX(DT_NODELABEL(n1), 0) // 2
DT_NUM_PINCTRLS_BY_IDX(DT_NODELABEL(n2), 0) // 1
Parameters
node_idnode identifier with a pinctrl property
pc_idxindex of the pinctrl property itself
Returns
number of phandles in the property with that index

◆ DT_NUM_PINCTRLS_BY_NAME

#define DT_NUM_PINCTRLS_BY_NAME ( node_id,
name )

#include <zephyr/devicetree/pinctrl.h>

Value:

Like DT_NUM_PINCTRLS_BY_IDX(), but by name instead.

Example devicetree fragment:

n: node {
        pinctrl-0 = <&foo &bar>;
        pinctrl-1 = <&baz>
        pinctrl-names = "default", "sleep";
};

Example usage:

DT_NUM_PINCTRLS_BY_NAME(DT_NODELABEL(n), default) // 2
DT_NUM_PINCTRLS_BY_NAME(DT_NODELABEL(n), sleep)   // 1
Parameters
node_idnode identifier with a pinctrl property
namelowercase-and-underscores name name of the pinctrl property
Returns
number of phandles in the property with that name

◆ DT_PINCTRL_0

#define DT_PINCTRL_0 ( node_id,
idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_PINCTRL_BY_IDX(node_id, 0, idx)

Get a node identifier from a pinctrl-0 property.

This is equivalent to:

DT_PINCTRL_BY_IDX(node_id, 0, idx)

It is provided for convenience since pinctrl-0 is commonly used.

Parameters
node_idnode with a pinctrl-0 property
idxindex into the pinctrl-0 property
Returns
node identifier for the phandle at index idx in the pinctrl-0 property of that node

◆ DT_PINCTRL_BY_IDX

#define DT_PINCTRL_BY_IDX ( node_id,
pc_idx,
idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_CAT6(node_id, _P_pinctrl_, pc_idx, _IDX_, idx, _PH)

Get a node identifier for a phandle in a pinctrl property by index.

Example devicetree fragment:

n: node {
        pinctrl-0 = <&foo &bar>;
        pinctrl-1 = <&baz &blub>;
}

Example usage:

DT_PINCTRL_BY_IDX(DT_NODELABEL(n), 0, 1) // DT_NODELABEL(bar)
DT_PINCTRL_BY_IDX(DT_NODELABEL(n), 1, 0) // DT_NODELABEL(baz)
Parameters
node_idnode with a pinctrl-'pc_idx' property
pc_idxindex of the pinctrl property itself
idxindex into the value of the pinctrl property
Returns
node identifier for the phandle at index 'idx' in 'pinctrl-'pc_idx''

◆ DT_PINCTRL_BY_NAME

#define DT_PINCTRL_BY_NAME ( node_id,
name,
idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_CAT6(node_id, _PINCTRL_NAME_, name, _IDX_, idx, _PH)

Get a node identifier for a phandle inside a pinctrl node by name.

Example devicetree fragment:

n: node {
        pinctrl-0 = <&foo &bar>;
        pinctrl-1 = <&baz &blub>;
        pinctrl-names = "default", "sleep";
};

Example usage:

DT_PINCTRL_BY_NAME(DT_NODELABEL(n), default, 1) // DT_NODELABEL(bar)
DT_PINCTRL_BY_NAME(DT_NODELABEL(n), sleep, 0) // DT_NODELABEL(baz)
Parameters
node_idnode with a named pinctrl property
namelowercase-and-underscores pinctrl property name
idxindex into the value of the named pinctrl property
Returns
node identifier for the phandle at that index in the pinctrl property

◆ DT_PINCTRL_HAS_IDX

#define DT_PINCTRL_HAS_IDX ( node_id,
pc_idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
IS_ENABLED(DT_CAT4(node_id, _PINCTRL_IDX_, pc_idx, _EXISTS))
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:124

Test if a node has a pinctrl property with an index.

This expands to 1 if the pinctrl-'idx' property exists. Otherwise, it expands to 0.

Example devicetree fragment:

n1: node-1 {
        pinctrl-0 = <...>;
        pinctrl-1 = <...>;
};

n2: node-2 {
};

Example usage:

DT_PINCTRL_HAS_IDX(DT_NODELABEL(n1), 0) // 1
DT_PINCTRL_HAS_IDX(DT_NODELABEL(n1), 1) // 1
DT_PINCTRL_HAS_IDX(DT_NODELABEL(n1), 2) // 0
DT_PINCTRL_HAS_IDX(DT_NODELABEL(n2), 0) // 0
Parameters
node_idnode identifier; may or may not have any pinctrl properties
pc_idxindex of a pinctrl property whose existence to check
Returns
1 if the property exists, 0 otherwise

◆ DT_PINCTRL_HAS_NAME

#define DT_PINCTRL_HAS_NAME ( node_id,
name )

#include <zephyr/devicetree/pinctrl.h>

Value:
IS_ENABLED(DT_CAT4(node_id, _PINCTRL_NAME_, name, _EXISTS))

Test if a node has a pinctrl property with a name.

This expands to 1 if the named pinctrl property exists. Otherwise, it expands to 0.

Example devicetree fragment:

n1: node-1 {
        pinctrl-0 = <...>;
        pinctrl-names = "default";
};

n2: node-2 {
};

Example usage:

DT_PINCTRL_HAS_NAME(DT_NODELABEL(n1), default) // 1
DT_PINCTRL_HAS_NAME(DT_NODELABEL(n1), sleep)   // 0
DT_PINCTRL_HAS_NAME(DT_NODELABEL(n2), default) // 0
Parameters
node_idnode identifier; may or may not have any pinctrl properties
namelowercase-and-underscores pinctrl property name to check
Returns
1 if the property exists, 0 otherwise

◆ DT_PINCTRL_IDX_TO_NAME_TOKEN

#define DT_PINCTRL_IDX_TO_NAME_TOKEN ( node_id,
pc_idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_CAT4(node_id, _PINCTRL_IDX_, pc_idx, _TOKEN)

Convert a pinctrl property index to its name as a token.

This allows you to get a pinctrl property's name, and "remove the quotes" from it.

DT_PINCTRL_IDX_TO_NAME_TOKEN() can only be used if the node has a pinctrl-'pc_idx' property and a pinctrl-names property element for that index. It is an error to use it in other circumstances.

Example devicetree fragment:

n: node {
        pinctrl-0 = <...>;
        pinctrl-1 = <...>;
        pinctrl-names = "default", "f.o.o2";
};

Example usage:

DT_PINCTRL_IDX_TO_NAME_TOKEN(DT_NODELABEL(n), 0) // default
DT_PINCTRL_IDX_TO_NAME_TOKEN(DT_NODELABEL(n), 1) // f_o_o2

The same caveats and restrictions that apply to DT_STRING_TOKEN()'s return value also apply here.

Parameters
node_idnode identifier
pc_idxindex of a pinctrl property in that node
Returns
name of the pinctrl property, as a token, without any quotes and with non-alphanumeric characters converted to underscores

◆ DT_PINCTRL_IDX_TO_NAME_UPPER_TOKEN

#define DT_PINCTRL_IDX_TO_NAME_UPPER_TOKEN ( node_id,
pc_idx )

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_CAT4(node_id, _PINCTRL_IDX_, pc_idx, _UPPER_TOKEN)

Like DT_PINCTRL_IDX_TO_NAME_TOKEN(), but with an uppercased result.

This does the a similar conversion as DT_PINCTRL_IDX_TO_NAME_TOKEN(node_id, pc_idx). The only difference is that alphabetical characters in the result are uppercased.

Example devicetree fragment:

n: node {
        pinctrl-0 = <...>;
        pinctrl-1 = <...>;
        pinctrl-names = "default", "f.o.o2";
};

Example usage:

DT_PINCTRL_IDX_TO_NAME_TOKEN(DT_NODELABEL(n), 0) // DEFAULT
DT_PINCTRL_IDX_TO_NAME_TOKEN(DT_NODELABEL(n), 1) // F_O_O2

The same caveats and restrictions that apply to DT_STRING_UPPER_TOKEN()'s return value also apply here.

◆ DT_PINCTRL_NAME_TO_IDX

#define DT_PINCTRL_NAME_TO_IDX ( node_id,
name )

#include <zephyr/devicetree/pinctrl.h>

Value:
DT_CAT4(node_id, _PINCTRL_NAME_, name, _IDX)

Convert a pinctrl name to its corresponding index.

Example devicetree fragment:

n: node {
        pinctrl-0 = <&foo &bar>;
        pinctrl-1 = <&baz &blub>;
        pinctrl-names = "default", "sleep";
};

Example usage:

DT_PINCTRL_NAME_TO_IDX(DT_NODELABEL(n), default) // 0
DT_PINCTRL_NAME_TO_IDX(DT_NODELABEL(n), sleep)   // 1
Parameters
node_idnode identifier with a named pinctrl property
namelowercase-and-underscores name name of the pinctrl whose index to get
Returns
integer literal for the index of the pinctrl property with that name