diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/buffered_uarte.rs similarity index 98% rename from embassy-nrf/src/uarte.rs rename to embassy-nrf/src/buffered_uarte.rs index 3a33e7597..9e138ad4f 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs @@ -133,7 +133,7 @@ enum TxState { /// are disabled before using `Uarte`. See product specification: /// - nrf52832: Section 15.2 /// - nrf52840: Section 6.1.2 -pub struct Uarte { +pub struct BufferedUarte { started: bool, state: UnsafeCell>, } @@ -163,7 +163,7 @@ fn port_bit(port: GpioPort) -> bool { } } -impl Uarte { +impl BufferedUarte { pub fn new(uarte: T, mut pins: Pins, parity: Parity, baudrate: Baudrate) -> Self { // Select pins uarte.psel.rxd.write(|w| { @@ -218,7 +218,7 @@ impl Uarte { // Configure frequency uarte.baudrate.write(|w| w.baudrate().variant(baudrate)); - Uarte { + BufferedUarte { started: false, state: UnsafeCell::new(UarteState { inner: uarte, @@ -262,14 +262,14 @@ impl Uarte { } } -impl Drop for Uarte { +impl Drop for BufferedUarte { fn drop(&mut self) { // stop DMA before dropping, because DMA is using the buffer in `self`. todo!() } } -impl AsyncBufRead for Uarte { +impl AsyncBufRead for BufferedUarte { fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { self.with_state(|s| s.poll_fill_buf(cx)) } @@ -279,7 +279,7 @@ impl AsyncBufRead for Uarte { } } -impl AsyncWrite for Uarte { +impl AsyncWrite for BufferedUarte { fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll> { self.with_state(|s| s.poll_write(cx, buf)) } diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 7b3368d66..0ca328138 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -51,11 +51,11 @@ pub use nrf52840_hal as hal; // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt; +pub mod buffered_uarte; pub mod gpiote; pub mod interrupt; #[cfg(feature = "52840")] pub mod qspi; pub mod rtc; -pub mod uarte; pub use cortex_m_rt::interrupt; diff --git a/examples/src/bin/uart.rs b/examples/src/bin/uart.rs index 553bbb356..e664fcef2 100644 --- a/examples/src/bin/uart.rs +++ b/examples/src/bin/uart.rs @@ -13,7 +13,7 @@ use nrf52840_hal::gpio; use embassy::executor::{task, Executor}; use embassy::io::{AsyncBufRead, AsyncBufReadExt, AsyncWrite, AsyncWriteExt}; use embassy::util::Forever; -use embassy_nrf::uarte; +use embassy_nrf::buffered_uarte; #[task] async fn run() { @@ -21,7 +21,7 @@ async fn run() { let port0 = gpio::p0::Parts::new(p.P0); - let pins = uarte::Pins { + let pins = buffered_uarte::Pins { rxd: port0.p0_08.into_floating_input().degrade(), txd: port0 .p0_06 @@ -31,11 +31,11 @@ async fn run() { rts: None, }; - let u = uarte::Uarte::new( + let u = buffered_uarte::BufferedUarte::new( p.UARTE0, pins, - uarte::Parity::EXCLUDED, - uarte::Baudrate::BAUD115200, + buffered_uarte::Parity::EXCLUDED, + buffered_uarte::Baudrate::BAUD115200, ); pin_mut!(u);