From e6ec81b999541cca847b50075ac0d5d826f97dcd Mon Sep 17 00:00:00 2001 From: Dion Dokter Date: Thu, 14 Oct 2021 15:13:45 +0200 Subject: [PATCH] Fixed examples and added defmt format to the new error types --- embassy-nrf/src/buffered_uarte.rs | 1 + embassy-nrf/src/ppi.rs | 1 + embassy-nrf/src/uarte.rs | 1 + examples/nrf/src/bin/buffered_uart.rs | 4 ++-- examples/nrf/src/bin/uart_idle.rs | 4 ++-- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index f7e55e42..8ec0fb2c 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs @@ -25,6 +25,7 @@ pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Pari #[non_exhaustive] #[derive(Clone, Debug)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Error { PpiError(ppi::Error), } diff --git a/embassy-nrf/src/ppi.rs b/embassy-nrf/src/ppi.rs index 1f825bf4..7aaf17ee 100644 --- a/embassy-nrf/src/ppi.rs +++ b/embassy-nrf/src/ppi.rs @@ -23,6 +23,7 @@ use embassy_hal_common::{unborrow, unsafe_impl_unborrow}; /// Error type of the PPI driver #[non_exhaustive] #[derive(Clone, Debug)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Error { /// There is no capacity to enable this task or event (nRF51 & nRF52 only) NoCapacityLeft, diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index f2bf01f1..71401a56 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -27,6 +27,7 @@ pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Pari #[non_exhaustive] #[derive(Clone, Debug)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Error { PpiError(crate::ppi::Error), } diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index 69c7de93..b01c83ce 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 { - BufferedUarte::new( + unwrap!(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/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index e9f4a285..e04e5cf0 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 { - uarte::UarteWithIdle::new( + unwrap!(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!");