zephyr
zephyr copied to clipboard
Allow switching form Interrupt-driven UPART API to asynchronous API on STM32.
Is your enhancement proposal related to a problem? Please describe.
Actual implementation does not support use case when UART driver is initialized to use Interrupt-driven API (uart_irq_callback_set
) and then we want to switch later to asynchronous API (uart_callback_set
).
It is because the "old" callback for interrupt API is still remembered, and it is still used in ISR.
This disturbs logic of asynchronous API code in ISR (TC flag is cleared before used).
Describe the solution you'd like When given API is initialized (i.e., asynchronous) then other types of API (i.e., interrupt-driven) should not used anymore.
Describe alternatives you've considered
It is still possible to call uart_irq_callback_set
with NULL callback before calling to uart_callback_set
but it looks more than workaround and it depends on how some things are implemented now.
Additional context
So I had a quick look to irq and async implementation in serial drivers in Zephyr:
4 are implementing both IRQ driven and ASYNC mode simultaneously (nrfx_uarte
implements both modes but they are exclusive).
On these 4, mcux_lpuart
, sam0
and stm32
behave the way that you describe.
nrfx_uart
does some specific processing to check if irq are disabled first, so I think it should be compliant with your expectations.
So the workaround that you are mentioning is more a main line way of doing things. If there is a change to be done, I'd expect a clarification of the uart API to be done first.