aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-12-14 14:09:59 +0000
committerGitHub <[email protected]>2021-12-14 14:09:59 +0000
commit1a7b9e3279b4920392cfb1a6614968d8be4eee2a (patch)
treef4e0387818d6a12fc47349e9376ea12355e8b95f /examples/nrf/src
parent3f3b7d066ebfeee76dc9467ee3c4c05468730e40 (diff)
parent153b1bbdbfc38b7973b27c05589514bee993e690 (diff)
Merge #542
542: nrf/gpiote: remove PortInput, move impls to Input/FlexPin. r=Dirbaio a=Dirbaio `PortInput` is just a dumb wrapper around `Input`, it has no reason whatsoever to exist. This PR moves the `wait_for_x` functionality to `Input` directly. It also adds it to `FlexPin` for completeness and consistency with `Input`. (The reason `PortInput` exists is a while ago `GPIOTE` was an owned singleton that you had to initialize, so `PortInput::new()` would require it to enforce it's been initialized. This doesn't apply anymore now that GPIOTE is "global") Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'examples/nrf/src')
-rw-r--r--examples/nrf/src/bin/gpiote_port.rs11
-rw-r--r--examples/nrf/src/bin/wdt.rs3
2 files changed, 6 insertions, 8 deletions
diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs
index ba9436aca..76c861d95 100644
--- a/examples/nrf/src/bin/gpiote_port.rs
+++ b/examples/nrf/src/bin/gpiote_port.rs
@@ -8,12 +8,11 @@ mod example_common;
8use embassy::executor::Spawner; 8use embassy::executor::Spawner;
9use embassy::traits::gpio::{WaitForHigh, WaitForLow}; 9use embassy::traits::gpio::{WaitForHigh, WaitForLow};
10use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; 10use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
11use embassy_nrf::gpiote::PortInput;
12use embassy_nrf::Peripherals; 11use embassy_nrf::Peripherals;
13use example_common::*; 12use example_common::*;
14 13
15#[embassy::task(pool_size = 4)] 14#[embassy::task(pool_size = 4)]
16async fn button_task(n: usize, mut pin: PortInput<'static, AnyPin>) { 15async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) {
17 loop { 16 loop {
18 pin.wait_for_low().await; 17 pin.wait_for_low().await;
19 info!("Button {:?} pressed!", n); 18 info!("Button {:?} pressed!", n);
@@ -26,10 +25,10 @@ async fn button_task(n: usize, mut pin: PortInput<'static, AnyPin>) {
26async fn main(spawner: Spawner, p: Peripherals) { 25async fn main(spawner: Spawner, p: Peripherals) {
27 info!("Starting!"); 26 info!("Starting!");
28 27
29 let btn1 = PortInput::new(Input::new(p.P0_11.degrade(), Pull::Up)); 28 let btn1 = Input::new(p.P0_11.degrade(), Pull::Up);
30 let btn2 = PortInput::new(Input::new(p.P0_12.degrade(), Pull::Up)); 29 let btn2 = Input::new(p.P0_12.degrade(), Pull::Up);
31 let btn3 = PortInput::new(Input::new(p.P0_24.degrade(), Pull::Up)); 30 let btn3 = Input::new(p.P0_24.degrade(), Pull::Up);
32 let btn4 = PortInput::new(Input::new(p.P0_25.degrade(), Pull::Up)); 31 let btn4 = Input::new(p.P0_25.degrade(), Pull::Up);
33 32
34 unwrap!(spawner.spawn(button_task(1, btn1))); 33 unwrap!(spawner.spawn(button_task(1, btn1)));
35 unwrap!(spawner.spawn(button_task(2, btn2))); 34 unwrap!(spawner.spawn(button_task(2, btn2)));
diff --git a/examples/nrf/src/bin/wdt.rs b/examples/nrf/src/bin/wdt.rs
index 76f171cd3..78c2205d9 100644
--- a/examples/nrf/src/bin/wdt.rs
+++ b/examples/nrf/src/bin/wdt.rs
@@ -8,7 +8,6 @@ mod example_common;
8use defmt::*; 8use defmt::*;
9use embassy::executor::Spawner; 9use embassy::executor::Spawner;
10use embassy_nrf::gpio::{Input, Pull}; 10use embassy_nrf::gpio::{Input, Pull};
11use embassy_nrf::gpiote::PortInput;
12use embassy_nrf::wdt::{Config, Watchdog}; 11use embassy_nrf::wdt::{Config, Watchdog};
13use embassy_nrf::Peripherals; 12use embassy_nrf::Peripherals;
14use embassy_traits::gpio::{WaitForHigh, WaitForLow}; 13use embassy_traits::gpio::{WaitForHigh, WaitForLow};
@@ -32,7 +31,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
32 } 31 }
33 }; 32 };
34 33
35 let mut button = PortInput::new(Input::new(p.P0_11, Pull::Up)); 34 let mut button = Input::new(p.P0_11, Pull::Up);
36 35
37 info!("Watchdog started, press button 1 to pet it or I'll reset in 3 seconds!"); 36 info!("Watchdog started, press button 1 to pet it or I'll reset in 3 seconds!");
38 37