various: Cleanup COND_CODE_1 usage or replace with IF_ENABLED()
Cleanup around COND_CODE_1 usage and replacing with IF_ENABLED if applicable. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
79519c4dbe
commit
d716e3a66c
7 changed files with 99 additions and 111 deletions
|
@ -351,21 +351,20 @@ static const struct nrf_clock_control_config config = {
|
||||||
.start_tsk = NRF_CLOCK_TASK_HFCLKSTART,
|
.start_tsk = NRF_CLOCK_TASK_HFCLKSTART,
|
||||||
.started_evt = NRF_CLOCK_EVENT_HFCLKSTARTED,
|
.started_evt = NRF_CLOCK_EVENT_HFCLKSTARTED,
|
||||||
.stop_tsk = NRF_CLOCK_TASK_HFCLKSTOP,
|
.stop_tsk = NRF_CLOCK_TASK_HFCLKSTOP,
|
||||||
COND_CODE_1(CONFIG_LOG, (.name = "hfclk",), ())
|
IF_ENABLED(CONFIG_LOG, (.name = "hfclk",))
|
||||||
},
|
},
|
||||||
[CLOCK_CONTROL_NRF_TYPE_LFCLK] = {
|
[CLOCK_CONTROL_NRF_TYPE_LFCLK] = {
|
||||||
.start_tsk = NRF_CLOCK_TASK_LFCLKSTART,
|
.start_tsk = NRF_CLOCK_TASK_LFCLKSTART,
|
||||||
.started_evt = NRF_CLOCK_EVENT_LFCLKSTARTED,
|
.started_evt = NRF_CLOCK_EVENT_LFCLKSTARTED,
|
||||||
.stop_tsk = NRF_CLOCK_TASK_LFCLKSTOP,
|
.stop_tsk = NRF_CLOCK_TASK_LFCLKSTOP,
|
||||||
COND_CODE_1(CONFIG_LOG, (.name = "lfclk",), ())
|
IF_ENABLED(CONFIG_LOG, (.name = "lfclk",))
|
||||||
.start_handler =
|
IF_ENABLED(
|
||||||
IS_ENABLED(
|
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION,
|
||||||
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION) ?
|
(
|
||||||
z_nrf_clock_calibration_start : NULL,
|
.start_handler = z_nrf_clock_calibration_start,
|
||||||
.stop_handler =
|
.stop_handler = z_nrf_clock_calibration_stop,
|
||||||
IS_ENABLED(
|
)
|
||||||
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION) ?
|
)
|
||||||
z_nrf_clock_calibration_stop : NULL
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -676,10 +676,10 @@ static const struct counter_driver_api counter_nrfx_driver_api = {
|
||||||
}, \
|
}, \
|
||||||
.ch_data = counter##idx##_ch_data, \
|
.ch_data = counter##idx##_ch_data, \
|
||||||
.rtc = NRF_RTC##idx, \
|
.rtc = NRF_RTC##idx, \
|
||||||
COND_CODE_1(DT_NORDIC_NRF_RTC_RTC_##idx##_PPI_WRAP, \
|
IF_ENABLED(DT_NORDIC_NRF_RTC_RTC_##idx##_PPI_WRAP, \
|
||||||
(.use_ppi = true,), ()) \
|
(.use_ppi = true,)) \
|
||||||
COND_CODE_1(CONFIG_COUNTER_RTC_CUSTOM_TOP_SUPPORT, \
|
IF_ENABLED(CONFIG_COUNTER_RTC_CUSTOM_TOP_SUPPORT, \
|
||||||
(.fixed_top = DT_NORDIC_NRF_RTC_RTC_##idx##_FIXED_TOP,), ()) \
|
(.fixed_top = DT_NORDIC_NRF_RTC_RTC_##idx##_FIXED_TOP,)) \
|
||||||
LOG_INSTANCE_PTR_INIT(log, LOG_MODULE_NAME, idx) \
|
LOG_INSTANCE_PTR_INIT(log, LOG_MODULE_NAME, idx) \
|
||||||
}; \
|
}; \
|
||||||
DEVICE_AND_API_INIT(rtc_##idx, \
|
DEVICE_AND_API_INIT(rtc_##idx, \
|
||||||
|
|
|
@ -227,8 +227,7 @@ DEVICE_AND_API_INIT(vipm_nrf_##_idx, "IPM_"#_idx, \
|
||||||
&vipm_nrf_##_idx##_driver_api)
|
&vipm_nrf_##_idx##_driver_api)
|
||||||
|
|
||||||
#define VIPM_DEVICE(_idx, _) \
|
#define VIPM_DEVICE(_idx, _) \
|
||||||
COND_CODE_1(IS_ENABLED(CONFIG_IPM_MSG_CH_##_idx##_ENABLE), \
|
IF_ENABLED(CONFIG_IPM_MSG_CH_##_idx##_ENABLE, (VIPM_DEVICE_1(_idx);))
|
||||||
(VIPM_DEVICE_1(_idx);), ())
|
|
||||||
|
|
||||||
UTIL_LISTIFY(NRFX_IPC_ID_MAX_VALUE, VIPM_DEVICE, _);
|
UTIL_LISTIFY(NRFX_IPC_ID_MAX_VALUE, VIPM_DEVICE, _);
|
||||||
|
|
||||||
|
|
|
@ -475,13 +475,14 @@ static const struct uart_driver_api uart_esp32_api = {
|
||||||
#define ESP32_UART_IRQ_HANDLER(idx)
|
#define ESP32_UART_IRQ_HANDLER(idx)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ESP32_UART_INIT(idx) \
|
#define ESP32_UART_INIT(idx) \
|
||||||
ESP32_UART_IRQ_HANDLER_DECL(idx); \
|
ESP32_UART_IRQ_HANDLER_DECL(idx); \
|
||||||
static const struct uart_esp32_config uart_esp32_cfg_port_##idx = { \
|
static const struct uart_esp32_config uart_esp32_cfg_port_##idx = { \
|
||||||
.dev_conf = { \
|
.dev_conf = { \
|
||||||
.base = (u8_t *)DT_INST_##idx##_ESPRESSIF_ESP32_UART_BASE_ADDRESS, \
|
.base = \
|
||||||
.sys_clk_freq = DT_INST_0_CADENCE_TENSILICA_XTENSA_LX6_CLOCK_FREQUENCY, \
|
(u8_t *)DT_INST_##idx##_ESPRESSIF_ESP32_UART_BASE_ADDRESS, \
|
||||||
|
.sys_clk_freq = \
|
||||||
|
DT_INST_0_CADENCE_TENSILICA_XTENSA_LX6_CLOCK_FREQUENCY \
|
||||||
ESP32_UART_IRQ_HANDLER_FUNC(idx) \
|
ESP32_UART_IRQ_HANDLER_FUNC(idx) \
|
||||||
}, \
|
}, \
|
||||||
\
|
\
|
||||||
|
@ -500,12 +501,10 @@ static const struct uart_esp32_config uart_esp32_cfg_port_##idx = { \
|
||||||
.pins = { \
|
.pins = { \
|
||||||
.tx = DT_INST_##idx##_ESPRESSIF_ESP32_UART_TX_PIN, \
|
.tx = DT_INST_##idx##_ESPRESSIF_ESP32_UART_TX_PIN, \
|
||||||
.rx = DT_INST_##idx##_ESPRESSIF_ESP32_UART_RX_PIN, \
|
.rx = DT_INST_##idx##_ESPRESSIF_ESP32_UART_RX_PIN, \
|
||||||
COND_CODE_1(IS_ENABLED(DT_INST_##idx##_ESPRESSIF_ESP32_UART_HW_FLOW_CONTROL), \
|
IF_ENABLED( \
|
||||||
|
DT_INST_##idx##_ESPRESSIF_ESP32_UART_HW_FLOW_CONTROL, \
|
||||||
(.rts = DT_INST_##idx##_ESPRESSIF_ESP32_UART_RTS_PIN, \
|
(.rts = DT_INST_##idx##_ESPRESSIF_ESP32_UART_RTS_PIN, \
|
||||||
.cts = DT_INST_##idx##_ESPRESSIF_ESP32_UART_CTS_PIN, \
|
.cts = DT_INST_##idx##_ESPRESSIF_ESP32_UART_CTS_PIN, \
|
||||||
), \
|
|
||||||
(.rts = 0, \
|
|
||||||
.cts = 0 \
|
|
||||||
)) \
|
)) \
|
||||||
}, \
|
}, \
|
||||||
\
|
\
|
||||||
|
@ -521,9 +520,9 @@ static struct uart_esp32_data uart_esp32_data_##idx = { \
|
||||||
.parity = UART_CFG_PARITY_NONE, \
|
.parity = UART_CFG_PARITY_NONE, \
|
||||||
.stop_bits = UART_CFG_STOP_BITS_1, \
|
.stop_bits = UART_CFG_STOP_BITS_1, \
|
||||||
.data_bits = UART_CFG_DATA_BITS_8, \
|
.data_bits = UART_CFG_DATA_BITS_8, \
|
||||||
COND_CODE_1(IS_ENABLED(DT_INST_##idx##_ESPRESSIF_ESP32_UART_HW_FLOW_CONTROL), \
|
.flow_ctrl = IS_ENABLED( \
|
||||||
(.flow_ctrl = UART_CFG_FLOW_CTRL_RTS_CTS), \
|
DT_INST_##idx##_ESPRESSIF_ESP32_UART_HW_FLOW_CONTROL) ?\
|
||||||
(.flow_ctrl = UART_CFG_FLOW_CTRL_NONE)) \
|
UART_CFG_FLOW_CTRL_RTS_CTS : UART_CFG_FLOW_CTRL_NONE \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
|
|
|
@ -1326,22 +1326,19 @@ static int uarte_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
|
||||||
UARTE_ASYNC(idx); \
|
UARTE_ASYNC(idx); \
|
||||||
static struct uarte_nrfx_data uarte_##idx##_data = { \
|
static struct uarte_nrfx_data uarte_##idx##_data = { \
|
||||||
UARTE_CONFIG(idx), \
|
UARTE_CONFIG(idx), \
|
||||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_ASYNC), \
|
IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \
|
||||||
(.async = &uarte##idx##_async,), \
|
(.async = &uarte##idx##_async,)) \
|
||||||
()) \
|
IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \
|
||||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN), \
|
(.int_driven = &uarte##idx##_int_driven,)) \
|
||||||
(.int_driven = &uarte##idx##_int_driven,), \
|
|
||||||
()) \
|
|
||||||
}; \
|
}; \
|
||||||
static const struct uarte_nrfx_config uarte_##idx##z_config = { \
|
static const struct uarte_nrfx_config uarte_##idx##z_config = { \
|
||||||
.uarte_regs = (NRF_UARTE_Type *) \
|
.uarte_regs = (NRF_UARTE_Type *) \
|
||||||
DT_NORDIC_NRF_UARTE_UART_##idx##_BASE_ADDRESS, \
|
DT_NORDIC_NRF_UARTE_UART_##idx##_BASE_ADDRESS, \
|
||||||
.rts_cts_pins_set = IS_ENABLED(UARTE_##idx##_CONFIG_RTS_CTS), \
|
.rts_cts_pins_set = IS_ENABLED(UARTE_##idx##_CONFIG_RTS_CTS), \
|
||||||
.gpio_mgmt = IS_ENABLED(CONFIG_UART_##idx##_GPIO_MANAGEMENT), \
|
.gpio_mgmt = IS_ENABLED(CONFIG_UART_##idx##_GPIO_MANAGEMENT), \
|
||||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC), \
|
IF_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC, \
|
||||||
(.timer = NRFX_TIMER_INSTANCE( \
|
(.timer = NRFX_TIMER_INSTANCE( \
|
||||||
CONFIG_UART_##idx##_NRF_HW_ASYNC_TIMER),), \
|
CONFIG_UART_##idx##_NRF_HW_ASYNC_TIMER),)) \
|
||||||
()) \
|
|
||||||
}; \
|
}; \
|
||||||
static int uarte_##idx##_init(struct device *dev) \
|
static int uarte_##idx##_init(struct device *dev) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -1350,22 +1347,22 @@ static int uarte_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
|
||||||
.pselrxd = DT_NORDIC_NRF_UARTE_UART_##idx##_RX_PIN, \
|
.pselrxd = DT_NORDIC_NRF_UARTE_UART_##idx##_RX_PIN, \
|
||||||
UARTE_NRF_RTS_CTS_PINS(idx), \
|
UARTE_NRF_RTS_CTS_PINS(idx), \
|
||||||
}; \
|
}; \
|
||||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN), \
|
IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \
|
||||||
(IRQ_CONNECT( \
|
(IRQ_CONNECT( \
|
||||||
NRFX_IRQ_NUMBER_GET(NRF_UARTE##idx), \
|
NRFX_IRQ_NUMBER_GET(NRF_UARTE##idx), \
|
||||||
DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0_PRIORITY, \
|
DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0_PRIORITY, \
|
||||||
uarte_nrfx_isr_int, \
|
uarte_nrfx_isr_int, \
|
||||||
DEVICE_GET(uart_nrfx_uarte##idx), \
|
DEVICE_GET(uart_nrfx_uarte##idx), \
|
||||||
0); \
|
0); \
|
||||||
irq_enable(DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0);), ())\
|
irq_enable(DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0);)) \
|
||||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_ASYNC), \
|
IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \
|
||||||
(IRQ_CONNECT( \
|
(IRQ_CONNECT( \
|
||||||
NRFX_IRQ_NUMBER_GET(NRF_UARTE##idx), \
|
NRFX_IRQ_NUMBER_GET(NRF_UARTE##idx), \
|
||||||
DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0_PRIORITY, \
|
DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0_PRIORITY, \
|
||||||
uarte_nrfx_isr_async, \
|
uarte_nrfx_isr_async, \
|
||||||
DEVICE_GET(uart_nrfx_uarte##idx), \
|
DEVICE_GET(uart_nrfx_uarte##idx), \
|
||||||
0); \
|
0); \
|
||||||
irq_enable(DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0);), ())\
|
irq_enable(DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0);)) \
|
||||||
return uarte_instance_init( \
|
return uarte_instance_init( \
|
||||||
dev, \
|
dev, \
|
||||||
&init_config, \
|
&init_config, \
|
||||||
|
@ -1395,23 +1392,22 @@ static int uarte_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UARTE_NRF_RTS_CTS_PINS(idx) \
|
#define UARTE_NRF_RTS_CTS_PINS(idx) \
|
||||||
.pselcts = COND_CODE_1(IS_ENABLED(UARTE_##idx##_CONFIG_RTS_CTS), \
|
.pselcts = COND_CODE_1(UARTE_##idx##_CONFIG_RTS_CTS, \
|
||||||
(DT_NORDIC_NRF_UARTE_UART_##idx##_CTS_PIN), \
|
(DT_NORDIC_NRF_UARTE_UART_##idx##_CTS_PIN), \
|
||||||
(NRF_UARTE_PSEL_DISCONNECTED)), \
|
(NRF_UARTE_PSEL_DISCONNECTED)), \
|
||||||
.pselrts = COND_CODE_1(IS_ENABLED(UARTE_##idx##_CONFIG_RTS_CTS), \
|
.pselrts = COND_CODE_1(UARTE_##idx##_CONFIG_RTS_CTS, \
|
||||||
(DT_NORDIC_NRF_UARTE_UART_##idx##_RTS_PIN), \
|
(DT_NORDIC_NRF_UARTE_UART_##idx##_RTS_PIN), \
|
||||||
(NRF_UARTE_PSEL_DISCONNECTED))
|
(NRF_UARTE_PSEL_DISCONNECTED))
|
||||||
|
|
||||||
#define UARTE_ASYNC(idx) \
|
#define UARTE_ASYNC(idx) \
|
||||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_ASYNC), \
|
IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \
|
||||||
(struct uarte_async_cb uarte##idx##_async = { \
|
(struct uarte_async_cb uarte##idx##_async = { \
|
||||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC), \
|
.hw_rx_counting = \
|
||||||
(.hw_rx_counting = true), \
|
IS_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC), \
|
||||||
(.hw_rx_counting = false)), \
|
}))
|
||||||
}), ())
|
|
||||||
|
|
||||||
#define UARTE_INT_DRIVEN(idx) \
|
#define UARTE_INT_DRIVEN(idx) \
|
||||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN), \
|
IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \
|
||||||
(static u8_t uarte##idx##_tx_buffer[\
|
(static u8_t uarte##idx##_tx_buffer[\
|
||||||
MIN(CONFIG_UART_##idx##_NRF_TX_BUFFER_SIZE, \
|
MIN(CONFIG_UART_##idx##_NRF_TX_BUFFER_SIZE, \
|
||||||
BIT_MASK(UARTE##idx##_EASYDMA_MAXCNT_SIZE))]; \
|
BIT_MASK(UARTE##idx##_EASYDMA_MAXCNT_SIZE))]; \
|
||||||
|
@ -1419,8 +1415,7 @@ static int uarte_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
|
||||||
uarte##idx##_int_driven = { \
|
uarte##idx##_int_driven = { \
|
||||||
.tx_buffer = uarte##idx##_tx_buffer, \
|
.tx_buffer = uarte##idx##_tx_buffer, \
|
||||||
.tx_buff_size = sizeof(uarte##idx##_tx_buffer),\
|
.tx_buff_size = sizeof(uarte##idx##_tx_buffer),\
|
||||||
};), \
|
};))
|
||||||
())
|
|
||||||
|
|
||||||
#ifdef CONFIG_UART_0_NRF_UARTE
|
#ifdef CONFIG_UART_0_NRF_UARTE
|
||||||
#if defined(DT_NORDIC_NRF_UARTE_UART_0_RTS_PIN) && \
|
#if defined(DT_NORDIC_NRF_UARTE_UART_0_RTS_PIN) && \
|
||||||
|
|
|
@ -376,12 +376,11 @@ static int spim_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
|
||||||
: NRF_GPIO_PIN_NOPULL)
|
: NRF_GPIO_PIN_NOPULL)
|
||||||
|
|
||||||
#define SPI_NRFX_SPIM_EXTENDED_CONFIG(idx) \
|
#define SPI_NRFX_SPIM_EXTENDED_CONFIG(idx) \
|
||||||
COND_CODE_1(IS_ENABLED(NRFX_SPIM_EXTENDED_ENABLED), \
|
IF_ENABLED(NRFX_SPIM_EXTENDED_ENABLED, \
|
||||||
(.dcx_pin = NRFX_SPIM_PIN_NOT_USED, \
|
(.dcx_pin = NRFX_SPIM_PIN_NOT_USED, \
|
||||||
COND_CODE_1(SPIM##idx##_FEATURE_RXDELAY_PRESENT, \
|
IF_ENABLED(SPIM##idx##_FEATURE_RXDELAY_PRESENT, \
|
||||||
(.rx_delay = CONFIG_SPI_##idx##_NRF_RX_DELAY,), \
|
(.rx_delay = CONFIG_SPI_##idx##_NRF_RX_DELAY,)) \
|
||||||
())), \
|
))
|
||||||
())
|
|
||||||
|
|
||||||
#define SPI_NRFX_SPIM_DEVICE(idx) \
|
#define SPI_NRFX_SPIM_DEVICE(idx) \
|
||||||
BUILD_ASSERT_MSG( \
|
BUILD_ASSERT_MSG( \
|
||||||
|
|
|
@ -306,7 +306,7 @@ static inline char *log_strdup(const char *str)
|
||||||
#define _LOG_ARG1(arg1, ...) arg1
|
#define _LOG_ARG1(arg1, ...) arg1
|
||||||
|
|
||||||
#define _LOG_MODULE_CONST_DATA_CREATE(_name, _level) \
|
#define _LOG_MODULE_CONST_DATA_CREATE(_name, _level) \
|
||||||
COND_CODE_1(LOG_IN_CPLUSPLUS, (extern), ()) \
|
IF_ENABLED(LOG_IN_CPLUSPLUS, (extern)) \
|
||||||
const struct log_source_const_data LOG_ITEM_CONST_DATA(_name) \
|
const struct log_source_const_data LOG_ITEM_CONST_DATA(_name) \
|
||||||
__attribute__ ((section("." STRINGIFY(LOG_ITEM_CONST_DATA(_name))))) \
|
__attribute__ ((section("." STRINGIFY(LOG_ITEM_CONST_DATA(_name))))) \
|
||||||
__attribute__((used)) = { \
|
__attribute__((used)) = { \
|
||||||
|
@ -322,11 +322,8 @@ static inline char *log_strdup(const char *str)
|
||||||
__attribute__((used))
|
__attribute__((used))
|
||||||
|
|
||||||
#define _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name) \
|
#define _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name) \
|
||||||
COND_CODE_1( \
|
IF_ENABLED(CONFIG_LOG_RUNTIME_FILTERING, \
|
||||||
CONFIG_LOG_RUNTIME_FILTERING, \
|
(_LOG_MODULE_DYNAMIC_DATA_CREATE(_name);))
|
||||||
(_LOG_MODULE_DYNAMIC_DATA_CREATE(_name);), \
|
|
||||||
() \
|
|
||||||
)
|
|
||||||
|
|
||||||
#define _LOG_MODULE_DATA_CREATE(_name, _level) \
|
#define _LOG_MODULE_DATA_CREATE(_name, _level) \
|
||||||
_LOG_MODULE_CONST_DATA_CREATE(_name, _level); \
|
_LOG_MODULE_CONST_DATA_CREATE(_name, _level); \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue