aboutsummaryrefslogtreecommitdiff
path: root/rtic-macros/src
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2023-02-19 14:30:49 +0100
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2023-03-01 00:35:20 +0100
commitb9e0f36aff96ec4e39cf4f728777cbc808df2c78 (patch)
tree16e4e92c32d1bf9a9ec70d35d950bcf149b7eafd /rtic-macros/src
parent60f0342b697cdddbab9c0e8c6d772bc7aab9de38 (diff)
downloadrtic-b9e0f36aff96ec4e39cf4f728777cbc808df2c78.tar.gz
rtic-b9e0f36aff96ec4e39cf4f728777cbc808df2c78.tar.zst
rtic-b9e0f36aff96ec4e39cf4f728777cbc808df2c78.zip
Add feature flags
Diffstat (limited to 'rtic-macros/src')
-rw-r--r--rtic-macros/src/codegen/bindings.rs19
-rw-r--r--rtic-macros/src/codegen/bindings/cortex.rs50
-rw-r--r--rtic-macros/src/codegen/util.rs2
3 files changed, 26 insertions, 45 deletions
diff --git a/rtic-macros/src/codegen/bindings.rs b/rtic-macros/src/codegen/bindings.rs
index 1efe0ce0..a187820e 100644
--- a/rtic-macros/src/codegen/bindings.rs
+++ b/rtic-macros/src/codegen/bindings.rs
@@ -1,5 +1,18 @@
-// TODO: Feature gate
-mod cortex;
+#[cfg(not(any(
+ feature = "cortex_m_source_masking",
+ feature = "cortex_m_basepri",
+ feaute = "test_template"
+)))]
+compile_error!("No backend selected");
+
+#[cfg(any(feature = "cortex_m_source_masking", feature = "cortex_m_basepri"))]
+pub use cortex::*;
-// TODO: Feature gate
+#[cfg(feature = "test_template")]
pub use cortex::*;
+
+#[cfg(any(feature = "cortex_m_source_masking", feature = "cortex_m_basepri"))]
+mod cortex;
+
+#[cfg(feature = "test_template")]
+mod template;
diff --git a/rtic-macros/src/codegen/bindings/cortex.rs b/rtic-macros/src/codegen/bindings/cortex.rs
index 15976a10..f028cee7 100644
--- a/rtic-macros/src/codegen/bindings/cortex.rs
+++ b/rtic-macros/src/codegen/bindings/cortex.rs
@@ -8,8 +8,9 @@ use quote::quote;
use std::collections::HashSet;
use syn::{parse, Attribute, Ident};
-// TODO: This should be feature gated
-// pub use basepri::*;
+#[cfg(feature = "cortex_m_basepri")]
+pub use basepri::*;
+#[cfg(feature = "cortex_m_source_masking")]
pub use source_masking::*;
/// Whether `name` is an exception with configurable priority
@@ -29,7 +30,8 @@ fn is_exception(name: &Ident) -> bool {
)
}
-pub mod source_masking {
+#[cfg(feature = "cortex_m_source_masking")]
+mod source_masking {
use super::*;
use std::collections::HashMap;
@@ -87,14 +89,6 @@ pub mod source_masking {
));
}
- // if uses_exceptions_with_resources {
- // mod_app.push(quote!(
- // #[doc(hidden)]
- // #[allow(non_upper_case_globals)]
- // const __rtic_internal_V6_ERROR: () = rtic::export::no_basepri_panic();
- // ));
- // }
-
quote!(
#(#cfgs)*
impl<'a> rtic::Mutex for #path<'a> {
@@ -121,38 +115,12 @@ pub mod source_masking {
}
pub fn extra_assertions(_: &App, _: &SyntaxAnalysis) -> Vec<TokenStream2> {
- // let device = &app.args.device;
- // let no_basepri_checks: Vec<_> = app
- // .hardware_tasks
- // .iter()
- // .filter_map(|(_, task)| {
- // if !is_exception(&task.args.binds) {
- // let interrupt_name = &task.args.binds;
- // Some(quote!(
- // if (#device::Interrupt::#interrupt_name as usize) >= (#chunks_name * 32) {
- // ::core::panic!("An interrupt out of range is used while in armv6 or armv8m.base");
- // }
- // ))
- // } else {
- // None
- // }
- // })
- // .collect();
-
- // let const_check = quote! {
- // const _CONST_CHECK: () = {
- // #(#no_basepri_checks)*
- // };
-
- // let _ = _CONST_CHECK;
- // };
-
- // vec![const_check]
vec![]
}
}
-pub mod basepri {
+#[cfg(feature = "cortex_m_basepri")]
+mod basepri {
use super::*;
/// Generates a `Mutex` implementation
@@ -245,7 +213,7 @@ pub fn pre_init_enable_interrupts(app: &App, analysis: &CodegenAnalysis) -> Vec<
stmts.push(quote!(
core.NVIC.set_priority(
#rt_err::#interrupt::#name,
- rtic::export::logical2hw(#priority, #nvic_prio_bits),
+ rtic::export::cortex_logical2hw(#priority, #nvic_prio_bits),
);
));
@@ -272,7 +240,7 @@ pub fn pre_init_enable_interrupts(app: &App, analysis: &CodegenAnalysis) -> Vec<
stmts.push(quote!(core.SCB.set_priority(
rtic::export::SystemHandler::#name,
- rtic::export::logical2hw(#priority, #nvic_prio_bits),
+ rtic::export::cortex_logical2hw(#priority, #nvic_prio_bits),
);));
}
diff --git a/rtic-macros/src/codegen/util.rs b/rtic-macros/src/codegen/util.rs
index 27c8a2a1..2f44edb0 100644
--- a/rtic-macros/src/codegen/util.rs
+++ b/rtic-macros/src/codegen/util.rs
@@ -2,7 +2,7 @@ use crate::syntax::{ast::App, Context};
use core::sync::atomic::{AtomicUsize, Ordering};
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::quote;
-use syn::{Attribute, Ident, PatType};
+use syn::{Ident, PatType};
const RTIC_INTERNAL: &str = "__rtic_internal";