From 03f15d3a6093fe169791c5b132688bb115e8046f Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 11:32:39 -0400
Subject: [PATCH 01/10] Remove builders from Config(s) and examples.

---
 embassy-stm32/src/lib.rs               |  9 +--
 embassy-stm32/src/rcc/h7/mod.rs        | 77 --------------------------
 examples/stm32f0/src/example_common.rs |  4 +-
 examples/stm32f4/src/bin/hello.rs      |  4 +-
 examples/stm32h7/src/bin/dac.rs        | 17 +++++-
 examples/stm32h7/src/bin/eth.rs        | 25 ++++++---
 examples/stm32h7/src/bin/spi.rs        | 17 +++++-
 examples/stm32h7/src/bin/spi_dma.rs    | 18 +++++-
 8 files changed, 67 insertions(+), 104 deletions(-)

diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 0567aa72a..eb893353b 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -67,14 +67,7 @@ pub use generated::{peripherals, Peripherals};
 
 #[non_exhaustive]
 pub struct Config {
-    rcc: rcc::Config,
-}
-
-impl Config {
-    pub fn rcc(mut self, rcc: rcc::Config) -> Self {
-        self.rcc = rcc;
-        self
-    }
+    pub rcc: rcc::Config,
 }
 
 impl Default for Config {
diff --git a/embassy-stm32/src/rcc/h7/mod.rs b/embassy-stm32/src/rcc/h7/mod.rs
index 70632f280..5ec531820 100644
--- a/embassy-stm32/src/rcc/h7/mod.rs
+++ b/embassy-stm32/src/rcc/h7/mod.rs
@@ -70,83 +70,6 @@ pub struct Config {
     pub pll3: PllConfig,
 }
 
-impl Config {
-    pub fn sys_ck<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.sys_ck = Some(freq.into());
-        self
-    }
-
-    pub fn per_ck<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.per_ck = Some(freq.into());
-        self
-    }
-
-    pub fn pclk1<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pclk1 = Some(freq.into());
-        self
-    }
-
-    pub fn pclk2<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pclk2 = Some(freq.into());
-        self
-    }
-
-    pub fn pclk3<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pclk3 = Some(freq.into());
-        self
-    }
-
-    pub fn pclk4<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pclk4 = Some(freq.into());
-        self
-    }
-
-    pub fn pll1_p<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pll1.p_ck = Some(freq.into());
-        self
-    }
-
-    pub fn pll1_q<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pll1.q_ck = Some(freq.into());
-        self
-    }
-
-    pub fn pll1_r<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pll1.r_ck = Some(freq.into());
-        self
-    }
-
-    pub fn pll2_p<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pll2.p_ck = Some(freq.into());
-        self
-    }
-
-    pub fn pll2_q<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pll2.q_ck = Some(freq.into());
-        self
-    }
-
-    pub fn pll2_r<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pll2.r_ck = Some(freq.into());
-        self
-    }
-
-    pub fn pll3_p<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pll3.p_ck = Some(freq.into());
-        self
-    }
-
-    pub fn pll3_q<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pll3.q_ck = Some(freq.into());
-        self
-    }
-
-    pub fn pll3_r<T: Into<Hertz>>(mut self, freq: T) -> Self {
-        self.pll3.r_ck = Some(freq.into());
-        self
-    }
-}
-
 pub struct Rcc<'d> {
     inner: PhantomData<&'d ()>,
     config: Config,
