Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[avr-hal-generic] remove rustc version check #619

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions avr-hal-generic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -31,6 +30,3 @@ unwrap-infallible = "0.1.5"
version = "0.2.3"
package = "embedded-hal"
features = ["unproven"]

[build-dependencies]
rustversion = "1.0"
16 changes: 0 additions & 16 deletions avr-hal-generic/build.rs

This file was deleted.

53 changes: 17 additions & 36 deletions avr-hal-generic/src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -44,38 +44,24 @@ impl<SPEED> Delay<SPEED> {

// 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<u16> for Delay<crate::clock::MHz24> {
fn delay_us(&mut self, mut us: u16) {
Expand Down Expand Up @@ -106,16 +92,11 @@ impl delay_v0::DelayUs<u16> for Delay<crate::clock::MHz20> {

// 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)
Expand Down
3 changes: 1 addition & 2 deletions avr-hal-generic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down