aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2018-10-27 12:45:59 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2018-10-27 12:45:59 +0200
commit92f269f74181d7079650c669b37b5671f0379a7e (patch)
treec1865a7703f13ef9a4f2bd96c877fc7ab0a3f221 /src
parentd394540ca3583d0fdc959538f1f9201a5e132c5a (diff)
downloadcortex-m-92f269f74181d7079650c669b37b5671f0379a7e.tar.gz
cortex-m-92f269f74181d7079650c669b37b5671f0379a7e.tar.zst
cortex-m-92f269f74181d7079650c669b37b5671f0379a7e.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/peripheral/nvic.rs30
1 files changed, 25 insertions, 5 deletions
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<I>(&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<I>(&mut self, interrupt: I)
+ pub fn pend<I>(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<I>(&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<I>(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<I>(interrupt: &I) -> usize
where