Skip to content

Commit 07fdea1

Browse files
Ashutosh ParkhiMousius
andcommitted
Support for embedded_hal 1.0.0-alpha.8 in addition to 0.2.4
Co-authored-by: Chris Sidebottom <[email protected]>
1 parent 4e90862 commit 07fdea1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ bare-metal = "1"
2121
volatile-register = "0.2.0"
2222
bitfield = "0.13.2"
2323
embedded-hal = "0.2.4"
24+
eh1_0_alpha = { version = "=1.0.0-alpha.8", package="embedded-hal", optional=true }
25+
2426

2527
[dependencies.serde]
2628
version = "1"

src/delay.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
//! A delay driver based on SysTick.
22
33
use crate::peripheral::{syst::SystClkSource, SYST};
4+
#[cfg(feature = "eh1_0_alpha")]
5+
use core::convert::Infallible;
6+
7+
#[cfg(feature = "eh1_0_alpha")]
8+
use eh1_0_alpha::delay::blocking::DelayUs as EH1DelayUs;
49
use embedded_hal::blocking::delay::{DelayMs, DelayUs};
510

611
/// System timer (SysTick) as a delay provider.
@@ -75,6 +80,22 @@ impl Delay {
7580
}
7681
}
7782

83+
#[cfg(feature = "eh1_0_alpha")]
84+
impl EH1DelayUs for Delay {
85+
type Error = Infallible;
86+
87+
#[inline]
88+
fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> {
89+
Delay::delay_us(self, us);
90+
Ok(())
91+
}
92+
93+
fn delay_ms(&mut self, us: u32) -> Result<(), Self::Error> {
94+
Delay::delay_ms(self, us);
95+
Ok(())
96+
}
97+
}
98+
7899
impl DelayMs<u32> for Delay {
79100
#[inline]
80101
fn delay_ms(&mut self, ms: u32) {

0 commit comments

Comments
 (0)