Can UART ASYNC and UART INTERRUPT work together?

Question: Can UART ASYNC and UART INTERRUPT work together? I want to use async UART along with interrupt driven USB CDC, but I am not able to use both together.

Details:
1. I have enabled the UART driver on my nrf5340 using the following configurations:
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y
These configurations works and I am able to preform Rx and Tx on the UART port uart0.

2. Now I also want to use USB CDC, for which I added the following configurations:
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC ACM sample"
CONFIG_USB_CDC_ACM=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y

USB CDC works individually, but when I add USB CDC with async UART driver in #1 above, the code crashes. After some debugging, I found that it is crashing because in ncs/zephyr/drivers/serial/uart_nrfx_uarte.c, in function uarte_nrfx_callback_set(), we are trying to access data->async, but it is NULL for uart0. Now data->async should ideally get allocated in the following place but this piece of code is not getting compiled when I add USB CDC:


#define UARTE_ASYNC(idx) \
IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \
(struct uarte_async_cb uarte##idx##_async = { \
.hw_rx_counting = \
IS_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC), \
}))

Does this mean that CONFIG_UART_ASYNC_API (and therefore CONFIG_UART_0_ASYNC) get disabled when I make CONFIG_UART_INTERRUPT_DRIVEN as true?

PS:
I also found the following documentation:
Low power UART driver
The low power UART driver implements the standard asynchronous UART API that can be enabled with the CONFIG_UART_ASYNC_API configuration option. Alternatively, you can also enable the interrupt-driven UART API using the CONFIG_NRF_SW_LPUART_INT_DRIVEN configuration option.

Does the word "alternatively" here suggest that these two options should only be used individually and not concurrently?

Thanks in advance.

Related