Skip to content

Commit 0ebf91b

Browse files
committed
Fix uarte write
1 parent 8fc2df4 commit 0ebf91b

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
@@ -622,17 +622,17 @@ where
622622
let uarte = unsafe { &*T::ptr() };
623623

624624
// Prevent writing to buffer while DMA transfer is in progress.
625-
if uarte.events_txstarted.read().bits() == 1 {
625+
if uarte.events_txstarted.read().bits() == 1 && uarte.events_endtx.read().bits() == 0 {
626626
return Err(nb::Error::WouldBlock);
627627
}
628628

629-
if self.written < self.tx_buf.len() {
630-
self.tx_buf[self.written] = b;
631-
self.written += 1;
632-
Ok(())
633-
} else {
634-
self.flush()
629+
if self.written >= self.tx_buf.len() {
630+
self.flush()?;
635631
}
632+
633+
self.tx_buf[self.written] = b;
634+
self.written += 1;
635+
Ok(())
636636
}
637637

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

0 commit comments

Comments
 (0)