Skip to content

Commit 064cf19

Browse files
authored
Merge pull request #709 from romancardenas/master
cortex-m as optional dependency
2 parents 31055fa + ce508a1 commit 064cf19

File tree

6 files changed

+29
-26
lines changed

6 files changed

+29
-26
lines changed

rtic-macros/src/codegen/async_dispatchers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
4242
let device = &app.args.device;
4343
let enum_ = util::interrupt_ident();
4444

45-
quote!(rtic::pend(#device::#enum_::#dispatcher_name);)
45+
quote!(rtic::export::pend(#device::#enum_::#dispatcher_name);)
4646
} else {
4747
// For 0 priority tasks we don't need to pend anything
4848
quote!()

rtic-macros/src/codegen/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 {
141141
let device = &app.args.device;
142142
let enum_ = util::interrupt_ident();
143143
let interrupt = &analysis.interrupts.get(&priority).expect("UREACHABLE").0;
144-
quote!(rtic::pend(#device::#enum_::#interrupt);)
144+
quote!(rtic::export::pend(#device::#enum_::#interrupt);)
145145
} else {
146146
quote!()
147147
};

rtic/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
1313

1414
### Changed
1515

16+
- `cortex-m` set as an optional dependency
17+
- Moved `cortex-m`-related utilities from `rtic/lib.rs` to `rtic/export.rs`
1618
- Make async task priorities start at 0, instead of 1, to always start at the lowest priority
1719

1820
## [v1.1.4] - 2023-02-26

rtic/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ version = "2.0.0-alpha.0"
3434
name = "rtic"
3535

3636
[dependencies]
37-
cortex-m = "0.7.0"
37+
cortex-m = { version = "0.7.0", optional = true }
3838
bare-metal = "1.0.0"
3939
#portable-atomic = { version = "0.3.19" }
4040
atomic-polyfill = "1"
@@ -65,17 +65,17 @@ trybuild = "1"
6565
[features]
6666
default = []
6767

68-
thumbv6-backend = ["rtic-macros/cortex-m-source-masking"]
69-
thumbv7-backend = ["rtic-macros/cortex-m-basepri"]
70-
thumbv8base-backend = ["rtic-macros/cortex-m-source-masking"]
71-
thumbv8main-backend = ["rtic-macros/cortex-m-basepri"]
68+
thumbv6-backend = ["cortex-m", "rtic-macros/cortex-m-source-masking"]
69+
thumbv7-backend = ["cortex-m", "rtic-macros/cortex-m-basepri"]
70+
thumbv8base-backend = ["cortex-m", "rtic-macros/cortex-m-source-masking"]
71+
thumbv8main-backend = ["cortex-m", "rtic-macros/cortex-m-basepri"]
7272
# riscv-clic-backend = ["rtic-macros/riscv-clic"]
7373
# riscv-ch32-backend = ["rtic-macros/riscv-ch32"]
7474
# riscv-esp32c3-backend = ["rtic-macros/riscv-esp32c3"]
7575

7676
# needed for testing
77-
rtic-uitestv7 = ["thumbv7-backend", "rtic-macros/cortex-m-basepri"]
78-
rtic-uitestv6 = ["thumbv6-backend", "rtic-macros/cortex-m-source-masking"]
77+
rtic-uitestv7 = ["thumbv7-backend"]
78+
rtic-uitestv6 = ["thumbv6-backend"]
7979
test-critical-section = ["cortex-m/critical-section-single-core", "rtic-monotonics/systick-100hz"]
8080

8181
# [[example]]

rtic/src/export.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ pub use cortex_source_mask::*;
3232
#[cfg(any(feature = "cortex-m-source-masking", feature = "rtic-uitestv6"))]
3333
mod cortex_source_mask;
3434

35+
#[cfg(feature = "cortex-m")]
36+
pub use cortex_m::{interrupt::InterruptNumber, peripheral::NVIC};
37+
38+
/// Sets the given `interrupt` as pending
39+
///
40+
/// This is a convenience function around
41+
/// [`NVIC::pend`](../cortex_m/peripheral/struct.NVIC.html#method.pend)
42+
#[cfg(feature = "cortex-m")]
43+
pub fn pend<I>(interrupt: I)
44+
where
45+
I: InterruptNumber,
46+
{
47+
NVIC::pend(interrupt);
48+
}
49+
3550
/// Priority conversion, takes logical priorities 1..=N and converts it to NVIC priority.
36-
#[cfg(any(
37-
feature = "cortex-m-basepri",
38-
feature = "cortex-m-source-masking",
39-
feature = "rtic-uitestv6",
40-
feature = "rtic-uitestv7",
41-
))]
51+
#[cfg(feature = "cortex-m")]
4252
#[inline]
4353
#[must_use]
4454
pub const fn cortex_logical2hw(logical: u8, nvic_prio_bits: u8) -> u8 {

rtic/src/lib.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
//deny_warnings_placeholder_for_ci
3434
#![allow(clippy::inline_always)]
3535

36-
use cortex_m::{interrupt::InterruptNumber, peripheral::NVIC};
3736
pub use rtic_core::{prelude as mutex_prelude, Exclusive, Mutex};
3837
pub use rtic_macros::app;
3938
// pub use rtic_monotonic::{self, Monotonic};
@@ -47,16 +46,8 @@ pub mod mutex {
4746
#[doc(hidden)]
4847
pub mod export;
4948

50-
/// Sets the given `interrupt` as pending
51-
///
52-
/// This is a convenience function around
53-
/// [`NVIC::pend`](../cortex_m/peripheral/struct.NVIC.html#method.pend)
54-
pub fn pend<I>(interrupt: I)
55-
where
56-
I: InterruptNumber,
57-
{
58-
NVIC::pend(interrupt);
59-
}
49+
#[cfg(feature = "cortex-m")]
50+
pub use export::pend;
6051

6152
use core::cell::UnsafeCell;
6253

0 commit comments

Comments
 (0)