diff options
| author | Dario Nieuwenhuis <[email protected]> | 2020-12-28 23:57:50 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2020-12-28 23:57:50 +0100 |
| commit | 267ec334ac766097efb4c847c14b6e2fde44f9af (patch) | |
| tree | c842c9f703f259ecd4c3620e9fb63e8300c60901 | |
| parent | 4a7344cb6f33bc6acdb982b7c180e0da81ad2710 (diff) | |
Rename Uarte -> BufferedUarte
| -rw-r--r-- | embassy-nrf/src/buffered_uarte.rs (renamed from embassy-nrf/src/uarte.rs) | 12 | ||||
| -rw-r--r-- | embassy-nrf/src/lib.rs | 2 | ||||
| -rw-r--r-- | examples/src/bin/uart.rs | 10 |
3 files changed, 12 insertions, 12 deletions
diff --git a/embassy-nrf/src/uarte.rs b/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 { | |||
| 133 | /// are disabled before using `Uarte`. See product specification: | 133 | /// are disabled before using `Uarte`. See product specification: |
| 134 | /// - nrf52832: Section 15.2 | 134 | /// - nrf52832: Section 15.2 |
| 135 | /// - nrf52840: Section 6.1.2 | 135 | /// - nrf52840: Section 6.1.2 |
| 136 | pub struct Uarte<T: Instance> { | 136 | pub struct BufferedUarte<T: Instance> { |
| 137 | started: bool, | 137 | started: bool, |
| 138 | state: UnsafeCell<UarteState<T>>, | 138 | state: UnsafeCell<UarteState<T>>, |
| 139 | } | 139 | } |
| @@ -163,7 +163,7 @@ fn port_bit(port: GpioPort) -> bool { | |||
| 163 | } | 163 | } |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | impl<T: Instance> Uarte<T> { | 166 | impl<T: Instance> BufferedUarte<T> { |
| 167 | pub fn new(uarte: T, mut pins: Pins, parity: Parity, baudrate: Baudrate) -> Self { | 167 | pub fn new(uarte: T, mut pins: Pins, parity: Parity, baudrate: Baudrate) -> Self { |
| 168 | // Select pins | 168 | // Select pins |
| 169 | uarte.psel.rxd.write(|w| { | 169 | uarte.psel.rxd.write(|w| { |
| @@ -218,7 +218,7 @@ impl<T: Instance> Uarte<T> { | |||
| 218 | // Configure frequency | 218 | // Configure frequency |
| 219 | uarte.baudrate.write(|w| w.baudrate().variant(baudrate)); | 219 | uarte.baudrate.write(|w| w.baudrate().variant(baudrate)); |
| 220 | 220 | ||
| 221 | Uarte { | 221 | BufferedUarte { |
| 222 | started: false, | 222 | started: false, |
| 223 | state: UnsafeCell::new(UarteState { | 223 | state: UnsafeCell::new(UarteState { |
| 224 | inner: uarte, | 224 | inner: uarte, |
| @@ -262,14 +262,14 @@ impl<T: Instance> Uarte<T> { | |||
| 262 | } | 262 | } |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | impl<T: Instance> Drop for Uarte<T> { | 265 | impl<T: Instance> Drop for BufferedUarte<T> { |
| 266 | fn drop(&mut self) { | 266 | fn drop(&mut self) { |
| 267 | // stop DMA before dropping, because DMA is using the buffer in `self`. | 267 | // stop DMA before dropping, because DMA is using the buffer in `self`. |
| 268 | todo!() | 268 | todo!() |
| 269 | } | 269 | } |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | impl<T: Instance> AsyncBufRead for Uarte<T> { | 272 | impl<T: Instance> AsyncBufRead for BufferedUarte<T> { |
| 273 | fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>> { | 273 | fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>> { |
| 274 | self.with_state(|s| s.poll_fill_buf(cx)) | 274 | self.with_state(|s| s.poll_fill_buf(cx)) |
| 275 | } | 275 | } |
| @@ -279,7 +279,7 @@ impl<T: Instance> AsyncBufRead for Uarte<T> { | |||
| 279 | } | 279 | } |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | impl<T: Instance> AsyncWrite for Uarte<T> { | 282 | impl<T: Instance> AsyncWrite for BufferedUarte<T> { |
| 283 | fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>> { | 283 | fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>> { |
| 284 | self.with_state(|s| s.poll_write(cx, buf)) | 284 | self.with_state(|s| s.poll_write(cx, buf)) |
| 285 | } | 285 | } |
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; | |||
| 51 | // This mod MUST go first, so that the others see its macros. | 51 | // This mod MUST go first, so that the others see its macros. |
| 52 | pub(crate) mod fmt; | 52 | pub(crate) mod fmt; |
| 53 | 53 | ||
| 54 | pub mod buffered_uarte; | ||
| 54 | pub mod gpiote; | 55 | pub mod gpiote; |
| 55 | pub mod interrupt; | 56 | pub mod interrupt; |
| 56 | #[cfg(feature = "52840")] | 57 | #[cfg(feature = "52840")] |
| 57 | pub mod qspi; | 58 | pub mod qspi; |
| 58 | pub mod rtc; | 59 | pub mod rtc; |
| 59 | pub mod uarte; | ||
| 60 | 60 | ||
| 61 | pub use cortex_m_rt::interrupt; | 61 | 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; | |||
| 13 | use embassy::executor::{task, Executor}; | 13 | use embassy::executor::{task, Executor}; |
| 14 | use embassy::io::{AsyncBufRead, AsyncBufReadExt, AsyncWrite, AsyncWriteExt}; | 14 | use embassy::io::{AsyncBufRead, AsyncBufReadExt, AsyncWrite, AsyncWriteExt}; |
| 15 | use embassy::util::Forever; | 15 | use embassy::util::Forever; |
| 16 | use embassy_nrf::uarte; | 16 | use embassy_nrf::buffered_uarte; |
| 17 | 17 | ||
| 18 | #[task] | 18 | #[task] |
| 19 | async fn run() { | 19 | async fn run() { |
| @@ -21,7 +21,7 @@ async fn run() { | |||
| 21 | 21 | ||
| 22 | let port0 = gpio::p0::Parts::new(p.P0); | 22 | let port0 = gpio::p0::Parts::new(p.P0); |
| 23 | 23 | ||
| 24 | let pins = uarte::Pins { | 24 | let pins = buffered_uarte::Pins { |
| 25 | rxd: port0.p0_08.into_floating_input().degrade(), | 25 | rxd: port0.p0_08.into_floating_input().degrade(), |
| 26 | txd: port0 | 26 | txd: port0 |
| 27 | .p0_06 | 27 | .p0_06 |
| @@ -31,11 +31,11 @@ async fn run() { | |||
| 31 | rts: None, | 31 | rts: None, |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | let u = uarte::Uarte::new( | 34 | let u = buffered_uarte::BufferedUarte::new( |
| 35 | p.UARTE0, | 35 | p.UARTE0, |
| 36 | pins, | 36 | pins, |
| 37 | uarte::Parity::EXCLUDED, | 37 | buffered_uarte::Parity::EXCLUDED, |
| 38 | uarte::Baudrate::BAUD115200, | 38 | buffered_uarte::Baudrate::BAUD115200, |
| 39 | ); | 39 | ); |
| 40 | pin_mut!(u); | 40 | pin_mut!(u); |
| 41 | 41 | ||
