Skip to content

Commit 6d66f5a

Browse files
committed
cfg-gate interrupt::free, use new name for embedded_hal.
1 parent b8342cd commit 6d66f5a

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

cortex-m/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ rust-version = "1.61"
1818

1919
[dependencies]
2020
bare-metal = { version = "0.2.4", features = ["const-fn"] }
21-
critical-section = { version = "1.0.0", optional = true }
21+
critical-section = "1.0.0"
2222
volatile-register = "0.2.2"
2323
bitfield = "0.13.2"
2424
eh0 = { package = "embedded-hal", version = "0.2.4" }

cortex-m/src/interrupt.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub unsafe fn enable() {
5151
/// Execute closure `f` in an interrupt-free context.
5252
///
5353
/// This as also known as a "critical section".
54+
#[cfg(cortex_m)]
5455
#[inline]
5556
pub fn free<F, R>(f: F) -> R
5657
where
@@ -72,3 +73,15 @@ where
7273

7374
r
7475
}
76+
77+
// Make a `free()` function available to allow checking dependencies without specifying a target,
78+
// but that will panic at runtime if executed.
79+
#[doc(hidden)]
80+
#[cfg(not(cortex_m))]
81+
#[inline]
82+
pub fn free<F, R>(_: F) -> R
83+
where
84+
F: FnOnce(&CriticalSection) -> R,
85+
{
86+
panic!("cortex_m::interrupt::free() is only functional on cortex-m platforms");
87+
}

cortex-m/src/peripheral/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
use core::marker::PhantomData;
6161
use core::ops;
6262

63-
use crate::interrupt;
64-
6563
#[cfg(feature = "cm7")]
6664
pub mod ac;
6765
#[cfg(not(armv6m))]
@@ -165,7 +163,7 @@ impl Peripherals {
165163
/// Returns all the core peripherals *once*
166164
#[inline]
167165
pub fn take() -> Option<Self> {
168-
interrupt::free(|_| {
166+
crate::interrupt::free(|_| {
169167
if unsafe { TAKEN } {
170168
None
171169
} else {

cortex-m/src/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
//! Prelude
22
3-
pub use embedded_hal::prelude::*;
3+
pub use eh0::prelude::*;

0 commit comments

Comments
 (0)