Skip to content

Commit c7b4748

Browse files
bors[bot]burrbull
andauthored
Merge #325
325: Gpio inherent r=therealprof a=burrbull Depends on #266 Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents 8913a39 + 747f1e6 commit c7b4748

15 files changed

+707
-101
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12+
- `PinState` and `get/set_state`.
13+
- Inherent methods for infallible digital operations.
1214
- Generic `into_alternate` and `into_alternate_open_drain`. Non-generic ones are deprecated
1315
- Internal implementation of GPIO Pin API changed to use Const Generics
1416
- `PinExt` trait. Make `ExtiPin` implementation generic

examples/analog-stopwatch-with-spi-ssd1306.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ fn main() -> ! {
118118
let mut ss = gpioe.pe4.into_push_pull_output();
119119
let mut delay = hal::delay::Delay::new(cp.SYST, clocks);
120120

121-
ss.set_high().unwrap();
121+
ss.set_high();
122122
delay.delay_ms(100_u32);
123-
ss.set_low().unwrap();
123+
ss.set_low();
124124

125125
// Set up the display
126126
let interface = SPIInterfaceNoCS::new(spi, dc);
@@ -164,21 +164,21 @@ fn main() -> ! {
164164

165165
match state {
166166
StopwatchState::Ready => {
167-
led3.set_high().unwrap();
168-
led4.set_low().unwrap();
167+
led3.set_high();
168+
led4.set_low();
169169
}
170170
StopwatchState::Running => {
171171
if state_led {
172-
led4.set_low().unwrap();
173-
led3.set_high().unwrap();
172+
led4.set_low();
173+
led3.set_high();
174174
} else {
175-
led4.set_low().unwrap();
176-
led3.set_low().unwrap();
175+
led4.set_low();
176+
led3.set_low();
177177
}
178178
}
179179
StopwatchState::Stopped => {
180-
led3.set_low().unwrap();
181-
led4.set_high().unwrap();
180+
led3.set_low();
181+
led4.set_high();
182182
}
183183
};
184184

@@ -282,7 +282,7 @@ fn TIM2() {
282282
StopwatchState::Stopped => {
283283
let mut btn_ref = BUTTON.borrow(cs).borrow_mut();
284284
if let Some(ref mut btn) = btn_ref.deref_mut() {
285-
if btn.is_high().unwrap() {
285+
if btn.is_high() {
286286
cell_reset.replace(val_reset + 1);
287287
}
288288
}

examples/blinky-timer-irq.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use crate::hal::{
2020
use core::cell::RefCell;
2121
use cortex_m::{asm::wfi, interrupt::Mutex};
2222
use cortex_m_rt::entry;
23-
use embedded_hal::digital::v2::OutputPin;
2423
use embedded_hal::timer::CountDown;
2524

2625
// NOTE You can uncomment 'hprintln' here and in the code below for a bit more

examples/delay-blinky.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ fn main() -> ! {
3030

3131
loop {
3232
// On for 1s, off for 1s.
33-
led.set_high().unwrap();
33+
led.set_high();
3434
delay.delay_ms(1000_u32);
35-
led.set_low().unwrap();
35+
led.set_low();
3636
delay.delay_ms(1000_u32);
3737
}
3838
}

examples/dwt-blinky.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ fn main() -> ! {
3838
let mut sw = dwt.stopwatch(&mut lap_times);
3939
loop {
4040
// On for 1s, off for 1s.
41-
led1.set_high().unwrap();
42-
led2.set_low().unwrap();
41+
led1.set_high();
42+
led2.set_low();
4343
delay.delay_ms(1000_u32);
4444
sw.lap();
45-
led1.set_low().unwrap();
46-
led2.set_high().unwrap();
45+
led1.set_low();
46+
led2.set_high();
4747
delay.delay_ms(900_u32);
4848
// Also you can measure with almost clock precision
4949
let cd: ClockDuration = dwt.measure(|| delay.delay_ms(100_u32));

examples/f413disco_lcd_ferris.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ fn main() -> ! {
743743
let mut _te = gpiob.pb14.into_floating_input();
744744

745745
// Enable backlight
746-
gpioe.pe5.into_push_pull_output().set_high().ok();
746+
gpioe.pe5.into_push_pull_output().set_high();
747747

748748
// Get delay provider
749749
let mut delay = Delay::new(cp.SYST, clocks);

examples/i2s-audio-out-dma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn main() -> ! {
148148
// Keep DAC reset low for at least one millisecond
149149
delay.delay_ms(1u8);
150150
// Release the DAC from reset
151-
dac_reset.set_high().unwrap();
151+
dac_reset.set_high();
152152
// Wait at least 550 ns before starting I2C communication
153153
delay.delay_us(1u8);
154154

examples/i2s-audio-out.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn main() -> ! {
145145
// Keep DAC reset low for at least one millisecond
146146
delay.delay_ms(1u8);
147147
// Release the DAC from reset
148-
dac_reset.set_high().unwrap();
148+
dac_reset.set_high();
149149
// Wait at least 550 ns before starting I2C communication
150150
delay.delay_us(1u8);
151151

examples/qei.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ fn main() -> ! {
5252
// Light up the LED when turning clockwise, turn it off
5353
// when turning counter-clockwise.
5454
match rotary_encoder.direction() {
55-
RotaryDirection::Upcounting => led.set_low().unwrap(),
56-
RotaryDirection::Downcounting => led.set_high().unwrap(),
55+
RotaryDirection::Upcounting => led.set_low(),
56+
RotaryDirection::Downcounting => led.set_high(),
5757
}
5858

5959
current_count = new_count;

examples/rtic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ const APP: () = {
3838
#[task(binds = EXTI0, resources = [button, led])]
3939
fn button_click(ctx: button_click::Context) {
4040
ctx.resources.button.clear_interrupt_pending_bit();
41-
ctx.resources.led.toggle().unwrap();
41+
ctx.resources.led.toggle();
4242
}
4343
};

0 commit comments

Comments
 (0)