aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2017-07-06 23:25:29 -0500
committerGravatar Jorge Aparicio <jorge@japaric.io> 2017-07-06 23:25:29 -0500
commit3cebf49a2feb10b6dbf7e40e4671dbf7a3d8bedf (patch)
treed9b842d6f60439370ef81a4015993ed70f9aa7f8 /src
parent4b0c3bff871eb6125835fd911891bf503c61c820 (diff)
downloadrtic-3cebf49a2feb10b6dbf7e40e4671dbf7a3d8bedf.tar.gz
rtic-3cebf49a2feb10b6dbf7e40e4671dbf7a3d8bedf.tar.zst
rtic-3cebf49a2feb10b6dbf7e40e4671dbf7a3d8bedf.zip
syntax tweaks, relax check, add set_pending(), deal with imported types
- allow trailing commas in list of resources - make task.resources optional - add rtfm::set_pending function which can be used to force an interrupt into the pending state. This is a replacement of the old rtfm::request. rtfm::set_pending takes the Interrupt enum provided by the device crate as argument. (The old rtfm::request took a task function as argument) - the user may want to use types they imported into the root of the crate. These types are not available in e.g. `mod idle` so `idle::Resources` *can't* be defined in that module. To workaround this problem `idle::Resources` will be defined in the root, with some other name, and then be re-exported in the `idle` module. - remove the "a resource only used by one task should be local data" check. In some cases you do want a resource owned by a single task instead of local data since `init` can access resources but not a task local data.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f5c8b992..5d49af17 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -12,6 +12,7 @@ pub use cortex_m::asm::{bkpt, wfi};
pub use cortex_m::interrupt::CriticalSection;
pub use cortex_m::interrupt::free as atomic;
pub use static_ref::Static;
+use cortex_m::interrupt::Nr;
#[cfg(not(armv6m))]
use cortex_m::register::{basepri_max, basepri};
@@ -175,6 +176,16 @@ impl Threshold {
impl !Send for Threshold {}
+/// Sets an interrupt as pending
+pub fn set_pending<I>(interrupt: I)
+where
+ I: Nr,
+{
+ // NOTE(safe) atomic write
+ let nvic = unsafe { &*cortex_m::peripheral::NVIC.get() };
+ nvic.set_pending(interrupt);
+}
+
#[macro_export]
macro_rules! task {
($NAME:ident, $body:path) => {