Rename Uarte -> BufferedUarte
This commit is contained in:
parent
4a7344cb6f
commit
267ec334ac
@ -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<T: Instance> {
|
||||
pub struct BufferedUarte<T: Instance> {
|
||||
started: bool,
|
||||
state: UnsafeCell<UarteState<T>>,
|
||||
}
|
||||
@ -163,7 +163,7 @@ fn port_bit(port: GpioPort) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Instance> Uarte<T> {
|
||||
impl<T: Instance> BufferedUarte<T> {
|
||||
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<T: Instance> Uarte<T> {
|
||||
// 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<T: Instance> Uarte<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Instance> Drop for Uarte<T> {
|
||||
impl<T: Instance> Drop for BufferedUarte<T> {
|
||||
fn drop(&mut self) {
|
||||
// stop DMA before dropping, because DMA is using the buffer in `self`.
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Instance> AsyncBufRead for Uarte<T> {
|
||||
impl<T: Instance> AsyncBufRead for BufferedUarte<T> {
|
||||
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>> {
|
||||
self.with_state(|s| s.poll_fill_buf(cx))
|
||||
}
|
||||
@ -279,7 +279,7 @@ impl<T: Instance> AsyncBufRead for Uarte<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Instance> AsyncWrite for Uarte<T> {
|
||||
impl<T: Instance> AsyncWrite for BufferedUarte<T> {
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>> {
|
||||
self.with_state(|s| s.poll_write(cx, buf))
|
||||
}
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user