-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: adc: sam0: Fix driver and sample #41319
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
drivers: adc: sam0: Fix driver and sample #41319
Conversation
bdeedd4 to
05a0acd
Compare
nandojve
left a comment
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.
Thank you for this PR @attie-argentum ,
I particulary don't like #if .. #endif in code but sometimes we need to use. Did you considered add a fixup for adc? It could be something similar to those at soc/arm/atmel_sam0/common.
| #ifdef MCLK_APBAMASK_SERCOM0 |
Codecov Report
@@ Coverage Diff @@
## main #41319 +/- ##
==========================================
+ Coverage 51.24% 51.27% +0.03%
==========================================
Files 605 606 +1
Lines 70878 71042 +164
Branches 16333 16364 +31
==========================================
+ Hits 36318 36425 +107
- Misses 28572 28607 +35
- Partials 5988 6010 +22
Continue to review full report at Codecov.
|
05a0acd to
5537ac4
Compare
|
@nandojve thanks for your comments. I didn't consider a Regarding your 4x remaining comments, I hope my reasoning stands. If not, I'll do what I think you're after... |
|
@nandojve I believe I have now implemented an I've confirmed that this runs on a SAML21 XPro, and that it builds for a SAMD21 XPro, and a SAME54 XPro - I believe this should cover the bases on variants. |
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.
Hi @attie-argentum ,
I think fixups makes code far more clean to read. Thank you for doing it!
@nandojve I believe I have now implemented an adc_fixup.h as requested. I've left this as a separate patch, as it's quite far-reaching...
I will suggest that if you are willing to do, you could mode fixups before you introduce SAML21 support. This will clean the path to add the new SoC support.
d079c40 to
a527b91
Compare
a527b91 to
745997c
Compare
745997c to
f2216fb
Compare
nandojve
left a comment
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.
Hi @attie-argentum ,
Fixup file helped to read code. Thank you for introduce it.
c88fe84 to
97e3c68
Compare
36fec91 to
932378a
Compare
064c4b3 to
a6e18a7
Compare
|
I have some more fixes for the ADC driver coming - are is it okay for me to roll them into this PR, or would a new PR be preferred?
On second thought, this should mostly live in #41308 I have however made some minor cleanup and rebased on main. |
1f301eb to
c792ab3
Compare
2e5a9df to
eb421ef
Compare
|
Hi @anangl , @stephanosio , @mnkp, Should this fix be at v3.0? |
Previously this was expected to be equal to 1 at all times. This doesn't play well with the sample or other users (e.g: adc_shell). Instead, we should count the number of active channels in the bitfield, and ensure that only one is identified. Signed-off-by: Attie Grande <[email protected]>
All drivers that require input_positive to be set should be given it. Some parts may require an offset, so abstract this away too. Signed-off-by: Attie Grande <[email protected]>
Add a basic device tree overlay to support the use of the ATSAMD21 XPro dev board with the ADC sample application. Signed-off-by: Attie Grande <[email protected]>
The ADC driver now supports three different implementations. To maintain readability, this patch implements an adc_fixup.h that permits more generic access to relevant registers. This patch also introduces support for a new third shape ADC - as found in the SAML21 for example. Signed-off-by: Attie Grande <[email protected]>
Local variables should not be in capitals. Signed-off-by: Attie Grande <[email protected]>
eb421ef to
838a56e
Compare
|
Rebase |
The
adc_sam0driver previously expectedsequence->channels == 1, which is not compatible with the ADC sample, and might be unexpected. In an attempt to avoid breaking changes, I have revised this to require a single bit set (with no confirmation as to whether it is the correct bit). The input channel for this driver needs to be set using the "configurable inputs" API instead - differential or not.I have also revised
adc_sam0so that it supports devices withMCLK, but only one ADC. This will be important for SAML21 support (see #41308).Finally, I have revised the
drivers/adcsample so that it will operate the "configurable inputs" API correctly.This PR is split out from #41308.