Skip to content

Commit 4915e78

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 3c6d61e commit 4915e78

31 files changed

+202
-141
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

examples/adc-continious-dma.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
#![no_main]
33

44
mod utils;
5+
use utils::logger::info;
56

67
use crate::hal::{
78
adc::{
89
config,
910
config::{Continuous, Dma as AdcDma, SampleTime, Sequence},
1011
AdcClaim, ClockSource, Temperature, Vref,
1112
},
12-
delay::SYSTDelayExt,
13+
time::ExtU32,
14+
timer::Timer,
15+
delay::DelayFromCountDownTimer,
1316
dma::{config::DmaConfig, stream::DMAExt, TransferExt},
1417
gpio::GpioExt,
1518
pwr::PwrExt,
@@ -20,7 +23,6 @@ use crate::hal::{
2023
use stm32g4xx_hal as hal;
2124

2225
use cortex_m_rt::entry;
23-
use utils::logger::info;
2426

2527
#[entry]
2628
fn main() -> ! {
@@ -29,7 +31,7 @@ fn main() -> ! {
2931
info!("start");
3032

3133
let dp = Peripherals::take().unwrap();
32-
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
34+
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
3335

3436
info!("rcc");
3537
let rcc = dp.RCC.constrain();
@@ -47,7 +49,10 @@ fn main() -> ! {
4749
let pa0 = gpioa.pa0.into_analog();
4850

4951
info!("Setup Adc1");
50-
let mut delay = cp.SYST.delay(&rcc.clocks);
52+
// let mut delay = cp.SYST.delay(&rcc.clocks);
53+
let mut delay = DelayFromCountDownTimer::new(
54+
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
55+
);
5156
let mut adc = dp
5257
.ADC1
5358
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);

examples/adc-continious.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use crate::hal::{
66
config::{Continuous, Resolution, SampleTime, Sequence},
77
AdcClaim, ClockSource, Temperature, Vref,
88
},
9-
delay::SYSTDelayExt,
9+
time::ExtU32,
10+
timer::Timer,
11+
delay::DelayFromCountDownTimer,
1012
gpio::GpioExt,
1113
pwr::PwrExt,
1214
rcc::{Config, RccExt},
@@ -29,7 +31,7 @@ fn main() -> ! {
2931
info!("start");
3032

3133
let dp = Peripherals::take().unwrap();
32-
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
34+
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
3335

3436
info!("rcc");
3537

@@ -42,7 +44,10 @@ fn main() -> ! {
4244
let pa0 = gpioa.pa0.into_analog();
4345

4446
info!("Setup Adc1");
45-
let mut delay = cp.SYST.delay(&rcc.clocks);
47+
// let mut delay = cp.SYST.delay(&rcc.clocks);
48+
let mut delay = DelayFromCountDownTimer::new(
49+
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
50+
);
4651
let mut adc = dp
4752
.ADC1
4853
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);

examples/adc-one-shot-dma.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use crate::hal::{
88
config::{Continuous, Dma as AdcDma, Resolution, SampleTime, Sequence},
99
AdcClaim, ClockSource, Temperature,
1010
},
11-
delay::SYSTDelayExt,
11+
time::ExtU32,
12+
timer::Timer,
13+
delay::DelayFromCountDownTimer,
1214
dma::{config::DmaConfig, stream::DMAExt, TransferExt},
1315
gpio::GpioExt,
1416
pwr::PwrExt,
@@ -17,10 +19,10 @@ use crate::hal::{
1719
};
1820
use stm32g4xx_hal as hal;
1921

20-
use log::info;
2122

2223
#[macro_use]
2324
mod utils;
25+
use utils::logger::info;
2426

2527
#[entry]
2628
fn main() -> ! {
@@ -29,7 +31,7 @@ fn main() -> ! {
2931
info!("start");
3032

3133
let dp = Peripherals::take().unwrap();
32-
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
34+
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
3335

3436
info!("rcc");
3537

@@ -48,7 +50,10 @@ fn main() -> ! {
4850
let pa0 = gpioa.pa0.into_analog();
4951

5052
info!("Setup Adc1");
51-
let mut delay = cp.SYST.delay(&rcc.clocks);
53+
// let mut delay = cp.SYST.delay(&rcc.clocks);
54+
let mut delay = DelayFromCountDownTimer::new(
55+
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
56+
);
5257
let mut adc = dp
5358
.ADC1
5459
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);

examples/adc-one-shot.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
use crate::hal::{
55
adc::{config::SampleTime, AdcClaim},
6-
delay::SYSTDelayExt,
6+
time::ExtU32,
7+
timer::Timer,
8+
delay::DelayFromCountDownTimer,
79
pwr::PwrExt,
810
rcc::Config,
911
stm32::Peripherals,
@@ -13,10 +15,9 @@ use stm32g4xx_hal as hal;
1315

1416
use cortex_m_rt::entry;
1517

16-
use log::info;
17-
1818
#[macro_use]
1919
mod utils;
20+
use utils::logger::info;
2021

2122
#[entry]
2223
fn main() -> ! {
@@ -25,7 +26,7 @@ fn main() -> ! {
2526
info!("start");
2627

2728
let dp = Peripherals::take().unwrap();
28-
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
29+
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
2930

3031
info!("rcc");
3132

@@ -34,7 +35,10 @@ fn main() -> ! {
3435
let mut rcc = rcc.freeze(Config::hsi(), pwr);
3536

3637
info!("Setup Adc1");
37-
let mut delay = cp.SYST.delay(&rcc.clocks);
38+
// let mut delay = cp.SYST.delay(&rcc.clocks);
39+
let mut delay = DelayFromCountDownTimer::new(
40+
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
41+
);
3842
let mut adc = dp.ADC2.claim_and_configure(
3943
stm32g4xx_hal::adc::ClockSource::SystemClock,
4044
&rcc,

examples/blinky_delay.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use hal::stm32;
1111
use hal::time::ExtU32;
1212
use hal::timer::Timer;
1313
use stm32g4xx_hal as hal;
14-
use embedded_hal_one::delay::DelayNs;
14+
use embedded_hal::delay::DelayNs;
1515

1616
use cortex_m_rt::entry;
1717
use utils::logger::info;
@@ -48,6 +48,6 @@ fn main() -> ! {
4848
info!("Toggle");
4949
led.toggle().unwrap();
5050
info!("TIM2 delay");
51-
DelayNs::delay_ms(&mut delay_tim2, 1000);
51+
delay_tim2.delay_ms(1000);
5252
}
5353
}

examples/button.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use core::cell::RefCell;
1414
use core::sync::atomic::{AtomicBool, Ordering};
1515
use cortex_m::{asm::wfi, interrupt::Mutex};
1616
use cortex_m_rt::entry;
17-
use embedded_hal::digital::v2::OutputPin;
17+
use embedded_hal::digital::OutputPin;
1818

1919
type ButtonPin = gpioc::PC13<Input<PullDown>>;
2020

examples/can-echo.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ use core::num::{NonZeroU16, NonZeroU8};
2222

2323
use cortex_m_rt::entry;
2424

25-
use log::info;
26-
2725
#[macro_use]
2826
mod utils;
27+
use utils::logger::info;
2928

3029
#[entry]
3130
fn main() -> ! {
@@ -116,7 +115,7 @@ fn main() -> ! {
116115
bit_rate_switching: false,
117116
marker: None,
118117
};
119-
info!("Initial Header: {:#X?}", &header);
118+
info!("Initial Header: {:#?}", &header);
120119

121120
info!("Transmit initial message");
122121
block!(can.transmit(header, &buffer)).unwrap();

examples/comp_w_dac.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,25 @@ fn main() -> ! {
1818
#[cfg(feature = "stm32g474")]
1919
#[entry]
2020
fn main() -> ! {
21-
use embedded_hal::Direction;
21+
use embedded_hal_old::Direction;
22+
use stm32g4xx_hal as hal;
2223
use hal::comparator::{self, ComparatorExt, ComparatorSplit};
2324
use hal::dac::{Dac1IntSig1, DacExt, DacOut};
24-
use hal::delay::SYSTDelayExt;
25+
use hal::delay::DelayFromCountDownTimer;
26+
use hal::time::ExtU32;
27+
use hal::timer::Timer;
2528
use hal::gpio::GpioExt;
2629
use hal::rcc::RccExt;
2730
use hal::stm32;
28-
use stm32g4xx_hal as hal;
2931

3032
let dp = stm32::Peripherals::take().expect("cannot take peripherals");
31-
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
33+
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
3234

3335
let mut rcc = dp.RCC.constrain();
34-
let mut delay = cp.SYST.delay(&rcc.clocks);
36+
// let mut delay = cp.SYST.delay(&rcc.clocks);
37+
let mut delay = DelayFromCountDownTimer::new(
38+
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
39+
);
3540

3641
let gpioa = dp.GPIOA.split(&mut rcc);
3742

examples/dac.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
#![no_main]
99
#![no_std]
1010

11-
use embedded_hal::Direction;
11+
use embedded_hal_old::Direction;
1212
use hal::dac::{DacExt, DacOut, GeneratorConfig};
13-
use hal::delay::SYSTDelayExt;
1413
use hal::gpio::GpioExt;
1514
use hal::rcc::RccExt;
15+
use hal::time::ExtU32;
16+
use hal::timer::Timer;
17+
use hal::delay::DelayFromCountDownTimer;
1618
use stm32g4xx_hal as hal;
1719
mod utils;
1820
extern crate cortex_m_rt as rt;
@@ -23,10 +25,14 @@ use rt::entry;
2325
#[entry]
2426
fn main() -> ! {
2527
let dp = stm32::Peripherals::take().expect("cannot take peripherals");
26-
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
28+
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
2729

2830
let mut rcc = dp.RCC.constrain();
29-
let mut delay = cp.SYST.delay(&rcc.clocks);
31+
// cortex-m doesn't yet support hal-1 DelayNs on systick (PR #504)
32+
// let mut delay = cp.SYST.delay(&rcc.clocks);
33+
let mut delay = DelayFromCountDownTimer::new(
34+
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
35+
);
3036

3137
let gpioa = dp.GPIOA.split(&mut rcc);
3238
let (dac1ch1, dac1ch2) = dp.DAC1.constrain((gpioa.pa4, gpioa.pa5), &mut rcc);

0 commit comments

Comments
 (0)