From 96d0eb94767cea6fbecc0c87d43a30d5b6d7e8e5 Mon Sep 17 00:00:00 2001
From: Dario Nieuwenhuis <dirbaio@dirbaio.net>
Date: Sun, 8 May 2022 21:37:37 +0200
Subject: [PATCH] stm32: Fix stm32f107 build.

---
 ci.sh                        | 1 +
 embassy-stm32/src/exti.rs    | 2 +-
 embassy-stm32/src/rcc/mod.rs | 4 ++--
 embassy-stm32/src/usb_otg.rs | 4 ++--
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/ci.sh b/ci.sh
index c6fe9c4aa..00dc8cb9c 100755
--- a/ci.sh
+++ b/ci.sh
@@ -58,6 +58,7 @@ cargo batch  \
     --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,unstable-traits \
     --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,unstable-traits \
     --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,unstable-traits \
+    --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,unstable-traits \
     --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \
     --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \
     --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \
diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs
index 957a1ca55..d065a5557 100644
--- a/embassy-stm32/src/exti.rs
+++ b/embassy-stm32/src/exti.rs
@@ -371,7 +371,7 @@ pub(crate) unsafe fn init() {
 
     foreach_exti_irq!(enable_irq);
 
-    #[cfg(not(any(rcc_wb, rcc_wl5, rcc_wle, rcc_f1)))]
+    #[cfg(not(any(rcc_wb, rcc_wl5, rcc_wle, stm32f1)))]
     <crate::peripherals::SYSCFG as crate::rcc::sealed::RccPeripheral>::enable();
     #[cfg(stm32f1)]
     <crate::peripherals::AFIO as crate::rcc::sealed::RccPeripheral>::enable();
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs
index d3710b8c3..959e59265 100644
--- a/embassy-stm32/src/rcc/mod.rs
+++ b/embassy-stm32/src/rcc/mod.rs
@@ -4,7 +4,7 @@ use crate::time::Hertz;
 use core::mem::MaybeUninit;
 
 #[cfg_attr(rcc_f0, path = "f0.rs")]
-#[cfg_attr(rcc_f1, path = "f1.rs")]
+#[cfg_attr(any(rcc_f1, rcc_f1cl), path = "f1.rs")]
 #[cfg_attr(rcc_f2, path = "f2.rs")]
 #[cfg_attr(rcc_f3, path = "f3.rs")]
 #[cfg_attr(any(rcc_f4, rcc_f410), path = "f4.rs")]
@@ -56,7 +56,7 @@ pub struct Clocks {
     #[cfg(any(rcc_f2, rcc_f4, rcc_f410, rcc_f7))]
     pub pll48: Option<Hertz>,
 
-    #[cfg(rcc_f1)]
+    #[cfg(stm32f1)]
     pub adc: Hertz,
 
     #[cfg(any(rcc_h7, rcc_h7ab))]
diff --git a/embassy-stm32/src/usb_otg.rs b/embassy-stm32/src/usb_otg.rs
index 21b890d7c..c3cd776ca 100644
--- a/embassy-stm32/src/usb_otg.rs
+++ b/embassy-stm32/src/usb_otg.rs
@@ -3,7 +3,6 @@ use embassy::util::Unborrow;
 use embassy_hal_common::unborrow;
 
 use crate::gpio::sealed::AFType;
-use crate::gpio::Speed;
 use crate::{peripherals, rcc::RccPeripheral};
 
 macro_rules! config_ulpi_pins {
@@ -13,7 +12,8 @@ macro_rules! config_ulpi_pins {
         critical_section::with(|_| unsafe {
             $(
                 $pin.set_as_af($pin.af_num(), AFType::OutputPushPull);
-                $pin.set_speed(Speed::VeryHigh);
+                #[cfg(gpio_v2)]
+                $pin.set_speed(crate::gpio::Speed::VeryHigh);
             )*
         })
     };