From 48eac0b1462726ab292354b50e299c8ebfde85c6 Mon Sep 17 00:00:00 2001 From: pennae Date: Fri, 21 Jul 2023 21:01:56 +0200 Subject: [PATCH] rp: add AdcChannel trait this is more general than AdcPin and can also cover the temperature sensor. --- embassy-rp/src/adc.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/embassy-rp/src/adc.rs b/embassy-rp/src/adc.rs index 4fba31169..e0c2910b8 100644 --- a/embassy-rp/src/adc.rs +++ b/embassy-rp/src/adc.rs @@ -223,21 +223,23 @@ impl interrupt::typelevel::Handler for Inter } mod sealed { - pub trait AdcPin: crate::gpio::sealed::Pin { + pub trait AdcChannel { fn channel(&mut self) -> u8; } } -pub trait AdcPin: sealed::AdcPin + gpio::Pin {} +pub trait AdcChannel: sealed::AdcChannel {} +pub trait AdcPin: AdcChannel + gpio::Pin {} macro_rules! impl_pin { ($pin:ident, $channel:expr) => { - impl sealed::AdcPin for peripherals::$pin { + impl sealed::AdcChannel for peripherals::$pin { fn channel(&mut self) -> u8 { $channel } } + impl AdcChannel for peripherals::$pin {} impl AdcPin for peripherals::$pin {} }; }