-
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
Refactor samd21 #5743
Refactor samd21 #5743
Conversation
Yes I did test UART, I2C and SPI with this branch on a samr21-xpro and everything worked as expected. Also note that Murdocks output looks pretty nice. It just complains about whitespace errors in CMSIS headers. How do we handle that? |
Add the dirs to the |
CFLAGS += -DCPU_FAM_$(shell echo $(CPU_FAM) | tr 'a-z-' 'A-Z_') | ||
|
||
# Define the SAM0 family so we can differentiate between them in the code | ||
CFLAGS += -DSAM0_FAM_$(shell echo $(SAM0_FAM) | tr 'a-z-' 'A-Z_') |
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.
Any reason to not use CPU_FAM
instead of SAM0_FAM
? Seems redundant.
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.
I looked at it, but the problem is that CPU_FAM
is currently set in cpu/samd21/Makefile.include
. And that one is shared for samd21 and samr21 boards. We need a parameter to distinguish between these two.
Notice that for samr21-xpro SAM0_FAM
is set to samr21
.
That why I came up with SAM0_FAM
which must be set in the board configuration.
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.
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 do you pick on me? I'd say, look at your own contribution of cpu/saml21. It has the whole set of cmsis for saml21.
IMHO we should just select the right cmsis header directly (in cpu_conf.h).
You can't. Not without adding a define like, eh, SAM0_FAM_xyz
. If you had let me move samd21 to samr21 and add the 'real' samd21, then the three samd21
, samr21
, saml21
would all have had the same structure. And SAM0_FAM
wouldn't be needed.
@keestux Thank you for your patience with this tedious task. Please fix the whitespace errors (trailing whitespaces) in the CMSIS headers as a separate commit. edit: added missing -i in the sed command line |
Are the samd21 CMSIS headers used anywhere with this PR? If not please cut them out of this PR for better reviewability, and add them together with the first board using them (autonomo?) |
+1! |
@kaspar030 About the samd21 CMSIS files. I rather keep them in. |
I'm sorry if you have the impression that I'm picking on you. That's definitely not my intend. Feel invited for a drink the moment we meet in person! :)
Well, I think we shouldn't let the vendor headers influence too much on how we best organize our platforms. The samr21 is just a variant of samd21, even if Atmel is shipping a whole new include tree. A diff shows that they are practically identical. Please take a look at keestux#1. In there I've just copied the four samr21 specific files into the samd21 cmsis folder, and added the extra case to samd21.h. Works fine as is, saves 20k lines of duplicated header files and removes the need for SAM0_FAM. |
Den 13 aug. 2016 09:32 skrev "Kaspar Schleiser" notifications@github.com:
Keep in mind the maintainability of the files. I don't see any problem with
|
well, I promise to script the merging of the two cmsis trees the next time one of them needs an update. (edit removed email leftovers) |
Okay, agreed. Let's get this in so that @keestux can get back to working on Den 13 aug. 2016 11:20 AM skrev "Kaspar Schleiser" <notifications@github.com
|
well, picking on keestux was me already reviewing. :) as the samr21 is probably our most used board, I'll do more thorough testing. won't get to it until tomorrow, though. -----Original Message----- Okay, agreed. Let's get this in so that @keestux can get back to working on Den 13 aug. 2016 11:20 AM skrev "Kaspar Schleiser" <notifications@github.com
You are receiving this because you were mentioned. |
@kaspar030 I can give a bit support in detailed testing. Already did a quick test with networking, spi and i2c which worked well. |
Ok, you convinced me that fiddling with the cmsis files or their structure is a bad idea compared to the small overhead of duplicated/identical vendor headers. Still, @keestux, I would like to get rid of the SAM0_FAM C defines. As I see it, it is only used for selecting the correct cmsis include path (in the makefiles) and include file. Could you live with creating a |
@kaspar030 About the sam0.h, yes that seems possible. I'll give it a try. |
d1a622e
to
b0ed884
Compare
@kaspar030 I've update the branch with the suggested sam0.h |
As in #5525 Murdock doesn't seem to finish here too... |
In the Makefile.include of the board it is required to set the correct define. Currently only SAMRG18A is supported, as required by samr21-xpro.
A generic function is added to initialize a SERCOM. Notice that uart_conf_t was expanded with pad settings, but it isn't used yet.
Notice that saml21 does not use I2C (yet).
The former i2c_init_master was too complicated. It was trying to set IN/OUT mode of the pins, but all that is needed is to set the proper MUX. Also the configuration for the boards was incomplete (no MUX, no pad setting). It was tested on a SODAQ Autonomo, but not on a samr21-xpro
The board config can define SPI_1_EN as 0, and in that case #ifdef won't work. Add some more comments, and fix typos.
The pinmux is now part of the board config. The pad setting is done with clear names instead of numbers.
Notice the extra fields in uart_conf_t for rx_pad and tx_pad.
This define conflicts with LITTLE_ENDIAN defined in include/machine/endian.h which is part of gcc-arm-none-eabi. Also, the define does not seem to be used by the ASF included files.
d2bcafe
to
d367090
Compare
@kaspar030 Update is available
|
ACK. |
Wow, great work @keestux. I'm also putting together a board based on SAMR21, so I appreciate you cleaning stuff up! |
I know this PR took a long road and I support the effort for a cleaner structure in the Atmel CPU tree of RIOT. But I think here are some/many things that went wrong with this PR! My main issues are:
@kYc0o @PeterKietzmann @kaspar030 I know this PR took a long road, but let's not relax our requirements on code quality and PR structure! @keestux I really appreciate your effort! Maybe next time try to go in small steps, which makes things so much easier (and hopefully faster) to review and merge. |
@haukepetersen Hmm. You did notice that this already got merged, right?
Small steps? Like #4780 ? ;-) |
I think what Hauke is trying to say is that though there is no convention as to how big a PR is to be, this is - as a rule of thumb 😜 - generally not good for review: |
As an outside, I must agree. Even after I knew that this PR was responsible for #5868, searching through the changes made in the PR took a very long time. edit: although I really really appreciate that it was not squashed and the commits within the PR were distinct |
Our coding conventions are inherit from the Linux coding conventions. See section 8 in |
This is the fourth attempt to reorganize cpu/samd21 so that it will be possible to add new boards like SODAQ Autonomo and Arduino Zero.
There are 11 commits which do the following steps
Notice that there is no new "cpu" and a start is made to move common code to sam21_common. The only thing I want to mention is that samd21 boards now need a few extras in their Makefile.include, like
This is already taken care of in samr21-xpro.
@PeterKietzmann was kind enough to already test these changes on a samr21-xpro and confirmed that everything continues to work.