From fb61a78cdd99e27914cc355f721c04d901dd3ae4 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Thu, 1 Oct 2020 20:01:25 +0200 Subject: [PATCH 1/2] Added `bare_metal::CriticalSection` to `init::Context` --- Cargo.toml | 1 + macros/src/codegen/module.rs | 8 ++++++++ src/export.rs | 1 + 3 files changed, 10 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index d4ad4ef05e..6fe5fce38f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,6 +60,7 @@ cortex-m-rtic-macros = { path = "macros", version = "0.5.2" } rtic-core = "0.3.0" cortex-m-rt = "0.6.9" heapless = "0.5.0" +bare-metal = "1.0.0" [build-dependencies] version_check = "0.9" diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 863f6c5b73..359c1cce4e 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -47,6 +47,14 @@ pub fn codegen(ctxt: Context, resources_tick: bool, app: &App, extra: &Extra) -> values.push(quote!(device: #device::Peripherals::steal())); } + lt = Some(quote!('a)); + fields.push(quote!( + /// Critical section token for init + pub cs: rtic::export::CriticalSection<#lt> + )); + + values.push(quote!(cs: rtic::export::CriticalSection::new())); + values.push(quote!(core)); } diff --git a/src/export.rs b/src/export.rs index 8a5d4e3e56..1e64941f3f 100644 --- a/src/export.rs +++ b/src/export.rs @@ -4,6 +4,7 @@ use core::{ }; pub use crate::tq::{NotReady, TimerQueue}; +pub use bare_metal::CriticalSection; #[cfg(armv7m)] pub use cortex_m::register::basepri; pub use cortex_m::{ From 86001c46bcae85c9448d63dde534bd218301f0e4 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Thu, 1 Oct 2020 20:16:00 +0200 Subject: [PATCH 2/2] Fixing test errors --- ui/single/locals-cfg.stderr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/single/locals-cfg.stderr b/ui/single/locals-cfg.stderr index bb558fa60e..49695cbf1b 100644 --- a/ui/single/locals-cfg.stderr +++ b/ui/single/locals-cfg.stderr @@ -28,10 +28,10 @@ error[E0425]: cannot find value `FOO` in this scope 44 | FOO; | ^^^ not found in this scope -error: duplicate lang item in crate `panic_halt`: `panic_impl`. +error: duplicate lang item in crate `panic_semihosting`: `panic_impl`. | = note: first defined in crate `std`. -error: duplicate lang item in crate `panic_semihosting`: `panic_impl`. +error: duplicate lang item in crate `panic_halt`: `panic_impl`. | - = note: first defined in crate `panic_halt`. + = note: first defined in crate `panic_semihosting`.