= Pin<$Gpiox, Ux, Mode>;
-
- #[doc = "All Pins and associated registers for GPIO port " $GPIOX]
- pub mod $gpiox {
- use core::marker::PhantomData;
-
- use crate::{
- pac::{$gpioy, $GPIOX},
- rcc::{AHB, Enable, Reset},
- };
-
- use super::{Afr, $Gpiox, GpioExt, Moder, Ospeedr, Otyper, Pupdr, U};
-
- #[allow(unused_imports)]
- use super::{
- Input, Output, Analog, PushPull, OpenDrain,
- AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, AF8, AF9, AF10, AF11, AF12, AF13, AF14, AF15,
- };
-
- pub use super::{
- $PXx,
- $(
- $PXi,
- )+
- };
-
- /// GPIO parts
- pub struct Parts {
- /// Opaque AFRH register
- pub afrh: AFRH,
- /// Opaque AFRL register
- pub afrl: AFRL,
- /// Opaque MODER register
- pub moder: MODER,
- /// Opaque OSPEEDR register
- pub ospeedr: OSPEEDR,
- /// Opaque OTYPER register
- pub otyper: OTYPER,
- /// Opaque PUPDR register
- pub pupdr: PUPDR,
- $(
- #[doc = "Pin " $PXi]
- pub $pxi: $PXi<$MODE>,
- )+
- }
+ /// GPIO parts
+ pub struct Parts {
+ /// Opaque AFRH register
+ pub afrh: AFRH,
+ /// Opaque AFRL register
+ pub afrl: AFRL,
+ /// Opaque MODER register
+ pub moder: MODER,
+ /// Opaque OSPEEDR register
+ pub ospeedr: OSPEEDR,
+ /// Opaque OTYPER register
+ pub otyper: OTYPER,
+ /// Opaque PUPDR register
+ pub pupdr: PUPDR,
+ $(
+ #[doc = concat!("Pin ", stringify!($PXi))]
+ pub $pxi: $PXi<$MODE>,
+ )+
+ }
- impl GpioExt for $GPIOX {
- type Parts = Parts;
-
- fn split(self, ahb: &mut AHB) -> Parts {
- <$GPIOX>::enable(ahb);
- <$GPIOX>::reset(ahb);
-
- Parts {
- afrh: AFRH(()),
- afrl: AFRL(()),
- moder: MODER(()),
- ospeedr: OSPEEDR(()),
- otyper: OTYPER(()),
- pupdr: PUPDR(()),
- $(
- $pxi: $PXi {
- gpio: $Gpiox,
- index: U::<$i>,
- _mode: PhantomData,
- },
- )+
- }
+ impl GpioExt for $GPIOX {
+ type Parts = Parts;
+
+ fn split(self, ahb: &mut AHB) -> Parts {
+ <$GPIOX>::enable(ahb);
+ <$GPIOX>::reset(ahb);
+
+ Parts {
+ afrh: AFRH(()),
+ afrl: AFRL(()),
+ moder: MODER(()),
+ ospeedr: OSPEEDR(()),
+ otyper: OTYPER(()),
+ pupdr: PUPDR(()),
+ $(
+ $pxi: $PXi {
+ gpio: $Gpiox,
+ index: U::<$i>,
+ _mode: PhantomData,
+ },
+ )+
}
}
+ }
- /// Opaque AFRH register
- pub struct AFRH(());
+ /// Opaque AFRH register
+ pub struct AFRH(());
- impl Afr for AFRH {
- #[inline]
- fn afx(&mut self, i: u8, x: u8) {
- const BITWIDTH: u8 = 4;
- unsafe { crate::modify_at!((*$GPIOX::ptr()).afrh, BITWIDTH, i - 8, x as u32) };
- }
+ impl Afr for AFRH {
+ #[inline]
+ fn afx(&mut self, i: u8, x: u8) {
+ const BITWIDTH: u8 = 4;
+ unsafe { crate::modify_at!((*$GPIOX::ptr()).afrh, BITWIDTH, i - 8, x as u32) };
}
+ }
- /// Opaque AFRL register
- pub struct AFRL(());
+ /// Opaque AFRL register
+ pub struct AFRL(());
- impl Afr for AFRL {
- #[inline]
- fn afx(&mut self, i: u8, x: u8) {
- const BITWIDTH: u8 = 4;
- unsafe { crate::modify_at!((*$GPIOX::ptr()).afrl, BITWIDTH, i, x as u32) };
- }
+ impl Afr for AFRL {
+ #[inline]
+ fn afx(&mut self, i: u8, x: u8) {
+ const BITWIDTH: u8 = 4;
+ unsafe { crate::modify_at!((*$GPIOX::ptr()).afrl, BITWIDTH, i, x as u32) };
}
+ }
- /// Opaque MODER register
- pub struct MODER(());
-
- r_trait! {
- ($GPIOX, $gpioy::moder::MODER15_A, 2);
- impl Moder for MODER {
- fn input { INPUT }
- fn output { OUTPUT }
- fn alternate { ALTERNATE }
- fn analog { ANALOG }
- }
+ /// Opaque MODER register
+ pub struct MODER(());
+
+ r_trait! {
+ ($GPIOX, $gpioy::moder::MODER15_A, 2);
+ impl Moder for MODER {
+ fn input { INPUT }
+ fn output { OUTPUT }
+ fn alternate { ALTERNATE }
+ fn analog { ANALOG }
}
+ }
- /// Opaque OSPEEDR register
- pub struct OSPEEDR(());
-
- r_trait! {
- ($GPIOX, $gpioy::ospeedr::OSPEEDR15_A, 2);
- impl Ospeedr for OSPEEDR {
- fn low { LOWSPEED }
- fn medium { MEDIUMSPEED }
- fn high { HIGHSPEED }
- }
+ /// Opaque OSPEEDR register
+ pub struct OSPEEDR(());
+
+ r_trait! {
+ ($GPIOX, $gpioy::ospeedr::OSPEEDR15_A, 2);
+ impl Ospeedr for OSPEEDR {
+ fn low { LOWSPEED }
+ fn medium { MEDIUMSPEED }
+ fn high { HIGHSPEED }
}
+ }
- /// Opaque OTYPER register
- pub struct OTYPER(());
+ /// Opaque OTYPER register
+ pub struct OTYPER(());
- r_trait! {
- ($GPIOX, $gpioy::otyper::OT15_A, 1);
- impl Otyper for OTYPER {
- fn push_pull { PUSHPULL }
- fn open_drain { OPENDRAIN }
- }
+ r_trait! {
+ ($GPIOX, $gpioy::otyper::OT15_A, 1);
+ impl Otyper for OTYPER {
+ fn push_pull { PUSHPULL }
+ fn open_drain { OPENDRAIN }
}
+ }
- /// Opaque PUPDR register
- pub struct PUPDR(());
-
- r_trait! {
- ($GPIOX, $gpioy::pupdr::PUPDR15_A, 2);
- impl Pupdr for PUPDR {
- fn floating { FLOATING }
- fn pull_up { PULLUP }
- fn pull_down { PULLDOWN }
- }
+ /// Opaque PUPDR register
+ pub struct PUPDR(());
+
+ r_trait! {
+ ($GPIOX, $gpioy::pupdr::PUPDR15_A, 2);
+ impl Pupdr for PUPDR {
+ fn floating { FLOATING }
+ fn pull_up { PULLUP }
+ fn pull_down { PULLDOWN }
}
}
}
@@ -1003,7 +1023,7 @@ macro_rules! gpio {
partially_erased_pin: [],
pins: [$(
$i => (
- [
], [
], $MODE, [], [$([]),*],
+ [], [
], $MODE, [], [$($af),*],
),
)+],
});
diff --git a/src/timer.rs b/src/timer.rs
index 4618c089a..f15b808ea 100644
--- a/src/timer.rs
+++ b/src/timer.rs
@@ -61,7 +61,7 @@ impl MonoTimer {
/// Returns an `Instant` corresponding to "now"
pub fn now(&self) -> Instant {
Instant {
- now: DWT::get_cycle_count(),
+ now: DWT::cycle_count(),
}
}
}
@@ -76,7 +76,7 @@ pub struct Instant {
impl Instant {
/// Ticks elapsed since the `Instant` was created
pub fn elapsed(self) -> u32 {
- DWT::get_cycle_count().wrapping_sub(self.now)
+ DWT::cycle_count().wrapping_sub(self.now)
}
}