Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions drivers/serial/Kconfig.nrfx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ config UART_ASYNC_TX_CACHE_SIZE
in RAM, because EasyDMA in UARTE peripherals can only transfer data
from RAM.

config UART_NRFX_UARTE_DIRECT_ISR
bool "Use direct ISR"

config UART_NRFX_UARTE_SPURIOUS_RXTO_WORKAROUND
bool
help
Expand Down
34 changes: 26 additions & 8 deletions drivers/serial/uart_nrfx_uarte.c
Original file line number Diff line number Diff line change
Expand Up @@ -2449,12 +2449,31 @@
return pm_device_driver_init(dev, uarte_nrfx_pm_action);
}

#define UARTE_IRQ_CONFIGURE(idx, isr_handler) \
do { \
IRQ_CONNECT(DT_IRQN(UARTE(idx)), DT_IRQ(UARTE(idx), priority), \
isr_handler, DEVICE_DT_GET(UARTE(idx)), 0); \
irq_enable(DT_IRQN(UARTE(idx))); \
#define UARTE_GET_ISR(idx) \
COND_CODE_1(CONFIG_UART_##idx##_ASYNC, (uarte_nrfx_isr_async), (uarte_nrfx_isr_int))

/* Declare interrupt handler for direct ISR. */
#define UARTE_DIRECT_ISR_DECLARE(idx) \
IF_ENABLED(CONFIG_UART_NRFX_UARTE_DIRECT_ISR, ( \

Check notice on line 2457 in drivers/serial/uart_nrfx_uarte.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/serial/uart_nrfx_uarte.c:2457 -#define UARTE_GET_ISR(idx) \ +#define UARTE_GET_ISR(idx) \ COND_CODE_1(CONFIG_UART_##idx##_ASYNC, (uarte_nrfx_isr_async), (uarte_nrfx_isr_int)) /* Declare interrupt handler for direct ISR. */ -#define UARTE_DIRECT_ISR_DECLARE(idx) \ +#define UARTE_DIRECT_ISR_DECLARE(idx) \
ISR_DIRECT_DECLARE(uarte_##idx##_direct_isr) \
{ \
ISR_DIRECT_PM(); \
UARTE_GET_ISR(idx)(DEVICE_DT_GET(UARTE(idx))); \
return 1; \
} \
))

/* Depending on configuration standard or direct IRQ is connected. */
#define UARTE_IRQ_CONNECT(idx, irqn, prio) \
COND_CODE_1(CONFIG_UART_NRFX_UARTE_DIRECT_ISR, \
(IRQ_DIRECT_CONNECT(irqn, prio, uarte_##idx##_direct_isr, 0)), \
(IRQ_CONNECT(irqn, prio, UARTE_GET_ISR(idx), DEVICE_DT_GET(UARTE(idx)), 0)))

#define UARTE_IRQ_CONFIGURE(idx) \
do { \
UARTE_IRQ_CONNECT(idx, DT_IRQN(UARTE(idx)), DT_IRQ(UARTE(idx), priority)); \
irq_enable(DT_IRQN(UARTE(idx))); \
} while (false)

Check notice on line 2476 in drivers/serial/uart_nrfx_uarte.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/serial/uart_nrfx_uarte.c:2476 -#define UARTE_IRQ_CONNECT(idx, irqn, prio) \ +#define UARTE_IRQ_CONNECT(idx, irqn, prio) \ COND_CODE_1(CONFIG_UART_NRFX_UARTE_DIRECT_ISR, \ (IRQ_DIRECT_CONNECT(irqn, prio, uarte_##idx##_direct_isr, 0)), \ (IRQ_CONNECT(irqn, prio, UARTE_GET_ISR(idx), DEVICE_DT_GET(UARTE(idx)), 0))) -#define UARTE_IRQ_CONFIGURE(idx) \ - do { \ - UARTE_IRQ_CONNECT(idx, DT_IRQN(UARTE(idx)), DT_IRQ(UARTE(idx), priority)); \ - irq_enable(DT_IRQN(UARTE(idx))); \ +#define UARTE_IRQ_CONFIGURE(idx) \ + do { \ + UARTE_IRQ_CONNECT(idx, DT_IRQN(UARTE(idx)), DT_IRQ(UARTE(idx), priority)); \ + irq_enable(DT_IRQN(UARTE(idx))); \

/* Low power mode is used when disable_rx is not defined or in async mode if
* kconfig option is enabled.
Expand Down Expand Up @@ -2602,11 +2621,10 @@
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,\
},)) \
}; \
UARTE_DIRECT_ISR_DECLARE(idx) \
static int uarte_##idx##_init(const struct device *dev) \
{ \
COND_CODE_1(CONFIG_UART_##idx##_ASYNC, \
(UARTE_IRQ_CONFIGURE(idx, uarte_nrfx_isr_async);), \
(UARTE_IRQ_CONFIGURE(idx, uarte_nrfx_isr_int);)) \
UARTE_IRQ_CONFIGURE(idx); \
return uarte_instance_init( \
dev, \
IS_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN)); \
Expand All @@ -2623,7 +2641,7 @@
UARTE_INIT_LEVEL(idx), \
UARTE_INIT_PRIO(idx), \
&uart_nrfx_uarte_driver_api)

Check notice on line 2644 in drivers/serial/uart_nrfx_uarte.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/serial/uart_nrfx_uarte.c:2644 - (PM_DEVICE_ISR_SAFE), (0)))))) \ - -#define UART_NRF_UARTE_DEVICE(idx) \ - NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(UARTE(idx)); \ - UARTE_INT_DRIVEN(idx); \ - PINCTRL_DT_DEFINE(UARTE(idx)); \ + (PM_DEVICE_ISR_SAFE), (0)))))) + +#define UART_NRF_UARTE_DEVICE(idx) \ + NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(UARTE(idx)); \ + UARTE_INT_DRIVEN(idx); \ + PINCTRL_DT_DEFINE(UARTE(idx)); \ IF_ENABLED(CONFIG_UART_##idx##_ASYNC, ( \ static uint8_t \ uarte##idx##_tx_cache[CONFIG_UART_ASYNC_TX_CACHE_SIZE] \ DMM_MEMORY_SECTION(UARTE(idx)); \ static uint8_t uarte##idx##_flush_buf[UARTE_HW_RX_FIFO_SIZE] \ DMM_MEMORY_SECTION(UARTE(idx)); \ - struct uarte_async_cb uarte##idx##_async;)) \ - static uint8_t uarte##idx##_poll_out_byte DMM_MEMORY_SECTION(UARTE(idx));\ - static uint8_t uarte##idx##_poll_in_byte DMM_MEMORY_SECTION(UARTE(idx)); \ - static struct uarte_nrfx_data uarte_##idx##_data = { \ - IF_ENABLED(CONFIG_UART_USE_RUNTIME_CONFIGURE, \ - (.uart_config = UARTE_CONFIG(idx),)) \ - IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \ - (.async = &uarte##idx##_async,)) \ - IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \ - (.int_driven = &uarte##idx##_int_driven,)) \ - }; \ + struct uarte_async_cb uarte##idx##_async;)) \ + static uint8_t uarte##idx##_poll_out_byte DMM_MEMORY_SECTION(UARTE(idx)); \ + static uint8_t uarte##idx##_poll_in_byte DMM_MEMORY_SECTION(UARTE(idx)); \ + static struct uarte_nrfx_data uarte_##idx##_data = {IF_ENABLED(CONFIG_UART_USE_RUNTIME_CONFIGURE, \ + (.uart_config = UARTE_CONFIG(idx),)) \ + IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \ + (.async = &uarte##idx##_async,)) \ + IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \ + (.int_driven = &uarte##idx##_int_driven,)) }; \ COND_CODE_1(CONFIG_UART_USE_RUNTIME_CONFIGURE, (), \ (BUILD_ASSERT(UARTE_GET_BAUDRATE(idx) > 0, \ - "Unsupported baudrate");)) \ - static const struct uarte_nrfx_config uarte_##idx##z_config = { \ - COND_CODE_1(CONFIG_UART_USE_RUNTIME_CONFIGURE, \ + "Unsupported baudrate");)) \ + static const struct uarte_nrfx_config uarte_##idx##z_config = {COND_CODE_1(CONFIG_UART_USE_RUNTIME_CONFIGURE, \ (.clock_freq = NRF_PERIPH_GET_FREQUENCY(UARTE(idx)),), \ (IF_ENABLED(UARTE_HAS_FRAME_TIMEOUT, \ (.baudrate = UARTE_PROP(idx, current_speed),)) \ .nrf_baudrate = UARTE_GET_BAUDRATE(idx), \ - .hw_config = UARTE_NRF_CONFIG(idx),)) \ - .pcfg = PINCTRL_DT_DEV_CONFIG_GET(UARTE(idx)), \ - .uarte_regs = _CONCAT(NRF_UARTE, idx), \ - IF_ENABLED(CONFIG_HAS_NORDIC_DMM, \ - (.mem_reg = DMM_DEV_TO_REG(UARTE(idx)),)) \ - .flags = \ - (IS_ENABLED(CONFIG_UART_##idx##_ENHANCED_POLL_OUT) ?
#define UARTE_INT_DRIVEN(idx) \
IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \
(static uint8_t uarte##idx##_tx_buffer \
Expand Down
Loading