Skip to content

Commit 6197455

Browse files
committed
removed(hal)!: Remove embedded-hal v0.2 implementations (atsamd-rs#875)
1 parent d22f2af commit 6197455

File tree

19 files changed

+16
-206
lines changed

19 files changed

+16
-206
lines changed

hal/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ bitflags = "2.6.0"
3737
cipher = "0.3"
3838
critical-section = "1.2.0"
3939
cortex-m = "0.7"
40-
embedded-hal-02 = {package = "embedded-hal", version = "0.2", features = ["unproven"]}
41-
embedded-hal-1 = {package = "embedded-hal", version = "1.0.0"}
40+
embedded-hal = "1.0.0"
4241
embedded-hal-nb = "1.0.0"
4342
embedded-io = "0.6"
4443
fugit = "0.3"

hal/src/delay.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use cortex_m::peripheral::syst::SystClkSource;
66

77
use crate::clock::GenericClockController;
88
use crate::ehal::delay::DelayNs;
9-
use crate::ehal_02;
109
use crate::time::Hertz;
1110

1211
#[hal_cfg("rtc-d5x")]

hal/src/gpio/dynpin.rs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -550,50 +550,3 @@ impl StatefulOutputPin for DynPin {
550550
self._is_set_low()
551551
}
552552
}
553-
554-
//==============================================================================
555-
// Embedded HAL v0.2 traits
556-
//==============================================================================
557-
558-
impl crate::ehal_02::digital::v2::OutputPin for DynPin {
559-
type Error = Error;
560-
#[inline]
561-
fn set_high(&mut self) -> Result<(), Self::Error> {
562-
self._set_high()
563-
}
564-
#[inline]
565-
fn set_low(&mut self) -> Result<(), Self::Error> {
566-
self._set_low()
567-
}
568-
}
569-
570-
impl crate::ehal_02::digital::v2::InputPin for DynPin {
571-
type Error = Error;
572-
#[inline]
573-
fn is_high(&self) -> Result<bool, Self::Error> {
574-
self._is_high()
575-
}
576-
#[inline]
577-
fn is_low(&self) -> Result<bool, Self::Error> {
578-
self._is_low()
579-
}
580-
}
581-
582-
impl crate::ehal_02::digital::v2::ToggleableOutputPin for DynPin {
583-
type Error = Error;
584-
#[inline]
585-
fn toggle(&mut self) -> Result<(), Self::Error> {
586-
self._toggle()
587-
}
588-
}
589-
590-
impl crate::ehal_02::digital::v2::StatefulOutputPin for DynPin {
591-
#[inline]
592-
fn is_set_high(&self) -> Result<bool, Self::Error> {
593-
self._is_set_high()
594-
}
595-
#[inline]
596-
fn is_set_low(&self) -> Result<bool, Self::Error> {
597-
self._is_set_low()
598-
}
599-
}

hal/src/gpio/pin.rs

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -969,103 +969,6 @@ where
969969
}
970970
}
971971

972-
//==============================================================================
973-
// Embedded HAL v0.2 traits
974-
//==============================================================================
975-
976-
impl<I, C> crate::ehal_02::digital::v2::OutputPin for Pin<I, Output<C>>
977-
where
978-
I: PinId,
979-
C: OutputConfig,
980-
{
981-
type Error = Infallible;
982-
#[inline]
983-
fn set_high(&mut self) -> Result<(), Self::Error> {
984-
self._set_high();
985-
Ok(())
986-
}
987-
#[inline]
988-
fn set_low(&mut self) -> Result<(), Self::Error> {
989-
self._set_low();
990-
Ok(())
991-
}
992-
}
993-
994-
impl<I> crate::ehal_02::digital::v2::InputPin for Pin<I, ReadableOutput>
995-
where
996-
I: PinId,
997-
{
998-
type Error = Infallible;
999-
#[inline]
1000-
fn is_high(&self) -> Result<bool, Self::Error> {
1001-
Ok(self._is_high())
1002-
}
1003-
#[inline]
1004-
fn is_low(&self) -> Result<bool, Self::Error> {
1005-
Ok(self._is_low())
1006-
}
1007-
}
1008-
1009-
impl<I, C> crate::ehal_02::digital::v2::InputPin for Pin<I, Input<C>>
1010-
where
1011-
I: PinId,
1012-
C: InputConfig,
1013-
{
1014-
type Error = Infallible;
1015-
#[inline]
1016-
fn is_high(&self) -> Result<bool, Self::Error> {
1017-
Ok(self._is_high())
1018-
}
1019-
#[inline]
1020-
fn is_low(&self) -> Result<bool, Self::Error> {
1021-
Ok(self._is_low())
1022-
}
1023-
}
1024-
1025-
impl<I, C> crate::ehal_02::digital::v2::InputPin for Pin<I, Interrupt<C>>
1026-
where
1027-
I: PinId,
1028-
C: InterruptConfig,
1029-
{
1030-
type Error = Infallible;
1031-
#[inline]
1032-
fn is_high(&self) -> Result<bool, Self::Error> {
1033-
Ok(self._is_high())
1034-
}
1035-
#[inline]
1036-
fn is_low(&self) -> Result<bool, Self::Error> {
1037-
Ok(self._is_low())
1038-
}
1039-
}
1040-
1041-
impl<I, C> crate::ehal_02::digital::v2::ToggleableOutputPin for Pin<I, Output<C>>
1042-
where
1043-
I: PinId,
1044-
C: OutputConfig,
1045-
{
1046-
type Error = Infallible;
1047-
#[inline]
1048-
fn toggle(&mut self) -> Result<(), Self::Error> {
1049-
self._toggle();
1050-
Ok(())
1051-
}
1052-
}
1053-
1054-
impl<I, C> crate::ehal_02::digital::v2::StatefulOutputPin for Pin<I, Output<C>>
1055-
where
1056-
I: PinId,
1057-
C: OutputConfig,
1058-
{
1059-
#[inline]
1060-
fn is_set_high(&self) -> Result<bool, Self::Error> {
1061-
Ok(self._is_set_high())
1062-
}
1063-
#[inline]
1064-
fn is_set_low(&self) -> Result<bool, Self::Error> {
1065-
Ok(self._is_set_low())
1066-
}
1067-
}
1068-
1069972
//==============================================================================
1070973
// Pin definitions
1071974
//==============================================================================

