diff --git a/avr-hal-generic/Cargo.toml b/avr-hal-generic/Cargo.toml index feaeecf026..c5d0ff446f 100644 --- a/avr-hal-generic/Cargo.toml +++ b/avr-hal-generic/Cargo.toml @@ -17,7 +17,6 @@ features = ["docsrs"] docsrs = ["avr-device/docsrs"] [dependencies] -cfg-if = "1" nb = "1.1.0" ufmt = "0.2.0" paste = "1.0.0" @@ -31,6 +30,3 @@ unwrap-infallible = "0.1.5" version = "0.2.3" package = "embedded-hal" features = ["unproven"] - -[build-dependencies] -rustversion = "1.0" diff --git a/avr-hal-generic/build.rs b/avr-hal-generic/build.rs deleted file mode 100644 index b22938833f..0000000000 --- a/avr-hal-generic/build.rs +++ /dev/null @@ -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_hal_asm_macro"); -} diff --git a/avr-hal-generic/src/delay.rs b/avr-hal-generic/src/delay.rs index 8d8996e90a..f76366cdbd 100644 --- a/avr-hal-generic/src/delay.rs +++ b/avr-hal-generic/src/delay.rs @@ -4,7 +4,7 @@ use core::marker; use embedded_hal::delay::DelayNs; use embedded_hal_v0::blocking::delay as delay_v0; -#[cfg(all(target_arch = "avr", avr_hal_asm_macro))] +#[cfg(target_arch = "avr")] use core::arch::asm; /// A busy-loop delay implementation @@ -44,38 +44,24 @@ impl Delay { // based on https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/wiring.c -cfg_if::cfg_if! { - if #[cfg(all(target_arch = "avr", avr_hal_asm_macro))] { - #[allow(unused_assignments)] - fn busy_loop(mut c: u16) { - unsafe { - asm!( - "1:", - "sbiw {c}, 1", - "brne 1b", - c = inout(reg_iw) c, - ); - } - } - } else if #[cfg(target_arch = "avr")] { - #[allow(unused_assignments)] - fn busy_loop(mut c: u16) { - unsafe { - llvm_asm!("1: sbiw $0,1\n\tbrne 1b" - : "=w"(c) - : "0"(c) - : - : "volatile" - ); - } - } - } else { - fn busy_loop(_c: u16) { - unimplemented!("Implementation is only available for avr targets!") - } +#[cfg(target_arch = "avr")] +#[allow(unused_assignments)] +fn busy_loop(mut c: u16) { + unsafe { + asm!( + "1:", + "sbiw {c}, 1", + "brne 1b", + c = inout(reg_iw) c, + ); } } +#[cfg(not(target_arch = "avr"))] +fn busy_loop(_c: u16) { + unimplemented!("Implementation is only available for avr targets!") +} + // Clock-Specific Delay Implementations ----------------------------------- {{{ impl delay_v0::DelayUs for Delay { fn delay_us(&mut self, mut us: u16) { @@ -106,16 +92,11 @@ impl delay_v0::DelayUs for Delay { // for a one-microsecond delay, simply return. the overhead // of the function call takes 18 (20) cycles, which is 1us - #[cfg(all(target_arch = "avr", avr_hal_asm_macro))] + #[cfg(target_arch = "avr")] unsafe { asm!("nop", "nop", "nop", "nop"); } - #[cfg(all(target_arch = "avr", not(avr_hal_asm_macro)))] - unsafe { - llvm_asm!("nop\nnop\nnop\nnop" :::: "volatile"); - } - if us <= 1 { return; } // = 3 cycles, (4 when true) diff --git a/avr-hal-generic/src/lib.rs b/avr-hal-generic/src/lib.rs index 41d3c9d688..365bf3b21a 100644 --- a/avr-hal-generic/src/lib.rs +++ b/avr-hal-generic/src/lib.rs @@ -1,6 +1,5 @@ #![no_std] -#![cfg_attr(avr_hal_asm_macro, feature(asm_experimental_arch))] -#![cfg_attr(not(avr_hal_asm_macro), feature(llvm_asm))] +#![feature(asm_experimental_arch)] pub use embedded_hal as hal; pub use embedded_hal_v0 as hal_v0;