diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-06-29 15:53:11 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-06-29 15:53:11 +0000 |
| commit | 4feabb13bfbda46de74be09566118adc1ba49d5d (patch) | |
| tree | 39801dfa890d3d6b94c7a72938484dc136c35514 | |
| parent | fa2cda81db03f66c803c4ae931e1603973750548 (diff) | |
| parent | 3f19879f41e8c39c5c38e7905a180160b24807fc (diff) | |
Merge pull request #1599 from ilikepi63/main
feature(1355): Add trigger to task, triggered + clear to Event
| -rw-r--r-- | embassy-nrf/src/ppi/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs index 7c18da6ee..76757a248 100644 --- a/embassy-nrf/src/ppi/mod.rs +++ b/embassy-nrf/src/ppi/mod.rs | |||
| @@ -137,6 +137,11 @@ impl Task { | |||
| 137 | Self(ptr) | 137 | Self(ptr) |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | /// Triggers this task. | ||
| 141 | pub fn trigger(&mut self) { | ||
| 142 | unsafe { self.0.as_ptr().write_volatile(1) }; | ||
| 143 | } | ||
| 144 | |||
| 140 | pub(crate) fn from_reg<T>(reg: &T) -> Self { | 145 | pub(crate) fn from_reg<T>(reg: &T) -> Self { |
| 141 | Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) | 146 | Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) |
| 142 | } | 147 | } |
| @@ -173,6 +178,16 @@ impl Event { | |||
| 173 | Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) | 178 | Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) |
| 174 | } | 179 | } |
| 175 | 180 | ||
| 181 | /// Describes whether this Event is currently in a triggered state. | ||
| 182 | pub fn is_triggered(&self) -> bool { | ||
| 183 | unsafe { self.0.as_ptr().read_volatile() == 1 } | ||
| 184 | } | ||
| 185 | |||
| 186 | /// Clear the current register's triggered state, reverting it to 0. | ||
| 187 | pub fn clear(&mut self) { | ||
| 188 | unsafe { self.0.as_ptr().write_volatile(0) }; | ||
| 189 | } | ||
| 190 | |||
| 176 | /// Address of publish register for this event. | 191 | /// Address of publish register for this event. |
| 177 | #[cfg(feature = "_dppi")] | 192 | #[cfg(feature = "_dppi")] |
| 178 | pub fn publish_reg(&self) -> *mut u32 { | 193 | pub fn publish_reg(&self) -> *mut u32 { |
