-
Notifications
You must be signed in to change notification settings - Fork 3
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
Nano Every (ATMega4809) + Due (SAM3) support and some HAL restructuring #19
base: main
Are you sure you want to change the base?
Conversation
using the AVR Mega4809 mcu.
Every Nano and Due.
Now I feel a bit better about this. Using the UNO R3 and the Mega2560 I reworked the sections for the older devices too. I also separated the arch.h into arch.h + arch_user.h. Latter contains definitions influenced by user code macros. Test.ino + tesy.py passes on the: For the older AVR devices I changed the deprecated macros to the new style. E.g. sbi, cli |
Thanks, lots of improvements here. I'll have time to review it in detail this weekend. At first glance, it's a little hard for me to follow all the I'm wondering---what's the justification to bring back |
Let me start with that I'm not an expert by any means. I'm an engineer not a CS person. |
cleaned up conditional cross includes
I did those changes. Maybe a bit better. |
I am also no C expert, thanks for bearing with me (: I think you're right to split into the user-included The camino library A user So we'd have three files total: external Do you think this would work? I'm unfamiliar with |
Yep, that sounds great. Merging the library cpps and hs will make some of the back and forth includes less confusing. I've been thinking more about this and I think if there was a proper way somebody would've done it by now. I played around with the thought of defining function templates in the library and letting the compiler create every possible version (e.g. for all serial ports) then via only picking one during user code compilation, the linker would throw out the rest. Then I realized this wouldn't work with buffer sizes and the other options. I also think I made a mistake in my last commit. I hastily merged stuff into options.h and didn't test with everything after. (classic) This might've made the ISR_ALIAS more confusing, because I somehow left out an explicit declaration of the vector functions being extern to the user code. To address your concern ISR_ALIAS should work just fine, but now thinking about it probably it can be done simpler. |
Hi Nathan,
Here's my monstrosity. I'm not convinced that my architecture changes would make it better, so maybe it should be a separate thing, but I really don't want to deal with the package management, so here we are.
The fundamental problem is that the Arduino environment doesn't allow the library and the user code to mingle at compile time. One solution is, as you did it, to put everything in the user code by including it in the header files. This here instead leaves as much as possible in the library part, just implements minimum necessary snippets in the headers imported from the user code and relies on extern declarations in the library to pick up user configured code during linking.
On the AVR versions there should be one or two extra clock cycles tops overhead.
E.g. the ISR routines take an extra instruction due to the aliasing method, or instead of #defining the buffer array size, the whole buffer is defined in the user header, and linked together as an extern variable reference.
The hearder files also check if they were included from library or user code. It could be split, but this is more compact.
I didn't touch the original AVR arch code as I can't test it. I ordered an Arduino UNO and a Mega 2560. Considering how deep I am in the rabbit hole with this I might as well complete it.