Skip to content

Commit 5a16c71

Browse files
committed
Fix uarte write
1 parent 344e78b commit 5a16c71

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

nrf-hal-common/src/uarte.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -585,17 +585,17 @@ where
585585
let uarte = unsafe { &*T::ptr() };
586586

587587
// Prevent writing to buffer while DMA transfer is in progress.
588-
if uarte.events_txstarted.read().bits() == 1 {
588+
if uarte.events_txstarted.read().bits() == 1 && uarte.events_endtx.read().bits() == 0 {
589589
return Err(nb::Error::WouldBlock);
590590
}
591591

592-
if self.written < self.tx_buf.len() {
593-
self.tx_buf[self.written] = b;
594-
self.written += 1;
595-
Ok(())
596-
} else {
597-
self.flush()
592+
if self.written >= self.tx_buf.len() {
593+
self.flush()?;
598594
}
595+
596+
self.tx_buf[self.written] = b;
597+
self.written += 1;
598+
Ok(())
599599
}
600600

601601
/// Flush the TX buffer non-blocking. Returns nb::Error::WouldBlock if not yet flushed.

0 commit comments

Comments
 (0)