-
Notifications
You must be signed in to change notification settings - Fork 220
feat(adc): differential sampling support #999
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
Open
NoahLutz
wants to merge
45
commits into
atsamd-rs:master
Choose a base branch
from
VoltServer:adc-differential-sampling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 36 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
93cb1d5
added ability to trigger ADC flush, added call in Adc::read_channel()
NoahLutz 9493627
initial implementation to support differential sampling
NoahLutz e6498b8
restored CPU voltage measurment
NoahLutz 25be268
updated d11 implementation to support differential sampling
NoahLutz 698c958
removed unused macro
NoahLutz a7eb6da
added missing DAC0 analog input channel for D5x family chips
NoahLutz 9a4a58c
fixed typo in Muxposselect enum variant name
NoahLutz 31901e2
added method to retrieve ADC sample resolution
NoahLutz ecb62f5
Merge branch 'adc-retrieve-resolution' into adc-differential-sampling
NoahLutz e45ba54
fixed enum variant match syntax
NoahLutz d005756
Merge branch 'adc-retrieve-resolution' into adc-differential-sampling
NoahLutz 607694f
added associated type to AdcInput to handle signedness for ADC result…
NoahLutz 4f5d207
set CTRLB.LEFTADJ when using differential sampling, added appropriate…
NoahLutz 52eb5c1
added support for right-shifting 8-bit, 10-bit and 16-bit results whe…
NoahLutz a13b4a4
added support for offset and reference compensation
NoahLutz b55cf0b
added support for automatically handling left-adjusting and enabling …
NoahLutz 5138ebe
added read of RESULT register in check_read_discard() to discard ADC …
NoahLutz f2e39ac
Merge branch 'adc-fix-read-discard' into adc-differential-sampling
NoahLutz 9f019d3
added handling of enable/disable of offset compensation when auto rai…
NoahLutz 1047ef0
fixed unintentional overwriting of various registers during operation
NoahLutz 429d732
cleaned up the logic for handling left-shifted results
NoahLutz 28d5cae
simplified get_resolution() and adjusted auto left-shit to only adjus…
NoahLutz 72d6d2c
Merge branch 'master' into adc-differential-sampling
NoahLutz 36fbece
removed now unecessary flush() after conversion
NoahLutz e61a562
added support for d11 implementation
NoahLutz 6e3fdb0
refactored read* functions and elevated CpuSourceVoltage to type-leve…
NoahLutz a46c8ce
removed conditonally-compiled fields in AdcSettings
NoahLutz 49efeb2
updated API to use pin parameters and inputs as mutable borrows and c…
NoahLutz c3d1d40
updated impacted board examples
NoahLutz 89f06da
added back initialization of INPUTCTRL.GAIN for D11/D21 family chips
NoahLutz f58a86e
minor formatting changes
NoahLutz 8da29df
updated doc example
NoahLutz d4a885b
Merge branch 'master' into adc-differential-sampling
NoahLutz 5051226
rustfmt changes and additional documentation comments
NoahLutz 2ba7322
fixed clippy errors
NoahLutz c60c17a
fixed same clippy error in d11 implementation
NoahLutz c0eeb9d
refactored to remove AdcInput wrapper type, separated functionality i…
NoahLutz 3e1f35b
moved remaining traits to mod.rs, removed input.rs
NoahLutz feb6f77
Revert "updated impacted board examples"
NoahLutz 1e014e7
fix d11 implementation
NoahLutz c81757f
fix feather_m0 ADC example
NoahLutz 51d3b2f
added feature gates for enable_offset_compensation() and enable_auto_…
NoahLutz 9d8b0c5
updated documentation comments
NoahLutz f8991fd
Merge branch 'atsamd-rs:master' into adc-differential-sampling
NoahLutz c4334d1
replaced cast_signed() with cast using as
NoahLutz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| use core::marker::PhantomData; | ||
| use atsamd_hal_macros::hal_cfg; | ||
| use crate::{ | ||
| adc::*, | ||
| pac::adc::inputctrl::{Muxposselect, Muxnegselect}, | ||
| typelevel::Sealed, | ||
| }; | ||
|
|
||
| macro_rules! channel { | ||
| ( | ||
| $( | ||
| $CH:ident: ($($PMUX:path)?, $($NMUX:path)?) $(+ $MARKER:ident)* | ||
| ),+ | ||
| $(,)? | ||
| ) => { | ||
| crate::paste::paste!{ | ||
| $( | ||
| pub struct $CH<I: AdcInstance> { | ||
| adc: PhantomData<I>, | ||
| } | ||
|
|
||
| impl<I: AdcInstance> Sealed for $CH<I> {} | ||
|
|
||
| $( | ||
| impl<I: AdcInstance> PosChannel<I> for $CH<I> { | ||
| const MUXVAL: Muxposselect = $PMUX; | ||
| } | ||
| )? | ||
| $( | ||
| impl<I: AdcInstance> NegChannel<I> for $CH<I> { | ||
| const MUXVAL: Muxnegselect = $NMUX; | ||
| } | ||
| )? | ||
| $( | ||
| impl<I: AdcInstance> $MARKER<I> for $CH<I> {} | ||
| )* | ||
|
|
||
| impl<I: AdcInstance> $CH<I> { | ||
| pub fn get_channel() -> Self { | ||
| Self { | ||
| adc: PhantomData | ||
| } | ||
| } | ||
| } | ||
| )+ | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| #[hal_cfg("adc-d21")] | ||
| channel! { | ||
| AIN0: (Muxposselect::Pin0, Muxnegselect::Pin0), | ||
| AIN1: (Muxposselect::Pin1, Muxnegselect::Pin1), | ||
| AIN2: (Muxposselect::Pin2, Muxnegselect::Pin2), | ||
| AIN3: (Muxposselect::Pin3, Muxnegselect::Pin3), | ||
| AIN4: (Muxposselect::Pin4, Muxnegselect::Pin4), | ||
| AIN5: (Muxposselect::Pin5, Muxnegselect::Pin5), | ||
| AIN6: (Muxposselect::Pin6, Muxnegselect::Pin6), | ||
| AIN7: (Muxposselect::Pin7, Muxnegselect::Pin7), | ||
| AIN8: (Muxposselect::Pin8, ), | ||
| AIN9: (Muxposselect::Pin9, ), | ||
| AIN10: (Muxposselect::Pin10, ), | ||
| AIN11: (Muxposselect::Pin11, ), | ||
| AIN12: (Muxposselect::Pin12, ), | ||
| AIN13: (Muxposselect::Pin13, ), | ||
| AIN14: (Muxposselect::Pin14, ), | ||
| AIN15: (Muxposselect::Pin15, ), | ||
| AIN16: (Muxposselect::Pin15, ), | ||
| AIN17: (Muxposselect::Pin15, ), | ||
| AIN18: (Muxposselect::Pin15, ), | ||
| AIN19: (Muxposselect::Pin15, ), | ||
| TEMP: (Muxposselect::Temp, ), | ||
| SCALEDCOREVCC: (Muxposselect::Scaledcorevcc, ) + CpuVoltageSource, | ||
| SCALEDIOVCC: (Muxposselect::Scalediovcc, ) + CpuVoltageSource, | ||
| BANDGAP: (Muxposselect::Bandgap, ) + CpuVoltageSource, | ||
| DAC: (Muxposselect::Dac, ), | ||
| GND: (, Muxnegselect::Gnd), | ||
| IOGND: (, Muxnegselect::Iognd), | ||
| } | ||
|
|
||
| #[hal_cfg("adc-d11")] | ||
| channel! { | ||
| AIN0: (Muxposselect::Pin0, Muxnegselect::Pin0), | ||
| AIN1: (Muxposselect::Pin1, Muxnegselect::Pin1), | ||
| AIN2: (Muxposselect::Pin2, Muxnegselect::Pin2), | ||
| AIN3: (Muxposselect::Pin3, Muxnegselect::Pin3), | ||
| AIN4: (Muxposselect::Pin4, Muxnegselect::Pin4), | ||
| AIN5: (Muxposselect::Pin5, Muxnegselect::Pin5), | ||
| AIN6: (Muxposselect::Pin6, Muxnegselect::Pin6), | ||
| AIN7: (Muxposselect::Pin7, Muxnegselect::Pin7), | ||
| AIN8: (Muxposselect::Pin8, ), | ||
| AIN9: (Muxposselect::Pin9, ), | ||
| TEMP: (Muxposselect::Temp, ), | ||
| SCALEDCOREVCC: (Muxposselect::Scaledcorevcc, ) + CpuVoltageSource, | ||
| SCALEDIOVCC: (Muxposselect::Scalediovcc, ) + CpuVoltageSource, | ||
| BANDGAP: (Muxposselect::Bandgap, ) + CpuVoltageSource, | ||
| DAC: (Muxposselect::Dac, ), | ||
| GND: (, Muxnegselect::Gnd), | ||
| IOGND: (, Muxnegselect::Iognd), | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.