Skip to content

Commit d051999

Browse files
committed
remove embedded-hal 0.2 from prelude, rename hals
embedded-hal 1.0 renamed from embedded-hal-one to embedded-hal embedded-hal 0.2 renamed from embedded-hal to embedded-hal-old, still re-exported as hal-02
1 parent 0036ca4 commit d051999

File tree

12 files changed

+105
-85
lines changed

12 files changed

+105
-85
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ default-features = false
3737
features = ["const-fn"]
3838
version = "0.2.5"
3939

40-
[dependencies.embedded-hal]
40+
[dependencies.embedded-hal-old]
41+
package = "embedded-hal"
4142
features = ["unproven"]
42-
version = "0.2.4"
43+
version = "0.2.7"
4344

44-
[dependencies.embedded-hal-one]
45+
[dependencies.embedded-hal]
4546
version = "1.0.0"
46-
package = "embedded-hal"
4747

4848
[dependencies.embedded-dma]
4949
version = "0.1.2"
@@ -95,7 +95,7 @@ stm32g4a1 = ["stm32g4/stm32g4a1"]
9595
log-itm = ["cortex-m-log/itm"]
9696
log-rtt = []
9797
log-semihost = ["cortex-m-log/semihosting"]
98-
defmt-logging = ["defmt", "nb/defmt-0-3", "embedded-hal-one/defmt-03", "embedded-io/defmt-03"]
98+
defmt-logging = ["defmt", "nb/defmt-0-3", "embedded-hal/defmt-03", "embedded-io/defmt-03"]
9999

100100
[profile.dev]
101101
codegen-units = 1