diff --git a/examples/stm32f0/src/example_common.rs b/examples/stm32f0/src/example_common.rs
index e0ba4cd01..c166522e2 100644
--- a/examples/stm32f0/src/example_common.rs
+++ b/examples/stm32f0/src/example_common.rs
@@ -12,7 +12,9 @@ use embassy_stm32::Config;
 pub fn config() -> Config {
     let mut rcc_config = rcc::Config::default();
     rcc_config.enable_debug_wfe = true;
-    Config::default().rcc(rcc_config)
+    let mut config = Config::default();
+    config.rcc = rcc_config;
+    config
 }
 
 defmt::timestamp! {"{=u64}", {
diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs
index 8ee6c1ef8..8cbd46d6e 100644
--- a/examples/stm32f4/src/bin/hello.rs
+++ b/examples/stm32f4/src/bin/hello.rs
@@ -22,7 +22,9 @@ fn config() -> Config {
     rcc_config.sys_ck = Some(Hertz(84_000_000));
     rcc_config.enable_debug_wfe = true;
 
-    Config::default().rcc(rcc_config)
+    let mut config = Config::default();
+    config.rcc = rcc_config;
+    config
 }
 
 #[embassy::main(config = "config()")]
diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs
index 658449f11..fb2feb7bb 100644
--- a/examples/stm32h7/src/bin/dac.rs
+++ b/examples/stm32h7/src/bin/dac.rs
@@ -22,9 +22,7 @@ use embassy_stm32::Config;
 fn main() -> ! {
     info!("Hello World, dude!");
 
-    let p = embassy_stm32::init(
-        Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())),
-    );
+    let p = embassy_stm32::init( config() );
 
     unsafe {
         Dbgmcu::enable_all();
@@ -54,3 +52,16 @@ fn to_sine_wave(v: u8) -> u8 {
         (r.sin() * 128.0 + 127.0) as u8
     }
 }
+
+fn config() -> Config {
+    let mut config = Config::default();
+    config.rcc = rcc_config();
+    config
+}
+
+fn rcc_config() -> rcc::Config {
+    let mut config = rcc::Config::default();
+    config.sys_ck = Some(400.mhz().into());
+    config.pll1.q_ck = Some( 100.mhz().into() );
+    config
+}
\ No newline at end of file
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index e49a101bf..233c5e4c3 100644
--- a/examples/stm32h7/src/bin/eth.rs
+++ b/examples/stm32h7/src/bin/eth.rs
@@ -22,9 +22,10 @@ use embassy_net::{
 use embassy_stm32::clock::{Alarm, Clock};
 use embassy_stm32::eth::lan8742a::LAN8742A;
 use embassy_stm32::eth::{Ethernet, State};
-use embassy_stm32::rcc::{Config as RccConfig, Rcc};
+use embassy_stm32::rcc::{self, Rcc};
 use embassy_stm32::rng::Random;
 use embassy_stm32::time::Hertz;
+use embassy_stm32::time::U32Ext;
 use embassy_stm32::{interrupt, peripherals, Config};
 use heapless::Vec;
 use panic_probe as _;
@@ -108,16 +109,11 @@ fn main() -> ! {
     info!("Hello World!");
 
     info!("Setup RCC...");
-    let mut rcc_config = RccConfig::default();
-    rcc_config.sys_ck = Some(Hertz(400_000_000));
-    rcc_config.pll1.q_ck = Some(Hertz(100_000_000));
-    let config = Config::default().rcc(rcc_config);
-
-    let mut p = embassy_stm32::init(config);
+    let mut p = embassy_stm32::init(config());
 
     // Constrain and Freeze clock
 
-    let mut rcc = Rcc::new(&mut p.RCC, RccConfig::default());
+    let mut rcc = Rcc::new(&mut p.RCC, rcc::Config::default());
     rcc.enable_debug_wfe(&mut p.DBGMCU, true);
 
     let rtc_int = interrupt_take!(TIM2);
@@ -157,3 +153,16 @@ fn main() -> ! {
         unwrap!(spawner.spawn(main_task(eth, config, spawner)));
     })
 }
+
+fn config() -> Config {
+    let mut config = Config::default();
+    config.rcc = rcc_config();
+    config
+}
+
+fn rcc_config() -> rcc::Config {
+    let mut config = rcc::Config::default();
+    config.sys_ck = Some(400.mhz().into());
+    config.pll1.q_ck = Some( 100.mhz().into() );
+    config
+}
\ No newline at end of file
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs
index 3ae2ae7d7..b2cf19615 100644
--- a/examples/stm32h7/src/bin/spi.rs
+++ b/examples/stm32h7/src/bin/spi.rs
@@ -60,9 +60,7 @@ fn main() -> ! {
         Dbgmcu::enable_all();
     }
 
-    let p = embassy_stm32::init(
-        Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())),
-    );
+    let p = embassy_stm32::init( config() );
 
     let spi = spi::Spi::new(
         p.SPI3,
@@ -82,3 +80,16 @@ fn main() -> ! {
         unwrap!(spawner.spawn(main_task(spi)));
     })
 }
