mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-25 21:19:35 +01:00
Merge #315
315: allow handlers to be named 'main' r=korken89 a=japaric `#[init]`, `#[idle]` and `#[task]` handlers can now be named `main` fixes #311 Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
This commit is contained in:
commit
4795c1dba3
7 changed files with 82 additions and 3 deletions
20
examples/t-htask-main.rs
Normal file
20
examples/t-htask-main.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
rtfm::pend(lm3s6965::Interrupt::UART0)
|
||||
}
|
||||
|
||||
#[task(binds = UART0)]
|
||||
fn main(_: main::Context) {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
};
|
20
examples/t-idle-main.rs
Normal file
20
examples/t-idle-main.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
}
|
||||
|
||||
#[idle]
|
||||
fn main(_: main::Context) -> ! {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
loop {}
|
||||
}
|
||||
};
|
15
examples/t-init-main.rs
Normal file
15
examples/t-init-main.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn main(_: main::Context) {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
};
|
24
examples/t-stask-main.rs
Normal file
24
examples/t-stask-main.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtfm::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(spawn = [main])]
|
||||
fn init(cx: init::Context) {
|
||||
cx.spawn.main().ok();
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn main(_: main::Context) {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn UART0();
|
||||
}
|
||||
};
|
|
@ -141,7 +141,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
#let_instant
|
||||
#fq.split().0.enqueue_unchecked(index);
|
||||
let priority = &rtfm::export::Priority::new(PRIORITY);
|
||||
#name(
|
||||
crate::#name(
|
||||
#locals_new
|
||||
#name::Context::new(priority #instant)
|
||||
#(,#pats)*
|
||||
|
|
|
@ -72,7 +72,7 @@ pub fn codegen(
|
|||
));
|
||||
|
||||
let locals_new = locals_new.iter();
|
||||
let call_idle = quote!(#name(
|
||||
let call_idle = quote!(crate::#name(
|
||||
#(#locals_new,)*
|
||||
#name::Context::new(&rtfm::export::Priority::new(0))
|
||||
));
|
||||
|
|
|
@ -109,7 +109,7 @@ pub fn codegen(
|
|||
|
||||
let locals_new = locals_new.iter();
|
||||
let call_init =
|
||||
Some(quote!(let late = #name(#(#locals_new,)* #name::Context::new(core.into()));));
|
||||
Some(quote!(let late = crate::#name(#(#locals_new,)* #name::Context::new(core.into()));));
|
||||
|
||||
root_init.push(module::codegen(Context::Init(core), needs_lt, app, extra));
|
||||
|
||||
|
|
Loading…
Reference in a new issue