src/adc.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ use crate::{
2020
};
2121
use core::fmt;
2222
use core::marker::PhantomData;
23-
use embedded_hal::{
23+
use embedded_hal_old::{
2424
adc::{Channel, OneShot},
25-
blocking::delay::DelayUs,
2625
};
26+
use embedded_hal::delay::DelayNs;
2727

2828
use self::config::ExternalTrigger12;
2929

@@ -168,7 +168,7 @@ macro_rules! adc_op_follower {
168168

169169
/// Contains types related to ADC configuration
170170
pub mod config {
171-
use embedded_hal::adc::Channel;
171+
use embedded_hal_old::adc::Channel;
172172

173173
/// The place in the sequence a given channel should be captured
174174
#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
@@ -1381,7 +1381,7 @@ pub trait AdcClaim<TYPE: TriggerType> {
13811381
self,
13821382
cs: ClockSource,
13831383
rcc: &Rcc,
1384-
delay: &mut impl DelayUs<u8>,
1384+
delay: &mut impl DelayNs,
13851385
reset: bool,
13861386
) -> Adc<TYPE, Disabled>;
13871387

@@ -1391,7 +1391,7 @@ pub trait AdcClaim<TYPE: TriggerType> {
13911391
cs: ClockSource,
13921392
rcc: &Rcc,
13931393
config: config::AdcConfig<TYPE::ExternalTrigger>,
1394-
delay: &mut impl DelayUs<u8>,
1394+
delay: &mut impl DelayNs,
13951395
reset: bool,
13961396
) -> Adc<TYPE, Configured>;
13971397
}
@@ -1583,7 +1583,7 @@ macro_rules! adc {
15831583

15841584
/// Powers-up an powered-down Adc
15851585
#[inline(always)]
1586-
pub fn power_up(&mut self, delay: &mut impl DelayUs<u8>) {
1586+
pub fn power_up(&mut self, delay: &mut impl DelayNs) {
15871587
if self.is_deeppwd_enabled() {
15881588
self.disable_deeppwd_down();
15891589
}
@@ -1616,7 +1616,7 @@ macro_rules! adc {
16161616

16171617
/// Enables the Voltage Regulator
16181618
#[inline(always)]
1619-
pub fn enable_vreg(&mut self, delay: &mut impl DelayUs<u8>) {
1619+
pub fn enable_vreg(&mut self, delay: &mut impl DelayNs) {
16201620
self.adc_reg.cr.modify(|_, w| w.advregen().set_bit());
16211621
while !self.adc_reg.cr.read().advregen().bit_is_set() {}
16221622

@@ -2124,7 +2124,7 @@ macro_rules! adc {
21242124
/// * `reset` - should a reset be performed. This is provided because on some devices multiple ADCs share the same common reset
21252125
/// TODO: fix needing SYST
21262126
#[inline(always)]
2127-
fn claim(self, cs: ClockSource, rcc: &Rcc, delay: &mut impl DelayUs<u8>, reset: bool) -> Adc<stm32::$adc_type, Disabled> {
2127+
fn claim(self, cs: ClockSource, rcc: &Rcc, delay: &mut impl DelayNs, reset: bool) -> Adc<stm32::$adc_type, Disabled> {
21282128
unsafe {
21292129
let rcc_ptr = &(*stm32::RCC::ptr());
21302130
stm32::$adc_type::enable(rcc_ptr);
@@ -2148,7 +2148,7 @@ macro_rules! adc {
21482148

21492149
/// claims and configures the Adc
21502150
#[inline(always)]
2151-
fn claim_and_configure(self, cs: ClockSource, rcc: &Rcc, config: config::AdcConfig<$trigger_type>, delay: &mut impl DelayUs<u8>, reset :bool) -> Adc<stm32::$adc_type, Configured> {
2151+
fn claim_and_configure(self, cs: ClockSource, rcc: &Rcc, config: config::AdcConfig<$trigger_type>, delay: &mut impl DelayNs, reset :bool) -> Adc<stm32::$adc_type, Configured> {
21522152
let mut adc = self.claim(cs, rcc, delay, reset);
21532153
adc.adc.config = config;
21542154

@@ -2172,7 +2172,7 @@ macro_rules! adc {
21722172
impl Adc<stm32::$adc_type, PoweredDown> {
21732173
/// Powers-up an powered-down Adc
21742174
#[inline(always)]
2175-
pub fn power_up(mut self, delay: &mut impl DelayUs<u8>) -> Adc<stm32::$adc_type, Disabled> {
2175+
pub fn power_up(mut self, delay: &mut impl DelayNs) -> Adc<stm32::$adc_type, Disabled> {
21762176
self.adc.power_up(delay);
21772177

21782178
Adc {

src/dac.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::gpio::gpioa::{PA4, PA5, PA6};
1212
use crate::gpio::DefaultMode;
1313
use crate::rcc::{self, *};
1414
use crate::stm32::{DAC1, DAC2, DAC3, DAC4, RCC};
15-
use hal::blocking::delay::DelayUs;
15+
use embedded_hal::delay::DelayNs;
1616

1717
pub trait DacOut<V> {
1818
fn set_value(&mut self, val: V);
@@ -230,9 +230,9 @@ macro_rules! dac_helper {
230230
///
231231
/// After the calibration operation, the DAC channel is
232232
/// disabled.
233-
pub fn calibrate_buffer<T>(self, delay: &mut T) -> $CX<MODE_BITS, Disabled>
233+
pub fn calibrate_buffer<D>(self, delay: &mut D) -> $CX<MODE_BITS, Disabled>
234234
where
235-
T: DelayUs<u32>,
235+
D: DelayNs
236236
{
237237
let dac = unsafe { &(*<$DAC>::ptr()) };
238238
dac.dac_cr.modify(|_, w| w.$en().clear_bit());

src/delay.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ use fugit::ExtU32Ceil;
4444

4545
use crate::nb::block;
4646
use crate::time::ExtU32;
47-
use embedded_hal::blocking::delay::{DelayMs, DelayUs};
48-
use embedded_hal_one::delay::DelayNs;
47+
use embedded_hal_old::blocking::delay::{DelayMs, DelayUs};
48+
use embedded_hal::delay::DelayNs;
4949

50-
pub trait CountDown: embedded_hal::timer::CountDown {
50+
pub trait CountDown: embedded_hal_old::timer::CountDown {
5151
fn max_period(&self) -> MicroSecond;
5252
}
5353

src/gpio.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ macro_rules! gpio {
240240
/// GPIO
241241
pub mod $gpiox {
242242
use core::marker::PhantomData;
243-
use hal::digital::v2::{toggleable, InputPin, OutputPin, StatefulOutputPin};
244-
use embedded_hal_one as hal1;
243+
use embedded_hal_old::digital::v2::{toggleable, InputPin, OutputPin, StatefulOutputPin};
245244
use crate::stm32::{EXTI, $GPIOX};
246245
use crate::exti::{ExtiExt, Event};
247246
use crate::rcc::Rcc;
@@ -289,11 +288,11 @@ macro_rules! gpio {
289288
}
290289
}
291290

292-
impl<MODE> hal1::digital::ErrorType for $PXx<Output<MODE>> {
291+
impl<MODE> embedded_hal::digital::ErrorType for $PXx<Output<MODE>> {
293292
type Error = core::convert::Infallible;
294293
}
295294

296-
impl<MODE> hal1::digital::OutputPin for $PXx<Output<MODE>> {
295+
impl<MODE> embedded_hal::digital::OutputPin for $PXx<Output<MODE>> {
297296
fn set_high(&mut self) -> Result<(), Self::Error> {
298297
// NOTE(unsafe) atomic write to a stateless register
299298
unsafe { (*$GPIOX::ptr()).bsrr.write(|w| w.bits(1 << self.i)) };
@@ -320,7 +319,7 @@ macro_rules! gpio {
320319
}
321320
}
322321

323-
impl<MODE> hal1::digital::StatefulOutputPin for $PXx<Output<MODE>> {
322+
impl<MODE> embedded_hal::digital::StatefulOutputPin for $PXx<Output<MODE>> {
324323
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
325324
let is_set_high = !self.is_set_low()?;
326325
Ok(is_set_high)
@@ -350,7 +349,7 @@ macro_rules! gpio {
350349
}
351350
}
352351

353-
impl<MODE> hal1::digital::InputPin for $PXx<Output<MODE>> {
352+
impl<MODE> embedded_hal::digital::InputPin for $PXx<Output<MODE>> {
354353
fn is_high(&mut self) -> Result<bool, Self::Error> {
355354
let is_high = !self.is_low()?;
356355
Ok(is_high)
@@ -379,11 +378,11 @@ macro_rules! gpio {
379378
}
380379
}
381380

382-
impl<MODE> hal1::digital::ErrorType for $PXx<Input<MODE>> {
381+
impl<MODE> embedded_hal::digital::ErrorType for $PXx<Input<MODE>> {
383382
type Error = core::convert::Infallible;
384383
}
385384

386-
impl<MODE> hal1::digital::InputPin for $PXx<Input<MODE>> {
385+
impl<MODE> embedded_hal::digital::InputPin for $PXx<Input<MODE>> {
387386
fn is_high(&mut self) -> Result<bool, Self::Error> {
388387
let is_high = !self.is_low()?;
389388
Ok(is_high)
@@ -642,11 +641,11 @@ macro_rules! gpio {
642641
}
643642
}
644643

645-
impl<MODE> hal1::digital::ErrorType for $PXi<Output<MODE>> {
644+
impl<MODE> embedded_hal::digital::ErrorType for $PXi<Output<MODE>> {
646645
type Error = core::convert::Infallible;
647646
}
648647

649-
impl<MODE> hal1::digital::OutputPin for $PXi<Output<MODE>> {
648+
impl<MODE> embedded_hal::digital::OutputPin for $PXi<Output<MODE>> {
650649
fn set_high(&mut self) -> Result<(), Self::Error> {
651650
// NOTE(unsafe) atomic write to a stateless register
652651
unsafe { (*$GPIOX::ptr()).bsrr.write(|w| w.bits(1 << $i)) };
@@ -673,7 +672,7 @@ macro_rules! gpio {
673672
}
674673
}
675674

676-
impl<MODE> hal1::digital::StatefulOutputPin for $PXi<Output<MODE>> {
675+
impl<MODE> embedded_hal::digital::StatefulOutputPin for $PXi<Output<MODE>> {
677676
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
678677
let is_set_high = !self.is_set_low()?;
679678
Ok(is_set_high)
@@ -703,7 +702,7 @@ macro_rules! gpio {
703702
}
704703
}
705704

706-
impl<MODE> hal1::digital::InputPin for $PXi<Output<MODE>> {
705+
impl<MODE> embedded_hal::digital::InputPin for $PXi<Output<MODE>> {
707706
fn is_high(&mut self) -> Result<bool, Self::Error> {
708707
let is_high = !self.is_low()?;
709708
Ok(is_high)
@@ -726,11 +725,11 @@ macro_rules! gpio {
726725
}
727726
}
728727

729-
impl<MODE> hal1::digital::ErrorType for $PXi<Input<MODE>> {
728+
impl<MODE> embedded_hal::digital::ErrorType for $PXi<Input<MODE>> {
730729
type Error = core::convert::Infallible;
731730
}
732731

733-
impl<MODE> hal1::digital::InputPin for $PXi<Input<MODE>> {
732+
impl<MODE> embedded_hal::digital::InputPin for $PXi<Input<MODE>> {
734733
fn is_high(&mut self) -> Result<bool, Self::Error> {
735734
let is_high = !self.is_low()?;
736735
Ok(is_high)

src/i2c.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! I2C
2-
use hal::blocking::i2c::{Read, Write, WriteRead};
3-
use embedded_hal_one::i2c::{ErrorKind, Operation, SevenBitAddress, TenBitAddress};
2+
use embedded_hal_old::blocking::i2c::{Read, Write, WriteRead};
3+
use embedded_hal::i2c::{ErrorKind, Operation, SevenBitAddress, TenBitAddress};
44

55
use crate::gpio::{gpioa::*, gpiob::*, gpioc::*, gpiof::*};
66
#[cfg(any(
@@ -128,11 +128,11 @@ pub enum Error {
128128
ArbitrationLost,
129129
}
130130

131-
impl embedded_hal_one::i2c::Error for Error {
132-
fn kind(&self) -> embedded_hal_one::i2c::ErrorKind {
131+
impl embedded_hal::i2c::Error for Error {
132+
fn kind(&self) -> embedded_hal::i2c::ErrorKind {
133133
match self {
134134
Self::Overrun => ErrorKind::Overrun,
135-
Self::Nack => ErrorKind::NoAcknowledge(embedded_hal_one::i2c::NoAcknowledgeSource::Unknown),
135+
Self::Nack => ErrorKind::NoAcknowledge(embedded_hal::i2c::NoAcknowledgeSource::Unknown),
136136
Self::PECError => ErrorKind::Other,
137137
Self::BusError => ErrorKind::Bus,
138138
Self::ArbitrationLost => ErrorKind::ArbitrationLoss
@@ -364,12 +364,12 @@ macro_rules! i2c {
364364
}
365365
}
366366

367-
impl<SDA, SCL> embedded_hal_one::i2c::ErrorType for I2c<$I2CX, SDA, SCL> {
367+
impl<SDA, SCL> embedded_hal::i2c::ErrorType for I2c<$I2CX, SDA, SCL> {
368368
type Error = Error;
369369
}
370370

371371
// TODO: custom read/write/read_write impl with hardware stop logic
372-
impl<SDA, SCL> embedded_hal_one::i2c::I2c for I2c<$I2CX, SDA, SCL> {
372+
impl<SDA, SCL> embedded_hal::i2c::I2c for I2c<$I2CX, SDA, SCL> {
373373
fn transaction(
374374
&mut self,
375375
address: SevenBitAddress,
@@ -386,7 +386,7 @@ macro_rules! i2c {
386386
})
387387
}
388388
}
389-
impl<SDA, SCL> embedded_hal_one::i2c::I2c<TenBitAddress> for I2c<$I2CX, SDA, SCL> {
389+
impl<SDA, SCL> embedded_hal::i2c::I2c<TenBitAddress> for I2c<$I2CX, SDA, SCL> {
390390
fn transaction(
391391
&mut self,
392392
address: TenBitAddress,

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ extern crate bare_metal;
2929
extern crate void;
3030

3131
pub extern crate cortex_m;
32-
pub extern crate embedded_hal as hal;
3332
pub extern crate nb;
3433
pub extern crate stm32g4;
3534

3635
pub use nb::block;
36+
pub use embedded_hal as hal;
37+
pub use embedded_hal_old as hal_02;
3738

3839
mod sealed {
3940
pub trait Sealed {}

src/prelude.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
pub use hal::digital::v2::*;
2-
pub use hal::prelude::*;
1+
pub use embedded_hal::{
2+
delay::DelayNs,
3+
digital::{InputPin, OutputPin, StatefulOutputPin},
4+
i2c::I2c,
5+
pwm::SetDutyCycle,
6+
spi::SpiBus,
7+
};
38

4-
pub use hal::adc::OneShot as _;
5-
pub use hal::watchdog::Watchdog as _;
6-
pub use hal::watchdog::WatchdogEnable as _;
9+
pub use embedded_hal_old::{
10+
adc::OneShot as _,
11+
watchdog::{Watchdog as _, WatchdogEnable as _},
12+
};
713

814
// pub use crate::analog::adc::AdcExt as _;
915

0 commit comments

Comments
 (0)