diff options
| -rw-r--r-- | embassy-nrf/Cargo.toml | 3 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 16 |
2 files changed, 11 insertions, 8 deletions
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 420d8ced8..62df81f42 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -5,9 +5,6 @@ authors = ["Dario Nieuwenhuis <[email protected]>"] | |||
| 5 | edition = "2018" | 5 | edition = "2018" |
| 6 | 6 | ||
| 7 | [features] | 7 | [features] |
| 8 | default = [ | ||
| 9 | "defmt-default", | ||
| 10 | ] | ||
| 11 | defmt-default = [] | 8 | defmt-default = [] |
| 12 | defmt-trace = [] | 9 | defmt-trace = [] |
| 13 | defmt-debug = [] | 10 | defmt-debug = [] |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 5195f926a..ef25109ee 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -85,9 +85,9 @@ impl Gpiote { | |||
| 85 | 85 | ||
| 86 | pub fn new_input_channel<'a, T>( | 86 | pub fn new_input_channel<'a, T>( |
| 87 | &'a self, | 87 | &'a self, |
| 88 | pin: &'a Pin<Input<T>>, | 88 | pin: Pin<Input<T>>, |
| 89 | trigger_mode: EventPolarity, | 89 | trigger_mode: EventPolarity, |
| 90 | ) -> Result<InputChannel<'a>, NewChannelError> { | 90 | ) -> Result<InputChannel<'a, T>, NewChannelError> { |
| 91 | interrupt::free(|_| { | 91 | interrupt::free(|_| { |
| 92 | unsafe { INSTANCE = self }; | 92 | unsafe { INSTANCE = self }; |
| 93 | let index = self.allocate_channel()?; | 93 | let index = self.allocate_channel()?; |
| @@ -113,6 +113,7 @@ impl Gpiote { | |||
| 113 | Ok(InputChannel { | 113 | Ok(InputChannel { |
| 114 | gpiote: self, | 114 | gpiote: self, |
| 115 | index, | 115 | index, |
| 116 | pin, | ||
| 116 | }) | 117 | }) |
| 117 | }) | 118 | }) |
| 118 | } | 119 | } |
| @@ -157,21 +158,26 @@ impl Gpiote { | |||
| 157 | } | 158 | } |
| 158 | } | 159 | } |
| 159 | 160 | ||
| 160 | pub struct InputChannel<'a> { | 161 | pub struct InputChannel<'a, T> { |
| 161 | gpiote: &'a Gpiote, | 162 | gpiote: &'a Gpiote, |
| 163 | pin: Pin<Input<T>>, | ||
| 162 | index: u8, | 164 | index: u8, |
| 163 | } | 165 | } |
| 164 | 166 | ||
| 165 | impl<'a> Drop for InputChannel<'a> { | 167 | impl<'a, T> Drop for InputChannel<'a, T> { |
| 166 | fn drop(&mut self) { | 168 | fn drop(&mut self) { |
| 167 | self.gpiote.free_channel(self.index); | 169 | self.gpiote.free_channel(self.index); |
| 168 | } | 170 | } |
| 169 | } | 171 | } |
| 170 | 172 | ||
| 171 | impl<'a> InputChannel<'a> { | 173 | impl<'a, T> InputChannel<'a, T> { |
| 172 | pub async fn wait(&self) -> () { | 174 | pub async fn wait(&self) -> () { |
| 173 | self.gpiote.signals[self.index as usize].wait().await; | 175 | self.gpiote.signals[self.index as usize].wait().await; |
| 174 | } | 176 | } |
| 177 | |||
| 178 | pub fn pin(&self) -> &Pin<Input<T>> { | ||
| 179 | &self.pin | ||
| 180 | } | ||
| 175 | } | 181 | } |
| 176 | 182 | ||
| 177 | pub struct OutputChannel<'a> { | 183 | pub struct OutputChannel<'a> { |
