diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-10-13 22:01:39 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-10-13 22:13:26 +0200 |
| commit | d8c3365d6a78f272a28ee9c2740d4e7543dde474 (patch) | |
| tree | 5ad11479c98557381a6f994229f16212ea10758d | |
| parent | 0d709fa5c8c517a29594c29323f1dcfc845f38cd (diff) | |
nrf/saadc: make Input trait sealed.
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index 7f81d255f..c2787e02b 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -228,17 +228,24 @@ impl<'d, const N: usize> Drop for OneShot<'d, N> { | |||
| 228 | } | 228 | } |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | /// An input that can be used as either or negative end of a ADC differential in the SAADC periperhal. | 231 | pub(crate) mod sealed { |
| 232 | pub trait Input: Unborrow<Target = Self> { | 232 | use super::*; |
| 233 | fn channel(&self) -> InputChannel; | 233 | |
| 234 | pub trait Input { | ||
| 235 | fn channel(&self) -> InputChannel; | ||
| 236 | } | ||
| 234 | } | 237 | } |
| 235 | 238 | ||
| 239 | /// An input that can be used as either or negative end of a ADC differential in the SAADC periperhal. | ||
| 240 | pub trait Input: sealed::Input + Unborrow<Target = Self> {} | ||
| 241 | |||
| 236 | macro_rules! impl_saadc_input { | 242 | macro_rules! impl_saadc_input { |
| 237 | ($pin:ident, $ch:ident) => { | 243 | ($pin:ident, $ch:ident) => { |
| 238 | impl crate::saadc::Input for crate::peripherals::$pin { | 244 | impl crate::saadc::sealed::Input for crate::peripherals::$pin { |
| 239 | fn channel(&self) -> crate::saadc::InputChannel { | 245 | fn channel(&self) -> crate::saadc::InputChannel { |
| 240 | crate::saadc::InputChannel::$ch | 246 | crate::saadc::InputChannel::$ch |
| 241 | } | 247 | } |
| 242 | } | 248 | } |
| 249 | impl crate::saadc::Input for crate::peripherals::$pin {} | ||
| 243 | }; | 250 | }; |
| 244 | } | 251 | } |
