aboutsummaryrefslogtreecommitdiff
path: root/rtic-macros/src/codegen/bindings/cortex.rs
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2023-03-29 20:43:27 +0200
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2023-03-29 20:46:24 +0200
commit323b847bf692a0054647536a6495f20373f6d9c7 (patch)
treeb5bcd9047d6feac883098ee4f85e4aced8c51a72 /rtic-macros/src/codegen/bindings/cortex.rs
parent3a0e2ac92438c818f7f12d894c576de9af9fcc01 (diff)
downloadrtic-323b847bf692a0054647536a6495f20373f6d9c7.tar.gz
rtic-323b847bf692a0054647536a6495f20373f6d9c7.tar.zst
rtic-323b847bf692a0054647536a6495f20373f6d9c7.zip
Adding a limit that async HALs can read and have as max prio
Diffstat (limited to 'rtic-macros/src/codegen/bindings/cortex.rs')
-rw-r--r--rtic-macros/src/codegen/bindings/cortex.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/rtic-macros/src/codegen/bindings/cortex.rs b/rtic-macros/src/codegen/bindings/cortex.rs
index 767befa9..eba2afca 100644
--- a/rtic-macros/src/codegen/bindings/cortex.rs
+++ b/rtic-macros/src/codegen/bindings/cortex.rs
@@ -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;
+ )]
+}