Skip to content

Commit 9b71094

Browse files
nordic-krchRafal-Nordic
authored andcommitted
drivers: serial: nrfx_uarte: Add support for direct interrupts
Add option to use direct ISR. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent d22a133 commit 9b71094

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

drivers/serial/Kconfig.nrfx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ config UART_ASYNC_TX_CACHE_SIZE
6363
in RAM, because EasyDMA in UARTE peripherals can only transfer data
6464
from RAM.
6565

66+
config UART_NRFX_UARTE_DIRECT_ISR
67+
bool "Use direct ISR"
68+
6669
config UART_NRFX_UARTE_SPURIOUS_RXTO_WORKAROUND
6770
bool
6871
help

drivers/serial/uart_nrfx_uarte.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,11 +2449,30 @@ static int uarte_instance_init(const struct device *dev,
24492449
return pm_device_driver_init(dev, uarte_nrfx_pm_action);
24502450
}
24512451

2452-
#define UARTE_IRQ_CONFIGURE(idx, isr_handler) \
2453-
do { \
2454-
IRQ_CONNECT(DT_IRQN(UARTE(idx)), DT_IRQ(UARTE(idx), priority), \
2455-
isr_handler, DEVICE_DT_GET(UARTE(idx)), 0); \
2456-
irq_enable(DT_IRQN(UARTE(idx))); \
2452+
#define UARTE_GET_ISR(idx) \
2453+
COND_CODE_1(CONFIG_UART_##idx##_ASYNC, (uarte_nrfx_isr_async), (uarte_nrfx_isr_int))
2454+
2455+
/* Declare interrupt handler for direct ISR. */
2456+
#define UARTE_DIRECT_ISR_DECLARE(idx) \
2457+
IF_ENABLED(CONFIG_UART_NRFX_UARTE_DIRECT_ISR, ( \
2458+
ISR_DIRECT_DECLARE(uarte_##idx##_direct_isr) \
2459+
{ \
2460+
ISR_DIRECT_PM(); \
2461+
UARTE_GET_ISR(idx)(DEVICE_DT_GET(UARTE(idx))); \
2462+
return 1; \
2463+
} \
2464+
))
2465+
2466+
/* Depending on configuration standard or direct IRQ is connected. */
2467+
#define UARTE_IRQ_CONNECT(idx, irqn, prio) \
2468+
COND_CODE_1(CONFIG_UART_NRFX_UARTE_DIRECT_ISR, \
2469+
(IRQ_DIRECT_CONNECT(irqn, prio, uarte_##idx##_direct_isr, 0)), \
2470+
(IRQ_CONNECT(irqn, prio, UARTE_GET_ISR(idx), DEVICE_DT_GET(UARTE(idx)), 0)))
2471+
2472+
#define UARTE_IRQ_CONFIGURE(idx) \
2473+
do { \
2474+
UARTE_IRQ_CONNECT(idx, DT_IRQN(UARTE(idx)), DT_IRQ(UARTE(idx), priority)); \
2475+
irq_enable(DT_IRQN(UARTE(idx))); \
24572476
} while (false)
24582477

24592478
/* Low power mode is used when disable_rx is not defined or in async mode if
@@ -2602,11 +2621,10 @@ static int uarte_instance_init(const struct device *dev,
26022621
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,\
26032622
},)) \
26042623
}; \
2624+
UARTE_DIRECT_ISR_DECLARE(idx) \
26052625
static int uarte_##idx##_init(const struct device *dev) \
26062626
{ \
2607-
COND_CODE_1(CONFIG_UART_##idx##_ASYNC, \
2608-
(UARTE_IRQ_CONFIGURE(idx, uarte_nrfx_isr_async);), \
2609-
(UARTE_IRQ_CONFIGURE(idx, uarte_nrfx_isr_int);)) \
2627+
UARTE_IRQ_CONFIGURE(idx); \
26102628
return uarte_instance_init( \
26112629
dev, \
26122630
IS_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN)); \

0 commit comments

Comments
 (0)