+
+fn config() -> Config {
+    let mut config = Config::default();
+    config.rcc = rcc_config();
+    config
+}
+
+fn rcc_config() -> rcc::Config {
+    let mut config = rcc::Config::default();
+    config.sys_ck = Some(400.mhz().into());
+    config.pll1.q_ck = Some( 100.mhz().into() );
+    config
+}
\ No newline at end of file
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs
index 17cc98f95..0ce4212b8 100644
--- a/examples/stm32h7/src/bin/spi_dma.rs
+++ b/examples/stm32h7/src/bin/spi_dma.rs
@@ -8,6 +8,7 @@
 
 #[path = "../example_common.rs"]
 mod example_common;
+
 use core::fmt::Write;
 use embassy::executor::Executor;
 use embassy::time::Clock;
@@ -55,9 +56,7 @@ fn main() -> ! {
         Dbgmcu::enable_all();
     }
 
-    let p = embassy_stm32::init(
-        Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())),
-    );
+    let p = embassy_stm32::init( config() );
 
     let spi = spi::Spi::new(
         p.SPI3,
@@ -77,3 +76,16 @@ fn main() -> ! {
         unwrap!(spawner.spawn(main_task(spi)));
     })
 }
+
+fn config() -> Config {
+    let mut config = Config::default();
+    config.rcc = rcc_config();
+    config
+}
+
+fn rcc_config() -> rcc::Config {
+    let mut config = rcc::Config::default();
+    config.sys_ck = Some(400.mhz().into());
+    config.pll1.q_ck = Some( 100.mhz().into() );
+    config
+}

From 0787c8f8f553a5677a75e3d33904c84f879fa421 Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 11:35:18 -0400
Subject: [PATCH 02/10] Formatting.

---
 examples/stm32h7/src/bin/dac.rs     | 6 +++---
 examples/stm32h7/src/bin/eth.rs     | 4 ++--
 examples/stm32h7/src/bin/spi.rs     | 6 +++---
 examples/stm32h7/src/bin/spi_dma.rs | 4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs
