aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/modules/ROOT/examples/basic/src/main.rs3
-rw-r--r--embassy-nrf/src/gpio.rs62
-rw-r--r--embassy-nrf/src/gpiote.rs53
-rw-r--r--examples/nrf52840/src/bin/ethernet_enc28j60.rs12
-rw-r--r--examples/nrf52840/src/bin/gpiote_port.rs12
-rw-r--r--examples/nrf52840/src/bin/usb_hid_keyboard.rs4
-rw-r--r--examples/nrf52840/src/bin/wifi_esp_hosted.rs12
-rw-r--r--tests/nrf/src/bin/ethernet_enc28j60_perf.rs5
-rw-r--r--tests/nrf/src/bin/wifi_esp_hosted_perf.rs12
9 files changed, 86 insertions, 89 deletions
diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs
index 2a4ee5968..4412712c8 100644
--- a/docs/modules/ROOT/examples/basic/src/main.rs
+++ b/docs/modules/ROOT/examples/basic/src/main.rs
@@ -4,12 +4,11 @@
4use defmt::*; 4use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_nrf::gpio::{Level, Output, OutputDrive}; 6use embassy_nrf::gpio::{Level, Output, OutputDrive};
7use embassy_nrf::peripherals::P0_13;
8use embassy_time::{Duration, Timer}; 7use embassy_time::{Duration, Timer};
9use {defmt_rtt as _, panic_probe as _}; // global logger 8use {defmt_rtt as _, panic_probe as _}; // global logger
10 9
11#[embassy_executor::task] 10#[embassy_executor::task]
12async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { 11async fn blinker(mut led: Output<'static>, interval: Duration) {
13 loop { 12 loop {
14 led.set_high(); 13 led.set_high();
15 Timer::after(interval).await; 14 Timer::after(interval).await;
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs
index eabf409dd..287811e61 100644
--- a/embassy-nrf/src/gpio.rs
+++ b/embassy-nrf/src/gpio.rs
@@ -36,14 +36,14 @@ pub enum Pull {
36} 36}
37 37
38/// GPIO input driver. 38/// GPIO input driver.
39pub struct Input<'d, T: Pin> { 39pub struct Input<'d> {
40 pub(crate) pin: Flex<'d, T>, 40 pub(crate) pin: Flex<'d>,
41} 41}
42 42
43impl<'d, T: Pin> Input<'d, T> { 43impl<'d> Input<'d> {
44 /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. 44 /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration.
45 #[inline] 45 #[inline]
46 pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self { 46 pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, pull: Pull) -> Self {
47 let mut pin = Flex::new(pin); 47 let mut pin = Flex::new(pin);
48 pin.set_as_input(pull); 48 pin.set_as_input(pull);
49 49
@@ -122,14 +122,14 @@ pub enum OutputDrive {
122} 122}
123 123
124/// GPIO output driver. 124/// GPIO output driver.
125pub struct Output<'d, T: Pin> { 125pub struct Output<'d> {
126 pub(crate) pin: Flex<'d, T>, 126 pub(crate) pin: Flex<'d>,
127} 127}
128 128
129impl<'d, T: Pin> Output<'d, T> { 129impl<'d> Output<'d> {
130 /// Create GPIO output driver for a [Pin] with the provided [Level] and [OutputDriver] configuration. 130 /// Create GPIO output driver for a [Pin] with the provided [Level] and [OutputDriver] configuration.
131 #[inline] 131 #[inline]
132 pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, drive: OutputDrive) -> Self { 132 pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level, drive: OutputDrive) -> Self {
133 let mut pin = Flex::new(pin); 133 let mut pin = Flex::new(pin);
134 match initial_output { 134 match initial_output {
135 Level::High => pin.set_high(), 135 Level::High => pin.set_high(),
@@ -209,20 +209,20 @@ fn convert_pull(pull: Pull) -> PULL_A {
209/// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain 209/// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain
210/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output 210/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output
211/// mode. 211/// mode.
212pub struct Flex<'d, T: Pin> { 212pub struct Flex<'d> {
213 pub(crate) pin: PeripheralRef<'d, T>, 213 pub(crate) pin: PeripheralRef<'d, AnyPin>,
214} 214}
215 215
216impl<'d, T: Pin> Flex<'d, T> { 216impl<'d> Flex<'d> {
217 /// Wrap the pin in a `Flex`. 217 /// Wrap the pin in a `Flex`.
218 /// 218 ///
219 /// The pin remains disconnected. The initial output level is unspecified, but can be changed 219 /// The pin remains disconnected. The initial output level is unspecified, but can be changed
220 /// before the pin is put into output mode. 220 /// before the pin is put into output mode.
221 #[inline] 221 #[inline]
222 pub fn new(pin: impl Peripheral<P = T> + 'd) -> Self { 222 pub fn new(pin: impl Peripheral<P = impl Pin> + 'd) -> Self {
223 into_ref!(pin); 223 into_ref!(pin);
224 // Pin will be in disconnected state. 224 // Pin will be in disconnected state.
225 Self { pin } 225 Self { pin: pin.map_into() }
226 } 226 }
227 227
228 /// Put the pin into input mode. 228 /// Put the pin into input mode.
@@ -349,7 +349,7 @@ impl<'d, T: Pin> Flex<'d, T> {
349 } 349 }
350} 350}
351 351
352impl<'d, T: Pin> Drop for Flex<'d, T> { 352impl<'d> Drop for Flex<'d> {
353 fn drop(&mut self) { 353 fn drop(&mut self) {
354 self.pin.conf().reset(); 354 self.pin.conf().reset();
355 } 355 }
@@ -510,7 +510,7 @@ macro_rules! impl_pin {
510mod eh02 { 510mod eh02 {
511 use super::*; 511 use super::*;
512 512
513 impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { 513 impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> {
514 type Error = Infallible; 514 type Error = Infallible;
515 515
516 fn is_high(&self) -> Result<bool, Self::Error> { 516 fn is_high(&self) -> Result<bool, Self::Error> {
@@ -522,7 +522,7 @@ mod eh02 {
522 } 522 }
523 } 523 }
524 524
525 impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { 525 impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> {
526 type Error = Infallible; 526 type Error = Infallible;
527 527
528 fn set_high(&mut self) -> Result<(), Self::Error> { 528 fn set_high(&mut self) -> Result<(), Self::Error> {
@@ -534,7 +534,7 @@ mod eh02 {
534 } 534 }
535 } 535 }
536 536
537 impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { 537 impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> {
538 fn is_set_high(&self) -> Result<bool, Self::Error> { 538 fn is_set_high(&self) -> Result<bool, Self::Error> {
539 Ok(self.is_set_high()) 539 Ok(self.is_set_high())
540 } 540 }
@@ -544,7 +544,7 @@ mod eh02 {
544 } 544 }
545 } 545 }
546 546
547 impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> { 547 impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> {
548 type Error = Infallible; 548 type Error = Infallible;
549 #[inline] 549 #[inline]
550 fn toggle(&mut self) -> Result<(), Self::Error> { 550 fn toggle(&mut self) -> Result<(), Self::Error> {
@@ -556,7 +556,7 @@ mod eh02 {
556 /// Implement [`embedded_hal_02::digital::v2::InputPin`] for [`Flex`]; 556 /// Implement [`embedded_hal_02::digital::v2::InputPin`] for [`Flex`];
557 /// 557 ///
558 /// If the pin is not in input mode the result is unspecified. 558 /// If the pin is not in input mode the result is unspecified.
559 impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { 559 impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> {
560 type Error = Infallible; 560 type Error = Infallible;
561 561
562 fn is_high(&self) -> Result<bool, Self::Error> { 562 fn is_high(&self) -> Result<bool, Self::Error> {
@@ -568,7 +568,7 @@ mod eh02 {
568 } 568 }
569 } 569 }
570 570
571 impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { 571 impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> {
572 type Error = Infallible; 572 type Error = Infallible;
573 573
574 fn set_high(&mut self) -> Result<(), Self::Error> { 574 fn set_high(&mut self) -> Result<(), Self::Error> {
@@ -580,7 +580,7 @@ mod eh02 {
580 } 580 }
581 } 581 }
582 582
583 impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { 583 impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> {
584 fn is_set_high(&self) -> Result<bool, Self::Error> { 584 fn is_set_high(&self) -> Result<bool, Self::Error> {
585 Ok(self.is_set_high()) 585 Ok(self.is_set_high())
586 } 586 }
@@ -590,7 +590,7 @@ mod eh02 {
590 } 590 }
591 } 591 }
592 592
593 impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> { 593 impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> {
594 type Error = Infallible; 594 type Error = Infallible;
595 #[inline] 595 #[inline]
596 fn toggle(&mut self) -> Result<(), Self::Error> { 596 fn toggle(&mut self) -> Result<(), Self::Error> {
@@ -600,11 +600,11 @@ mod eh02 {
600 } 600 }
601} 601}
602 602
603impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { 603impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> {
604 type Error = Infallible; 604 type Error = Infallible;
605} 605}
606 606
607impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { 607impl<'d> embedded_hal_1::digital::InputPin for Input<'d> {
608 fn is_high(&mut self) -> Result<bool, Self::Error> { 608 fn is_high(&mut self) -> Result<bool, Self::Error> {
609 Ok((*self).is_high()) 609 Ok((*self).is_high())
610 } 610 }
@@ -614,11 +614,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
614 } 614 }
615} 615}
616 616
617impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { 617impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> {
618 type Error = Infallible; 618 type Error = Infallible;
619} 619}
620 620
621impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { 621impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> {
622 fn set_high(&mut self) -> Result<(), Self::Error> { 622 fn set_high(&mut self) -> Result<(), Self::Error> {
623 Ok(self.set_high()) 623 Ok(self.set_high())
624 } 624 }
@@ -628,7 +628,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
628 } 628 }
629} 629}
630 630
631impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { 631impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> {
632 fn is_set_high(&mut self) -> Result<bool, Self::Error> { 632 fn is_set_high(&mut self) -> Result<bool, Self::Error> {
633 Ok((*self).is_set_high()) 633 Ok((*self).is_set_high())
634 } 634 }
@@ -638,14 +638,14 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
638 } 638 }
639} 639}
640 640
641impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { 641impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> {
642 type Error = Infallible; 642 type Error = Infallible;
643} 643}
644 644
645/// Implement [`InputPin`] for [`Flex`]; 645/// Implement [`InputPin`] for [`Flex`];
646/// 646///
647/// If the pin is not in input mode the result is unspecified. 647/// If the pin is not in input mode the result is unspecified.
648impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { 648impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> {
649 fn is_high(&mut self) -> Result<bool, Self::Error> { 649 fn is_high(&mut self) -> Result<bool, Self::Error> {
650 Ok((*self).is_high()) 650 Ok((*self).is_high())
651 } 651 }
@@ -655,7 +655,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
655 } 655 }
656} 656}
657 657
658impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { 658impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> {
659 fn set_high(&mut self) -> Result<(), Self::Error> { 659 fn set_high(&mut self) -> Result<(), Self::Error> {
660 Ok(self.set_high()) 660 Ok(self.set_high())
661 } 661 }
@@ -665,7 +665,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
665 } 665 }
666} 666}
667 667
668impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { 668impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> {
669 fn is_set_high(&mut self) -> Result<bool, Self::Error> { 669 fn is_set_high(&mut self) -> Result<bool, Self::Error> {
670 Ok((*self).is_set_high()) 670 Ok((*self).is_set_high())
671 } 671 }
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index 8020b8dc2..a459446a2 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -156,12 +156,12 @@ impl Iterator for BitIter {
156} 156}
157 157
158/// GPIOTE channel driver in input mode 158/// GPIOTE channel driver in input mode
159pub struct InputChannel<'d, C: Channel, T: GpioPin> { 159pub struct InputChannel<'d> {
160 ch: PeripheralRef<'d, C>, 160 ch: PeripheralRef<'d, AnyChannel>,
161 pin: Input<'d, T>, 161 pin: Input<'d>,
162} 162}
163 163
164impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> { 164impl<'d> Drop for InputChannel<'d> {
165 fn drop(&mut self) { 165 fn drop(&mut self) {
166 let g = regs(); 166 let g = regs();
167 let num = self.ch.number(); 167 let num = self.ch.number();
@@ -170,9 +170,9 @@ impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> {
170 } 170 }
171} 171}
172 172
173impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { 173impl<'d> InputChannel<'d> {
174 /// Create a new GPIOTE input channel driver. 174 /// Create a new GPIOTE input channel driver.
175 pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Input<'d, T>, polarity: InputChannelPolarity) -> Self { 175 pub fn new(ch: impl Peripheral<P = impl Channel> + 'd, pin: Input<'d>, polarity: InputChannelPolarity) -> Self {
176 into_ref!(ch); 176 into_ref!(ch);
177 177
178 let g = regs(); 178 let g = regs();
@@ -195,7 +195,7 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> {
195 195
196 g.events_in[num].reset(); 196 g.events_in[num].reset();
197 197
198 InputChannel { ch, pin } 198 InputChannel { ch: ch.map_into(), pin }
199 } 199 }
200 200
201 /// Asynchronously wait for an event in this channel. 201 /// Asynchronously wait for an event in this channel.
@@ -227,12 +227,12 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> {
227} 227}
228 228
229/// GPIOTE channel driver in output mode 229/// GPIOTE channel driver in output mode
230pub struct OutputChannel<'d, C: Channel, T: GpioPin> { 230pub struct OutputChannel<'d> {
231 ch: PeripheralRef<'d, C>, 231 ch: PeripheralRef<'d, AnyChannel>,
232 _pin: Output<'d, T>, 232 _pin: Output<'d>,
233} 233}
234 234
235impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { 235impl<'d> Drop for OutputChannel<'d> {
236 fn drop(&mut self) { 236 fn drop(&mut self) {
237 let g = regs(); 237 let g = regs();
238 let num = self.ch.number(); 238 let num = self.ch.number();
@@ -241,9 +241,9 @@ impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> {
241 } 241 }
242} 242}
243 243
244impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { 244impl<'d> OutputChannel<'d> {
245 /// Create a new GPIOTE output channel driver. 245 /// Create a new GPIOTE output channel driver.
246 pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { 246 pub fn new(ch: impl Peripheral<P = impl Channel> + 'd, pin: Output<'d>, polarity: OutputChannelPolarity) -> Self {
247 into_ref!(ch); 247 into_ref!(ch);
248 let g = regs(); 248 let g = regs();
249 let num = ch.number(); 249 let num = ch.number();
@@ -267,7 +267,10 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> {
267 unsafe { w.psel().bits(pin.pin.pin.pin()) } 267 unsafe { w.psel().bits(pin.pin.pin.pin()) }
268 }); 268 });
269 269
270 OutputChannel { ch, _pin: pin } 270 OutputChannel {
271 ch: ch.map_into(),
272 _pin: pin,
273 }
271 } 274 }
272 275
273 /// Triggers the OUT task (does the action as configured with task_out_polarity, defaults to Toggle). 276 /// Triggers the OUT task (does the action as configured with task_out_polarity, defaults to Toggle).
@@ -348,7 +351,7 @@ impl<'a> Future for PortInputFuture<'a> {
348 } 351 }
349} 352}
350 353
351impl<'d, T: GpioPin> Input<'d, T> { 354impl<'d> Input<'d> {
352 /// Wait until the pin is high. If it is already high, return immediately. 355 /// Wait until the pin is high. If it is already high, return immediately.
353 pub async fn wait_for_high(&mut self) { 356 pub async fn wait_for_high(&mut self) {
354 self.pin.wait_for_high().await 357 self.pin.wait_for_high().await
@@ -375,7 +378,7 @@ impl<'d, T: GpioPin> Input<'d, T> {
375 } 378 }
376} 379}
377 380
378impl<'d, T: GpioPin> Flex<'d, T> { 381impl<'d> Flex<'d> {
379 /// Wait until the pin is high. If it is already high, return immediately. 382 /// Wait until the pin is high. If it is already high, return immediately.
380 pub async fn wait_for_high(&mut self) { 383 pub async fn wait_for_high(&mut self) {
381 self.pin.conf().modify(|_, w| w.sense().high()); 384 self.pin.conf().modify(|_, w| w.sense().high());
@@ -420,7 +423,7 @@ mod sealed {
420/// GPIOTE channel trait. 423/// GPIOTE channel trait.
421/// 424///
422/// Implemented by all GPIOTE channels. 425/// Implemented by all GPIOTE channels.
423pub trait Channel: sealed::Channel + Sized { 426pub trait Channel: sealed::Channel + Into<AnyChannel> + Sized + 'static {
424 /// Get the channel number. 427 /// Get the channel number.
425 fn number(&self) -> usize; 428 fn number(&self) -> usize;
426 429
@@ -460,6 +463,12 @@ macro_rules! impl_channel {
460 $number as usize 463 $number as usize
461 } 464 }
462 } 465 }
466
467 impl From<peripherals::$type> for AnyChannel {
468 fn from(val: peripherals::$type) -> Self {
469 Channel::degrade(val)
470 }
471 }
463 }; 472 };
464} 473}
465 474
@@ -477,7 +486,7 @@ impl_channel!(GPIOTE_CH7, 7);
477mod eh02 { 486mod eh02 {
478 use super::*; 487 use super::*;
479 488
480 impl<'d, C: Channel, T: GpioPin> embedded_hal_02::digital::v2::InputPin for InputChannel<'d, C, T> { 489 impl<'d> embedded_hal_02::digital::v2::InputPin for InputChannel<'d> {
481 type Error = Infallible; 490 type Error = Infallible;
482 491
483 fn is_high(&self) -> Result<bool, Self::Error> { 492 fn is_high(&self) -> Result<bool, Self::Error> {
@@ -490,11 +499,11 @@ mod eh02 {
490 } 499 }
491} 500}
492 501
493impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { 502impl<'d> embedded_hal_1::digital::ErrorType for InputChannel<'d> {
494 type Error = Infallible; 503 type Error = Infallible;
495} 504}
496 505
497impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> { 506impl<'d> embedded_hal_1::digital::InputPin for InputChannel<'d> {
498 fn is_high(&mut self) -> Result<bool, Self::Error> { 507 fn is_high(&mut self) -> Result<bool, Self::Error> {
499 Ok(self.pin.is_high()) 508 Ok(self.pin.is_high())
500 } 509 }
@@ -504,7 +513,7 @@ impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChan
504 } 513 }
505} 514}
506 515
507impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { 516impl<'d> embedded_hal_async::digital::Wait for Input<'d> {
508 async fn wait_for_high(&mut self) -> Result<(), Self::Error> { 517 async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
509 Ok(self.wait_for_high().await) 518 Ok(self.wait_for_high().await)
510 } 519 }
@@ -526,7 +535,7 @@ impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> {
526 } 535 }
527} 536}
528 537
529impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { 538impl<'d> embedded_hal_async::digital::Wait for Flex<'d> {
530 async fn wait_for_high(&mut self) -> Result<(), Self::Error> { 539 async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
531 Ok(self.wait_for_high().await) 540 Ok(self.wait_for_high().await)
532 } 541 }
diff --git a/examples/nrf52840/src/bin/ethernet_enc28j60.rs b/examples/nrf52840/src/bin/ethernet_enc28j60.rs
index a8e64b38a..279f32edc 100644
--- a/examples/nrf52840/src/bin/ethernet_enc28j60.rs
+++ b/examples/nrf52840/src/bin/ethernet_enc28j60.rs
@@ -24,10 +24,7 @@ bind_interrupts!(struct Irqs {
24#[embassy_executor::task] 24#[embassy_executor::task]
25async fn net_task( 25async fn net_task(
26 stack: &'static Stack< 26 stack: &'static Stack<
27 Enc28j60< 27 Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>,
28 ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>,
29 Output<'static, peripherals::P0_13>,
30 >,
31 >, 28 >,
32) -> ! { 29) -> ! {
33 stack.run().await 30 stack.run().await
@@ -71,12 +68,7 @@ async fn main(spawner: Spawner) {
71 // Init network stack 68 // Init network stack
72 static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); 69 static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
73 static STACK: StaticCell< 70 static STACK: StaticCell<
74 Stack< 71 Stack<Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>>,
75 Enc28j60<
76 ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>,
77 Output<'static, peripherals::P0_13>,
78 >,
79 >,
80 > = StaticCell::new(); 72 > = StaticCell::new();
81 let stack = STACK.init(Stack::new( 73 let stack = STACK.init(Stack::new(
82 device, 74 device,
diff --git a/examples/nrf52840/src/bin/gpiote_port.rs b/examples/nrf52840/src/bin/gpiote_port.rs
index c1afe2f20..0dddb1a97 100644
--- a/examples/nrf52840/src/bin/gpiote_port.rs
+++ b/examples/nrf52840/src/bin/gpiote_port.rs
@@ -3,11 +3,11 @@
3 3
4use defmt::{info, unwrap}; 4use defmt::{info, unwrap};
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; 6use embassy_nrf::gpio::{Input, Pull};
7use {defmt_rtt as _, panic_probe as _}; 7use {defmt_rtt as _, panic_probe as _};
8 8
9#[embassy_executor::task(pool_size = 4)] 9#[embassy_executor::task(pool_size = 4)]
10async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { 10async fn button_task(n: usize, mut pin: Input<'static>) {
11 loop { 11 loop {
12 pin.wait_for_low().await; 12 pin.wait_for_low().await;
13 info!("Button {:?} pressed!", n); 13 info!("Button {:?} pressed!", n);
@@ -21,10 +21,10 @@ async fn main(spawner: Spawner) {
21 let p = embassy_nrf::init(Default::default()); 21 let p = embassy_nrf::init(Default::default());
22 info!("Starting!"); 22 info!("Starting!");
23 23
24 let btn1 = Input::new(p.P0_11.degrade(), Pull::Up); 24 let btn1 = Input::new(p.P0_11, Pull::Up);
25 let btn2 = Input::new(p.P0_12.degrade(), Pull::Up); 25 let btn2 = Input::new(p.P0_12, Pull::Up);
26 let btn3 = Input::new(p.P0_24.degrade(), Pull::Up); 26 let btn3 = Input::new(p.P0_24, Pull::Up);
27 let btn4 = Input::new(p.P0_25.degrade(), Pull::Up); 27 let btn4 = Input::new(p.P0_25, Pull::Up);
28 28
29 unwrap!(spawner.spawn(button_task(1, btn1))); 29 unwrap!(spawner.spawn(button_task(1, btn1)));
30 unwrap!(spawner.spawn(button_task(2, btn2))); 30 unwrap!(spawner.spawn(button_task(2, btn2)));
diff --git a/examples/nrf52840/src/bin/usb_hid_keyboard.rs b/examples/nrf52840/src/bin/usb_hid_keyboard.rs
index 45850b4a4..3e86590c4 100644
--- a/examples/nrf52840/src/bin/usb_hid_keyboard.rs
+++ b/examples/nrf52840/src/bin/usb_hid_keyboard.rs
@@ -8,7 +8,7 @@ use defmt::*;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_futures::join::join; 9use embassy_futures::join::join;
10use embassy_futures::select::{select, Either}; 10use embassy_futures::select::{select, Either};
11use embassy_nrf::gpio::{Input, Pin, Pull}; 11use embassy_nrf::gpio::{Input, Pull};
12use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; 12use embassy_nrf::usb::vbus_detect::HardwareVbusDetect;
13use embassy_nrf::usb::Driver; 13use embassy_nrf::usb::Driver;
14use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; 14use embassy_nrf::{bind_interrupts, pac, peripherals, usb};
@@ -97,7 +97,7 @@ async fn main(_spawner: Spawner) {
97 } 97 }
98 }; 98 };
99 99
100 let mut button = Input::new(p.P0_11.degrade(), Pull::Up); 100 let mut button = Input::new(p.P0_11, Pull::Up);
101 101
102 let (reader, mut writer) = hid.split(); 102 let (reader, mut writer) = hid.split();
103 103
diff --git a/examples/nrf52840/src/bin/wifi_esp_hosted.rs b/examples/nrf52840/src/bin/wifi_esp_hosted.rs
index fc2086f75..00bd50081 100644
--- a/examples/nrf52840/src/bin/wifi_esp_hosted.rs
+++ b/examples/nrf52840/src/bin/wifi_esp_hosted.rs
@@ -5,7 +5,7 @@ use defmt::{info, unwrap, warn};
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_net::tcp::TcpSocket; 6use embassy_net::tcp::TcpSocket;
7use embassy_net::{Stack, StackResources}; 7use embassy_net::{Stack, StackResources};
8use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; 8use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
9use embassy_nrf::rng::Rng; 9use embassy_nrf::rng::Rng;
10use embassy_nrf::spim::{self, Spim}; 10use embassy_nrf::spim::{self, Spim};
11use embassy_nrf::{bind_interrupts, peripherals}; 11use embassy_nrf::{bind_interrupts, peripherals};
@@ -27,9 +27,9 @@ bind_interrupts!(struct Irqs {
27async fn wifi_task( 27async fn wifi_task(
28 runner: hosted::Runner< 28 runner: hosted::Runner<
29 'static, 29 'static,
30 ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_31>, Delay>, 30 ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>,
31 Input<'static, AnyPin>, 31 Input<'static>,
32 Output<'static, peripherals::P1_05>, 32 Output<'static>,
33 >, 33 >,
34) -> ! { 34) -> ! {
35 runner.run().await 35 runner.run().await
@@ -50,8 +50,8 @@ async fn main(spawner: Spawner) {
50 let sck = p.P0_29; 50 let sck = p.P0_29;
51 let mosi = p.P0_30; 51 let mosi = p.P0_30;
52 let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); 52 let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive);
53 let handshake = Input::new(p.P1_01.degrade(), Pull::Up); 53 let handshake = Input::new(p.P1_01, Pull::Up);
54 let ready = Input::new(p.P1_04.degrade(), Pull::None); 54 let ready = Input::new(p.P1_04, Pull::None);
55 let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); 55 let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard);
56 56
57 let mut config = spim::Config::default(); 57 let mut config = spim::Config::default();
diff --git a/tests/nrf/src/bin/ethernet_enc28j60_perf.rs b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs
index 7dc1941d7..33c2f4235 100644
--- a/tests/nrf/src/bin/ethernet_enc28j60_perf.rs
+++ b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs
@@ -21,10 +21,7 @@ bind_interrupts!(struct Irqs {
21 RNG => embassy_nrf::rng::InterruptHandler<peripherals::RNG>; 21 RNG => embassy_nrf::rng::InterruptHandler<peripherals::RNG>;
22}); 22});
23 23
24type MyDriver = Enc28j60< 24type MyDriver = Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>;
25 ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>,
26 Output<'static, peripherals::P0_13>,
27>;
28 25
29#[embassy_executor::task] 26#[embassy_executor::task]
30async fn net_task(stack: &'static Stack<MyDriver>) -> ! { 27async fn net_task(stack: &'static Stack<MyDriver>) -> ! {
diff --git a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs
index c96064f84..b83edddc4 100644
--- a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs
+++ b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs
@@ -6,7 +6,7 @@ teleprobe_meta::timeout!(120);
6use defmt::{info, unwrap}; 6use defmt::{info, unwrap};
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_net::{Config, Stack, StackResources}; 8use embassy_net::{Config, Stack, StackResources};
9use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; 9use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
10use embassy_nrf::rng::Rng; 10use embassy_nrf::rng::Rng;
11use embassy_nrf::spim::{self, Spim}; 11use embassy_nrf::spim::{self, Spim};
12use embassy_nrf::{bind_interrupts, peripherals}; 12use embassy_nrf::{bind_interrupts, peripherals};
@@ -28,9 +28,9 @@ const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud";
28async fn wifi_task( 28async fn wifi_task(
29 runner: hosted::Runner< 29 runner: hosted::Runner<
30 'static, 30 'static,
31 ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_31>, Delay>, 31 ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>,
32 Input<'static, AnyPin>, 32 Input<'static>,
33 Output<'static, peripherals::P1_05>, 33 Output<'static>,
34 >, 34 >,
35) -> ! { 35) -> ! {
36 runner.run().await 36 runner.run().await
@@ -53,8 +53,8 @@ async fn main(spawner: Spawner) {
53 let sck = p.P0_29; 53 let sck = p.P0_29;
54 let mosi = p.P0_30; 54 let mosi = p.P0_30;
55 let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); 55 let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive);
56 let handshake = Input::new(p.P1_01.degrade(), Pull::Up); 56 let handshake = Input::new(p.P1_01, Pull::Up);
57 let ready = Input::new(p.P1_04.degrade(), Pull::None); 57 let ready = Input::new(p.P1_04, Pull::None);
58 let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); 58 let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard);
59 59
60 let mut config = spim::Config::default(); 60 let mut config = spim::Config::default();