aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-10-25 00:56:44 +0000
committerGitHub <[email protected]>2021-10-25 00:56:44 +0000
commit9b59eb3dbecb1c1b79f2be55e4f68747b0698953 (patch)
tree00ebd4a1aed263c35850122aa63036150bfba972
parentf3f3858328ed4f13efb3790e32ee4fba772b57a2 (diff)
parent32850bba79cbf5fcb06f8068cfd46919020b19be (diff)
Merge #448
448: Dummy pin implementation for Saadc internal vdd sampling r=Dirbaio a=jacobrosenthal For instance, for reading the battery input voltage on the nrf Api ends up looking like `let channel_config = saadc::ChannelConfig::single_ended(saadc::VddInput::default());` I ~haven't confirmed a sane reading yet~, but this compiles so is ready for bikeshedding Update: It looks like Ive got sane readings Co-authored-by: Jacob Rosenthal <[email protected]>
-rw-r--r--embassy-nrf/src/saadc.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs
index 215f968a7..efcdfb2b1 100644
--- a/embassy-nrf/src/saadc.rs
+++ b/embassy-nrf/src/saadc.rs
@@ -78,6 +78,29 @@ pub struct ChannelConfig<'d> {
78 phantom: PhantomData<&'d ()>, 78 phantom: PhantomData<&'d ()>,
79} 79}
80 80
81/// A dummy `Input` pin implementation for SAADC peripheral sampling from the
82/// internal voltage.
83pub struct VddInput;
84
85unsafe impl Unborrow for VddInput {
86 type Target = VddInput;
87 unsafe fn unborrow(self) -> Self::Target {
88 self
89 }
90}
91
92impl sealed::Input for VddInput {
93 #[cfg(not(feature = "nrf9160"))]
94 fn channel(&self) -> InputChannel {
95 InputChannel::VDD
96 }
97 #[cfg(feature = "nrf9160")]
98 fn channel(&self) -> InputChannel {
99 InputChannel::VDDGPIO
100 }
101}
102impl Input for VddInput {}
103
81impl<'d> ChannelConfig<'d> { 104impl<'d> ChannelConfig<'d> {
82 /// Default configuration for single ended channel sampling. 105 /// Default configuration for single ended channel sampling.
83 pub fn single_ended(input: impl Unborrow<Target = impl Input> + 'd) -> Self { 106 pub fn single_ended(input: impl Unborrow<Target = impl Input> + 'd) -> Self {