aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/dispatchers.rs
diff options
context:
space:
mode:
authorGravatar bors[bot] <26634292+bors[bot]@users.noreply.github.com> 2020-10-15 16:42:30 +0000
committerGravatar GitHub <noreply@github.com> 2020-10-15 16:42:30 +0000
commit355cb82d0693fe108ac28ec8a0d77e8aab4e6e06 (patch)
tree67c0eadf6d8a98a2691b816d46a5103d159d6bbc /macros/src/codegen/dispatchers.rs
parentf9303cef1cf5b2d57d26e7667289fbdccf959ea8 (diff)
parent6808cc7cdf1512a7b10dd43f268f430a676c606e (diff)
downloadrtic-355cb82d0693fe108ac28ec8a0d77e8aab4e6e06.tar.gz
rtic-355cb82d0693fe108ac28ec8a0d77e8aab4e6e06.tar.zst
rtic-355cb82d0693fe108ac28ec8a0d77e8aab4e6e06.zip
Merge #390
390: Spawn and schedule from anywhere r=AfoHT a=korken89 This PR moves RTIC to the spawn and schedule from anywhere syntax. Notable changes: * We do no longer support non-`Send` types. * Some extra code is generated as any task may spawn/schedule any task. However Rust/LLVM does a great job optimizing away non used instantiations (no real code-size difference observed). * Worst case priority inversion has increased, but it is now predictable. Upsides: * With this we should be able to support async/await. * RTIC tasks can now be callbacks (spawned and scheduled). * RTIC tasks can be stored. Needs the following PR to land first: https://github.com/rtic-rs/rtic-syntax/pull/34 The following now works: ```rust #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] mod app { #[init] fn init(mut cx: init::Context) -> init::LateResources { // Init stuff... // New spawn syntax foo::spawn().unwrap(); // New schedule syntax bar::schedule(now + 4_000_000.cycles()).unwrap(); init::LateResources {} } #[task] fn foo(_: foo::Context) {} #[task] fn bar(_: bar::Context) {} extern "C" { fn SSI0(); } } ``` Co-authored-by: Per Lindgren <per.lindgren@ltu.se> Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Diffstat (limited to 'macros/src/codegen/dispatchers.rs')
-rw-r--r--macros/src/codegen/dispatchers.rs24
1 files changed, 3 insertions, 21 deletions
diff --git a/macros/src/codegen/dispatchers.rs b/macros/src/codegen/dispatchers.rs
index 300aa996..bf6986b8 100644
--- a/macros/src/codegen/dispatchers.rs
+++ b/macros/src/codegen/dispatchers.rs
@@ -35,7 +35,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
#[allow(non_camel_case_types)]
#[derive(Clone, Copy)]
#[doc = #doc]
- enum #t {
+ pub enum #t {
#(#variants,)*
}
));
@@ -57,27 +57,9 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
);
items.push(quote!(
#[doc = #doc]
- static mut #rq: #rq_ty = #rq_expr;
+ pub static mut #rq: #rq_ty = #rq_expr;
));
- if let Some(ceiling) = channel.ceiling {
- items.push(quote!(
- struct #rq<'a> {
- priority: &'a rtic::export::Priority,
- }
- ));
-
- items.push(util::impl_mutex(
- extra,
- &[],
- false,
- &rq,
- rq_ty,
- ceiling,
- quote!(&mut #rq),
- ));
- }
-
let arms = channel
.tasks
.iter()
@@ -88,7 +70,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
let inputs = util::inputs_ident(name);
let (_, tupled, pats, _) = util::regroup_inputs(&task.inputs);
- let (let_instant, instant) = if app.uses_schedule() {
+ let (let_instant, instant) = if extra.monotonic.is_some() {
let instants = util::instants_ident(name);
(