Skip to content

Commit 705bbb3

Browse files
authored
Merge pull request #1 from HarkonenBade/master
Added implementation of the default toggleable trait
2 parents 162083a + 27bead1 commit 705bbb3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

examples/blinky_delay.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ fn main() -> ! {
3030
let mut delay = Delay::new(cp.SYST, clocks);
3131

3232
loop {
33-
led.set_high();
34-
delay.delay_ms(1_000_u16);
35-
36-
led.set_low();
33+
led.toggle();
3734
delay.delay_ms(1_000_u16);
3835
}
3936
}

src/gpio.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ macro_rules! gpio {
5757
pub mod $gpiox {
5858
use core::marker::PhantomData;
5959

60-
use embedded_hal::digital::{InputPin, OutputPin, StatefulOutputPin};
60+
use embedded_hal::digital::{InputPin, OutputPin, StatefulOutputPin, toggleable};
6161
use crate::stm32::$GPIOX;
6262

6363
use crate::stm32::RCC;
@@ -119,6 +119,8 @@ macro_rules! gpio {
119119
}
120120
}
121121

122+
impl<MODE> toggleable::Default for $PXx<Output<MODE>> {}
123+
122124
impl<MODE> InputPin for $PXx<Input<MODE>> {
123125
fn is_high(&self) -> bool {
124126
!self.is_low()
@@ -411,6 +413,8 @@ macro_rules! gpio {
411413
}
412414
}
413415

416+
impl<MODE> toggleable::Default for $PXi<Output<MODE>> {}
417+
414418
impl<MODE> $PXi<Input<MODE>> {
415419
/// Erases the pin number from the type
416420
///

0 commit comments

Comments
 (0)