We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8fc2df4 commit 0ebf91bCopy full SHA for 0ebf91b
1 file changed
nrf-hal-common/src/uarte.rs
@@ -622,17 +622,17 @@ where
622
let uarte = unsafe { &*T::ptr() };
623
624
// Prevent writing to buffer while DMA transfer is in progress.
625
- if uarte.events_txstarted.read().bits() == 1 {
+ if uarte.events_txstarted.read().bits() == 1 && uarte.events_endtx.read().bits() == 0 {
626
return Err(nb::Error::WouldBlock);
627
}
628
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()
+ if self.written >= self.tx_buf.len() {
+ self.flush()?;
635
+
+ self.tx_buf[self.written] = b;
+ self.written += 1;
+ Ok(())
636
637
638
/// Flush the TX buffer non-blocking. Returns nb::Error::WouldBlock if not yet flushed.
0 commit comments