-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new cortex-m-interrupt-number crate
- Loading branch information
Showing
8 changed files
with
46 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "cortex-m-interrupt-number" | ||
version = "1.0.0" | ||
edition = "2021" | ||
categories = ["embedded", "hardware-support", "no-std"] | ||
description = "Shared trait for Cortex-M interrupt numbers" | ||
keywords = ["arm", "cortex-m", "register", "peripheral"] | ||
license = "MIT OR Apache-2.0" | ||
readme = "README.md" | ||
repository = "https://github.com/rust-embedded/cortex-m" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# cortex-m-interrupt-number | ||
|
||
This crate provides the definition of a trait that is shared between | ||
the `cortex-m` crate and all peripheral access crates (PACs) for | ||
Cortex-M microcontrollers. | ||
|
||
The PACs must implement the `InterruptNumber` trait on an enum of possible | ||
interrupts; refer to the `InterruptNumber` [documentation] for more details. | ||
|
||
[documentation]: https://docs.rs/cortex-m-interrupt-number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// Trait for enums of external interrupt numbers. | ||
/// | ||
/// This trait should be implemented by a peripheral access crate (PAC) | ||
/// on its enum of available external interrupts for a specific device. | ||
/// Each variant must convert to a u16 of its interrupt number, | ||
/// which is its exception number - 16. | ||
/// | ||
/// # Safety | ||
/// | ||
/// This trait must only be implemented on enums of device interrupts. Each | ||
/// enum variant must represent a distinct value (no duplicates are permitted), | ||
/// and must always return the same value (do not change at runtime). | ||
/// | ||
/// These requirements ensure safe nesting of critical sections. | ||
pub unsafe trait InterruptNumber: Copy { | ||
/// Return the interrupt number associated with this variant. | ||
/// | ||
/// See trait documentation for safety requirements. | ||
fn number(self) -> u16; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters