Skip to content

Support for embedded_hal 1.0.0-alpha.8 in addition to 0.2.4 #444

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

Closed
Closed
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: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright 2022 Arm Limited and/or its affiliates <[email protected]>

[package]
authors = [
"The Cortex-M Team <[email protected]>",
Expand All @@ -21,6 +23,8 @@ bare-metal = "1"
volatile-register = "0.2.0"
bitfield = "0.13.2"
embedded-hal = "0.2.4"
eh1_0_alpha = { version = "=1.0.0-alpha.8", package="embedded-hal", optional=true }


[dependencies.serde]
version = "1"
Expand Down
23 changes: 23 additions & 0 deletions src/delay.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// # Copyright 2022 Arm Limited and/or its affiliates <[email protected]>

//! A delay driver based on SysTick.

use crate::peripheral::{syst::SystClkSource, SYST};
#[cfg(feature = "eh1_0_alpha")]
use core::convert::Infallible;

#[cfg(feature = "eh1_0_alpha")]
use eh1_0_alpha::delay::blocking::DelayUs as EH1DelayUs;
use embedded_hal::blocking::delay::{DelayMs, DelayUs};

/// System timer (SysTick) as a delay provider.
Expand Down Expand Up @@ -75,6 +82,22 @@ impl Delay {
}
}

#[cfg(feature = "eh1_0_alpha")]
impl EH1DelayUs for Delay {
type Error = Infallible;

#[inline]
fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> {
Delay::delay_us(self, us);
Ok(())
}

fn delay_ms(&mut self, us: u32) -> Result<(), Self::Error> {
Delay::delay_ms(self, us);
Ok(())
}
}

impl DelayMs<u32> for Delay {
#[inline]
fn delay_ms(&mut self, ms: u32) {
Expand Down