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,
|
||||
.started_evt = NRF_CLOCK_EVENT_HFCLKSTARTED,
|
||||
.stop_tsk = NRF_CLOCK_TASK_HFCLKSTOP,
|
||||
COND_CODE_1(CONFIG_LOG, (.name = "hfclk",), ())
|
||||
IF_ENABLED(CONFIG_LOG, (.name = "hfclk",))
|
||||
},
|
||||
[CLOCK_CONTROL_NRF_TYPE_LFCLK] = {
|
||||
.start_tsk = NRF_CLOCK_TASK_LFCLKSTART,
|
||||
.started_evt = NRF_CLOCK_EVENT_LFCLKSTARTED,
|
||||
.stop_tsk = NRF_CLOCK_TASK_LFCLKSTOP,
|
||||
COND_CODE_1(CONFIG_LOG, (.name = "lfclk",), ())
|
||||
.start_handler =
|
||||
IS_ENABLED(
|
||||
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION) ?
|
||||
z_nrf_clock_calibration_start : NULL,
|
||||
.stop_handler =
|
||||
IS_ENABLED(
|
||||
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION) ?
|
||||
z_nrf_clock_calibration_stop : NULL
|
||||
IF_ENABLED(CONFIG_LOG, (.name = "lfclk",))
|
||||
IF_ENABLED(
|
||||
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION,
|
||||
(
|
||||
.start_handler = z_nrf_clock_calibration_start,
|
||||
.stop_handler = z_nrf_clock_calibration_stop,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -676,10 +676,10 @@ static const struct counter_driver_api counter_nrfx_driver_api = {
|
|||
}, \
|
||||
.ch_data = counter##idx##_ch_data, \
|
||||
.rtc = NRF_RTC##idx, \
|
||||
COND_CODE_1(DT_NORDIC_NRF_RTC_RTC_##idx##_PPI_WRAP, \
|
||||
(.use_ppi = true,), ()) \
|
||||
COND_CODE_1(CONFIG_COUNTER_RTC_CUSTOM_TOP_SUPPORT, \
|
||||
(.fixed_top = DT_NORDIC_NRF_RTC_RTC_##idx##_FIXED_TOP,), ()) \
|
||||
IF_ENABLED(DT_NORDIC_NRF_RTC_RTC_##idx##_PPI_WRAP, \
|
||||
(.use_ppi = true,)) \
|
||||
IF_ENABLED(CONFIG_COUNTER_RTC_CUSTOM_TOP_SUPPORT, \
|
||||
(.fixed_top = DT_NORDIC_NRF_RTC_RTC_##idx##_FIXED_TOP,)) \
|
||||
LOG_INSTANCE_PTR_INIT(log, LOG_MODULE_NAME, 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)
|
||||
|
||||
#define VIPM_DEVICE(_idx, _) \
|
||||
COND_CODE_1(IS_ENABLED(CONFIG_IPM_MSG_CH_##_idx##_ENABLE), \
|
||||
(VIPM_DEVICE_1(_idx);), ())
|
||||
IF_ENABLED(CONFIG_IPM_MSG_CH_##_idx##_ENABLE, (VIPM_DEVICE_1(_idx);))
|
||||
|
||||
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)
|
||||
|
||||
#endif
|
||||
|
||||
#define ESP32_UART_INIT(idx) \
|
||||
ESP32_UART_IRQ_HANDLER_DECL(idx); \
|
||||
static const struct uart_esp32_config uart_esp32_cfg_port_##idx = { \
|
||||
.dev_conf = { \
|
||||
.base = (u8_t *)DT_INST_##idx##_ESPRESSIF_ESP32_UART_BASE_ADDRESS, \
|
||||
.sys_clk_freq = DT_INST_0_CADENCE_TENSILICA_XTENSA_LX6_CLOCK_FREQUENCY, \
|
||||
.base = \
|
||||
(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) \
|
||||
}, \
|
||||
\
|
||||
|
@ -500,12 +501,10 @@ static const struct uart_esp32_config uart_esp32_cfg_port_##idx = { \
|
|||
.pins = { \
|
||||
.tx = DT_INST_##idx##_ESPRESSIF_ESP32_UART_TX_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, \
|
||||
.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, \
|
||||
.stop_bits = UART_CFG_STOP_BITS_1, \
|
||||
.data_bits = UART_CFG_DATA_BITS_8, \
|
||||
COND_CODE_1(IS_ENABLED(DT_INST_##idx##_ESPRESSIF_ESP32_UART_HW_FLOW_CONTROL), \
|
||||
(.flow_ctrl = UART_CFG_FLOW_CTRL_RTS_CTS), \
|
||||
(.flow_ctrl = UART_CFG_FLOW_CTRL_NONE)) \
|
||||
.flow_ctrl = IS_ENABLED( \
|
||||
DT_INST_##idx##_ESPRESSIF_ESP32_UART_HW_FLOW_CONTROL) ?\
|
||||
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); \
|
||||
static struct uarte_nrfx_data uarte_##idx##_data = { \
|
||||
UARTE_CONFIG(idx), \
|
||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_ASYNC), \
|
||||
(.async = &uarte##idx##_async,), \
|
||||
()) \
|
||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN), \
|
||||
(.int_driven = &uarte##idx##_int_driven,), \
|
||||
()) \
|
||||
IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \
|
||||
(.async = &uarte##idx##_async,)) \
|
||||
IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \
|
||||
(.int_driven = &uarte##idx##_int_driven,)) \
|
||||
}; \
|
||||
static const struct uarte_nrfx_config uarte_##idx##z_config = { \
|
||||
.uarte_regs = (NRF_UARTE_Type *) \
|
||||
DT_NORDIC_NRF_UARTE_UART_##idx##_BASE_ADDRESS, \
|
||||
.rts_cts_pins_set = IS_ENABLED(UARTE_##idx##_CONFIG_RTS_CTS), \
|
||||
.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( \
|
||||
CONFIG_UART_##idx##_NRF_HW_ASYNC_TIMER),), \
|
||||
()) \
|
||||
CONFIG_UART_##idx##_NRF_HW_ASYNC_TIMER),)) \
|
||||
}; \
|
||||
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, \
|
||||
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( \
|
||||
NRFX_IRQ_NUMBER_GET(NRF_UARTE##idx), \
|
||||
DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0_PRIORITY, \
|
||||
uarte_nrfx_isr_int, \
|
||||
DEVICE_GET(uart_nrfx_uarte##idx), \
|
||||
0); \
|
||||
irq_enable(DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0);), ())\
|
||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_ASYNC), \
|
||||
irq_enable(DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0);)) \
|
||||
IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \
|
||||
(IRQ_CONNECT( \
|
||||
NRFX_IRQ_NUMBER_GET(NRF_UARTE##idx), \
|
||||
DT_NORDIC_NRF_UARTE_UART_##idx##_IRQ_0_PRIORITY, \
|
||||
uarte_nrfx_isr_async, \
|
||||
DEVICE_GET(uart_nrfx_uarte##idx), \
|
||||
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( \
|
||||
dev, \
|
||||
&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) \
|
||||
.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), \
|
||||
(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), \
|
||||
(NRF_UARTE_PSEL_DISCONNECTED))
|
||||
|
||||
#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 = { \
|
||||
COND_CODE_1(IS_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC), \
|
||||
(.hw_rx_counting = true), \
|
||||
(.hw_rx_counting = false)), \
|
||||
}), ())
|
||||
.hw_rx_counting = \
|
||||
IS_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC), \
|
||||
}))
|
||||
|
||||
#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[\
|
||||
MIN(CONFIG_UART_##idx##_NRF_TX_BUFFER_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 = { \
|
||||
.tx_buffer = uarte##idx##_tx_buffer, \
|
||||
.tx_buff_size = sizeof(uarte##idx##_tx_buffer),\
|
||||
};), \
|
||||
())
|
||||
};))
|
||||
|
||||
#ifdef CONFIG_UART_0_NRF_UARTE
|
||||
#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)
|
||||
|
||||
#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, \
|
||||
COND_CODE_1(SPIM##idx##_FEATURE_RXDELAY_PRESENT, \
|
||||
(.rx_delay = CONFIG_SPI_##idx##_NRF_RX_DELAY,), \
|
||||
())), \
|
||||
())
|
||||
IF_ENABLED(SPIM##idx##_FEATURE_RXDELAY_PRESENT, \
|
||||
(.rx_delay = CONFIG_SPI_##idx##_NRF_RX_DELAY,)) \
|
||||
))
|
||||
|
||||
#define SPI_NRFX_SPIM_DEVICE(idx) \
|
||||
BUILD_ASSERT_MSG( \
|
||||
|
|
|
@ -306,7 +306,7 @@ static inline char *log_strdup(const char *str)
|
|||
#define _LOG_ARG1(arg1, ...) arg1
|
||||
|
||||
#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) \
|
||||
__attribute__ ((section("." STRINGIFY(LOG_ITEM_CONST_DATA(_name))))) \
|
||||
__attribute__((used)) = { \
|
||||
|
@ -322,11 +322,8 @@ static inline char *log_strdup(const char *str)
|
|||
__attribute__((used))
|
||||
|
||||
#define _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name) \
|
||||
COND_CODE_1( \
|
||||
CONFIG_LOG_RUNTIME_FILTERING, \
|
||||
(_LOG_MODULE_DYNAMIC_DATA_CREATE(_name);), \
|
||||
() \
|
||||
)
|
||||
IF_ENABLED(CONFIG_LOG_RUNTIME_FILTERING, \
|
||||
(_LOG_MODULE_DYNAMIC_DATA_CREATE(_name);))
|
||||
|
||||
#define _LOG_MODULE_DATA_CREATE(_name, _level) \
|
||||
_LOG_MODULE_CONST_DATA_CREATE(_name, _level); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue