Skip to content

Commit 50b267f

Browse files
mbolivar-nordiccfriedt
authored andcommitted
soc: nordic_nrf: add NRF_DT_GPIOS_TO_PSEL_OR
Helper macro for getting the PSEL value from optional devicetree properties. Signed-off-by: Martí Bolívar <[email protected]>
1 parent b1e0bac commit 50b267f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

soc/arm/nordic_nrf/soc_nrf_common.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@
130130
(DT_GPIO_PIN(node_id, prop) + \
131131
(DT_PROP_BY_PHANDLE(node_id, prop, port) << 5))
132132

133+
/**
134+
* If the node has the property, expands to
135+
* NRF_DT_GPIOS_TO_PSEL(node_id, prop). The default_value argument is
136+
* not expanded in this case.
137+
*
138+
* Otherwise, expands to default_value.
139+
*/
140+
#define NRF_DT_GPIOS_TO_PSEL_OR(node_id, prop, default_value) \
141+
COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
142+
(NRF_DT_GPIOS_TO_PSEL(node_id, prop)), \
143+
(default_value))
144+
133145
/**
134146
* Error out the build if 'prop' is set on node 'node_id' and
135147
* DT_GPIO_CTLR(node_id, prop) is not an SoC GPIO controller,

0 commit comments

Comments
 (0)