aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf/src/bin
diff options
context:
space:
mode:
authorDion Dokter <[email protected]>2021-10-18 16:23:39 +0200
committerDario Nieuwenhuis <[email protected]>2021-10-26 14:47:12 +0200
commit11655af034538b463ff8220714e9b97cf53f8f56 (patch)
treeb22cd986313293328f472bb8c9637c59b654af65 /examples/nrf/src/bin
parente6ec81b999541cca847b50075ac0d5d826f97dcd (diff)
Another redo using the feedback.
PPI is now split up into PPI and DPPI under the name 'interconnect'. The tasks and events are tracked and reset in the drop function.
Diffstat (limited to 'examples/nrf/src/bin')
-rw-r--r--examples/nrf/src/bin/buffered_uart.rs4
-rw-r--r--examples/nrf/src/bin/ppi.rs24
-rw-r--r--examples/nrf/src/bin/uart_idle.rs4
3 files changed, 14 insertions, 18 deletions
diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs
index b01c83ce3..69c7de93b 100644
--- a/examples/nrf/src/bin/buffered_uart.rs
+++ b/examples/nrf/src/bin/buffered_uart.rs
@@ -26,7 +26,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
26 let irq = interrupt::take!(UARTE0_UART0); 26 let irq = interrupt::take!(UARTE0_UART0);
27 let mut state = State::new(); 27 let mut state = State::new();
28 let u = unsafe { 28 let u = unsafe {
29 unwrap!(BufferedUarte::new( 29 BufferedUarte::new(
30 &mut state, 30 &mut state,
31 p.UARTE0, 31 p.UARTE0,
32 p.TIMER0, 32 p.TIMER0,
@@ -40,7 +40,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
40 config, 40 config,
41 &mut rx_buffer, 41 &mut rx_buffer,
42 &mut tx_buffer, 42 &mut tx_buffer,
43 )) 43 )
44 }; 44 };
45 pin_mut!(u); 45 pin_mut!(u);
46 46
diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs
index 550893968..4edb5d7c0 100644
--- a/examples/nrf/src/bin/ppi.rs
+++ b/examples/nrf/src/bin/ppi.rs
@@ -10,7 +10,7 @@ use core::future::pending;
10use embassy::executor::Spawner; 10use embassy::executor::Spawner;
11use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; 11use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
12use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; 12use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity};
13use embassy_nrf::ppi::Ppi; 13use embassy_nrf::interconnect::Ppi;
14use embassy_nrf::Peripherals; 14use embassy_nrf::Peripherals;
15use gpiote::{OutputChannel, OutputChannelPolarity}; 15use gpiote::{OutputChannel, OutputChannelPolarity};
16 16
@@ -51,25 +51,21 @@ async fn main(_spawner: Spawner, p: Peripherals) {
51 OutputChannelPolarity::Toggle, 51 OutputChannelPolarity::Toggle,
52 ); 52 );
53 53
54 let mut ppi = Ppi::new(p.PPI_CH0); 54 let mut ppi = Ppi::new_one_to_one(p.PPI_CH0, button1.event_in(), led1.task_out());
55 ppi.publish(button1.event_in()).unwrap();
56 ppi.subscribe(led1.task_out()).unwrap();
57 ppi.enable(); 55 ppi.enable();
58 56
59 let mut ppi = Ppi::new(p.PPI_CH1); 57 let mut ppi = Ppi::new_one_to_one(p.PPI_CH1, button2.event_in(), led1.task_clr());
60 ppi.publish(button2.event_in()).unwrap();
61 ppi.subscribe(led1.task_clr()).unwrap();
62 ppi.enable(); 58 ppi.enable();
63 59
64 let mut ppi = Ppi::new(p.PPI_CH2); 60 let mut ppi = Ppi::new_one_to_one(p.PPI_CH2, button3.event_in(), led1.task_set());
65 ppi.publish(button3.event_in()).unwrap();
66 ppi.subscribe(led1.task_set()).unwrap();
67 ppi.enable(); 61 ppi.enable();
68 62
69 let mut ppi = Ppi::new(p.PPI_CH3); 63 let mut ppi = Ppi::new_one_to_two(
70 ppi.publish(button4.event_in()).unwrap(); 64 p.PPI_CH3,
71 ppi.subscribe(led1.task_out()).unwrap(); 65 button4.event_in(),
72 ppi.subscribe(led2.task_out()).unwrap(); 66 led1.task_out(),
67 led2.task_out(),
68 );
73 ppi.enable(); 69 ppi.enable();
74 70
75 info!("PPI setup!"); 71 info!("PPI setup!");
diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs
index e04e5cf04..e9f4a285a 100644
--- a/examples/nrf/src/bin/uart_idle.rs
+++ b/examples/nrf/src/bin/uart_idle.rs
@@ -21,9 +21,9 @@ async fn main(_spawner: Spawner, p: Peripherals) {
21 21
22 let irq = interrupt::take!(UARTE0_UART0); 22 let irq = interrupt::take!(UARTE0_UART0);
23 let mut uart = unsafe { 23 let mut uart = unsafe {
24 unwrap!(uarte::UarteWithIdle::new( 24 uarte::UarteWithIdle::new(
25 p.UARTE0, p.TIMER0, p.PPI_CH0, p.PPI_CH1, irq, p.P0_08, p.P0_06, NoPin, NoPin, config, 25 p.UARTE0, p.TIMER0, p.PPI_CH0, p.PPI_CH1, irq, p.P0_08, p.P0_06, NoPin, NoPin, config,
26 )) 26 )
27 }; 27 };
28 28
29 info!("uarte initialized!"); 29 info!("uarte initialized!");