mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 05:45:19 +01:00
Merge branch 'master' into master
This commit is contained in:
commit
ce508a1882
17 changed files with 55 additions and 17 deletions
|
|
@ -11,6 +11,7 @@ use syn::Ident;
|
|||
pub struct Analysis {
|
||||
parent: analyze::Analysis,
|
||||
pub interrupts: BTreeMap<Priority, (Ident, Dispatcher)>,
|
||||
pub max_async_prio: Option<u8>,
|
||||
}
|
||||
|
||||
impl ops::Deref for Analysis {
|
||||
|
|
@ -42,8 +43,16 @@ pub fn app(analysis: analyze::Analysis, app: &App) -> Analysis {
|
|||
.map(|p| (p, available_interrupt.pop().expect("UNREACHABLE")))
|
||||
.collect();
|
||||
|
||||
let max_async_prio = app
|
||||
.hardware_tasks
|
||||
.iter()
|
||||
.map(|(_, task)| task.args.priority)
|
||||
.min()
|
||||
.map(|v| v - 1); // One less than the smallest HW task
|
||||
|
||||
Analysis {
|
||||
parent: analysis,
|
||||
interrupts,
|
||||
max_async_prio,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ pub fn app(app: &App, analysis: &Analysis) -> TokenStream2 {
|
|||
let device = &app.args.device;
|
||||
|
||||
let rt_err = util::rt_err_ident();
|
||||
let async_limit = bindings::async_prio_limit(app, analysis);
|
||||
|
||||
quote!(
|
||||
/// The RTIC application module
|
||||
|
|
@ -52,6 +53,8 @@ pub fn app(app: &App, analysis: &Analysis) -> TokenStream2 {
|
|||
/// Always include the device crate which contains the vector table
|
||||
use #device as #rt_err;
|
||||
|
||||
#(#async_limit)*
|
||||
|
||||
#(#user_imports)*
|
||||
|
||||
#(#user_code)*
|
||||
|
|
|
|||
|
|
@ -322,3 +322,19 @@ pub fn interrupt_entry(_app: &App, _analysis: &CodegenAnalysis) -> Vec<TokenStre
|
|||
pub fn interrupt_exit(_app: &App, _analysis: &CodegenAnalysis) -> Vec<TokenStream2> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
pub fn async_prio_limit(app: &App, analysis: &CodegenAnalysis) -> Vec<TokenStream2> {
|
||||
let max = if let Some(max) = analysis.max_async_prio {
|
||||
quote!(#max)
|
||||
} else {
|
||||
// No limit
|
||||
let device = &app.args.device;
|
||||
quote!(1 << #device::NVIC_PRIO_BITS)
|
||||
};
|
||||
|
||||
vec![quote!(
|
||||
/// Holds the maximum priority level for use by async HAL drivers.
|
||||
#[no_mangle]
|
||||
static RTIC_ASYNC_MAX_LOGICAL_PRIO: u8 = #max;
|
||||
)]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,3 +42,7 @@ pub fn interrupt_entry(_app: &App, _analysis: &CodegenAnalysis) -> Vec<TokenStre
|
|||
pub fn interrupt_exit(_app: &App, _analysis: &CodegenAnalysis) -> Vec<TokenStream2> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
pub fn async_prio_limit(app: &App, _analysis: &CodegenAnalysis) -> Vec<TokenStream2> {
|
||||
vec![]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,11 +289,13 @@ fn task_args(tokens: TokenStream2) -> parse::Result<Either<HardwareTaskArgs, Sof
|
|||
// Handle comma: ,
|
||||
let _: Token![,] = content.parse()?;
|
||||
}
|
||||
let priority = priority.unwrap_or(1);
|
||||
let shared_resources = shared_resources.unwrap_or_default();
|
||||
let local_resources = local_resources.unwrap_or_default();
|
||||
|
||||
Ok(if let Some(binds) = binds {
|
||||
// Hardware tasks can't run at anything lower than 1
|
||||
let priority = priority.unwrap_or(1);
|
||||
|
||||
if priority == 0 {
|
||||
return Err(parse::Error::new(
|
||||
prio_span.unwrap(),
|
||||
|
|
@ -308,6 +310,9 @@ fn task_args(tokens: TokenStream2) -> parse::Result<Either<HardwareTaskArgs, Sof
|
|||
local_resources,
|
||||
})
|
||||
} else {
|
||||
// Software tasks start at idle priority
|
||||
let priority = priority.unwrap_or(0);
|
||||
|
||||
Either::Right(SoftwareTaskArgs {
|
||||
priority,
|
||||
shared_resources,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue