From 241488ef1ce365dc4582f51dee6dfa742f1fd63d Mon Sep 17 00:00:00 2001
From: eZio Pan <eziopan@qq.com>
Date: Wed, 18 Oct 2023 19:42:31 +0800
Subject: [PATCH] bypass `ODEN` if chip doesn't have it

---
 embassy-stm32/src/rcc/f4f7.rs | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/embassy-stm32/src/rcc/f4f7.rs b/embassy-stm32/src/rcc/f4f7.rs
index de37eab72..3f9a2be67 100644
--- a/embassy-stm32/src/rcc/f4f7.rs
+++ b/embassy-stm32/src/rcc/f4f7.rs
@@ -2,7 +2,7 @@ pub use crate::pac::rcc::vals::{
     Hpre as AHBPrescaler, Pllm as PllPreDiv, Plln as PllMul, Pllp, Pllq, Pllr, Pllsrc as PllSource,
     Ppre as APBPrescaler, Sw as Sysclk,
 };
-use crate::pac::{FLASH, PWR, RCC};
+use crate::pac::{FLASH, RCC};
 use crate::rcc::{set_freqs, Clocks};
 use crate::time::Hertz;
 
@@ -101,11 +101,17 @@ impl Default for Config {
 
 pub(crate) unsafe fn init(config: Config) {
     // always enable overdrive for now. Make it configurable in the future.
-    PWR.cr1().modify(|w| w.set_oden(true));
-    while !PWR.csr1().read().odrdy() {}
+    #[cfg(not(any(
+        stm32f401, stm32f410, stm32f411, stm32f412, stm32f413, stm32f423, stm32f405, stm32f407, stm32f415, stm32f417
+    )))]
+    {
+        use crate::pac::PWR;
+        PWR.cr1().modify(|w| w.set_oden(true));
+        while !PWR.csr1().read().odrdy() {}
 
-    PWR.cr1().modify(|w| w.set_odswen(true));
-    while !PWR.csr1().read().odswrdy() {}
+        PWR.cr1().modify(|w| w.set_odswen(true));
+        while !PWR.csr1().read().odswrdy() {}
+    }
 
     // Configure HSI
     let hsi = match config.hsi {