~ruther/avr-device

1e37fc069fcf1789c9ccf211b039d933769d88d5 — Michael Buesch 2 years ago 68c266f
Update the bare-metal crate to 1.0.0

The new crate version generates much cleaner code due to #[inline] annotations.
This is an API break, because the CriticalSection + Mutex mechanism changes
from exterior reference lifetime to interior reference lifetime management.
2 files changed, 4 insertions(+), 4 deletions(-)

M Cargo.toml
M src/interrupt.rs
M Cargo.toml => Cargo.toml +1 -1
@@ 62,7 62,7 @@ docsrs = ["rt", "atmega328p", "atmega32u4", "atmega2560", "attiny85", "atmega480
udebug = ["dep:ufmt"]

[dependencies]
bare-metal = "0.2.5"
bare-metal = "1.0.0"
vcell = "0.1.2"
cfg-if = "0.1.10"
ufmt = { version = "0.2.0", optional = true }

M src/interrupt.rs => src/interrupt.rs +3 -3
@@ 28,7 28,7 @@
//! });
//! ```

pub use bare_metal::{CriticalSection, Mutex, Nr};
pub use bare_metal::{CriticalSection, Mutex};

#[cfg(target_arch = "avr")]
use core::arch::asm;


@@ 215,14 215,14 @@ pub fn is_enabled() -> bool {
#[inline(always)]
pub fn free<F, R>(f: F) -> R
where
    F: FnOnce(&CriticalSection) -> R,
    F: FnOnce(CriticalSection) -> R,
{
    cfg_if::cfg_if! {
        if #[cfg(target_arch = "avr")] {
            // Disable interrupts. This is an optimization fence.
            let irq_flag = disable_save();

            let r = f(unsafe { &CriticalSection::new() });
            let r = f(unsafe { CriticalSection::new() });

            // Restore interrupt state. This is an optimization fence.
            unsafe { restore(irq_flag); }

Do not follow this link