diff --git a/soc/arm/nordic_nrf/soc_nrf_common.h b/soc/arm/nordic_nrf/soc_nrf_common.h index ca889344f25..c6235f80acf 100644 --- a/soc/arm/nordic_nrf/soc_nrf_common.h +++ b/soc/arm/nordic_nrf/soc_nrf_common.h @@ -130,6 +130,18 @@ (DT_GPIO_PIN(node_id, prop) + \ (DT_PROP_BY_PHANDLE(node_id, prop, port) << 5)) +/** + * If the node has the property, expands to + * NRF_DT_GPIOS_TO_PSEL(node_id, prop). The default_value argument is + * not expanded in this case. + * + * Otherwise, expands to default_value. + */ +#define NRF_DT_GPIOS_TO_PSEL_OR(node_id, prop, default_value) \ + COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \ + (NRF_DT_GPIOS_TO_PSEL(node_id, prop)), \ + (default_value)) + /** * Error out the build if 'prop' is set on node 'node_id' and * DT_GPIO_CTLR(node_id, prop) is not an SoC GPIO controller,