aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/post_init.rs
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2023-01-23 20:05:47 +0100
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2023-03-01 00:33:31 +0100
commit306aa47170fd59369b7a184924e287dc3706d64d (patch)
tree75a331a63a4021f078e330bf2ce4edb1228e2ecf /macros/src/codegen/post_init.rs
parentb8b881f446a226d6f3c4a7db7c9174590b47dbf6 (diff)
downloadrtic-306aa47170fd59369b7a184924e287dc3706d64d.tar.gz
rtic-306aa47170fd59369b7a184924e287dc3706d64d.tar.zst
rtic-306aa47170fd59369b7a184924e287dc3706d64d.zip
Add rtic-timer (timerqueue + monotonic) and rtic-monotonics (systick-monotonic)
Diffstat (limited to 'macros/src/codegen/post_init.rs')
-rw-r--r--macros/src/codegen/post_init.rs47
1 files changed, 0 insertions, 47 deletions
diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs
deleted file mode 100644
index c4e53837..00000000
--- a/macros/src/codegen/post_init.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use crate::{analyze::Analysis, codegen::util, syntax::ast::App};
-use proc_macro2::TokenStream as TokenStream2;
-use quote::quote;
-
-/// Generates code that runs after `#[init]` returns
-pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
- let mut stmts = vec![];
-
- // Initialize shared resources
- for (name, res) in &app.shared_resources {
- let mangled_name = util::static_shared_resource_ident(name);
- // If it's live
- let cfgs = res.cfgs.clone();
- if analysis.shared_resources.get(name).is_some() {
- stmts.push(quote!(
- // We include the cfgs
- #(#cfgs)*
- // Resource is a RacyCell<MaybeUninit<T>>
- // - `get_mut` to obtain a raw pointer to `MaybeUninit<T>`
- // - `write` the defined value for the late resource T
- #mangled_name.get_mut().write(core::mem::MaybeUninit::new(shared_resources.#name));
- ));
- }
- }
-
- // Initialize local resources
- for (name, res) in &app.local_resources {
- let mangled_name = util::static_local_resource_ident(name);
- // If it's live
- let cfgs = res.cfgs.clone();
- if analysis.local_resources.get(name).is_some() {
- stmts.push(quote!(
- // We include the cfgs
- #(#cfgs)*
- // Resource is a RacyCell<MaybeUninit<T>>
- // - `get_mut` to obtain a raw pointer to `MaybeUninit<T>`
- // - `write` the defined value for the late resource T
- #mangled_name.get_mut().write(core::mem::MaybeUninit::new(local_resources.#name));
- ));
- }
- }
-
- // Enable the interrupts -- this completes the `init`-ialization phase
- stmts.push(quote!(rtic::export::interrupt::enable();));
-
- stmts
-}