Skip to content
This repository was archived by the owner on May 15, 2021. It is now read-only.
This repository was archived by the owner on May 15, 2021. It is now read-only.

serial::Write implementation is blocking #4

Closed
@Nemo157

Description

@Nemo157

Opening this issue to avoid polluting rust-embedded/nb#13 with too much device specific discussion.


The current impl embedded_hal::serial::Write for Tx<UART0> is blocking, the easy implementation of

fn write(&mut self, byte: u8) -> nb::Result<(), !> {
    let uart = unsafe { &*UART0::ptr() };
    if uart.events_txdrdy.read().bits() == 1 {
         uart.events_txdrdy.reset();
         uart.txd.write(|w| unsafe { w.bits(u32::from(byte)) });
         Ok(())
    } else {
        Err(nb::Error::WouldBlock)
    }
}

doesn't work because events_txdrdy is only set after a byte is transmitted, not when the peripheral is first enabled. It doesn't appear to be possible to manually set event registers as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions