Skip to content

Commit f150162

Browse files
burrbullusbalbin
authored andcommitted
infallible IO
1 parent 9f86833 commit f150162

File tree

12 files changed

+204
-145
lines changed

12 files changed

+204
-145
lines changed

examples/blinky.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ fn main() -> ! {
2929
loop {
3030
info!("Set Led low");
3131
for _ in 0..10_000_000 {
32-
led.set_low().unwrap();
32+
led.set_low();
3333
}
3434

3535
info!("Set Led High");
3636
for _ in 0..10_000_000 {
37-
led.set_high().unwrap();
37+
led.set_high();
3838
}
3939
}
4040
}

examples/blinky_delay.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ fn main() -> ! {
4040

4141
loop {
4242
info!("Toggle");
43-
led.toggle().unwrap();
43+
led.toggle();
4444
info!("SYST delay");
4545
delay_syst.delay(1000.millis());
4646
info!("Toggle");
47-
led.toggle().unwrap();
47+
led.toggle();
4848
info!("TIM2 delay");
4949
delay_tim2.delay_ms(1000);
5050
}

examples/button.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ 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::OutputPin;
1817

1918
type ButtonPin = gpio::PC13<Input<PullDown>>;
2019

@@ -86,10 +85,10 @@ fn main() -> ! {
8685

8786
if G_LED_ON.load(Ordering::Relaxed) {
8887
println!("Turn Led On!");
89-
led.set_high().unwrap();
88+
led.set_high();
9089
} else {
9190
println!("Turn Led Off!");
92-
led.set_low().unwrap();
91+
led.set_low();
9392
}
9493
}
9594
}

examples/can-echo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ fn main() -> ! {
5757

5858
let can1 = {
5959
info!("Init CAN 1");
60-
let rx = gpiob.pb8.into_alternate().set_speed(Speed::VeryHigh);
61-
let tx = gpiob.pb9.into_alternate().set_speed(Speed::VeryHigh);
60+
let rx = gpiob.pb8.into_alternate().speed(Speed::VeryHigh);
61+
let tx = gpiob.pb9.into_alternate().speed(Speed::VeryHigh);
6262

6363
info!("-- Create CAN 1 instance");
6464
let mut can = dp.FDCAN1.fdcan(tx, rx, &rcc);
@@ -82,8 +82,8 @@ fn main() -> ! {
8282

8383
// let can2 = {
8484
// info!("Init CAN 2");
85-
// let rx = gpiob.pb5.into_alternate().set_speed(Speed::VeryHigh);
86-
// let tx = gpiob.pb13.into_alternate().set_speed(Speed::VeryHigh);
85+
// let rx = gpiob.pb5.into_alternate().speed(Speed::VeryHigh);
86+
// let tx = gpiob.pb13.into_alternate().speed(Speed::VeryHigh);
8787

8888
// info!("-- Create CAN 2 instance");
8989
// let mut can = dp.FDCAN2.fdcan(tx, rx, &rcc);

examples/comp.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use rt::entry;
1717
fn main() -> ! {
1818
use hal::comparator::{refint_input, ComparatorExt, ComparatorSplit, Config, Hysteresis};
1919
use hal::gpio::GpioExt;
20-
use hal::prelude::OutputPin;
2120
use hal::rcc::RccExt;
2221
use hal::stm32;
2322
use stm32g4xx_hal as hal;
@@ -55,8 +54,8 @@ fn main() -> ! {
5554
loop {
5655
// Read comp1 output and update led1 accordingly
5756
match comp1.output() {
58-
true => led1.set_high().unwrap(),
59-
false => led1.set_low().unwrap(),
57+
true => led1.set_high(),
58+
false => led1.set_low(),
6059
}
6160
}
6261
}

examples/spi-example.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ fn main() -> ! {
4545
.SPI1
4646
.spi((sclk, miso, mosi), spi::MODE_0, 400.kHz(), &mut rcc);
4747
let mut cs = gpioa.pa8.into_push_pull_output();
48-
cs.set_high().unwrap();
48+
cs.set_high();
4949

5050
// "Hello world!"
5151
let message = b"Hello world!";
5252
let mut received_byte: u8;
5353

5454
loop {
5555
for &byte in message {
56-
cs.set_low().unwrap();
56+
cs.set_low();
5757
spi.send(byte).unwrap();
5858
received_byte = nb::block!(FullDuplex::read(&mut spi)).unwrap();
59-
cs.set_high().unwrap();
59+
cs.set_high();
6060

6161
info!("{}", received_byte as char);
6262
}

examples/spi-sd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() -> ! {
3535

3636
let cs = {
3737
let mut cs = gpiof.pf8.into_push_pull_output();
38-
cs.set_high().unwrap();
38+
cs.set_high();
3939
cs
4040
};
4141

examples/uart-dma-tx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn main() -> ! {
7575
while !transfer.get_transfer_complete_flag() {}
7676

7777
delay_syst.delay(1000.millis());
78-
led.toggle().unwrap();
78+
led.toggle();
7979
transfer.restart(|_tx| {});
8080
}
8181
}

examples/usb_serial.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn main() -> ! {
3131
let gpioa = dp.GPIOA.split(&mut rcc);
3232

3333
let mut led = gpioa.pa5.into_push_pull_output();
34-
led.set_low().ok();
34+
led.set_low();
3535

3636
let usb_dm = gpioa.pa11.into_alternate();
3737
let usb_dp = gpioa.pa12.into_alternate();
@@ -63,7 +63,7 @@ fn main() -> ! {
6363

6464
match serial.read(&mut buf) {
6565
Ok(count) if count > 0 => {
66-
led.set_high().ok();
66+
led.set_high();
6767

6868
// Echo back in upper case
6969
for c in buf[0..count].iter_mut() {
@@ -85,6 +85,6 @@ fn main() -> ! {
8585
_ => {}
8686
}
8787

88-
led.set_low().ok();
88+
led.set_low();
8989
}
9090
}

0 commit comments

Comments
 (0)