Move the event resets closer to where we check the events.
@@ -179,8 +179,6 @@ where
// before any DMA action has started.
compiler_fence(SeqCst);
- // Reset the events.
- self.0.events_endtx.reset();
// Set up the DMA write.
self.0.txd.ptr.write(|w|
@@ -200,11 +198,15 @@ where
// values.
unsafe { w.maxcnt().bits(tx_buffer.len() as _) });
+ // Reset the event
+ self.0.events_endtx.reset();
+
// Start UARTE Transmit transaction.
self.0.tasks_starttx.write(|w|
// `1` is a valid value to write to task registers.
unsafe { w.bits(1) });
+
// Wait for transmission to end.
while self.0.events_endtx.read().bits() == 0 {
// TODO: Do something here which uses less power. Like `wfi`.
@@ -215,6 +217,9 @@ where
// after all possible DMA actions have completed.
compiler_fence(SeqCst);
+ // Reset the event
+ self.0.events_txstopped.reset();
+
// Lower power consumption by disabling the transmitter once we're
// finished.
self.0.tasks_stoptx.write(|w|
