From 2aa2b843ce6b96aacd72e52fe29b550e7ebc55b3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 29 Jun 2023 17:11:36 +0200 Subject: [PATCH] feature(1355): Add trigger to task, triggered + clear to Event --- embassy-nrf/src/ppi/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs index 7c18da6e..ba95849e 100644 --- a/embassy-nrf/src/ppi/mod.rs +++ b/embassy-nrf/src/ppi/mod.rs @@ -137,6 +137,11 @@ impl Task { Self(ptr) } + // Triggers this task. + pub unsafe fn trigger(&mut self) { + self.0.write(|w| unsafe { w.bits(1) }); + } + pub(crate) fn from_reg(reg: &T) -> Self { Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) } @@ -173,6 +178,16 @@ impl Event { Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) } + // Describes whether this Event is currently in a triggered state. + pub unsafe fn is_triggered(&self) -> bool { + self.0.read().bits() == 1 + } + + // Clear the current register's triggered state, reverting it to 0. + pub unsafe fn clear(&mut self) { + self.0.write(|w| unsafe { w.bits(0) }); + } + /// Address of publish register for this event. #[cfg(feature = "_dppi")] pub fn publish_reg(&self) -> *mut u32 {