From 11655af034538b463ff8220714e9b97cf53f8f56 Mon Sep 17 00:00:00 2001 From: Dion Dokter Date: Mon, 18 Oct 2021 16:23:39 +0200 Subject: 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. --- examples/nrf/src/bin/buffered_uart.rs | 4 ++-- examples/nrf/src/bin/ppi.rs | 24 ++++++++++-------------- examples/nrf/src/bin/uart_idle.rs | 4 ++-- 3 files changed, 14 insertions(+), 18 deletions(-) (limited to 'examples') 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) { let irq = interrupt::take!(UARTE0_UART0); let mut state = State::new(); let u = unsafe { - unwrap!(BufferedUarte::new( + BufferedUarte::new( &mut state, p.UARTE0, p.TIMER0, @@ -40,7 +40,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { config, &mut rx_buffer, &mut tx_buffer, - )) + ) }; pin_mut!(u); 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; use embassy::executor::Spawner; use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; -use embassy_nrf::ppi::Ppi; +use embassy_nrf::interconnect::Ppi; use embassy_nrf::Peripherals; use gpiote::{OutputChannel, OutputChannelPolarity}; @@ -51,25 +51,21 @@ async fn main(_spawner: Spawner, p: Peripherals) { OutputChannelPolarity::Toggle, ); - let mut ppi = Ppi::new(p.PPI_CH0); - ppi.publish(button1.event_in()).unwrap(); - ppi.subscribe(led1.task_out()).unwrap(); + let mut ppi = Ppi::new_one_to_one(p.PPI_CH0, button1.event_in(), led1.task_out()); ppi.enable(); - let mut ppi = Ppi::new(p.PPI_CH1); - ppi.publish(button2.event_in()).unwrap(); - ppi.subscribe(led1.task_clr()).unwrap(); + let mut ppi = Ppi::new_one_to_one(p.PPI_CH1, button2.event_in(), led1.task_clr()); ppi.enable(); - let mut ppi = Ppi::new(p.PPI_CH2); - ppi.publish(button3.event_in()).unwrap(); - ppi.subscribe(led1.task_set()).unwrap(); + let mut ppi = Ppi::new_one_to_one(p.PPI_CH2, button3.event_in(), led1.task_set()); ppi.enable(); - let mut ppi = Ppi::new(p.PPI_CH3); - ppi.publish(button4.event_in()).unwrap(); - ppi.subscribe(led1.task_out()).unwrap(); - ppi.subscribe(led2.task_out()).unwrap(); + let mut ppi = Ppi::new_one_to_two( + p.PPI_CH3, + button4.event_in(), + led1.task_out(), + led2.task_out(), + ); ppi.enable(); 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) { let irq = interrupt::take!(UARTE0_UART0); let mut uart = unsafe { - unwrap!(uarte::UarteWithIdle::new( + uarte::UarteWithIdle::new( p.UARTE0, p.TIMER0, p.PPI_CH0, p.PPI_CH1, irq, p.P0_08, p.P0_06, NoPin, NoPin, config, - )) + ) }; info!("uarte initialized!"); -- cgit