-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
driver: uart stm32: Check irq enabled in API calls #31192
driver: uart stm32: Check irq enabled in API calls #31192
Conversation
When calling irq_rx_ready or irq_tx_ready API, return the logical AND between the irq status and the enable of that irq. Signed-off-by: Nicolas VINCENT <[email protected]>
@@ -533,7 +533,8 @@ static int uart_stm32_irq_tx_ready(const struct device *dev) | |||
{ | |||
USART_TypeDef *UartInstance = UART_STRUCT(dev); | |||
|
|||
return LL_USART_IsActiveFlag_TXE(UartInstance); | |||
return LL_USART_IsActiveFlag_TXE(UartInstance) && | |||
LL_USART_IsEnabledIT_TC(UartInstance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why mixing LL_USART_IsActiveFlag_TXE with TC here ?
as the _uart_stm32_irq_tx_complete_
exists and could be:
LL_USART_IsActiveFlag_TC && LL_USART_IsEnabledIT_TC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FRASTM Agree this is not clear and situation is due to a reported behavior where rq_tx_ready
could be called after irq_tx_disable
has been called and in that case is "expected" to return 0.
This is not explicit in the API, but apparently this behavior is also used in other (at least some) uart drivers.
To achieve that, since irq_tx_disable
is actually disabling TC, this is TC flag that should checked here.
Adding the API label as there are several examples in the code that rely on this behavior which isn't explicit in the API and not implemented in several drivers. |
@dcpleung According to various uart api users that could be found in tree, the proposal implement an expected behavior. But this is not explicit in the API and not uniformly implemented. |
@nordic-krch could you please comment on this PR? |
ok, that was merged a bit fast... |
In zephyrproject-rtos#31192 stm32 uart driver uart_irq_rx/tx_ready functions were modified to take into account status of irq. While it seems wlecome for TX (based on uart client's implementation), this is not correct for RX. Revert change in uart_stm32_irq_rx_ready function. Signed-off-by: Erwan Gouriou <[email protected]>
In #31192 stm32 uart driver uart_irq_rx/tx_ready functions were modified to take into account status of irq. While it seems wlecome for TX (based on uart client's implementation), this is not correct for RX. Revert change in uart_stm32_irq_rx_ready function. Signed-off-by: Erwan Gouriou <[email protected]>
When calling
irq_rx_ready
orirq_tx_ready
API, return the logical AND between the irq status and the enable of that irq.The reason behind this PR is to be consistent with nRF and MCUX chips and return true on the
irq_[tr]x_ready
if the corresponding irq is set and enabled.This allows #26516 improvements to work on stm32.
This has been tested on nucleo_h743 and nucleo_f429 on the
sample/subsys/modbus/
samples.