Skip to content

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
TheZoq2 committed May 1, 2020
1 parent 047d842 commit 9f063bb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/dynamic_gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use nb::block;
use cortex_m_rt::entry;
use cortex_m_semihosting::hprintln;
use embedded_hal::digital::v2::{InputPin, OutputPin};
use stm32f1xx_hal::{pac, prelude::*, timer::Timer, gpio::State};
use stm32f1xx_hal::{gpio::State, pac, prelude::*, timer::Timer};

#[entry]
fn main() -> ! {
Expand Down
2 changes: 1 addition & 1 deletion examples/multi_mode_gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use nb::block;
use cortex_m_rt::entry;
use cortex_m_semihosting::hprintln;
use embedded_hal::digital::v2::{InputPin, OutputPin};
use stm32f1xx_hal::{pac, prelude::*, timer::Timer, gpio::State};
use stm32f1xx_hal::{gpio::State, pac, prelude::*, timer::Timer};

#[entry]
fn main() -> ! {
Expand Down
15 changes: 5 additions & 10 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ pub trait ExtiPin {
fn check_interrupt(&mut self) -> bool;
}


pub enum Dynamic {
InputFloating,
InputPullUp,
Expand All @@ -110,20 +109,19 @@ pub enum PinModeError {
IncorrectMode,
}


impl Dynamic {
fn is_input(&self) -> bool {
use Dynamic::*;
match self {
InputFloating | InputPullUp | InputPullDown | OutputOpenDrain => true,
OutputPushPull => false
OutputPushPull => false,
}
}
fn is_output(&self) -> bool {
use Dynamic::*;
match self {
InputFloating | InputPullUp | InputPullDown => false,
OutputPushPull | OutputOpenDrain => true
OutputPushPull | OutputOpenDrain => true,
}
}
}
Expand All @@ -134,21 +132,20 @@ pub trait PinMode<CR> {
unsafe fn set_mode(cr: &mut CR) -> Self;
}


// These impls are needed because a macro can not brace initialise a ty token
impl<MODE> Input<MODE> {
fn _new() -> Self {
Self {_mode: PhantomData }
Self { _mode: PhantomData }
}
}
impl<MODE> Output<MODE> {
fn _new() -> Self {
Self {_mode: PhantomData }
Self { _mode: PhantomData }
}
}
impl<MODE> Alternate<MODE> {
fn _new() -> Self {
Self {_mode: PhantomData }
Self { _mode: PhantomData }
}
}
impl Debugger {
Expand Down Expand Up @@ -1095,7 +1092,6 @@ macro_rules! impl_pxx {
}
}


impl_pxx! {
(gpioa::PAx),
(gpiob::PBx),
Expand All @@ -1104,7 +1100,6 @@ impl_pxx! {
(gpioe::PEx)
}


gpio!(GPIOA, gpioa, gpioa, PAx, 0, [
PA0: (pa0, 0, Input<Floating>, CRL, exticr1),
PA1: (pa1, 1, Input<Floating>, CRL, exticr1),
Expand Down

0 comments on commit 9f063bb

Please sign in to comment.