-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[RFC] Improve stm32f0 interrupts vector implementation #6617
Conversation
Looks OK for me. Can you maybe rebase to include Murdock2? |
Oh, it was added automatically. No need for rebase. |
Well this PR is not meant to be merged as is. I opened it in order to find to better solution (or leave things as they are now) to the actual way of implementing |
Ah, I just noticed there is a |
Actually, I don't like this, I think those defines make it completely unreadable and therefore next to impossible to actually spot errors. Just think what happens if we add 15 more stm32f0s to the list (or even merge all stm cpus at one point...). IMHO a nicer solution would be to pre-define complete tables for the single cpu types and just load the fitting one into the final table at compile time. |
That was actually one of the reasons why I opened this PR initially.
Looks interesting and doable with the prepropessor. What do you think of the second point I mentionned in the PR: use a dedicated stm32fxxx_vectors.c for each supported cpu ? |
da0ca23
to
ea9edca
Compare
@haukepetersen, ea9edca implements your suggestion about injecting complete tables at compile time. The file/directory names could be improved. Better suggestions are welcome. |
@aabadie how about just inserting the file directly into the vector specification? ISR_VECTORS void * const interrupt_vector[] = {
[CORTEXM_VECTORS]
#if defined(CPU_STM32something)
#include "vectors/stm32something.c"
#elif defined(CPU_STM32sthelse)
#include "vectors/stm32sthelse.c"
#endif
}; |
I thought including .c file in another .c file was not a good practice but maybe in this particular case it could be done. |
ea9edca
to
7153ae0
Compare
@aabadie yes, I agree it's bad practice, but this file would become incredibly long and impossible to navigate if we don't split it up. Having a macro like the current proposal avoids that bad practice, but instead we need to escape the newlines which may also be seen as a bit of a hassle. I'm not really sure what would be the better solution of the two, actually. |
Why not a |
👍 |
Yes that was one of the initial alternatives I proposed. The problem comes from my poor knowledge of the build system : can you give some advice on how to build the right .c depending on the type of MCU ? @astralien3000 also suggested me IRL to skip the macro and directly include a .h file. |
I pushed a couple of commits with what @astralien3000 had in mind. I think it's much better now : no more macro and the file in included once. |
You could also add some code to prevent to include several .h, like : #ifdef MCU_SPECIFIC_VECTOR
#error "Two MCU-specific interrupt vector enabled"
#endif
#define MCU_SPECIFIC_VECTOR But it is maybe overkill. |
Hm, I don't like it. Now we have a bunch of headers with essentially broken syntax. Could you try the one-file-per-vectortable? I suggest creating a module "stm32_vectors" (e.g., as subfolder of cpu/stm32_common or /f0). In there you create files "vectors_<cpu>.c", containing the full vector table:
In In
This should suffice, as the linker will sort mcu* after cortex*. If not, a sorting statement might need to be added to the linker script section. Advantages over including:
Actually this would be a nice improvement for all Cortex-M, not just stm32. edit fixed < > being invisible |
@kaspar030 thanks, your suggestion indeed is a nice idea. I'll try it. |
1a3995d
to
14173db
Compare
ping @kaspar030 |
@aabadie While this is is definitely an improvement, I have the feeling that a lot of lines get duplicated this way.
|
b5c4ef5
to
a6c1033
Compare
@aabadie You're the one juggling with nucleo boards. Do you think this is an improvement? To me it looks like a lot of duplication. The nucleos are so similar... |
We have plenty of them here :)
Not sure I understand. Did you mean the stm32 cpus instead ? |
It seems to me (I might be wrong so), that the current state is having two problems:
|
Closing this one in favor of #7535 |
This PR modifies the
cpu/stm32f0/vectors.c
file to better fit the interruptions defined for each type of CPU in this family (following the cmsis header file): f030r8, f042k6, f051r8, f070rb, f072rb and f091.The change here is based on
define
but makes the code hard to read/follow. I know it's not a good solution, as it put a lot of mess in the file. It will also become more and more harder with more complex CPU (f3, f4, etc). I see other ways to better handle this:What do you think ?