-
Notifications
You must be signed in to change notification settings - Fork 3k
STM32L0: fix uart irq index #5917
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
Conversation
Automatic CI verification build not done, please verify manually. |
@ARMmbed/team-st-mcd Please review |
@marcemmers Can you please sign https://os.mbed.com/contributor_agreement/? |
@0xc0170 is it enough to connect my mbed account with signed agreement to this github account? |
Thanks for the PR. I looked carefully in all L0 devices on mbed and here is the status concerning indexes. The indexes are chosen at serial object init inside the serial_api.c file common to all STM32 devices. The status is the following: For L072/L073 devices For L053 devices For L011/L031 devices Looking at your PR, I see 2 problems:
Then, there is another problem, related to USART4 and USART5 sharing the same IRQ vector for L072/L073 devices. See my fix in PR #5907. Basically you have to create a common function uart4_5_irq (instead of 2 functions uart4_irq and uart5_irq) which will call uart_irq(2) and uart_irq(3) sequentially. And you have also to assign the uart4_5_irq function to USART4/5 ( |
…ng as in serial_api.c
That does explain the reason for the lpuart having index 2 assigned. It was probably tested on a L053 before and that worked just fine. To be honest I don't really like the solution with the target defines because that might cause the same problems later on when adding new devices. In the newest commit I have tried to solve this by using the same numbering scheme as used in the general STM serial_api.c The only thing I am not really sure of is if which option would be better, where the latter lets uart_irq() take care of which irq was the cause:
Edit: Also, there is a possible issue with the LPUART1 using the same irq vector as AES en RNG in some STM32L0xx microcontrollers. This is not solved in this scope. |
LGTM
Same for me. The less we add targets in the source files the better it is...
Yes it is a nicer way of doing it. The only drawback I can see is that there is an additional function call in the interrupt, and I don't know if it may have an impact on critical communications ?
I think the first solution you chose looks a little bit faster to execute but not sure...
I looked in the RNG code and I don't see the use of interrupt. So it should be ok. But I agree that it could be a problem the day it will be available... Another point: I think it would be nice to move the |
I discussed the changes with a collegae of mine and he also mentioned the extra function call. This could be resolved by adding the inline keyword as long as the function is only used once. The IAR compiler already does this by itself when optimization is set to high but i don't know about other compilers. |
FYI while working on refactoring the usart index, I noticed there is also an issue with the indexes in the |
irq_handler(serial_irq_ids[id], TxIrq); | ||
uint8_t index = 0; | ||
#if defined(USART1_BASE) | ||
if (uart_base == USART1_BASE) return index; |
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.
can you align the new changes please (see https://docs.mbed.com/docs/mbed-os-handbook/en/latest/cont/code_style/)
Yes I have finished to change the irq index for all other STM32 series. I am going to send my PR. But I didn't touch the L0. You can merge this PR. |
Thank you for answers. I'll close this PR (can reopen if needed) |
I missed this comment, I can reopen or you can cherry-pick this change and include it in the PR to fix all STM32? Let me know |
Description
Issue flagged here: #5916
Status
READY
Migrations
NO