aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-07-21 21:01:56 +0200
committerpennae <[email protected]>2023-08-01 18:31:28 +0200
commit48eac0b1462726ab292354b50e299c8ebfde85c6 (patch)
treef440e3363b92d8858576bea34c59c010c366392a
parent0d8a9b1e7a963fe1a1a3cf0e10c33314bba65e2d (diff)
rp: add AdcChannel trait
this is more general than AdcPin and can also cover the temperature sensor.
-rw-r--r--embassy-rp/src/adc.rs8
1 files 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<interrupt::typelevel::ADC_IRQ_FIFO> for Inter
223} 223}
224 224
225mod sealed { 225mod sealed {
226 pub trait AdcPin: crate::gpio::sealed::Pin { 226 pub trait AdcChannel {
227 fn channel(&mut self) -> u8; 227 fn channel(&mut self) -> u8;
228 } 228 }
229} 229}
230 230
231pub trait AdcPin: sealed::AdcPin + gpio::Pin {} 231pub trait AdcChannel: sealed::AdcChannel {}
232pub trait AdcPin: AdcChannel + gpio::Pin {}
232 233
233macro_rules! impl_pin { 234macro_rules! impl_pin {
234 ($pin:ident, $channel:expr) => { 235 ($pin:ident, $channel:expr) => {
235 impl sealed::AdcPin for peripherals::$pin { 236 impl sealed::AdcChannel for peripherals::$pin {
236 fn channel(&mut self) -> u8 { 237 fn channel(&mut self) -> u8 {
237 $channel 238 $channel
238 } 239 }
239 } 240 }
240 241
242 impl AdcChannel for peripherals::$pin {}
241 impl AdcPin for peripherals::$pin {} 243 impl AdcPin for peripherals::$pin {}
242 }; 244 };
243} 245}