Skip to content

Commit

Permalink
Apply rustfmt to some crates
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahix committed Jul 4, 2022
1 parent 754619f commit 9cba3f1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 27 deletions.
2 changes: 1 addition & 1 deletion arduino-hal/src/simple_pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ pub use avr_hal_generic::simple_pwm::Prescaler;
pub use atmega_hal::simple_pwm::*;

#[cfg(feature = "mcu-attiny")]
pub use attiny_hal::simple_pwm::*;
pub use attiny_hal::simple_pwm::*;
24 changes: 12 additions & 12 deletions avr-hal-generic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@

pub extern crate embedded_hal as hal;

#[doc(hidden)]
pub extern crate avr_device;
#[doc(hidden)]
pub extern crate nb;
#[doc(hidden)]
pub extern crate void;
pub extern crate paste;
#[doc(hidden)]
pub extern crate ufmt;
#[doc(hidden)]
pub extern crate paste;
#[doc(hidden)]
pub extern crate avr_device;
pub extern crate void;

pub mod adc;
pub mod clock;
pub mod delay;
pub mod port;
pub mod usart;
pub mod i2c;
pub mod spi;
pub mod adc;
pub mod port;
pub mod simple_pwm;
pub mod spi;
pub mod usart;
pub mod wdt;

/// Prelude containing all HAL traits
pub mod prelude {
pub use hal::prelude::*;
pub use hal::digital::v2::OutputPin as _;
pub use hal::digital::v2::InputPin as _;
pub use hal::digital::v2::OutputPin as _;
pub use hal::digital::v2::StatefulOutputPin as _;
pub use hal::digital::v2::ToggleableOutputPin as _;
pub use void::ResultVoidExt as _;
pub use void::ResultVoidErrExt as _;
pub use hal::prelude::*;
pub use ufmt::uWrite as _;
pub use void::ResultVoidErrExt as _;
pub use void::ResultVoidExt as _;
}

// For making certain traits unimplementable from outside this crate.
Expand Down
2 changes: 1 addition & 1 deletion avr-hal-generic/src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub mod mode {
impl crate::Sealed for OpenDrain {}

pub struct PwmOutput<TC> {
pub(crate) _timer: PhantomData<TC>
pub(crate) _timer: PhantomData<TC>,
}
impl<TC> super::PinMode for PwmOutput<TC> {}
impl<TC> crate::Sealed for PwmOutput<TC> {}
Expand Down
6 changes: 3 additions & 3 deletions avr-hal-generic/src/simple_pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
use core::marker::PhantomData;

use crate::port::Pin;
use crate::port::mode;
use crate::port::Pin;

/// Clock prescaler for PWM
///
Expand Down Expand Up @@ -55,7 +55,7 @@ impl<TC, PIN: PwmPinOps<TC>> IntoPwmPin<TC, PIN> for Pin<mode::Output, PIN> {
fn into_pwm(self, _timer: &TC) -> Pin<mode::PwmOutput<TC>, PIN> {
Pin {
pin: self.pin,
_mode: PhantomData
_mode: PhantomData,
}
}
}
Expand Down Expand Up @@ -157,4 +157,4 @@ macro_rules! impl_simple_pwm {
}
)+
}
}
}
34 changes: 24 additions & 10 deletions mcu/atmega-hal/src/simple_pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ use avr_hal_generic::simple_pwm::Prescaler;

use crate::port::*;

#[cfg(any(feature = "atmega48p", feature = "atmega168", feature = "atmega328p", feature = "atmega328pb"))]
#[cfg(any(
feature = "atmega48p",
feature = "atmega168",
feature = "atmega328p",
feature = "atmega328pb"
))]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC0` for PWM (pins `PD5`, `PD6`)
///
Expand Down Expand Up @@ -50,7 +55,12 @@ avr_hal_generic::impl_simple_pwm! {
}
}

#[cfg(any(feature = "atmega48p", feature = "atmega168", feature = "atmega328p", feature = "atmega328pb"))]
#[cfg(any(
feature = "atmega48p",
feature = "atmega168",
feature = "atmega328p",
feature = "atmega328pb"
))]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC1` for PWM (pins `PB1`, `PB2`)
///
Expand Down Expand Up @@ -102,7 +112,12 @@ avr_hal_generic::impl_simple_pwm! {
}
}

#[cfg(any(feature = "atmega48p", feature = "atmega168", feature = "atmega328p", feature = "atmega328pb"))]
#[cfg(any(
feature = "atmega48p",
feature = "atmega168",
feature = "atmega328p",
feature = "atmega328pb"
))]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC2` for PWM (pins `PB3`, `PD3`)
///
Expand Down Expand Up @@ -232,8 +247,7 @@ avr_hal_generic::impl_simple_pwm! {
}
}


#[cfg(any(feature = "atmega1280", feature="atmega2560"))]
#[cfg(any(feature = "atmega1280", feature = "atmega2560"))]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC0` for PWM (pins `PB7`, `PG5`)
///
Expand Down Expand Up @@ -281,7 +295,7 @@ avr_hal_generic::impl_simple_pwm! {
}
}

#[cfg(any(feature = "atmega1280", feature="atmega2560"))]
#[cfg(any(feature = "atmega1280", feature = "atmega2560"))]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC1` for PWM (pins `PB5`, `PB6`, `PB7`)
///
Expand Down Expand Up @@ -339,7 +353,7 @@ avr_hal_generic::impl_simple_pwm! {
}
}

#[cfg(any(feature = "atmega1280", feature="atmega2560"))]
#[cfg(any(feature = "atmega1280", feature = "atmega2560"))]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC2` for PWM (pins `PB4`, `PH6`)
///
Expand Down Expand Up @@ -392,7 +406,7 @@ avr_hal_generic::impl_simple_pwm! {
}
}

#[cfg(any(feature = "atmega1280", feature="atmega2560"))]
#[cfg(any(feature = "atmega1280", feature = "atmega2560"))]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC3` for PWM (pins `PE3`, `PE4`, `PE5`)
///
Expand Down Expand Up @@ -455,7 +469,7 @@ avr_hal_generic::impl_simple_pwm! {
}
}

#[cfg(any(feature = "atmega1280", feature="atmega2560"))]
#[cfg(any(feature = "atmega1280", feature = "atmega2560"))]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC4` for PWM (pins `PH3`, `PH4`, `PH5`)
///
Expand Down Expand Up @@ -518,7 +532,7 @@ avr_hal_generic::impl_simple_pwm! {
}
}

#[cfg(any(feature = "atmega1280", feature="atmega2560"))]
#[cfg(any(feature = "atmega1280", feature = "atmega2560"))]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC5` for PWM (pins `PL3`, `PL4`, `PL5`)
///
Expand Down

0 comments on commit 9cba3f1

Please sign in to comment.