aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf-examples/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-03-27 03:50:18 +0100
committerDario Nieuwenhuis <[email protected]>2021-03-29 00:58:58 +0200
commit2bd9323f28537da035692e48820ce8687e627c9e (patch)
tree945934f7590590e2430a6c3bc61f191c82609d2d /embassy-nrf-examples/src
parenta338841797e52e5a2032246ac63d29080014d16c (diff)
nrf/gpiote: update input channel to new API
Diffstat (limited to 'embassy-nrf-examples/src')
-rw-r--r--embassy-nrf-examples/src/bin/gpiote_channel.rs45
1 files changed, 29 insertions, 16 deletions
diff --git a/embassy-nrf-examples/src/bin/gpiote_channel.rs b/embassy-nrf-examples/src/bin/gpiote_channel.rs
index 599882a90..d223df7a3 100644
--- a/embassy-nrf-examples/src/bin/gpiote_channel.rs
+++ b/embassy-nrf-examples/src/bin/gpiote_channel.rs
@@ -11,31 +11,44 @@ use example_common::*;
11 11
12use cortex_m_rt::entry; 12use cortex_m_rt::entry;
13use defmt::panic; 13use defmt::panic;
14use nrf52840_hal::gpio;
15 14
16use embassy::executor::{task, Executor}; 15use embassy::executor::{task, Executor};
17use embassy::util::Forever; 16use embassy::util::Forever;
18use embassy_nrf::gpiote::{Gpiote, InputChannel, InputChannelPolarity}; 17use embassy_nrf::gpio::{Input, Pull};
19use embassy_nrf::interrupt; 18use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity};
19use embassy_nrf::{interrupt, Peripherals};
20 20
21#[task] 21#[task]
22async fn run() { 22async fn run() {
23 let p = unwrap!(embassy_nrf::pac::Peripherals::take()); 23 let p = Peripherals::take().unwrap();
24 let port0 = gpio::p0::Parts::new(p.P0); 24 let g = gpiote::initialize(p.GPIOTE, interrupt::take!(GPIOTE));
25
26 let (g, chs) = Gpiote::new(p.GPIOTE, interrupt::take!(GPIOTE));
27 25
28 info!("Starting!"); 26 info!("Starting!");
29 27
30 let pin1 = port0.p0_11.into_pullup_input().degrade(); 28 let ch1 = InputChannel::new(
31 let pin2 = port0.p0_12.into_pullup_input().degrade(); 29 g,
32 let pin3 = port0.p0_24.into_pullup_input().degrade(); 30 p.GPIOTE_CH0,
33 let pin4 = port0.p0_25.into_pullup_input().degrade(); 31 Input::new(p.P0_11, Pull::Up),
34 32 InputChannelPolarity::HiToLo,
35 let ch1 = InputChannel::new(g, chs.ch0, pin1, InputChannelPolarity::HiToLo); 33 );
36 let ch2 = InputChannel::new(g, chs.ch1, pin2, InputChannelPolarity::LoToHi); 34 let ch2 = InputChannel::new(
37 let ch3 = InputChannel::new(g, chs.ch2, pin3, InputChannelPolarity::Toggle); 35 g,
38 let ch4 = InputChannel::new(g, chs.ch3, pin4, InputChannelPolarity::Toggle); 36 p.GPIOTE_CH1,
37 Input::new(p.P0_12, Pull::Up),
38 InputChannelPolarity::LoToHi,
39 );
40 let ch3 = InputChannel::new(
41 g,
42 p.GPIOTE_CH2,
43 Input::new(p.P0_24, Pull::Up),
44 InputChannelPolarity::Toggle,
45 );
46 let ch4 = InputChannel::new(
47 g,
48 p.GPIOTE_CH3,
49 Input::new(p.P0_25, Pull::Up),
50 InputChannelPolarity::Toggle,
51 );
39 52
40 let button1 = async { 53 let button1 = async {
41 loop { 54 loop {