From 19588a9e6fb4474a2b3bdb64a97db9798027c700 Mon Sep 17 00:00:00 2001 From: pennae Date: Mon, 1 May 2023 15:22:39 +0200 Subject: [PATCH] rp/uart: rename state to buffered_state we'll add a dma state soon as well. --- embassy-rp/src/uart/buffered.rs | 24 ++++++++++++------------ embassy-rp/src/uart/mod.rs | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index b87345ee..f9fae4c5 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs @@ -47,7 +47,7 @@ pub(crate) fn init_buffers<'d, T: Instance + 'd>( tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], ) { - let state = T::state(); + let state = T::buffered_state(); let len = tx_buffer.len(); unsafe { state.tx_buf.init(tx_buffer.as_mut_ptr(), len) }; let len = rx_buffer.len(); @@ -189,7 +189,7 @@ impl<'d, T: Instance> BufferedUartRx<'d, T> { return Poll::Ready(Ok(0)); } - let state = T::state(); + let state = T::buffered_state(); let mut rx_reader = unsafe { state.rx_buf.reader() }; let n = rx_reader.pop(|data| { let n = data.len().min(buf.len()); @@ -221,7 +221,7 @@ impl<'d, T: Instance> BufferedUartRx<'d, T> { } loop { - let state = T::state(); + let state = T::buffered_state(); let mut rx_reader = unsafe { state.rx_buf.reader() }; let n = rx_reader.pop(|data| { let n = data.len().min(buf.len()); @@ -247,7 +247,7 @@ impl<'d, T: Instance> BufferedUartRx<'d, T> { fn fill_buf<'a>() -> impl Future> { poll_fn(move |cx| { - let state = T::state(); + let state = T::buffered_state(); let mut rx_reader = unsafe { state.rx_buf.reader() }; let (p, n) = rx_reader.pop_buf(); if n == 0 { @@ -261,7 +261,7 @@ impl<'d, T: Instance> BufferedUartRx<'d, T> { } fn consume(amt: usize) { - let state = T::state(); + let state = T::buffered_state(); let mut rx_reader = unsafe { state.rx_buf.reader() }; rx_reader.pop_done(amt); @@ -315,7 +315,7 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> { return Poll::Ready(Ok(0)); } - let state = T::state(); + let state = T::buffered_state(); let mut tx_writer = unsafe { state.tx_buf.writer() }; let n = tx_writer.push(|data| { let n = data.len().min(buf.len()); @@ -338,7 +338,7 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> { fn flush() -> impl Future> { poll_fn(move |cx| { - let state = T::state(); + let state = T::buffered_state(); if !state.tx_buf.is_empty() { state.tx_waker.register(cx.waker()); return Poll::Pending; @@ -354,7 +354,7 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> { } loop { - let state = T::state(); + let state = T::buffered_state(); let mut tx_writer = unsafe { state.tx_buf.writer() }; let n = tx_writer.push(|data| { let n = data.len().min(buf.len()); @@ -375,7 +375,7 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> { pub fn blocking_flush(&mut self) -> Result<(), Error> { loop { - let state = T::state(); + let state = T::buffered_state(); if state.tx_buf.is_empty() { return Ok(()); } @@ -422,7 +422,7 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> { impl<'d, T: Instance> Drop for BufferedUartRx<'d, T> { fn drop(&mut self) { - let state = T::state(); + let state = T::buffered_state(); unsafe { state.rx_buf.deinit(); @@ -437,7 +437,7 @@ impl<'d, T: Instance> Drop for BufferedUartRx<'d, T> { impl<'d, T: Instance> Drop for BufferedUartTx<'d, T> { fn drop(&mut self) { - let state = T::state(); + let state = T::buffered_state(); unsafe { state.tx_buf.deinit(); @@ -452,7 +452,7 @@ impl<'d, T: Instance> Drop for BufferedUartTx<'d, T> { pub(crate) unsafe fn on_interrupt(_: *mut ()) { let r = T::regs(); - let s = T::state(); + let s = T::buffered_state(); unsafe { // Clear TX and error interrupt flags diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index dd4a1cce..0b323978 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs @@ -763,7 +763,7 @@ mod sealed { fn regs() -> pac::uart::Uart; #[cfg(feature = "nightly")] - fn state() -> &'static buffered::State; + fn buffered_state() -> &'static buffered::State; } pub trait TxPin {} pub trait RxPin {} @@ -801,7 +801,7 @@ macro_rules! impl_instance { } #[cfg(feature = "nightly")] - fn state() -> &'static buffered::State { + fn buffered_state() -> &'static buffered::State { static STATE: buffered::State = buffered::State::new(); &STATE }