nrf/ppi: add AnyConfigurableChannel

This commit is contained in:
Dario Nieuwenhuis 2021-03-28 22:41:07 +02:00
parent 31b817ed27
commit 00e5f30352

View File

@ -123,7 +123,13 @@ pub trait Channel: sealed::Channel + Sized {
}
}
}
pub trait ConfigurableChannel: Channel + sealed::ConfigurableChannel {}
pub trait ConfigurableChannel: Channel + sealed::ConfigurableChannel {
fn degrade_configurable(self) -> AnyConfigurableChannel {
AnyConfigurableChannel {
number: self.number() as u8,
}
}
}
pub trait Group: sealed::Group + Sized {
fn number(&self) -> usize;
@ -148,6 +154,19 @@ impl Channel for AnyChannel {
}
}
pub struct AnyConfigurableChannel {
number: u8,
}
impl_unborrow!(AnyConfigurableChannel);
impl sealed::Channel for AnyConfigurableChannel {}
impl sealed::ConfigurableChannel for AnyConfigurableChannel {}
impl ConfigurableChannel for AnyConfigurableChannel {}
impl Channel for AnyConfigurableChannel {
fn number(&self) -> usize {
self.number as usize
}
}
macro_rules! impl_channel {
($type:ident, $number:expr, configurable) => {
impl_channel!($type, $number);