diff options
| author | Jacob Rosenthal <[email protected]> | 2021-10-23 15:53:31 -0700 |
|---|---|---|
| committer | Jacob Rosenthal <[email protected]> | 2021-10-24 09:41:51 -0700 |
| commit | 32850bba79cbf5fcb06f8068cfd46919020b19be (patch) | |
| tree | 00ebd4a1aed263c35850122aa63036150bfba972 | |
| parent | f3f3858328ed4f13efb3790e32ee4fba772b57a2 (diff) | |
nrf: saadc dummy pin for vdd sampling
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 23 |
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. | ||
| 83 | pub struct VddInput; | ||
| 84 | |||
| 85 | unsafe impl Unborrow for VddInput { | ||
| 86 | type Target = VddInput; | ||
| 87 | unsafe fn unborrow(self) -> Self::Target { | ||
| 88 | self | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | impl 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 | } | ||
| 102 | impl Input for VddInput {} | ||
| 103 | |||
| 81 | impl<'d> ChannelConfig<'d> { | 104 | impl<'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 { |