index fb2feb7bb..47e893aae 100644
--- a/examples/stm32h7/src/bin/dac.rs
+++ b/examples/stm32h7/src/bin/dac.rs
@@ -22,7 +22,7 @@ use embassy_stm32::Config;
 fn main() -> ! {
     info!("Hello World, dude!");
 
-    let p = embassy_stm32::init( config() );
+    let p = embassy_stm32::init(config());
 
     unsafe {
         Dbgmcu::enable_all();
@@ -62,6 +62,6 @@ fn config() -> Config {
 fn rcc_config() -> rcc::Config {
     let mut config = rcc::Config::default();
     config.sys_ck = Some(400.mhz().into());
-    config.pll1.q_ck = Some( 100.mhz().into() );
+    config.pll1.q_ck = Some(100.mhz().into());
     config
-}
\ No newline at end of file
+}
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index 233c5e4c3..49359dbd1 100644
--- a/examples/stm32h7/src/bin/eth.rs
+++ b/examples/stm32h7/src/bin/eth.rs
@@ -163,6 +163,6 @@ fn config() -> Config {
 fn rcc_config() -> rcc::Config {
     let mut config = rcc::Config::default();
     config.sys_ck = Some(400.mhz().into());
-    config.pll1.q_ck = Some( 100.mhz().into() );
+    config.pll1.q_ck = Some(100.mhz().into());
     config
-}
\ No newline at end of file
+}
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs
index b2cf19615..e72211e81 100644
--- a/examples/stm32h7/src/bin/spi.rs
+++ b/examples/stm32h7/src/bin/spi.rs
@@ -60,7 +60,7 @@ fn main() -> ! {
         Dbgmcu::enable_all();
     }
 
-    let p = embassy_stm32::init( config() );
+    let p = embassy_stm32::init(config());
 
     let spi = spi::Spi::new(
         p.SPI3,
@@ -90,6 +90,6 @@ fn config() -> Config {
 fn rcc_config() -> rcc::Config {
     let mut config = rcc::Config::default();
     config.sys_ck = Some(400.mhz().into());
-    config.pll1.q_ck = Some( 100.mhz().into() );
+    config.pll1.q_ck = Some(100.mhz().into());
     config
-}
\ No newline at end of file
+}
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs
index 0ce4212b8..aa120c974 100644
--- a/examples/stm32h7/src/bin/spi_dma.rs
+++ b/examples/stm32h7/src/bin/spi_dma.rs
@@ -56,7 +56,7 @@ fn main() -> ! {
         Dbgmcu::enable_all();
     }
 
-    let p = embassy_stm32::init( config() );
+    let p = embassy_stm32::init(config());
 
     let spi = spi::Spi::new(
         p.SPI3,
@@ -86,6 +86,6 @@ fn config() -> Config {
 fn rcc_config() -> rcc::Config {
     let mut config = rcc::Config::default();
     config.sys_ck = Some(400.mhz().into());
-    config.pll1.q_ck = Some( 100.mhz().into() );
+    config.pll1.q_ck = Some(100.mhz().into());
     config
 }

From 4fe9114695ee20e2a4ef62b09fe4b11a1c488655 Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 11:40:47 -0400
Subject: [PATCH 03/10] Remove unused import.

---
 examples/stm32h7/src/bin/eth.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index 49359dbd1..4ce2d854a 100644
--- a/examples/stm32h7/src/bin/eth.rs
+++ b/examples/stm32h7/src/bin/eth.rs
@@ -24,7 +24,6 @@ use embassy_stm32::eth::lan8742a::LAN8742A;
 use embassy_stm32::eth::{Ethernet, State};
 use embassy_stm32::rcc::{self, Rcc};
 use embassy_stm32::rng::Random;
-use embassy_stm32::time::Hertz;
 use embassy_stm32::time::U32Ext;
 use embassy_stm32::{interrupt, peripherals, Config};
 use heapless::Vec;

From f4971fbb791e6d58cddf88aa8a39d6fe16c05b4c Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 13:39:02 -0400
Subject: [PATCH 04/10] Further work sharing config for example and removing
 duplicated code.

---
 embassy-stm32/src/rcc/h7/mod.rs        |  5 ++++
 examples/stm32h7/src/bin/dac.rs        | 16 -----------
 examples/stm32h7/src/bin/eth.rs        | 39 ++++++--------------------
 examples/stm32h7/src/bin/spi.rs        | 14 ---------
 examples/stm32h7/src/bin/spi_dma.rs    | 13 ---------
 examples/stm32h7/src/example_common.rs | 11 ++++++++
 6 files changed, 25 insertions(+), 73 deletions(-)

diff --git a/embassy-stm32/src/rcc/h7/mod.rs b/embassy-stm32/src/rcc/h7/mod.rs
index 5ec531820..2d9602a34 100644
--- a/embassy-stm32/src/rcc/h7/mod.rs
+++ b/embassy-stm32/src/rcc/h7/mod.rs
@@ -68,6 +68,7 @@ pub struct Config {
     pub pll1: PllConfig,
     pub pll2: PllConfig,
     pub pll3: PllConfig,
+    pub enable_dma1: bool,
 }
 
 pub struct Rcc<'d> {
@@ -325,6 +326,10 @@ impl<'d> Rcc<'d> {
             });
             while !SYSCFG.cccsr().read().ready() {}
 
+            if self.config.enable_dma1 {
+                RCC.ahb1enr().modify(|w| w.set_dma1en(true));
+            }
+
             CoreClocks {
                 hclk: Hertz(rcc_hclk),
                 pclk1: Hertz(rcc_pclk1),
diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs
index 47e893aae..cc9e32574 100644
--- a/examples/stm32h7/src/bin/dac.rs
+++ b/examples/stm32h7/src/bin/dac.rs
@@ -14,9 +14,6 @@ use example_common::*;
 
 use cortex_m_rt::entry;
 use embassy_stm32::dac::{Channel, Dac, Value};
-use embassy_stm32::rcc;
-use embassy_stm32::time::U32Ext;
-use embassy_stm32::Config;
 
 #[entry]
 fn main() -> ! {
@@ -52,16 +49,3 @@ fn to_sine_wave(v: u8) -> u8 {
         (r.sin() * 128.0 + 127.0) as u8
     }
 }
-
-fn config() -> Config {
-    let mut config = Config::default();
-    config.rcc = rcc_config();
-    config
-}
-
-fn rcc_config() -> rcc::Config {
-    let mut config = rcc::Config::default();
-    config.sys_ck = Some(400.mhz().into());
-    config.pll1.q_ck = Some(100.mhz().into());
-    config
-}
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index 4ce2d854a..4a841405f 100644
--- a/examples/stm32h7/src/bin/eth.rs
+++ b/examples/stm32h7/src/bin/eth.rs
@@ -6,7 +6,9 @@
 #![feature(impl_trait_in_bindings)]
 #![feature(type_alias_impl_trait)]
 
-use core::sync::atomic::{AtomicUsize, Ordering};
+#[path = "../example_common.rs"]
+mod example_common;
+use example_common::config;
 
 use cortex_m_rt::entry;
 use defmt::{info, unwrap};
@@ -22,22 +24,12 @@ use embassy_net::{
 use embassy_stm32::clock::{Alarm, Clock};
 use embassy_stm32::eth::lan8742a::LAN8742A;
 use embassy_stm32::eth::{Ethernet, State};
-use embassy_stm32::rcc::{self, Rcc};
 use embassy_stm32::rng::Random;
-use embassy_stm32::time::U32Ext;
-use embassy_stm32::{interrupt, peripherals, Config};
+use embassy_stm32::{interrupt, peripherals};
 use heapless::Vec;
 use panic_probe as _;
 use peripherals::{RNG, TIM2};
-
-defmt::timestamp! {"{=u64}", {
-        static COUNT: AtomicUsize = AtomicUsize::new(0);
-        // NOTE(no-CAS) `timestamps` runs with interrupts disabled
-        let n = COUNT.load(Ordering::Relaxed);
-        COUNT.store(n + 1, Ordering::Relaxed);
-        n as u64
-    }
-}
+use embassy_stm32::dbgmcu::Dbgmcu;
 
 #[embassy::task]
 async fn main_task(
@@ -108,12 +100,12 @@ fn main() -> ! {
     info!("Hello World!");
 
     info!("Setup RCC...");
-    let mut p = embassy_stm32::init(config());
 
-    // Constrain and Freeze clock
+    unsafe {
+        Dbgmcu::enable_all();
+    }
 
-    let mut rcc = Rcc::new(&mut p.RCC, rcc::Config::default());
-    rcc.enable_debug_wfe(&mut p.DBGMCU, true);
+    let p = embassy_stm32::init(config());
 
     let rtc_int = interrupt_take!(TIM2);
     let rtc = TIMER_RTC.put(Clock::new(p.TIM2, rtc_int));
@@ -152,16 +144,3 @@ fn main() -> ! {
         unwrap!(spawner.spawn(main_task(eth, config, spawner)));
     })
 }
-
-fn config() -> Config {
-    let mut config = Config::default();
-    config.rcc = rcc_config();
-    config
-}
-
-fn rcc_config() -> rcc::Config {
-    let mut config = rcc::Config::default();
-    config.sys_ck = Some(400.mhz().into());
-    config.pll1.q_ck = Some(100.mhz().into());
-    config
-}
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs
index e72211e81..ed3e369bd 100644
--- a/examples/stm32h7/src/bin/spi.rs
+++ b/examples/stm32h7/src/bin/spi.rs
@@ -14,9 +14,7 @@ use embassy::executor::Executor;
 use embassy::time::Clock;
 use embassy::util::Forever;
 use embassy_stm32::dma::NoDma;
-use embassy_stm32::rcc;
 use embassy_stm32::spi;
-use embassy_stm32::Config;
 use embedded_hal::blocking::spi::Transfer;
 use example_common::*;
 
@@ -81,15 +79,3 @@ fn main() -> ! {
     })
 }
 
-fn config() -> Config {
-    let mut config = Config::default();
-    config.rcc = rcc_config();
-    config
-}
-
-fn rcc_config() -> rcc::Config {
-    let mut config = rcc::Config::default();
-    config.sys_ck = Some(400.mhz().into());
-    config.pll1.q_ck = Some(100.mhz().into());
-    config
-}
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs
index aa120c974..ae6fe3ca0 100644
--- a/examples/stm32h7/src/bin/spi_dma.rs
+++ b/examples/stm32h7/src/bin/spi_dma.rs
@@ -21,9 +21,7 @@ use core::str::from_utf8;
 use cortex_m_rt::entry;
 use embassy_stm32::dbgmcu::Dbgmcu;
 use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3};
-use embassy_stm32::rcc;
 use embassy_stm32::spi;
-use embassy_stm32::Config;
 use heapless::String;
 
 #[embassy::task]
@@ -77,15 +75,4 @@ fn main() -> ! {
     })
 }
 
-fn config() -> Config {
-    let mut config = Config::default();
-    config.rcc = rcc_config();
-    config
-}
 
-fn rcc_config() -> rcc::Config {
-    let mut config = rcc::Config::default();
-    config.sys_ck = Some(400.mhz().into());
-    config.pll1.q_ck = Some(100.mhz().into());
-    config
-}
diff --git a/examples/stm32h7/src/example_common.rs b/examples/stm32h7/src/example_common.rs
index 54d633837..25d80f654 100644
--- a/examples/stm32h7/src/example_common.rs
+++ b/examples/stm32h7/src/example_common.rs
@@ -6,6 +6,8 @@ use panic_probe as _;
 pub use defmt::*;
 
 use core::sync::atomic::{AtomicUsize, Ordering};
+use embassy_stm32::Config;
+use embassy_stm32::time::U32Ext;
 
 defmt::timestamp! {"{=u64}", {
         static COUNT: AtomicUsize = AtomicUsize::new(0);
@@ -15,3 +17,12 @@ defmt::timestamp! {"{=u64}", {
         n as u64
     }
 }
+
+#[allow(unused)]
+pub fn config() -> Config {
+    let mut config = Config::default();
+    config.rcc.sys_ck = Some(400.mhz().into());
+    config.rcc.pll1.q_ck = Some(100.mhz().into());
+    config.rcc.enable_dma1 = true;
+    config
+}

From f91bfef799cb3c9a3107caba80c3343a688c8527 Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 13:42:06 -0400
Subject: [PATCH 05/10] Formatting again.

---
 examples/stm32h7/src/bin/eth.rs        | 2 +-
 examples/stm32h7/src/bin/spi.rs        | 1 -
 examples/stm32h7/src/bin/spi_dma.rs    | 2 --
 examples/stm32h7/src/example_common.rs | 2 +-
 4 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index 4a841405f..323ffc8c9 100644
--- a/examples/stm32h7/src/bin/eth.rs
+++ b/examples/stm32h7/src/bin/eth.rs
@@ -22,6 +22,7 @@ use embassy_net::{
     Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket,
 };
 use embassy_stm32::clock::{Alarm, Clock};
+use embassy_stm32::dbgmcu::Dbgmcu;
 use embassy_stm32::eth::lan8742a::LAN8742A;
 use embassy_stm32::eth::{Ethernet, State};
 use embassy_stm32::rng::Random;
@@ -29,7 +30,6 @@ use embassy_stm32::{interrupt, peripherals};
 use heapless::Vec;
 use panic_probe as _;
 use peripherals::{RNG, TIM2};
-use embassy_stm32::dbgmcu::Dbgmcu;
 
 #[embassy::task]
 async fn main_task(
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs
index ed3e369bd..ef3ef2493 100644
--- a/examples/stm32h7/src/bin/spi.rs
+++ b/examples/stm32h7/src/bin/spi.rs
@@ -78,4 +78,3 @@ fn main() -> ! {
         unwrap!(spawner.spawn(main_task(spi)));
     })
 }
-
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs
index ae6fe3ca0..ccf0a703b 100644
--- a/examples/stm32h7/src/bin/spi_dma.rs
+++ b/examples/stm32h7/src/bin/spi_dma.rs
@@ -74,5 +74,3 @@ fn main() -> ! {
         unwrap!(spawner.spawn(main_task(spi)));
     })
 }
