From c54303be755d021f8a5a6b89c3032cfe834c6bc7 Mon Sep 17 00:00:00 2001 From: huntc Date: Mon, 10 Jan 2022 19:14:02 +1100 Subject: [PATCH] Makes the uarte endtx event available This commit allows event_endtx to be used outside of the Uarte itself. As a consequence, PPI can be used to drive tasks given the end of transmission on the Uarte. This is particularly useful for situations like RS485 where a GPIO must be set to high when transmitting then cleared when done. A non-ppi approach can cause a delay in the clearing of this GPIO as other Embassy tasks might become scheduled. --- embassy-nrf/src/uarte.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 131d07465..38480ecca 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -151,6 +151,12 @@ impl<'d, T: Instance> Uarte<'d, T> { (self.tx, self.rx) } + /// Return the endtx event for use with PPI + pub fn event_endtx(&self) -> Event { + let r = T::regs(); + Event::from_reg(&r.events_endtx) + } + fn on_interrupt(_: *mut ()) { let r = T::regs(); let s = T::state();