hal/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![no_std]
22

3-
pub use embedded_hal_1 as ehal;
4-
use embedded_hal_02 as ehal_02;
3+
pub use embedded_hal as ehal;
54
pub use embedded_hal_nb as ehal_nb;
65
pub use embedded_io;
76
pub use fugit;

hal/src/peripherals/adc/d11.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
use atsamd_hal_macros::hal_cfg;
33

44
use crate::clock::GenericClockController;
5-
use crate::ehal_02::adc::{Channel, OneShot};
65
use crate::gpio::*;
76
use crate::pac::{self, adc, Pm};
87

hal/src/peripherals/adc/d5x.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use atsamd_hal_macros::hal_cfg;
44
use crate::clock::GenericClockController;
55
#[rustfmt::skip]
66
use crate::gpio::*;
7-
use crate::ehal_02::adc::{Channel, OneShot};
87
use crate::pac::gclk::genctrl::Srcselect::Dfll;
98
use crate::pac::gclk::pchctrl::Genselect;
109
use crate::pac::{adc0, Adc0, Adc1, Mclk};

hal/src/peripherals/eic/d11/pin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use atsamd_hal_macros::hal_cfg;
22

3-
use core::convert::Infallible;
4-
use crate::ehal_02::digital::v2::InputPin as InputPin_02;
53
use crate::ehal::digital::{ErrorType, InputPin};
64
use crate::eic::*;
75
use crate::gpio::{
8-
self, pin::*, AnyPin, FloatingInterrupt, PinMode, PullDownInterrupt, PullUpInterrupt,
6+
self, AnyPin, FloatingInterrupt, PinMode, PullDownInterrupt, PullUpInterrupt, pin::*,
97
};
8+
use core::convert::Infallible;
109

1110
/// The pad macro defines the given EIC pin and implements EicPin for the
1211
/// given pins. The EicPin implementation will configure the pin for the
@@ -153,7 +152,8 @@ where
153152
}
154153

155154
impl<P, Id, F> InputPin for ExtInt<P, Id, F>
156-
where Self: ErrorType,
155+
where
156+
Self: ErrorType,
157157
P: EicPin,
158158
Id: ChId,
159159
{

hal/src/peripherals/eic/d5x/pin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use atsamd_hal_macros::hal_cfg;
22

3-
use core::convert::Infallible;
4-
use crate::ehal_02::digital::v2::InputPin as InputPin_02;
53
use crate::ehal::digital::{ErrorType, InputPin};
64
use crate::eic::*;
75
use crate::gpio::{
8-
self, pin::*, AnyPin, FloatingInterrupt, PinMode, PullDownInterrupt, PullUpInterrupt,
6+
self, AnyPin, FloatingInterrupt, PinMode, PullDownInterrupt, PullUpInterrupt, pin::*,
97
};
8+
use core::convert::Infallible;
109

1110
/// The pad macro defines the given EIC pin and implements EicPin for the
1211
/// given pins. The EicPin implementation will configure the pin for the
@@ -176,7 +175,8 @@ where
176175
}
177176

