Skip to content

Implement InterruptNumber for bare_metal::Nr #266

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 2 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- New `InterruptNumber` trait is now required on interrupt arguments to the
various NVIC functions, replacing the previous use of `Nr` from bare-metal.
For backwards compatibility, `InterruptNumber` is implemented for types
which are `Nr + Copy`, but this will be removed in a future version.
- Associated const `PTR` is introduced to Core Peripherals to
eventually replace the existing `ptr()` API.
- A delay driver based on SysTick.
Expand Down
11 changes: 10 additions & 1 deletion src/interrupt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Interrupts

pub use bare_metal::{CriticalSection, Mutex};
pub use bare_metal::{CriticalSection, Mutex, Nr};

/// Trait for enums of external interrupt numbers.
///
Expand All @@ -23,6 +23,15 @@ pub unsafe trait InterruptNumber: Copy {
fn number(self) -> u16;
}

/// Implement InterruptNumber for the old bare_metal::Nr trait.
/// This implementation is for backwards compatibility only and will be removed in cortex-m 0.8.
#[deprecated(since="0.7.0", note="Please update your PAC to one using the latest svd2rust")]
unsafe impl<T: Nr + Copy> InterruptNumber for T {
fn number(self) -> u16 {
self.nr() as u16
}
}

/// Disables all interrupts
#[inline]
pub fn disable() {
Expand Down