mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
Merge pull request #509 from jorgeig-space/v0.5.x
Use cortex-m `InterruptNumber` instead of bare_metal `Nr`
This commit is contained in:
commit
90f963e3bb
6 changed files with 77 additions and 9 deletions
18
Cargo.toml
18
Cargo.toml
|
@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0"
|
|||
name = "cortex-m-rtic"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/rtic-rs/cortex-m-rtic"
|
||||
version = "0.5.7"
|
||||
version = "0.5.8"
|
||||
|
||||
[lib]
|
||||
name = "rtic"
|
||||
|
@ -51,12 +51,21 @@ name = "types"
|
|||
required-features = ["__v7"]
|
||||
|
||||
[dependencies]
|
||||
cortex-m = "0.6.2"
|
||||
cortex-m-rtic-macros = { path = "macros", version = "0.5.3" }
|
||||
rtic-core = "0.3.0"
|
||||
cortex-m-rt = "0.6.9"
|
||||
heapless = "0.6.1"
|
||||
|
||||
[dependencies.cortex-m]
|
||||
package = "cortex-m"
|
||||
version = "0.6.2"
|
||||
optional = true
|
||||
|
||||
[dependencies.cortex-m-7]
|
||||
package = "cortex-m"
|
||||
version = "0.7.3"
|
||||
optional = true
|
||||
|
||||
[build-dependencies]
|
||||
version_check = "0.9"
|
||||
|
||||
|
@ -65,7 +74,9 @@ optional = true
|
|||
version = "0.1.0-alpha.2"
|
||||
|
||||
[dev-dependencies]
|
||||
lm3s6965 = "0.1.3"
|
||||
# The difference between this git version and the crates.io version is that this version implements Copy & Clone on Interrupt
|
||||
# which is needed for the cortex-m-7 feature (to use InterruptNumber instead of Nr on interrups)
|
||||
lm3s6965 = { git = "https://github.com/japaric/lm3s6965.git", version= "0.1.3", rev = "facf63aa0169c773175a143f6014a1d0977fb74f" }
|
||||
cortex-m-semihosting = "0.3.3"
|
||||
|
||||
[dev-dependencies.panic-semihosting]
|
||||
|
@ -76,6 +87,7 @@ version = "0.5.2"
|
|||
trybuild = "1"
|
||||
|
||||
[features]
|
||||
default = ["cortex-m"]
|
||||
heterogeneous = ["cortex-m-rtic-macros/heterogeneous", "microamp"]
|
||||
homogeneous = ["cortex-m-rtic-macros/homogeneous"]
|
||||
# used for testing this crate; do not use in applications
|
||||
|
|
|
@ -7,12 +7,17 @@ publish = false
|
|||
version = "0.0.0-alpha.0"
|
||||
|
||||
[dependencies]
|
||||
bare-metal = "0.2.4"
|
||||
cortex-m = { version = "0.7.3", optional = true }
|
||||
bare-metal = { version = "0.2.4", optional = true }
|
||||
|
||||
[dependencies.cortex-m-rtic]
|
||||
path = ".."
|
||||
features = ["heterogeneous"]
|
||||
|
||||
[features]
|
||||
default = ["bare-metal"]
|
||||
cortex-m-7 = ["cortex-m"]
|
||||
|
||||
[dev-dependencies]
|
||||
panic-halt = "0.2.0"
|
||||
microamp = "0.1.0-alpha.1"
|
||||
|
|
|
@ -7,7 +7,10 @@ use core::{
|
|||
ops::{Add, Sub},
|
||||
};
|
||||
|
||||
#[cfg(feature = "bare-metal")]
|
||||
use bare_metal::Nr;
|
||||
#[cfg(feature = "cortex-m-7")]
|
||||
use cortex_m::interrupt::InterruptNumber;
|
||||
use rtic::{Fraction, Monotonic, MultiCore};
|
||||
|
||||
// both cores have the exact same interrupts
|
||||
|
@ -16,7 +19,10 @@ pub use Interrupt_0 as Interrupt_1;
|
|||
// Fake priority bits
|
||||
pub const NVIC_PRIO_BITS: u8 = 3;
|
||||
|
||||
#[cfg(feature = "bare-metal")]
|
||||
pub fn xpend(_core: u8, _interrupt: impl Nr) {}
|
||||
#[cfg(feature = "cortex-m-7")]
|
||||
pub fn xpend(_core: u8, _interrupt: impl InterruptNumber) {}
|
||||
|
||||
/// Fake monotonic timer
|
||||
pub struct MT;
|
||||
|
@ -92,8 +98,16 @@ pub enum Interrupt_0 {
|
|||
I7 = 7,
|
||||
}
|
||||
|
||||
#[cfg(feature = "bare-metal")]
|
||||
unsafe impl Nr for Interrupt_0 {
|
||||
fn nr(&self) -> u8 {
|
||||
*self as u8
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cortex-m-7")]
|
||||
unsafe impl InterruptNumber for Interrupt_0 {
|
||||
fn number(self) -> u16 {
|
||||
self as u16
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,16 @@ publish = false
|
|||
version = "0.0.0-alpha.0"
|
||||
|
||||
[dependencies]
|
||||
bare-metal = "0.2.4"
|
||||
cortex-m = { version = "0.7.3", optional = true }
|
||||
bare-metal = { version = "0.2.4", optional = true }
|
||||
|
||||
[dependencies.cortex-m-rtic]
|
||||
path = ".."
|
||||
features = ["homogeneous"]
|
||||
|
||||
[features]
|
||||
default = ["bare-metal"]
|
||||
cortex-m-7 = ["cortex-m"]
|
||||
|
||||
[dev-dependencies]
|
||||
panic-halt = "0.2.0"
|
||||
|
|
|
@ -7,7 +7,10 @@ use core::{
|
|||
ops::{Add, Sub},
|
||||
};
|
||||
|
||||
#[cfg(feature = "bare-metal")]
|
||||
use bare_metal::Nr;
|
||||
#[cfg(feature = "cortex-m-7")]
|
||||
use cortex_m::interrupt::InterruptNumber;
|
||||
use rtic::{Fraction, Monotonic, MultiCore};
|
||||
|
||||
// both cores have the exact same interrupts
|
||||
|
@ -16,7 +19,10 @@ pub use Interrupt_0 as Interrupt_1;
|
|||
// Fake priority bits
|
||||
pub const NVIC_PRIO_BITS: u8 = 3;
|
||||
|
||||
#[cfg(feature = "bare-metal")]
|
||||
pub fn xpend(_core: u8, _interrupt: impl Nr) {}
|
||||
#[cfg(feature = "cortex-m-7")]
|
||||
pub fn xpend(_core: u8, _interrupt: impl InterruptNumber) {}
|
||||
|
||||
/// Fake monotonic timer
|
||||
pub struct MT;
|
||||
|
@ -92,8 +98,16 @@ pub enum Interrupt_0 {
|
|||
I7 = 7,
|
||||
}
|
||||
|
||||
#[cfg(feature = "bare-metal")]
|
||||
unsafe impl Nr for Interrupt_0 {
|
||||
fn nr(&self) -> u8 {
|
||||
*self as u8
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cortex-m-7")]
|
||||
unsafe impl InterruptNumber for Interrupt_0 {
|
||||
fn number(self) -> u16 {
|
||||
self as u16
|
||||
}
|
||||
}
|
||||
|
|
26
src/lib.rs
26
src/lib.rs
|
@ -44,10 +44,15 @@
|
|||
|
||||
use core::ops::Sub;
|
||||
|
||||
use cortex_m::{
|
||||
interrupt::Nr,
|
||||
peripheral::{CBP, CPUID, DCB, DWT, FPB, FPU, ITM, MPU, NVIC, SCB, TPIU},
|
||||
};
|
||||
#[cfg(feature = "cortex-m")]
|
||||
use cortex_m::interrupt::Nr;
|
||||
|
||||
#[cfg(feature = "cortex-m-7")]
|
||||
extern crate cortex_m_7 as cortex_m;
|
||||
#[cfg(feature = "cortex-m-7")]
|
||||
use cortex_m::interrupt::InterruptNumber;
|
||||
|
||||
use cortex_m::peripheral::{CBP, CPUID, DCB, DWT, FPB, FPU, ITM, MPU, NVIC, SCB, TPIU};
|
||||
#[cfg(all(not(feature = "heterogeneous"), not(feature = "homogeneous")))]
|
||||
use cortex_m_rt as _; // vector table
|
||||
pub use cortex_m_rtic_macros::app;
|
||||
|
@ -168,9 +173,22 @@ pub trait MultiCore {}
|
|||
///
|
||||
/// This is a convenience function around
|
||||
/// [`NVIC::pend`](../cortex_m/peripheral/struct.NVIC.html#method.pend)
|
||||
#[cfg(feature = "cortex-m")]
|
||||
pub fn pend<I>(interrupt: I)
|
||||
where
|
||||
I: Nr,
|
||||
{
|
||||
NVIC::pend(interrupt)
|
||||
}
|
||||
|
||||
/// Sets the given `interrupt` as pending
|
||||
///
|
||||
/// This is a convenience function around
|
||||
/// [`NVIC::pend`](../cortex_m/peripheral/struct.NVIC.html#method.pend)
|
||||
#[cfg(feature = "cortex-m-7")]
|
||||
pub fn pend<I>(interrupt: I)
|
||||
where
|
||||
I: InterruptNumber,
|
||||
{
|
||||
NVIC::pend(interrupt)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue