From 3bc6e414f7b1d4b4d138c7e90f7f9e85a7ca2885 Mon Sep 17 00:00:00 2001
From: Dario Nieuwenhuis <dirbaio@dirbaio.net>
Date: Wed, 10 Jan 2024 18:06:47 +0100
Subject: [PATCH] stm32: update metapac.

---
 embassy-stm32/Cargo.toml     |  4 +--
 embassy-stm32/src/opamp.rs   | 59 ++++++++++++------------------------
 embassy-stm32/src/sai/mod.rs |  9 +-----
 3 files changed, 22 insertions(+), 50 deletions(-)

diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index 2e5bf0e24..a798a8c5f 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -57,7 +57,7 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa
 rand_core = "0.6.3"
 sdio-host = "0.5.0"
 critical-section = "1.1"
-stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-d5096244fa0b7992454a894a2aeaa369ae674222" }
+stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-656ecf6714fa34fdfb3b3e2f2cd034bffed3f303" }
 vcell = "0.1.3"
 bxcan = "0.7.0"
 nb = "1.0.0"
@@ -75,7 +75,7 @@ critical-section = { version = "1.1", features = ["std"] }
 [build-dependencies]
 proc-macro2 = "1.0.36"
 quote = "1.0.15"
-stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-d5096244fa0b7992454a894a2aeaa369ae674222", default-features = false, features = ["metadata"]}
+stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-656ecf6714fa34fdfb3b3e2f2cd034bffed3f303", default-features = false, features = ["metadata"]}
 
 
 [features]
diff --git a/embassy-stm32/src/opamp.rs b/embassy-stm32/src/opamp.rs
index df8a78bcc..ae8b3cacc 100644
--- a/embassy-stm32/src/opamp.rs
+++ b/embassy-stm32/src/opamp.rs
@@ -3,6 +3,7 @@
 
 use embassy_hal_internal::{into_ref, PeripheralRef};
 
+use crate::pac::opamp::vals::*;
 use crate::Peripheral;
 
 /// Gain
@@ -25,11 +26,11 @@ pub enum OpAmpSpeed {
 }
 
 #[cfg(opamp_g4)]
-impl From<OpAmpSpeed> for crate::pac::opamp::vals::OpampCsrOpahsm {
+impl From<OpAmpSpeed> for crate::pac::opamp::vals::Opahsm {
     fn from(v: OpAmpSpeed) -> Self {
         match v {
-            OpAmpSpeed::Normal => crate::pac::opamp::vals::OpampCsrOpahsm::NORMAL,
-            OpAmpSpeed::HighSpeed => crate::pac::opamp::vals::OpampCsrOpahsm::HIGHSPEED,
+            OpAmpSpeed::Normal => crate::pac::opamp::vals::Opahsm::NORMAL,
+            OpAmpSpeed::HighSpeed => crate::pac::opamp::vals::Opahsm::HIGHSPEED,
         }
     }
 }
@@ -61,7 +62,7 @@ impl<'d, T: Instance> OpAmp<'d, T> {
         into_ref!(opamp);
 
         #[cfg(opamp_g4)]
-        T::regs().opamp_csr().modify(|w| {
+        T::regs().csr().modify(|w| {
             w.set_opahsm(speed.into());
         });
 
@@ -97,25 +98,15 @@ impl<'d, T: Instance> OpAmp<'d, T> {
             OpAmpGain::Mul16 => (0b10, 0b11),
         };
 
-        #[cfg(opamp_f3)]
-        T::regs().opampcsr().modify(|w| {
-            w.set_vp_sel(in_pin.channel());
-            w.set_vm_sel(vm_sel);
-            w.set_pga_gain(pga_gain);
+        T::regs().csr().modify(|w| {
+            w.set_vp_sel(VpSel::from_bits(in_pin.channel()));
+            w.set_vm_sel(VmSel::from_bits(vm_sel));
+            w.set_pga_gain(PgaGain::from_bits(pga_gain));
+            #[cfg(opamp_g4)]
+            w.set_opaintoen(Opaintoen::OUTPUTPIN);
             w.set_opampen(true);
         });
 
-        #[cfg(opamp_g4)]
-        T::regs().opamp_csr().modify(|w| {
-            use crate::pac::opamp::vals::*;
-
-            w.set_vp_sel(OpampCsrVpSel::from_bits(in_pin.channel()));
-            w.set_vm_sel(OpampCsrVmSel::from_bits(vm_sel));
-            w.set_pga_gain(OpampCsrPgaGain::from_bits(pga_gain));
-            w.set_opaintoen(OpampCsrOpaintoen::OUTPUTPIN);
-            w.set_opaen(true);
-        });
-
         OpAmpOutput { _inner: self }
     }
 
@@ -144,13 +135,13 @@ impl<'d, T: Instance> OpAmp<'d, T> {
             OpAmpGain::Mul16 => (0b10, 0b11),
         };
 
-        T::regs().opamp_csr().modify(|w| {
+        T::regs().csr().modify(|w| {
             use crate::pac::opamp::vals::*;
-            w.set_vp_sel(OpampCsrVpSel::from_bits(pin.channel()));
-            w.set_vm_sel(OpampCsrVmSel::from_bits(vm_sel));
-            w.set_pga_gain(OpampCsrPgaGain::from_bits(pga_gain));
-            w.set_opaintoen(OpampCsrOpaintoen::ADCCHANNEL);
-            w.set_opaen(true);
+            w.set_vp_sel(VpSel::from_bits(pin.channel()));
+            w.set_vm_sel(VmSel::from_bits(vm_sel));
+            w.set_pga_gain(PgaGain::from_bits(pga_gain));
+            w.set_opaintoen(Opaintoen::ADCCHANNEL);
+            w.set_opampen(true);
         });
 
         OpAmpInternalOutput { _inner: self }
@@ -159,29 +150,17 @@ impl<'d, T: Instance> OpAmp<'d, T> {
 
 impl<'d, T: Instance> Drop for OpAmpOutput<'d, T> {
     fn drop(&mut self) {
-        #[cfg(opamp_f3)]
-        T::regs().opampcsr().modify(|w| {
+        T::regs().csr().modify(|w| {
             w.set_opampen(false);
         });
-
-        #[cfg(opamp_g4)]
-        T::regs().opamp_csr().modify(|w| {
-            w.set_opaen(false);
-        });
     }
 }
 
 impl<'d, T: Instance> Drop for OpAmpInternalOutput<'d, T> {
     fn drop(&mut self) {
-        #[cfg(opamp_f3)]
-        T::regs().opampcsr().modify(|w| {
+        T::regs().csr().modify(|w| {
             w.set_opampen(false);
         });
-
-        #[cfg(opamp_g4)]
-        T::regs().opamp_csr().modify(|w| {
-            w.set_opaen(false);
-        });
     }
 }
 
diff --git a/embassy-stm32/src/sai/mod.rs b/embassy-stm32/src/sai/mod.rs
index ef8802184..5e647612c 100644
--- a/embassy-stm32/src/sai/mod.rs
+++ b/embassy-stm32/src/sai/mod.rs
@@ -846,14 +846,7 @@ impl<'d, T: Instance, C: Channel, W: word::Word> Sai<'d, T, C, W> {
     pub fn flush(&mut self) {
         let ch = T::REGS.ch(self.sub_block as usize);
         ch.cr1().modify(|w| w.set_saien(false));
-        #[cfg(any(sai_v1, sai_v2))]
-        {
-            ch.cr2().modify(|w| w.set_fflush(vals::Fflush::FLUSH));
-        }
-        #[cfg(any(sai_v3, sai_v4))]
-        {
-            ch.cr2().modify(|w| w.set_fflush(true));
-        }
+        ch.cr2().modify(|w| w.set_fflush(true));
         ch.cr1().modify(|w| w.set_saien(true));
     }