mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-25 21:19:35 +01:00
Merge #416
416: Move entry-point main into a separate module r=korken89 a=AfoHT Prevents conflict with user provided tasks named main Curious what the full test suite will make of this Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
This commit is contained in:
commit
53b2454799
2 changed files with 37 additions and 8 deletions
26
examples/task_named_main.rs
Normal file
26
examples/task_named_main.rs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
//! examples/task_named_main.rs
|
||||||
|
|
||||||
|
#![deny(unsafe_code)]
|
||||||
|
#![deny(warnings)]
|
||||||
|
#![no_main]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
use panic_semihosting as _;
|
||||||
|
|
||||||
|
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
||||||
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
|
||||||
|
#[init]
|
||||||
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
|
main::spawn().unwrap();
|
||||||
|
|
||||||
|
init::LateResources {}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[task]
|
||||||
|
fn main(_: main::Context) {
|
||||||
|
hprintln!("This task is named main, useful for rust-analyzer").unwrap();
|
||||||
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,19 +57,22 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
|
|
||||||
let main = util::suffixed("main");
|
let main = util::suffixed("main");
|
||||||
mains.push(quote!(
|
mains.push(quote!(
|
||||||
#[no_mangle]
|
mod rtic_ext {
|
||||||
unsafe extern "C" fn #main() -> ! {
|
use super::*;
|
||||||
let _TODO: () = ();
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn #main() -> ! {
|
||||||
|
let _TODO: () = ();
|
||||||
|
|
||||||
#(#assertion_stmts)*
|
#(#assertion_stmts)*
|
||||||
|
|
||||||
#(#pre_init_stmts)*
|
#(#pre_init_stmts)*
|
||||||
|
|
||||||
#call_init
|
#call_init
|
||||||
|
|
||||||
#(#post_init_stmts)*
|
#(#post_init_stmts)*
|
||||||
|
|
||||||
#call_idle
|
#call_idle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue