Skip to content

Commit ef7dda4

Browse files
committed
Adapt to embedded-hal 1.0.0-alpha.1
1 parent fc388fd commit ef7dda4

29 files changed

+179
-157
lines changed

Cargo.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,23 @@ features = ["stm32h743", "rt"]
2222
targets = ["thumbv7em-none-eabihf"]
2323

2424
[dependencies]
25-
embedded-hal = "0.2.4"
25+
embedded-hal = "=1.0.0-alpha.1"
2626
cortex-m = "^0.6.2"
2727
cortex-m-rt = "^0.6.12"
2828
stm32h7 = "0.11.0"
29-
void = { version = "1.0.2", default-features = false }
3029
cast = { version = "0.2.3", default-features = false }
31-
nb = "0.1.2"
30+
nb = "1"
3231
paste = "0.1.18"
3332

3433
[dependencies.bare-metal]
35-
version = "0.2.5"
36-
features = ["const-fn"]
34+
version = "1"
3735

3836
[dev-dependencies]
3937
panic-itm = "~0.4.1"
4038
cortex-m-rtic = "0.5.3"
4139
cortex-m-log = { version = "~0.6", features = ["itm"] }
4240

4341
[features]
44-
default = ["unproven"]
45-
unproven = ["embedded-hal/unproven"]
4642
device-selected = []
4743
revision_v = []
4844
singlecore = []
@@ -89,3 +85,4 @@ required-features = ["revision_v"]
8985
[[example]]
9086
name = "qspi"
9187
required-features = ["quadspi"]
88+

