Skip to content

Commit aa6da09

Browse files
committed
swap embedded-hals
1 parent f848188 commit aa6da09

32 files changed

+81
-129
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- shorten gpio ptr access
1313
- bump embedded-hal to `1.0.0-rc.3`
14+
- make `embedded-hal` `1.0` main implementation
1415

1516
## [v0.19.0] - 2023-12-11
1617

@@ -59,7 +60,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
5960

6061
### Changed
6162

62-
- implement `embedded_hal::blocking::i2c::Transactional` for `I2c` [#671]
63+
- implement `embedded_hal_02::blocking::i2c::Transactional` for `I2c` [#671]
6364

6465
### Fixed
6566

@@ -334,7 +335,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
334335

335336
### Fixed
336337

337-
- Fix `embedded_hal 1.0-alpha.7` version, public `PinMode`, update deps [#485]
338+
- Fix `embedded_hal_02 1.0-alpha.7` version, public `PinMode`, update deps [#485]
338339
- Remove the defmt feature/dependency name workaround [#479]
339340

340341
[#479]: https://github.com/stm32-rs/stm32f4xx-hal/pull/479
@@ -393,7 +394,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
393394
- Move `MonoTimer` from `timer` to dwt mode [#448]
394395
- Unify serial trait impls for embedded-hal 0.2 & 1.0 [#447]
395396
- Add possibility to select Timer master mode
396-
- Add inherent impl of `embedded_hal::Pwm` methods on `Pwm`s [#439]
397+
- Add inherent impl of `embedded_hal_02::Pwm` methods on `Pwm`s [#439]
397398
- Use `embedded-dma` v0.2 [#440]
398399
- Add LSI support for `Rtc` [#438]
399400
- Use `time` for `Rtc` instead of `rtcc`, add `rtc` example [#436]

Cargo.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ sdio-host = { version = "0.6.0", optional = true }
3939
embedded-dma = "0.2.0"
4040
bare-metal = { version = "1" }
4141
void = { default-features = false, version = "1.0.2" }
42-
embedded-hal = { features = ["unproven"], version = "0.2.7" }
43-
embedded-hal-nb = "=1.0.0-rc.3"
4442
display-interface = { version = "0.4.1", optional = true }
4543
fugit = "0.3.7"
4644
fugit-timer = "0.1.3"
@@ -54,9 +52,16 @@ vcell = "0.1.3"
5452
version = "0.3.14"
5553
default-features = false
5654

57-
[dependencies.embedded-hal-one]
58-
version = "=1.0.0-rc.3"
55+
[dependencies.embedded-hal-02]
5956
package = "embedded-hal"
57+
version = "0.2.7"
58+
features = ["unproven"]
59+
60+
[dependencies.embedded-hal]
61+
git = "https://github.com/rust-embedded/embedded-hal"
62+
63+
[dependencies.embedded-hal-nb]
64+
git = "https://github.com/rust-embedded/embedded-hal"
6065

6166
[dependencies.stm32_i2s_v12x]
6267
version = "0.5.0"

examples/delay-timer-blinky.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn main() -> ! {
3333
loop {
3434
// On for 1s, off for 3s.
3535
led.set_high();
36-
// Use `embedded_hal::DelayMs` trait
36+
// Use `embedded_hal_02::DelayMs` trait
3737
delay.delay_ms(1000_u32);
3838
led.set_low();
3939
// or use `fugit::ExtU32` trait

examples/qei.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use panic_halt as _;
1414

1515
use cortex_m_rt::entry;
16-
use embedded_hal::Direction as RotaryDirection;
16+
use embedded_hal_02::Direction as RotaryDirection;
1717
use stm32f4xx_hal::{pac, prelude::*, qei::Qei};
1818

1919
#[entry]

examples/rtic-spi-slave-dma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#[rtic::app(device = stm32f4xx_hal::pac, peripherals = true, dispatchers = [TIM2])]
77
mod app {
88

9-
use embedded_hal::spi::{Mode, Phase, Polarity};
9+
use embedded_hal_02::spi::{Mode, Phase, Polarity};
1010
use hal::{
1111
dma::{
1212
config::DmaConfig, DmaFlag, MemoryToPeripheral, PeripheralToMemory, Stream0, Stream5,

examples/spi-dma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use stm32f4xx_hal::dma::DmaFlag;
88
use core::cell::RefCell;
99
use cortex_m::interrupt::Mutex;
1010
use cortex_m_rt::entry;
11-
use embedded_hal::spi::{Mode, Phase, Polarity};
11+
use embedded_hal_02::spi::{Mode, Phase, Polarity};
1212
use stm32f4xx_hal::pac::interrupt;
1313
use stm32f4xx_hal::{
1414
dma::{config, MemoryToPeripheral, Stream4, StreamsTuple, Transfer},

src/adc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ macro_rules! adc {
860860
/// to sample for at a given ADC clock frequency
861861
pub fn configure_channel<CHANNEL>(&mut self, _channel: &CHANNEL, sequence: config::Sequence, sample_time: config::SampleTime)
862862
where
863-
CHANNEL: embedded_hal::adc::Channel<pac::$adc_type, ID=u8>
863+
CHANNEL: embedded_hal_02::adc::Channel<pac::$adc_type, ID=u8>
864864
{
865865
//Check the sequence is long enough
866866
self.adc_reg.sqr1.modify(|r, w| {
@@ -953,7 +953,7 @@ macro_rules! adc {
953953
/// Note that it reconfigures the adc sequence and doesn't restore it
954954
pub fn convert<PIN>(&mut self, pin: &PIN, sample_time: config::SampleTime) -> u16
955955
where
956-
PIN: embedded_hal::adc::Channel<pac::$adc_type, ID=u8>
956+
PIN: embedded_hal_02::adc::Channel<pac::$adc_type, ID=u8>
957957
{
958958
self.adc_reg.cr2.modify(|_, w| w
959959
.dma().clear_bit() //Disable dma
@@ -986,7 +986,7 @@ macro_rules! adc {
986986

987987
impl Adc<pac::$adc_type> {
988988
fn read<PIN>(&mut self, pin: &mut PIN) -> nb::Result<u16, ()>
989-
where PIN: embedded_hal::adc::Channel<pac::$adc_type, ID=u8>,
989+
where PIN: embedded_hal_02::adc::Channel<pac::$adc_type, ID=u8>,
990990
{
991991
let enabled = self.is_enabled();
992992
if !enabled {
@@ -1003,9 +1003,9 @@ macro_rules! adc {
10031003
}
10041004
}
10051005

1006-
impl<PIN> embedded_hal::adc::OneShot<pac::$adc_type, u16, PIN> for Adc<pac::$adc_type>
1006+
impl<PIN> embedded_hal_02::adc::OneShot<pac::$adc_type, u16, PIN> for Adc<pac::$adc_type>
10071007
where
1008-
PIN: embedded_hal::adc::Channel<pac::$adc_type, ID=u8>,
1008+
PIN: embedded_hal_02::adc::Channel<pac::$adc_type, ID=u8>,
10091009
{
10101010
type Error = ();
10111011

src/adc/f4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
macro_rules! adc_pins {
44
($($pin:ty => ($adc:ident, $chan:expr)),+ $(,)*) => {
55
$(
6-
impl embedded_hal::adc::Channel<pac::$adc> for $pin {
6+
impl embedded_hal_02::adc::Channel<pac::$adc> for $pin {
77
type ID = u8;
88
fn channel() -> u8 { $chan }
99
}

src/dwt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ impl Delay {
9797
}
9898

9999
// Implement DelayUs/DelayMs for various integer types
100-
impl<T: Into<u64>> embedded_hal::blocking::delay::DelayUs<T> for Delay {
100+
impl<T: Into<u64>> embedded_hal_02::blocking::delay::DelayUs<T> for Delay {
101101
fn delay_us(&mut self, us: T) {
102102
// Convert us to ticks
103103
let start = DWT::cycle_count();
104104
let ticks = (us.into() * self.clock.raw() as u64) / 1_000_000;
105105
Delay::delay_ticks(start, ticks);
106106
}
107107
}
108-
impl<T: Into<u64>> embedded_hal::blocking::delay::DelayMs<T> for Delay {
108+
impl<T: Into<u64>> embedded_hal_02::blocking::delay::DelayMs<T> for Delay {
109109
fn delay_ms(&mut self, ms: T) {
110110
// Convert ms to ticks
111111
let start = DWT::cycle_count();
@@ -114,7 +114,7 @@ impl<T: Into<u64>> embedded_hal::blocking::delay::DelayMs<T> for Delay {
114114
}
115115
}
116116

117-
impl embedded_hal_one::delay::DelayNs for Delay {
117+
impl embedded_hal::delay::DelayNs for Delay {
118118
fn delay_ns(&mut self, ns: u32) {
119119
// Convert us to ticks
120120
let start = DWT::cycle_count();

src/fmpi2c/hal_02.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod blocking {
22
use super::super::{fmpi2c1, Error, FMPI2c, Instance};
33
use core::ops::Deref;
4-
use embedded_hal::blocking::i2c::{Read, Write, WriteRead};
4+
use embedded_hal_02::blocking::i2c::{Read, Write, WriteRead};
55

66
impl<I2C: Instance> WriteRead for FMPI2c<I2C>
77
where

src/fmpi2c/hal_1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use embedded_hal_one::i2c::ErrorType;
1+
use embedded_hal::i2c::ErrorType;
22

33
use super::Instance;
44

@@ -9,9 +9,9 @@ impl<I2C: Instance> ErrorType for super::FMPI2c<I2C> {
99
mod blocking {
1010
use super::super::{fmpi2c1, FMPI2c, Instance};
1111
use core::ops::Deref;
12-
use embedded_hal_one::i2c::Operation;
12+
use embedded_hal::i2c::Operation;
1313

14-
impl<I2C: Instance> embedded_hal_one::i2c::I2c for FMPI2c<I2C>
14+
impl<I2C: Instance> embedded_hal::i2c::I2c for FMPI2c<I2C>
1515
where
1616
I2C: Deref<Target = fmpi2c1::RegisterBlock>,
1717
{

src/gpio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ mod hal_02;
7171
mod hal_1;
7272
pub mod outport;
7373

74-
pub use embedded_hal::digital::v2::PinState;
74+
pub use embedded_hal_02::digital::v2::PinState;
7575

7676
use core::fmt;
7777

src/gpio/dynamic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::*;
2-
use embedded_hal_one::digital::ErrorKind;
2+
use embedded_hal::digital::ErrorKind;
33

44
/// Pin type with dynamic mode
55
///
@@ -31,7 +31,7 @@ pub enum PinModeError {
3131
IncorrectMode,
3232
}
3333

34-
impl embedded_hal_one::digital::Error for PinModeError {
34+
impl embedded_hal::digital::Error for PinModeError {
3535
fn kind(&self) -> ErrorKind {
3636
ErrorKind::Other
3737
}

src/gpio/hal_02.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use super::{
55
PartiallyErasedPin, Pin, PinMode, PinState,
66
};
77

8-
use embedded_hal::digital::v2::{
9-
InputPin, IoPin, OutputPin, StatefulOutputPin, ToggleableOutputPin,
8+
use embedded_hal_02::digital::v2::{
9+
InputPin, IoPin, OutputPin, StatefulOutputPin,
1010
};
1111

1212
// Implementations for `Pin`
@@ -39,16 +39,6 @@ impl<const P: char, const N: u8, MODE> StatefulOutputPin for Pin<P, N, Output<MO
3939
}
4040
}
4141

42-
impl<const P: char, const N: u8, MODE> ToggleableOutputPin for Pin<P, N, Output<MODE>> {
43-
type Error = Infallible;
44-
45-
#[inline(always)]
46-
fn toggle(&mut self) -> Result<(), Self::Error> {
47-
self.toggle();
48-
Ok(())
49-
}
50-
}
51-
5242
impl<const P: char, const N: u8, MODE> InputPin for Pin<P, N, MODE>
5343
where
5444
MODE: marker::Readable,
@@ -135,16 +125,6 @@ impl<MODE> StatefulOutputPin for ErasedPin<Output<MODE>> {
135125
}
136126
}
137127

138-
impl<MODE> ToggleableOutputPin for ErasedPin<Output<MODE>> {
139-
type Error = Infallible;
140-
141-
#[inline(always)]
142-
fn toggle(&mut self) -> Result<(), Self::Error> {
143-
self.toggle();
144-
Ok(())
145-
}
146-
}
147-
148128
impl<MODE> InputPin for ErasedPin<MODE>
149129
where
150130
MODE: marker::Readable,
@@ -192,16 +172,6 @@ impl<const P: char, MODE> StatefulOutputPin for PartiallyErasedPin<P, Output<MOD
192172
}
193173
}
194174

195-
impl<const P: char, MODE> ToggleableOutputPin for PartiallyErasedPin<P, Output<MODE>> {
196-
type Error = Infallible;
197-
198-
#[inline(always)]
199-
fn toggle(&mut self) -> Result<(), Self::Error> {
200-
self.toggle();
201-
Ok(())
202-
}
203-
}
204-
205175
impl<const P: char, MODE> InputPin for PartiallyErasedPin<P, MODE>
206176
where
207177
MODE: marker::Readable,

src/gpio/hal_1.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use super::{
44
dynamic::PinModeError, marker, DynamicPin, ErasedPin, Output, PartiallyErasedPin, Pin,
55
};
66

7-
use embedded_hal_one::digital::{
8-
ErrorType, InputPin, OutputPin, StatefulOutputPin, ToggleableOutputPin,
7+
use embedded_hal::digital::{
8+
ErrorType, InputPin, OutputPin, StatefulOutputPin,
99
};
1010

1111
// Implementations for `Pin`
@@ -39,14 +39,6 @@ impl<const P: char, const N: u8, MODE> StatefulOutputPin for Pin<P, N, Output<MO
3939
}
4040
}
4141

42-
impl<const P: char, const N: u8, MODE> ToggleableOutputPin for Pin<P, N, Output<MODE>> {
43-
#[inline(always)]
44-
fn toggle(&mut self) -> Result<(), Self::Error> {
45-
self.toggle();
46-
Ok(())
47-
}
48-
}
49-
5042
impl<const P: char, const N: u8, MODE> InputPin for Pin<P, N, MODE>
5143
where
5244
MODE: marker::Readable,
@@ -93,14 +85,6 @@ impl<MODE> StatefulOutputPin for ErasedPin<Output<MODE>> {
9385
}
9486
}
9587

96-
impl<MODE> ToggleableOutputPin for ErasedPin<Output<MODE>> {
97-
#[inline(always)]
98-
fn toggle(&mut self) -> Result<(), Self::Error> {
99-
self.toggle();
100-
Ok(())
101-
}
102-
}
103-
10488
impl<MODE> InputPin for ErasedPin<MODE>
10589
where
10690
MODE: marker::Readable,
@@ -147,14 +131,6 @@ impl<const P: char, MODE> StatefulOutputPin for PartiallyErasedPin<P, Output<MOD
147131
}
148132
}
149133

150-
impl<const P: char, MODE> ToggleableOutputPin for PartiallyErasedPin<P, Output<MODE>> {
151-
#[inline(always)]
152-
fn toggle(&mut self) -> Result<(), Self::Error> {
153-
self.toggle();
154-
Ok(())
155-
}
156-
}
157-
158134
impl<const P: char, MODE> InputPin for PartiallyErasedPin<P, MODE>
159135
where
160136
MODE: marker::Readable,

src/i2c.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct I2c<I2C: Instance> {
7070
pins: (I2C::Scl, I2C::Sda),
7171
}
7272

73-
pub use embedded_hal_one::i2c::NoAcknowledgeSource;
73+
pub use embedded_hal::i2c::NoAcknowledgeSource;
7474

7575
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
7676
#[non_exhaustive]
@@ -605,5 +605,5 @@ macro_rules! transaction_impl {
605605
}
606606
use transaction_impl;
607607

608-
type Hal1Operation<'a> = embedded_hal_one::i2c::Operation<'a>;
609-
type Hal02Operation<'a> = embedded_hal::blocking::i2c::Operation<'a>;
608+
type Hal1Operation<'a> = embedded_hal::i2c::Operation<'a>;
609+
type Hal02Operation<'a> = embedded_hal_02::blocking::i2c::Operation<'a>;

src/i2c/hal_02.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mod blocking {
22
use super::super::{Error, I2c, Instance};
3-
use embedded_hal::blocking::i2c::{
3+
use embedded_hal_02::blocking::i2c::{
44
Operation, Read, Transactional, Write, WriteIter, WriteIterRead, WriteRead,
55
};
66

src/i2c/hal_1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use embedded_hal_one::i2c::{Error, ErrorKind, ErrorType};
1+
use embedded_hal::i2c::{Error, ErrorKind, ErrorType};
22

33
impl Error for super::Error {
44
fn kind(&self) -> ErrorKind {
@@ -18,9 +18,9 @@ impl<I2C: super::Instance> ErrorType for super::I2c<I2C> {
1818

1919
mod blocking {
2020
use super::super::{I2c, Instance};
21-
use embedded_hal_one::i2c::Operation;
21+
use embedded_hal::i2c::Operation;
2222

23-
impl<I2C: Instance> embedded_hal_one::i2c::I2c for I2c<I2C> {
23+
impl<I2C: Instance> embedded_hal::i2c::I2c for I2c<I2C> {
2424
fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
2525
self.read(addr, buffer)
2626
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ compile_error!(
2626
);
2727

2828
#[cfg(feature = "device-selected")]
29-
pub use embedded_hal as hal;
29+
pub use embedded_hal_02 as hal;
3030

3131
#[cfg(feature = "device-selected")]
3232
pub use nb;

0 commit comments

Comments
 (0)