diff options
| author | Román Cárdenas Rodríguez <rcardenas.rod@gmail.com> | 2024-03-20 21:06:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-20 20:06:47 +0000 |
| commit | 4060c3def88f82d4e4f48de7137ce365167ef265 (patch) | |
| tree | f326f0687092cab2b772952b579d63d12d3d34aa /rtic-macros/src/codegen/main.rs | |
| parent | 22ac33a826dedacde5d3d5c0964ff072555a9b32 (diff) | |
RISC-V support over CLINT (#815)
* Rebase to master
* using interrupt_mod
* bug fixes
* fix other backends
* Add changelog
* forgot about rtic-macros
* backend-specific configuration
* core peripherals optional over macro argument
* pre_init_preprocessing binding
* CI for RISC-V (WIP)
* separation of concerns
* add targets for RISC-V examples
* remove qemu feature
* prepare examples folder
* move examples all together
* move ci out of examples
* minor changes
* add cortex-m
* new xtask: proof of concept
* fix build.yml
* feature typo
* clean rtic examples
* reproduce weird issue
* remove unsafe code in user app
* update dependencies
* allow builds on riscv32imc
* let's fix QEMU
* Update .github/workflows/build.yml
Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
* New build.rs
* removing test features
* adapt ui test to new version of clippy
* add more examples to RISC-V backend
* proper configuration of heapless for riscv32imc
* opt-out examples for riscv32imc
* point to new version of riscv-slic
* adapt new macro bindings
* adapt examples and CI to stable
* fix cortex-m CI
* Review
---------
Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
Diffstat (limited to 'rtic-macros/src/codegen/main.rs')
| -rw-r--r-- | rtic-macros/src/codegen/main.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/rtic-macros/src/codegen/main.rs b/rtic-macros/src/codegen/main.rs index 5612796..80f2cf6 100644 --- a/rtic-macros/src/codegen/main.rs +++ b/rtic-macros/src/codegen/main.rs @@ -1,4 +1,3 @@ -use super::{assertions, post_init, pre_init}; use crate::{ analyze::Analysis, codegen::{bindings, util}, @@ -7,8 +6,12 @@ use crate::{ use proc_macro2::TokenStream as TokenStream2; use quote::quote; +use super::{assertions, extra_mods, post_init, pre_init}; + /// Generates code for `fn main` pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 { + let extra_mods_stmts = extra_mods::codegen(app, analysis); + let assertion_stmts = assertions::codegen(app, analysis); let pre_init_stmts = pre_init::codegen(app, analysis); @@ -40,9 +43,18 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 { let main = util::suffixed("main"); let init_name = &app.init.name; + + let init_args = if app.args.core { + quote!(core.into(), executors_size) + } else { + quote!(executors_size) + }; + let msp_check = bindings::check_stack_overflow_before_init(app, analysis); quote!( + #(#extra_mods_stmts)* + #[doc(hidden)] #[no_mangle] unsafe extern "C" fn #main() -> ! { @@ -63,7 +75,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 { // Wrap late_init_stmts in a function to ensure that stack space is reclaimed. __rtic_init_resources(||{ - let (shared_resources, local_resources) = #init_name(#init_name::Context::new(core.into(), executors_size)); + let (shared_resources, local_resources) = #init_name(#init_name::Context::new(#init_args)); #(#post_init_stmts)* }); |
