Skip to content

Commit b417d5c

Browse files
tones111Rahix
authored andcommitted
avr-hal-generic: remove rustc version check
The build.rs logic is only used to detect a relatively old compiler version (Feb 2022). Since a nightly build is required to target AVR it's unlikely anyone is benefiting from this check. By removing it we reduce dependencies and implementation complexity.
1 parent 949130a commit b417d5c

File tree

4 files changed

+18
-58
lines changed

4 files changed

+18
-58
lines changed

avr-hal-generic/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ features = ["docsrs"]
1717
docsrs = ["avr-device/docsrs"]
1818

1919
[dependencies]
20-
cfg-if = "1"
2120
nb = "1.1.0"
2221
ufmt = "0.2.0"
2322
paste = "1.0.0"
@@ -31,6 +30,3 @@ unwrap-infallible = "0.1.5"
3130
version = "0.2.3"
3231
package = "embedded-hal"
3332
features = ["unproven"]
34-
35-
[build-dependencies]
36-
rustversion = "1.0"

avr-hal-generic/build.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

avr-hal-generic/src/delay.rs

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::marker;
44
use embedded_hal::delay::DelayNs;
55
use embedded_hal_v0::blocking::delay as delay_v0;
66

7-
#[cfg(all(target_arch = "avr", avr_hal_asm_macro))]
7+
#[cfg(target_arch = "avr")]
88
use core::arch::asm;
99

1010
/// A busy-loop delay implementation
@@ -44,38 +44,24 @@ impl<SPEED> Delay<SPEED> {
4444

4545
// based on https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/wiring.c
4646

47-
cfg_if::cfg_if! {
48-
if #[cfg(all(target_arch = "avr", avr_hal_asm_macro))] {
49-
#[allow(unused_assignments)]
50-
fn busy_loop(mut c: u16) {
51-
unsafe {
52-
asm!(
53-
"1:",
54-
"sbiw {c}, 1",
55-
"brne 1b",
56-
c = inout(reg_iw) c,
57-
);
58-
}
59-
}
60-
} else if #[cfg(target_arch = "avr")] {
61-
#[allow(unused_assignments)]
62-
fn busy_loop(mut c: u16) {
63-
unsafe {
64-
llvm_asm!("1: sbiw $0,1\n\tbrne 1b"
65-
: "=w"(c)
66-
: "0"(c)
67-
:
68-
: "volatile"
69-
);
70-
}
71-
}
72-
} else {
73-
fn busy_loop(_c: u16) {
74-
unimplemented!("Implementation is only available for avr targets!")
75-
}
47+
#[cfg(target_arch = "avr")]
48+
#[allow(unused_assignments)]
49+
fn busy_loop(mut c: u16) {
50+
unsafe {
51+
asm!(
52+
"1:",
53+
"sbiw {c}, 1",
54+
"brne 1b",
55+
c = inout(reg_iw) c,
56+
);
7657
}
7758
}
7859

60+
#[cfg(not(target_arch = "avr"))]
61+
fn busy_loop(_c: u16) {
62+
unimplemented!("Implementation is only available for avr targets!")
63+
}
64+
7965
// Clock-Specific Delay Implementations ----------------------------------- {{{
8066
impl delay_v0::DelayUs<u16> for Delay<crate::clock::MHz24> {
8167
fn delay_us(&mut self, mut us: u16) {
@@ -106,16 +92,11 @@ impl delay_v0::DelayUs<u16> for Delay<crate::clock::MHz20> {
10692

10793
// for a one-microsecond delay, simply return. the overhead
10894
// of the function call takes 18 (20) cycles, which is 1us
109-
#[cfg(all(target_arch = "avr", avr_hal_asm_macro))]
95+
#[cfg(target_arch = "avr")]
11096
unsafe {
11197
asm!("nop", "nop", "nop", "nop");
11298
}
11399

114-
#[cfg(all(target_arch = "avr", not(avr_hal_asm_macro)))]
115-
unsafe {
116-
llvm_asm!("nop\nnop\nnop\nnop" :::: "volatile");
117-
}
118-
119100
if us <= 1 {
120101
return;
121102
} // = 3 cycles, (4 when true)

avr-hal-generic/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![no_std]
2-
#![cfg_attr(avr_hal_asm_macro, feature(asm_experimental_arch))]
3-
#![cfg_attr(not(avr_hal_asm_macro), feature(llvm_asm))]
2+
#![feature(asm_experimental_arch)]
43

54
pub use embedded_hal as hal;
65
pub use embedded_hal_v0 as hal_v0;

0 commit comments

Comments
 (0)