Skip to content

deprecate NVIC.{clear,set}_pending in favor of NVIC::{un,}pend #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/peripheral/nvic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down