Closed Nemo157 closed 6 years ago
Opening this issue to avoid polluting https://github.com/japaric/nb/issues/13 with too much device specific discussion.
The current impl embedded_hal::serial::Write for Tx<UART0> is blocking, the easy implementation of
impl embedded_hal::serial::Write for Tx<UART0>
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.
events_txdrdy
Thanks for the ticket. I'll have a look.
Turns out it was rather easy to address by just pumping in a \0 byte during initialisation even before enabling the UART.
I’m surprised that works, but happy to hear it :)
Opening this issue to avoid polluting https://github.com/japaric/nb/issues/13 with too much device specific discussion.
The current
impl embedded_hal::serial::Write for Tx<UART0>
is blocking, the easy implementation ofdoesn'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.