M Cargo.toml => Cargo.toml +0 -3
@@ 67,6 67,3 @@ cfg-if = "0.1.10"
path = "macros/"
version = "=0.3.4"
optional = true
-
-[build-dependencies]
-rustversion = "1.0"
D build.rs => build.rs +0 -16
@@ 1,16 0,0 @@
-fn main() {
- println!("cargo:rerun-if-changed=build.rs");
-
- maybe_enable_asm();
-}
-
-#[rustversion::before(1.59.0)]
-fn maybe_enable_asm() {
- //
-}
-
-#[rustversion::since(1.59.0)]
-fn maybe_enable_asm() {
- // https://github.com/rust-lang/rust/pull/92816
- println!("cargo:rustc-cfg=avr_device_asm_macro");
-}
M src/asm.rs => src/asm.rs +4 -10
@@ 1,16 1,14 @@
//! Assembly instructions
-#[cfg(all(target_arch = "avr", avr_device_asm_macro))]
+#[cfg(target_arch = "avr")]
use core::arch::asm;
/// No Operation
#[inline(always)]
pub fn nop() {
cfg_if::cfg_if! {
- if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] {
+ if #[cfg(target_arch = "avr")] {
unsafe { asm!("nop") }
- } else if #[cfg(target_arch = "avr")] {
- unsafe { llvm_asm!("nop") }
} else {
unimplemented!()
}
@@ 21,10 19,8 @@ pub fn nop() {
#[inline(always)]
pub fn sleep() {
cfg_if::cfg_if! {
- if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] {
+ if #[cfg(target_arch = "avr")] {
unsafe { asm!("sleep") }
- } else if #[cfg(target_arch = "avr")] {
- unsafe { llvm_asm!("sleep") }
} else {
unimplemented!()
}
@@ 35,10 31,8 @@ pub fn sleep() {
#[inline(always)]
pub fn wdr() {
cfg_if::cfg_if! {
- if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] {
+ if #[cfg(target_arch = "avr")] {
unsafe { asm!("wdr") }
- } else if #[cfg(target_arch = "avr")] {
- unsafe { llvm_asm!("wdr") }
} else {
unimplemented!()
}
M src/interrupt.rs => src/interrupt.rs +3 -14
@@ 30,7 30,7 @@
pub use bare_metal::{CriticalSection, Mutex, Nr};
-#[cfg(all(target_arch = "avr", avr_device_asm_macro))]
+#[cfg(target_arch = "avr")]
use core::arch::asm;
#[inline]
@@ 39,7 39,7 @@ use core::arch::asm;
/// Returns a bool, reflecting whether interrupts were enabled prior to calling this method.
pub fn disable() -> bool {
cfg_if::cfg_if! {
- if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] {
+ if #[cfg(target_arch = "avr")] {
// Store current state
let sreg: u8;
@@ 54,15 54,6 @@ pub fn disable() -> bool {
unsafe { asm!("cli") };
sreg & 0x80 == 0x80
- } else if #[cfg(target_arch = "avr")] {
- // Store current state
- let sreg: u8;
- unsafe { llvm_asm!("in $0,0x3F" :"=r"(sreg) ::: "volatile") };
-
- // Disable interrupts
- unsafe { llvm_asm!("cli" :::: "volatile") };
-
- sreg & 0x80 == 0x80
} else {
unimplemented!()
}
@@ 77,10 68,8 @@ pub fn disable() -> bool {
/// - Do not call this function inside an [crate::interrupt::free] critical section
pub unsafe fn enable() {
cfg_if::cfg_if! {
- if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] {
+ if #[cfg(target_arch = "avr")] {
asm!("sei");
- } else if #[cfg(target_arch = "avr")] {
- llvm_asm!("sei" :::: "volatile");
} else {
unimplemented!()
}
M src/lib.rs => src/lib.rs +1 -2
@@ 131,8 131,7 @@
//! * To enable the crate's runtime environment, use the `rt` feature.
#![no_std]
-#![cfg_attr(avr_device_asm_macro, feature(asm_experimental_arch))]
-#![cfg_attr(not(avr_device_asm_macro), feature(llvm_asm))]
+#![cfg_attr(target_arch = "avr", feature(asm_experimental_arch))] // for experimental AVR asm! macro.
pub mod asm;
pub mod interrupt;