178177
impl<P, Id, F> InputPin for ExtInt<P, Id, F>
179-
where Self: ErrorType,
178+
where
179+
Self: ErrorType,
180180
P: EicPin,
181181
Id: ChId,
182182
{

hal/src/peripherals/timer/d11.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use core::convert::Infallible;
44
use atsamd_hal_macros::hal_cfg;
55
use fugit::NanosDurationU32;
66

7-
use crate::ehal_02::timer::{CountDown, Periodic};
87
use crate::pac::Pm;
98
#[hal_cfg("tc1-d11")]
109
use crate::pac::{tc1::Count16 as Count16Reg, Tc1};

hal/src/peripherals/timer/d5x.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use core::convert::Infallible;
44
use atsamd_hal_macros::hal_cfg;
55
use fugit::NanosDurationU32;
66

7-
use crate::ehal_02::timer::{CountDown, Periodic};
87
use crate::pac::tc0::Count16 as Count16Reg;
98
use crate::pac::{Mclk, Tc2, Tc3};
109
#[hal_cfg(all("tc4", "tc5"))]

hal/src/peripherals/trng.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ use crate::pac::{self, Mclk};
22

33
use rand_core::{CryptoRng, RngCore};
44

5-
use crate::ehal_02::blocking::rng::Read;
6-
75
pub struct Trng(pac::Trng);
86

97
impl Trng {
@@ -62,8 +60,11 @@ impl RngCore for Trng {
6260

6361
impl CryptoRng for Trng {}
6462

65-
impl Read for Trng {
66-
type Error = ();
63+
impl embedded_io::ErrorType for Trng {
64+
type Error = core::convert::Infallible;
65+
}
66+
67+
impl embedded_io::Read for Trng {
6768
fn read(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error> {
6869
self.random(buffer);
6970
Ok(())

hal/src/peripherals/watchdog.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::ehal_02::watchdog;
21
use crate::pac::Wdt;
32
use atsamd_hal_macros::hal_macro_helper;
43

hal/src/prelude.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ pub use crate::timer_traits::InterruptDrivenTimer;
44
pub use fugit::ExtU32 as _;
55
pub use fugit::RateExtU32 as _;
66

7-
// embedded-hal doesn’t yet have v2 in its prelude, so we need to
8-
// export it ourselves
9-
pub use crate::ehal_02::digital::v2::InputPin as _atsamd_hal_embedded_hal_digital_v2_InputPin;
10-
pub use crate::ehal_02::digital::v2::OutputPin as _atsamd_hal_embedded_hal_digital_v2_OutputPin;
11-
pub use crate::ehal_02::digital::v2::ToggleableOutputPin as _atsamd_hal_embedded_hal_digital_v2_ToggleableOutputPin;
12-
13-
pub use crate::ehal_02::prelude::*;
14-
157
#[cfg(feature = "rtic")]
168
pub use rtic_time::Monotonic as _;
179

hal/src/rtc/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
use atsamd_hal_macros::{hal_cfg, hal_macro_helper};
33
use fugit::NanosDurationU32;
44

5-
use crate::ehal_02;
65
use crate::pac;
76
use crate::pac::rtc::{Mode0, Mode2};
87
use crate::time::{Hertz, Nanoseconds};

hal/src/sercom/spi/impl_ehal/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use super::*;
22
use crate::ehal::spi::{self, SpiBus};
3-
#[allow(unused_imports)]
4-
use crate::ehal_02::{blocking, serial};
53
use crate::ehal_nb;
64
use num_traits::PrimInt;
75

hal/src/sercom/spi/impl_ehal/thumbv7em.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
//! [`Size`]: super::Size
9696
//! [`spi_future`]: crate::sercom::spi_future
9797
98-
use crate::ehal_02;
9998
use crate::ehal_nb;
10099
use crate::sercom::spi::{
101100
AtomicSize, Config, DataWidth, Duplex, DynLength, Error, Flags, GreaterThan4, Length,

hal/src/sercom/uart/impl_ehal.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ use super::{
44
Capability, Config, DataReg, EightBit, Error, Error as UartError, Flags, Receive, Transmit,
55
Uart, ValidConfig, ValidPads,
66
};
7-
use crate::{
8-
ehal_02::{
9-
blocking,
10-
serial::{Read, Write},
11-
},
12-
typelevel::NoneT,
13-
};
7+
use crate::typelevel::NoneT;
148
use nb::Error::WouldBlock;
159
use num_traits::AsPrimitive;
1610

hal/src/sleeping_delay.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use cortex_m::asm;
44
use fugit::ExtU32;
55

66
use crate::ehal::delay::DelayNs;
7-
use crate::ehal_02;
87
use crate::timer_traits::InterruptDrivenTimer;
98

109
const NUM_NS_IN_S: u32 = 1_000_000_000;
@@ -36,26 +35,6 @@ where
3635
}
3736
}
3837

39-
impl<TIM, TYPE> ehal_02::blocking::delay::DelayUs<TYPE> for SleepingDelay<TIM>
40-
where
41-
TIM: InterruptDrivenTimer,
42-
TYPE: Into<u32>,
43-
{
44-
fn delay_us(&mut self, us: TYPE) {
45-
<Self as DelayNs>::delay_us(self, us.into());
46-
}
47-
}
48-
49-
impl<TIM, TYPE> ehal_02::blocking::delay::DelayMs<TYPE> for SleepingDelay<TIM>
50-
where
51-
TIM: InterruptDrivenTimer,
52-
TYPE: Into<u32>,
53-
{
54-
fn delay_ms(&mut self, ms: TYPE) {
55-
<Self as DelayNs>::delay_ms(self, ms.into());
56-
}
57-
}
58-
5938
impl<TIM: InterruptDrivenTimer> DelayNs for SleepingDelay<TIM> {
6039
fn delay_ns(&mut self, ns: u32) {
6140
// Determine how many cycles we need to run for this delay, if any

0 commit comments

Comments
 (0)