mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 06:15:45 +01:00
Fixing examples and tests, modules now import user imports correctly
Fmt Correct syntax crate UI test fix Fix build script Cleanup More cleanup
This commit is contained in:
parent
524273c96a
commit
5b8e6a22ab
28 changed files with 147 additions and 245 deletions
|
|
@ -15,11 +15,7 @@ mod post_init;
|
|||
mod pre_init;
|
||||
mod resources;
|
||||
mod resources_struct;
|
||||
// mod schedule;
|
||||
// mod schedule_body;
|
||||
mod software_tasks;
|
||||
// mod spawn;
|
||||
// mod spawn_body;
|
||||
mod timer_queue;
|
||||
mod util;
|
||||
|
||||
|
|
@ -115,17 +111,12 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
) = software_tasks::codegen(app, analysis, extra);
|
||||
|
||||
let mod_app_dispatchers = dispatchers::codegen(app, analysis, extra);
|
||||
|
||||
// let mod_app_spawn = spawn::codegen(app, analysis, extra);
|
||||
|
||||
let mod_app_timer_queue = timer_queue::codegen(app, analysis, extra);
|
||||
|
||||
// let mod_app_schedule = schedule::codegen(app, extra);
|
||||
|
||||
let user_imports = app.user_imports.clone();
|
||||
let user_code = app.user_code.clone();
|
||||
let user_imports = &app.user_imports;
|
||||
let user_code = &app.user_code;
|
||||
let name = &app.name;
|
||||
let device = extra.device;
|
||||
|
||||
quote!(
|
||||
#(#user)*
|
||||
|
||||
|
|
@ -170,12 +161,8 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
|
||||
#(#mod_app_dispatchers)*
|
||||
|
||||
// #(#mod_app_spawn)*
|
||||
|
||||
#(#mod_app_timer_queue)*
|
||||
|
||||
// #(#mod_app_schedule)*
|
||||
|
||||
#(#mains)*
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ pub fn codegen(
|
|||
let mut hardware_tasks_imports = vec![];
|
||||
|
||||
for (name, task) in &app.hardware_tasks {
|
||||
let (let_instant, instant) = if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
|
||||
let (let_instant, instant) = if let Some(m) = extra.monotonic {
|
||||
(
|
||||
Some(quote!(let instant = <#m as rtic::Monotonic>::now();)),
|
||||
Some(quote!(, instant)),
|
||||
|
|
|
|||
|
|
@ -62,8 +62,13 @@ pub fn codegen(
|
|||
root_idle.push(locals);
|
||||
}
|
||||
|
||||
root_idle.push(module::codegen(Context::Idle, needs_lt, app,analysis, extra));
|
||||
|
||||
root_idle.push(module::codegen(
|
||||
Context::Idle,
|
||||
needs_lt,
|
||||
app,
|
||||
analysis,
|
||||
extra,
|
||||
));
|
||||
|
||||
let attrs = &idle.attrs;
|
||||
let context = &idle.context;
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ pub fn codegen(
|
|||
let mut lt = None;
|
||||
match ctxt {
|
||||
Context::Init => {
|
||||
if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
|
||||
if let Some(m) = extra.monotonic {
|
||||
fields.push(quote!(
|
||||
/// System start time = `Instant(0 /* cycles */)`
|
||||
pub start: <#m as rtic::Monotonic>::Instant
|
||||
|
|
@ -67,9 +65,7 @@ pub fn codegen(
|
|||
Context::Idle => {}
|
||||
|
||||
Context::HardwareTask(..) => {
|
||||
if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
|
||||
if let Some(m) = extra.monotonic {
|
||||
fields.push(quote!(
|
||||
/// Time at which this handler started executing
|
||||
pub start: <#m as rtic::Monotonic>::Instant
|
||||
|
|
@ -82,9 +78,7 @@ pub fn codegen(
|
|||
}
|
||||
|
||||
Context::SoftwareTask(..) => {
|
||||
if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
|
||||
if let Some(m) = extra.monotonic {
|
||||
fields.push(quote!(
|
||||
/// The time at which this task was scheduled to run
|
||||
pub scheduled: <#m as rtic::Monotonic>::Instant
|
||||
|
|
@ -242,11 +236,10 @@ pub fn codegen(
|
|||
}));
|
||||
|
||||
// Schedule caller
|
||||
if extra.monotonic.is_some() {
|
||||
if let Some(m) = extra.monotonic {
|
||||
let instants = util::instants_ident(name);
|
||||
|
||||
let tq = util::tq_ident();
|
||||
let m = extra.monotonic();
|
||||
let t = util::schedule_t_ident();
|
||||
|
||||
items.push(quote!(
|
||||
|
|
@ -288,10 +281,16 @@ pub fn codegen(
|
|||
}
|
||||
|
||||
if !items.is_empty() {
|
||||
let user_imports = &app.user_imports;
|
||||
|
||||
quote!(
|
||||
#[allow(non_snake_case)]
|
||||
#[doc = #doc]
|
||||
pub mod #name {
|
||||
#(
|
||||
#[allow(unused_imports)]
|
||||
#user_imports
|
||||
)*
|
||||
#(#items)*
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,12 +12,8 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
stmts.push(quote!(rtic::export::interrupt::disable();));
|
||||
|
||||
// Populate the FreeQueue
|
||||
for fq in &app.software_tasks {
|
||||
// Get the task name
|
||||
let name = fq.0;
|
||||
let task = fq.1;
|
||||
for (name, task) in &app.software_tasks {
|
||||
let cap = task.args.capacity;
|
||||
|
||||
let fq_ident = util::fq_ident(name);
|
||||
|
||||
stmts.push(quote!(
|
||||
|
|
|
|||
|
|
@ -60,8 +60,7 @@ pub fn codegen(
|
|||
.map(|_| quote!(core::mem::MaybeUninit::uninit()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
if let Some(m) = extra.monotonic {
|
||||
let instants = util::instants_ident(name);
|
||||
|
||||
let uninit = mk_uninit();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::{analyze::Analysis, check::Extra, codegen::util};
|
|||
pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream2> {
|
||||
let mut items = vec![];
|
||||
|
||||
if extra.monotonic.is_some() {
|
||||
if let Some(m) = extra.monotonic {
|
||||
let t = util::schedule_t_ident();
|
||||
|
||||
// Enumeration of `schedule`-able tasks
|
||||
|
|
@ -42,7 +42,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
// Static variable and resource proxy
|
||||
{
|
||||
let doc = format!("Timer queue");
|
||||
let m = extra.monotonic();
|
||||
let cap = app
|
||||
.software_tasks
|
||||
.iter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue