Skip to content

Commit

Permalink
Fix uarte write
Browse files Browse the repository at this point in the history
  • Loading branch information
hargoniX committed Aug 10, 2021
1 parent 344e78b commit 5a16c71
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions nrf-hal-common/src/uarte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,17 +585,17 @@ where
let uarte = unsafe { &*T::ptr() };

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

if self.written < self.tx_buf.len() {
self.tx_buf[self.written] = b;
self.written += 1;
Ok(())
} else {
self.flush()
if self.written >= self.tx_buf.len() {
self.flush()?;
}

self.tx_buf[self.written] = b;
self.written += 1;
Ok(())
}

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

0 comments on commit 5a16c71

Please sign in to comment.