From 92f269f74181d7079650c669b37b5671f0379a7e Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 27 Oct 2018 12:45:59 +0200 Subject: deprecate NVIC.{clear,set}_pending in favor of NVIC::{un,}pend NVIC::{un,}pend are static methods that don't require an instance of NVIC to be invoked. --- src/peripheral/nvic.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/peripheral/nvic.rs b/src/peripheral/nvic.rs index 1005799..c59c2c8 100644 --- a/src/peripheral/nvic.rs +++ b/src/peripheral/nvic.rs @@ -69,13 +69,12 @@ pub struct RegisterBlock { impl NVIC { /// Clears `interrupt`'s pending state + #[deprecated(since = "0.5.8", note = "Use `NVIC::unpend`")] pub fn clear_pending(&mut self, interrupt: I) where I: Nr, { - let nr = interrupt.nr(); - - unsafe { self.icpr[usize::from(nr / 32)].write(1 << (nr % 32)) } + Self::unpend(interrupt) } /// Disables `interrupt` @@ -161,13 +160,23 @@ impl NVIC { } /// Forces `interrupt` into pending state - pub fn set_pending(&mut self, interrupt: I) + pub fn pend(interrupt: I) where I: Nr, { let nr = interrupt.nr(); - unsafe { self.ispr[usize::from(nr / 32)].write(1 << (nr % 32)) } + // NOTE(unsafe) atomic stateless write; ICPR doesn't store any state + unsafe { (*Self::ptr()).ispr[usize::from(nr / 32)].write(1 << (nr % 32)) } + } + + /// Forces `interrupt` into pending state + #[deprecated(since = "0.5.8", note = "Use `NVIC::pend`")] + pub fn set_pending(&mut self, interrupt: I) + where + I: Nr, + { + Self::pend(interrupt) } /// Sets the "priority" of `interrupt` to `prio` @@ -203,6 +212,17 @@ impl NVIC { } } + /// Clears `interrupt`'s pending state + pub fn unpend(interrupt: I) + where + I: Nr, + { + let nr = interrupt.nr(); + + // NOTE(unsafe) atomic stateless write; ICPR doesn't store any state + unsafe { (*Self::ptr()).icpr[usize::from(nr / 32)].write(1 << (nr % 32)) } + } + #[cfg(armv6m)] fn ipr_index(interrupt: &I) -> usize where -- cgit v1.2.3