mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
rp: add AdcChannel trait
this is more general than AdcPin and can also cover the temperature sensor.
This commit is contained in:
parent
0d8a9b1e7a
commit
48eac0b146
@ -223,21 +223,23 @@ impl interrupt::typelevel::Handler<interrupt::typelevel::ADC_IRQ_FIFO> for Inter
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod sealed {
|
mod sealed {
|
||||||
pub trait AdcPin: crate::gpio::sealed::Pin {
|
pub trait AdcChannel {
|
||||||
fn channel(&mut self) -> u8;
|
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 {
|
macro_rules! impl_pin {
|
||||||
($pin:ident, $channel:expr) => {
|
($pin:ident, $channel:expr) => {
|
||||||
impl sealed::AdcPin for peripherals::$pin {
|
impl sealed::AdcChannel for peripherals::$pin {
|
||||||
fn channel(&mut self) -> u8 {
|
fn channel(&mut self) -> u8 {
|
||||||
$channel
|
$channel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AdcChannel for peripherals::$pin {}
|
||||||
impl AdcPin for peripherals::$pin {}
|
impl AdcPin for peripherals::$pin {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user