diff options
author | 2020-09-21 23:55:43 +0000 | |
---|---|---|
committer | 2020-09-21 23:55:43 +0000 | |
commit | 43b9383cbedc5b0fb0b2df51df0e7af742fb7b61 (patch) | |
tree | 1bdb110a4d9d2192c8b546c23d7e10dadb27b4b5 /src | |
parent | aa77c89a5ff0f81f5bbd52799fe8caf12fb493d6 (diff) | |
parent | b7541ddb57b268ebec9591730898c97bd98d36d6 (diff) | |
download | cortex-m-43b9383cbedc5b0fb0b2df51df0e7af742fb7b61.tar.gz cortex-m-43b9383cbedc5b0fb0b2df51df0e7af742fb7b61.tar.zst cortex-m-43b9383cbedc5b0fb0b2df51df0e7af742fb7b61.zip |
Merge #266
266: Implement InterruptNumber for bare_metal::Nr r=therealprof a=adamgreig
This PR aims to help backwards compatibility by implementing the new `InterruptNumber` trait (coming in cortex-m 0.7) for the old `bare_metal::Nr` trait. With this included in cortex-m 0.7, existing PACs generated from the current svd2rust (0.17) will work with cortex-m 0.7, and new PACs generated from a to-be-released svd2rust which uses `InterruptNumber directly will also work.
We can then remove this implementation in cortex-m 0.8 and upgrade cortex-m to depend on bare-metal 1.0 (or not depend on it at all) at that time.
With this PR in place, the upgrade path looks like:
* We release cortex-m 0.7, which users can upgrade to without needing a new PAC
* We release svd2rust 0.18, which will generate new PACs
* PACs update, now requiring cortex-m 0.7
* Users can update their PAC so long as they've already upgraded to cortex-m 0.7
* For cortex-m 0.8, we drop this impl and move off bare-metal 0.2, and a new PAC is required to use 0.8 onwards
Co-authored-by: Adam Greig <adam@adamgreig.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/interrupt.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/interrupt.rs b/src/interrupt.rs index 68719ec..ad76ff2 100644 --- a/src/interrupt.rs +++ b/src/interrupt.rs @@ -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. /// @@ -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() { |