-
-
diff --git a/examples/stm32h7/src/example_common.rs b/examples/stm32h7/src/example_common.rs
index 25d80f654..2e26730fa 100644
--- a/examples/stm32h7/src/example_common.rs
+++ b/examples/stm32h7/src/example_common.rs
@@ -6,8 +6,8 @@ use panic_probe as _;
 pub use defmt::*;
 
 use core::sync::atomic::{AtomicUsize, Ordering};
-use embassy_stm32::Config;
 use embassy_stm32::time::U32Ext;
+use embassy_stm32::Config;
 
 defmt::timestamp! {"{=u64}", {
         static COUNT: AtomicUsize = AtomicUsize::new(0);

From 6fd8f6b79ad5c951229f72047da2f54342a02254 Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 13:55:34 -0400
Subject: [PATCH 06/10] Remove more extra vars.

---
 examples/stm32f0/src/example_common.rs | 4 +---
 examples/stm32f4/src/bin/hello.rs      | 6 ++----
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/examples/stm32f0/src/example_common.rs b/examples/stm32f0/src/example_common.rs
index c166522e2..fb39dcf27 100644
--- a/examples/stm32f0/src/example_common.rs
+++ b/examples/stm32f0/src/example_common.rs
@@ -10,10 +10,8 @@ use embassy_stm32::rcc;
 use embassy_stm32::Config;
 
 pub fn config() -> Config {
-    let mut rcc_config = rcc::Config::default();
-    rcc_config.enable_debug_wfe = true;
     let mut config = Config::default();
-    config.rcc = rcc_config;
+    config.rcc.enable_debug_wfe = true;
     config
 }
 
diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs
index 8cbd46d6e..435ed9748 100644
--- a/examples/stm32f4/src/bin/hello.rs
+++ b/examples/stm32f4/src/bin/hello.rs
@@ -18,12 +18,10 @@ use embassy_stm32::Peripherals;
 mod example_common;
 
 fn config() -> Config {
-    let mut rcc_config = RccConfig::default();
-    rcc_config.sys_ck = Some(Hertz(84_000_000));
-    rcc_config.enable_debug_wfe = true;
-
     let mut config = Config::default();
     config.rcc = rcc_config;
+    config.rcc.sys_ck = Some(Hertz(84_000_000));
+    config.rcc.enable_debug_wfe = true;
     config
 }
 

From dc126b9ab63047ec65551feeeca7f30195f33672 Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 14:14:36 -0400
Subject: [PATCH 07/10] Unused import.

---
 examples/stm32f0/src/example_common.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/examples/stm32f0/src/example_common.rs b/examples/stm32f0/src/example_common.rs
index fb39dcf27..f50119653 100644
--- a/examples/stm32f0/src/example_common.rs
+++ b/examples/stm32f0/src/example_common.rs
@@ -6,7 +6,6 @@ use panic_probe as _;
 pub use defmt::*;
 
 use core::sync::atomic::{AtomicUsize, Ordering};
-use embassy_stm32::rcc;
 use embassy_stm32::Config;
 
 pub fn config() -> Config {

From 08e7e5a3fa3d6c657ab122592079cc90b4f94656 Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 14:22:47 -0400
Subject: [PATCH 08/10] Um.

---
 examples/stm32f0/src/example_common.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/examples/stm32f0/src/example_common.rs b/examples/stm32f0/src/example_common.rs
index f50119653..524ac6dae 100644
--- a/examples/stm32f0/src/example_common.rs
+++ b/examples/stm32f0/src/example_common.rs
@@ -22,3 +22,4 @@ defmt::timestamp! {"{=u64}", {
         n as u64
     }
 }
+

From 97e4b89f82642f6b597a84a0112ae98e304cfc1f Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 14:32:22 -0400
Subject: [PATCH 09/10] Fmt giving me headaches.

---
 examples/stm32f0/src/example_common.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/examples/stm32f0/src/example_common.rs b/examples/stm32f0/src/example_common.rs
index 524ac6dae..f50119653 100644
--- a/examples/stm32f0/src/example_common.rs
+++ b/examples/stm32f0/src/example_common.rs
@@ -22,4 +22,3 @@ defmt::timestamp! {"{=u64}", {
         n as u64
     }
 }
-

From 9726f77ce13e4c31fbe9aaa7e259aa9c31b60c63 Mon Sep 17 00:00:00 2001
From: Bob McWhirter <bmcwhirt@redhat.com>
Date: Wed, 4 Aug 2021 15:28:08 -0400
Subject: [PATCH 10/10] Grep fails me.

---
 examples/stm32f4/src/bin/hello.rs | 2 --
 1 file changed, 2 deletions(-)

diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs
index 435ed9748..20eda3ae0 100644
--- a/examples/stm32f4/src/bin/hello.rs
+++ b/examples/stm32f4/src/bin/hello.rs
@@ -9,7 +9,6 @@
 use defmt::{info, panic};
 use embassy::executor::Spawner;
 use embassy::time::{Duration, Timer};
-use embassy_stm32::rcc::Config as RccConfig;
 use embassy_stm32::time::Hertz;
 use embassy_stm32::Config;
 use embassy_stm32::Peripherals;
@@ -19,7 +18,6 @@ mod example_common;
 
 fn config() -> Config {
     let mut config = Config::default();
-    config.rcc = rcc_config;
     config.rcc.sys_ck = Some(Hertz(84_000_000));
     config.rcc.enable_debug_wfe = true;
     config