examples/adc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn main() -> ! {
7373
let mut channel = gpioc.pc0.into_analog(); // ANALOG IN 10
7474

7575
loop {
76-
let data: u32 = adc1.read(&mut channel).unwrap();
76+
let data: u32 = adc1.try_read(&mut channel).unwrap();
7777
// voltage = reading * (vref/resolution)
7878
println!(
7979
log,

examples/adc12.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ fn main() -> ! {
6767
let mut channel_pc3 = gpioc.pc3.into_analog(); // AIN 13
6868

6969
loop {
70-
let data_pc2: u32 = adc1.read(&mut channel_pc2).unwrap();
71-
let data_pc3: u32 = adc2.read(&mut channel_pc3).unwrap();
70+
let data_pc2: u32 = adc1.try_read(&mut channel_pc2).unwrap();
71+
let data_pc3: u32 = adc2.try_read(&mut channel_pc3).unwrap();
7272
// voltage = reading * (vref/resolution)
7373
println!(log, "ADC readings: {} {}", data_pc2, data_pc3);
7474
}

examples/blinky.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
extern crate panic_itm;
77

88
use cortex_m_rt::entry;
9-
use stm32h7xx_hal::hal::digital::v2::OutputPin;
9+
use stm32h7xx_hal::hal::digital::OutputPin;
1010
use stm32h7xx_hal::{pac, prelude::*};
1111

1212
use cortex_m_log::println;
@@ -44,11 +44,11 @@ fn main() -> ! {
4444

4545
loop {
4646
loop {
47-
led.set_high().unwrap();
48-
delay.delay_ms(500_u16);
47+
led.try_set_high().unwrap();
48+
delay.try_delay_ms(500_u16).unwrap();
4949

50-
led.set_low().unwrap();
51-
delay.delay_ms(500_u16);
50+
led.try_set_low().unwrap();
51+
delay.try_delay_ms(500_u16).unwrap();
5252
}
5353
}
5454
}

examples/blinky_random.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
extern crate panic_itm;
77

88
use cortex_m_rt::entry;
9-
use stm32h7xx_hal::hal::digital::v2::ToggleableOutputPin;
9+
use stm32h7xx_hal::hal::digital::ToggleableOutputPin;
1010
use stm32h7xx_hal::{pac, prelude::*};
1111

1212
use cortex_m_log::println;
@@ -61,8 +61,8 @@ fn main() -> ! {
6161
// acceptable for your application.
6262
let period = random % 200_u32;
6363

64-
led.toggle().unwrap();
65-
delay.delay_ms(period);
64+
led.try_toggle().unwrap();
65+
delay.try_delay_ms(period).unwrap();
6666
}
6767
Err(err) => println!(log, "RNG error: {:?}", err),
6868
}

examples/blinky_timer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern crate panic_itm;
99
extern crate nb;
1010

1111
use cortex_m_rt::entry;
12-
use stm32h7xx_hal::hal::digital::v2::{OutputPin, ToggleableOutputPin};
12+
use stm32h7xx_hal::hal::digital::{OutputPin, ToggleableOutputPin};
1313
use stm32h7xx_hal::{pac, prelude::*};
1414

1515
use cortex_m_log::println;
@@ -41,7 +41,7 @@ fn main() -> ! {
4141

4242
// Configure PE1 as output.
4343
let mut led = gpioe.pe1.into_push_pull_output();
44-
led.set_low().unwrap();
44+
led.try_set_low().unwrap();
4545

4646
// Get the delay provider.
4747
let mut delay = cp.SYST.delay(ccdr.clocks);
@@ -52,14 +52,14 @@ fn main() -> ! {
5252
loop {
5353
for _ in 0..5 {
5454
// 20ms wait with timer
55-
led.toggle().unwrap();
56-
timer.start(20.ms());
57-
block!(timer.wait()).ok();
55+
led.try_toggle().unwrap();
56+
timer.try_start(20.ms()).unwrap();
57+
block!(timer.try_wait()).ok();
5858

5959
// Delay for 500ms. Timer must operate correctly on next
6060
// use.
61-
led.toggle().unwrap();
62-
delay.delay_ms(500_u16);
61+
led.try_toggle().unwrap();
62+
delay.try_delay_ms(500_u16).unwrap();
6363
}
6464
}
6565
}

examples/dac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern crate panic_itm;
77

88
use cortex_m::asm;
99
use cortex_m_rt::entry;
10-
use stm32h7xx_hal::hal::Direction;
10+
use stm32h7xx_hal::hal::qei::Direction;
1111
use stm32h7xx_hal::{pac, prelude::*};
1212

1313
use stm32h7xx_hal::traits::DacOut;

examples/i2c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ fn main() -> ! {
4141
let mut buf = [0x60];
4242
loop {
4343
buf[0] = 0x11;
44-
i2c.write_read(0x76, &buf.clone(), &mut buf).unwrap();
44+
i2c.try_write_read(0x76, &buf.clone(), &mut buf).unwrap();
4545
}
4646
}

examples/pwm.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@ fn main() -> ! {
5151
.pwm(pins, 10.khz(), ccdr.peripheral.TIM1, &ccdr.clocks);
5252

5353
// Output PWM on PA8
54-
let max = pwm.get_max_duty();
55-
pwm.set_duty(max / 2);
54+
let max = pwm.try_get_max_duty().unwrap();
55+
pwm.try_set_duty(max / 2).unwrap();
5656

5757
println!(log, "50%");
58-
pwm.enable();
58+
pwm.try_enable().unwrap();
5959
asm::bkpt();
6060

6161
println!(log, "25%");
62-
pwm.set_duty(max / 4);
62+
pwm.try_set_duty(max / 4).unwrap();
6363
asm::bkpt();
6464

6565
println!(log, "12.5%");
66-
pwm.set_duty(max / 8);
66+
pwm.try_set_duty(max / 8).unwrap();
6767
asm::bkpt();
6868

6969
println!(log, "100%");
70-
pwm.set_duty(max);
70+
pwm.try_set_duty(max).unwrap();
7171
asm::bkpt();
7272

7373
loop {}

examples/rtic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
extern crate panic_itm;
77
extern crate rtic;
88

9-
use stm32h7xx_hal::hal::digital::v2::ToggleableOutputPin;
9+
use stm32h7xx_hal::hal::digital::ToggleableOutputPin;
1010

1111
use rtic::app;
1212
use stm32h7xx_hal::gpio::{gpioc::PC13, gpioi::PI13};
@@ -52,6 +52,6 @@ const APP: () = {
5252
#[task(binds = EXTI15_10, resources = [button, led])]
5353
fn button_click(ctx: button_click::Context) {
5454
ctx.resources.button.clear_interrupt_pending_bit();
55-
ctx.resources.led.toggle().unwrap();
55+
ctx.resources.led.try_toggle().unwrap();
5656
}
5757
};

0 commit comments

Comments
 (0)