aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-03-28 22:41:07 +0200
committerDario Nieuwenhuis <[email protected]>2021-03-29 00:58:58 +0200
commit00e5f3035219656823ec7a2451f4ebae6802e1b8 (patch)
tree81ed48a1afe0e14f431fc4c132b2c47febb6cd76
parent31b817ed273ccecc4297a8a64d01b564bf51ae88 (diff)
nrf/ppi: add AnyConfigurableChannel
-rw-r--r--embassy-nrf/src/ppi.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/embassy-nrf/src/ppi.rs b/embassy-nrf/src/ppi.rs
index 0129a2a47..6487267da 100644
--- a/embassy-nrf/src/ppi.rs
+++ b/embassy-nrf/src/ppi.rs
@@ -123,7 +123,13 @@ pub trait Channel: sealed::Channel + Sized {
123 } 123 }
124 } 124 }
125} 125}
126pub trait ConfigurableChannel: Channel + sealed::ConfigurableChannel {} 126pub trait ConfigurableChannel: Channel + sealed::ConfigurableChannel {
127 fn degrade_configurable(self) -> AnyConfigurableChannel {
128 AnyConfigurableChannel {
129 number: self.number() as u8,
130 }
131 }
132}
127 133
128pub trait Group: sealed::Group + Sized { 134pub trait Group: sealed::Group + Sized {
129 fn number(&self) -> usize; 135 fn number(&self) -> usize;
@@ -148,6 +154,19 @@ impl Channel for AnyChannel {
148 } 154 }
149} 155}
150 156
157pub struct AnyConfigurableChannel {
158 number: u8,
159}
160impl_unborrow!(AnyConfigurableChannel);
161impl sealed::Channel for AnyConfigurableChannel {}
162impl sealed::ConfigurableChannel for AnyConfigurableChannel {}
163impl ConfigurableChannel for AnyConfigurableChannel {}
164impl Channel for AnyConfigurableChannel {
165 fn number(&self) -> usize {
166 self.number as usize
167 }
168}
169
151macro_rules! impl_channel { 170macro_rules! impl_channel {
152 ($type:ident, $number:expr, configurable) => { 171 ($type:ident, $number:expr, configurable) => {
153 impl_channel!($type, $number); 172 impl_channel!($type, $number);