aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-nrf/src/gpiote.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index 25ad90496..7f7468a20 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -2,7 +2,7 @@ use core::convert::Infallible;
2use core::future::{poll_fn, Future}; 2use core::future::{poll_fn, Future};
3use core::task::{Context, Poll}; 3use core::task::{Context, Poll};
4 4
5use embassy_hal_common::{impl_peripheral, Peripheral, PeripheralRef}; 5use embassy_hal_common::{impl_peripheral, into_ref, Peripheral, PeripheralRef};
6use embassy_sync::waitqueue::AtomicWaker; 6use embassy_sync::waitqueue::AtomicWaker;
7 7
8use crate::gpio::sealed::Pin as _; 8use crate::gpio::sealed::Pin as _;
@@ -148,7 +148,7 @@ impl Iterator for BitIter {
148 148
149/// GPIOTE channel driver in input mode 149/// GPIOTE channel driver in input mode
150pub struct InputChannel<'d, C: Channel, T: GpioPin> { 150pub struct InputChannel<'d, C: Channel, T: GpioPin> {
151 ch: C, 151 ch: PeripheralRef<'d, C>,
152 pin: Input<'d, T>, 152 pin: Input<'d, T>,
153} 153}
154 154
@@ -162,7 +162,9 @@ impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> {
162} 162}
163 163
164impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { 164impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> {
165 pub fn new(ch: C, pin: Input<'d, T>, polarity: InputChannelPolarity) -> Self { 165 pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Input<'d, T>, polarity: InputChannelPolarity) -> Self {
166 into_ref!(ch);
167
166 let g = regs(); 168 let g = regs();
167 let num = ch.number(); 169 let num = ch.number();
168 170
@@ -215,7 +217,7 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> {
215 217
216/// GPIOTE channel driver in output mode 218/// GPIOTE channel driver in output mode
217pub struct OutputChannel<'d, C: Channel, T: GpioPin> { 219pub struct OutputChannel<'d, C: Channel, T: GpioPin> {
218 ch: C, 220 ch: PeripheralRef<'d, C>,
219 _pin: Output<'d, T>, 221 _pin: Output<'d, T>,
220} 222}
221 223
@@ -229,7 +231,8 @@ impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> {
229} 231}
230 232
231impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { 233impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> {
232 pub fn new(ch: C, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { 234 pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self {
235 into_ref!(ch);
233 let g = regs(); 236 let g = regs();
234 let num = ch.number(); 237 let num = ch.number();
235 238